📄 intermezzo_fs.h
字号:
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * * Copyright (C) 2001, 2002 Cluster File Systems, Inc. * Copyright (C) 2001 Tacitus Systems, Inc. * Copyright (C) 2000 Stelias Computing, Inc. * Copyright (C) 2000 Red Hat, Inc. * Copyright (C) 2000 TurboLinux, Inc. * Copyright (C) 2000 Los Alamos National Laboratory. * * This file is part of InterMezzo, http://www.inter-mezzo.org. * * InterMezzo is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * InterMezzo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with InterMezzo; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#ifndef __INTERMEZZO_FS_H_#define __INTERMEZZO_FS_H_ 1#include <linux/intermezzo_lib.h>#include <linux/intermezzo_idl.h>#ifdef __KERNEL__typedef __u8 uuid_t[16];#else# include <uuid/uuid.h>#endifstruct lento_vfs_context { __u64 kml_offset; __u64 updated_time; __u64 remote_ino; __u64 remote_generation; __u32 slot_offset; __u32 recno; __u32 flags; uuid_t uuid; struct presto_version remote_version;};static inline int izo_ioctl_is_invalid(struct izo_ioctl_data *data);#ifdef __KERNEL__# include <linux/smp.h># include <linux/fsfilter.h># include <linux/slab.h># include <linux/vmalloc.h># include <linux/smp_lock.h>/* fixups for fs.h */# ifndef fs_down# define fs_down(sem) down(sem)# endif# ifndef fs_up# define fs_up(sem) up(sem)# endif# define KML_IDLE 0# define KML_DECODE 1# define KML_OPTIMIZE 2# define KML_REINT 3# define KML_OPEN_REINT 0x0100# define KML_REINT_BEGIN 0x0200# define KML_BACKFETCH 0x0400# define KML_REINT_END 0x0800# define KML_CLOSE_REINT 0x1000# define KML_REINT_MAXBUF (64 * 1024)# define CACHE_CLIENT_RO 0x4# define CACHE_LENTO_RO 0x8/* global variables */extern int presto_debug;extern int presto_print_entry;extern long presto_kmemory;extern long presto_vmemory;# define PRESTO_DEBUG# ifdef PRESTO_DEBUG/* debugging masks */# define D_SUPER 1# define D_INODE 2# define D_FILE 4# define D_CACHE 8 /* cache debugging */# define D_MALLOC 16 /* print malloc, de-alloc information */# define D_JOURNAL 32# define D_UPCALL 64 /* up and downcall debugging */# define D_PSDEV 128# define D_PIOCTL 256# define D_SPECIAL 512# define D_TIMING 1024# define D_DOWNCALL 2048# define D_KML 4096# define D_FSDATA 8192# define CDEBUG(mask, format, a...) \ do { \ if (presto_debug & mask) { \ printk("(%s:%s,l. %d %d): " format, __FILE__, \ __FUNCTION__, __LINE__, current->pid \ , ## a); \ } \ } while (0)#define CERROR(format, a...) \do { \ printk("(%s:%s,l. %d %d): " format, __FILE__, __FUNCTION__, \ __LINE__, current->pid , ## a); \} while (0)# define ENTRY \ if (presto_print_entry) \ printk("Process %d entered %s\n", current->pid, __FUNCTION__)# define EXIT \ if (presto_print_entry) \ printk("Process %d leaving %s at %d\n", current->pid, \ __FUNCTION__, __LINE__)# define presto_kmem_inc(ptr, size) presto_kmemory += (size)# define presto_kmem_dec(ptr, size) presto_kmemory -= (size)# define presto_vmem_inc(ptr, size) presto_vmemory += (size)# define presto_vmem_dec(ptr, size) presto_vmemory -= (size)# else /* !PRESTO_DEBUG */# define CDEBUG(mask, format, a...) do {} while (0)# define ENTRY do {} while (0)# define EXIT do {} while (0)# define presto_kmem_inc(ptr, size) do {} while (0)# define presto_kmem_dec(ptr, size) do {} while (0)# define presto_vmem_inc(ptr, size) do {} while (0)# define presto_vmem_dec(ptr, size) do {} while (0)# endif /* PRESTO_DEBUG */struct run_ctxt { struct vfsmount *pwdmnt; struct dentry *pwd; struct vfsmount *rootmnt; struct dentry *root; uid_t fsuid; gid_t fsgid; mm_segment_t fs; int ngroups; gid_t groups[NGROUPS];};static inline void push_ctxt(struct run_ctxt *save, struct run_ctxt *new){ int i; save->fs = get_fs(); save->pwd = dget(current->fs->pwd); save->pwdmnt = mntget(current->fs->pwdmnt); save->fsgid = current->fsgid; save->fsuid = current->fsuid; save->root = current->fs->root; save->rootmnt = current->fs->rootmnt; save->ngroups = current->ngroups; for (i = 0; i< current->ngroups; i++) save->groups[i] = current->groups[i]; set_fs(new->fs); lock_kernel(); set_fs_pwd(current->fs, new->pwdmnt, new->pwd); if (new->root) set_fs_root(current->fs, new->rootmnt, new->root); unlock_kernel(); current->fsuid = new->fsuid; current->fsgid = new->fsgid; if (new->ngroups > 0) { current->ngroups = new->ngroups; for (i = 0; i< new->ngroups; i++) current->groups[i] = new->groups[i]; } }static inline void pop_ctxt(struct run_ctxt *saved){ int i; set_fs(saved->fs); lock_kernel(); set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd); if (saved->root) set_fs_root(current->fs, saved->rootmnt, saved->root); unlock_kernel(); current->fsuid = saved->fsuid; current->fsgid = saved->fsgid; current->ngroups = saved->ngroups; for (i = 0; i< saved->ngroups; i++) current->groups[i] = saved->groups[i]; mntput(saved->pwdmnt); dput(saved->pwd);}static inline struct presto_dentry_data *presto_d2d(struct dentry *dentry){ return (struct presto_dentry_data *)(dentry->d_fsdata);}struct presto_cache { spinlock_t cache_lock; loff_t cache_reserved; struct vfsmount *cache_vfsmount; struct super_block *cache_sb; struct dentry *cache_root; struct list_head cache_chain; /* for the dev/cache hash */ int cache_flags; kdev_t cache_dev; /* underlying block device */ char *cache_type; /* filesystem type of cache */ struct filter_fs *cache_filter; struct upc_channel *cache_psdev; /* points to channel used */ struct list_head cache_channel_list; struct list_head cache_fset_list; /* filesets mounted in cache */};struct presto_log_fd { rwlock_t fd_lock; loff_t fd_offset; /* offset where next record should go */ struct file *fd_file; int fd_truncating; unsigned int fd_recno; /* last recno written */ struct list_head fd_reservations;};/* file sets */# define CHUNK_BITS 16struct presto_file_set { struct list_head fset_list; struct presto_log_fd fset_kml; struct presto_log_fd fset_lml; struct presto_log_fd fset_rcvd; struct list_head *fset_clients; /* cache of clients */ struct dentry *fset_dentry; struct vfsmount *fset_mnt; struct presto_cache *fset_cache; unsigned int fset_lento_recno; /* last recno mentioned to lento */ loff_t fset_lento_off; /* last offset mentioned to lento */ loff_t fset_kml_logical_off; /* logical offset of kml file byte 0 */ char * fset_name; int fset_flags; int fset_chunkbits; char *fset_reint_buf; /* temporary buffer holds kml during reint */ spinlock_t fset_permit_lock; int fset_permit_count; int fset_permit_upcall_count; /* This queue is used both for processes waiting for the kernel to give * up the permit as well as processes waiting for the kernel to be given * the permit, depending on the state of FSET_HASPERMIT. */ wait_queue_head_t fset_permit_queue; loff_t fset_file_maxio; /* writing more than this causes a close */ unsigned long int kml_truncate_size;};/* This is the default number of bytes written before a close is recorded*/#define FSET_DEFAULT_MAX_FILEIO (1024<<10)struct dentry *presto_tmpfs_ilookup(struct inode *dir, struct dentry *dentry, ino_t ino, unsigned int generation);struct dentry *presto_iget_ilookup(struct inode *dir, struct dentry *dentry, ino_t ino, unsigned int generation);struct dentry *presto_add_ilookup_dentry(struct dentry *parent, struct dentry *real);struct journal_ops { int (*tr_all_data)(struct inode *); loff_t (*tr_avail)(struct presto_cache *fset, struct super_block *); void *(*tr_start)(struct presto_file_set *, struct inode *, int op); void (*tr_commit)(struct presto_file_set *, void *handle); void (*tr_journal_data)(struct inode *); struct dentry *(*tr_ilookup)(struct inode *dir, struct dentry *dentry, ino_t ino, unsigned int generation); struct dentry *(*tr_add_ilookup)(struct dentry *parent, struct dentry *real);};extern struct journal_ops presto_ext2_journal_ops;extern struct journal_ops presto_ext3_journal_ops;extern struct journal_ops presto_tmpfs_journal_ops;extern struct journal_ops presto_xfs_journal_ops;extern struct journal_ops presto_reiserfs_journal_ops;extern struct journal_ops presto_obdfs_journal_ops;# define LENTO_FL_KML 0x0001# define LENTO_FL_EXPECT 0x0002# define LENTO_FL_VFSCHECK 0x0004# define LENTO_FL_JUSTLOG 0x0008
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -