📄 vfs_intent-2.6-sles10.patch
字号:
error = open(inode, f); if (error) goto cleanup_all;+ intent_release(f->f_it); } f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);@@ -849,6 +884,7 @@ cleanup_all: f->f_dentry = NULL; f->f_vfsmnt = NULL; cleanup_file:+ intent_release(f->f_it); put_filp(f); dput(dentry); mntput(mnt);@@ -874,6 +910,7 @@ static struct file *do_filp_open(int dfd { int namei_flags, error; struct nameidata nd;+ intent_init(&nd.intent, IT_OPEN); namei_flags = flags; if ((namei_flags+1) & O_ACCMODE)@@ -910,19 +947,19 @@ EXPORT_SYMBOL(filp_open); struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry, int (*open)(struct inode *, struct file *)) {- if (IS_ERR(nd->intent.open.file))+ if (IS_ERR(nd->intent.file)) goto out; if (IS_ERR(dentry)) goto out_err;- nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->mnt),- nd->intent.open.flags - 1,- nd->intent.open.file,+ nd->intent.file = __dentry_open(dget(dentry), mntget(nd->mnt),+ nd->intent.flags - 1,+ nd->intent.file, open); out:- return nd->intent.open.file;+ return nd->intent.file; out_err: release_open_intent(nd);- nd->intent.open.file = (struct file *)dentry;+ nd->intent.file = (struct file *)dentry; goto out; } EXPORT_SYMBOL_GPL(lookup_instantiate_filp);@@ -939,7 +976,8 @@ struct file *nameidata_to_filp(struct na struct file *filp; /* Pick up the filp from the open intent */- filp = nd->intent.open.file;+ filp = nd->intent.file;+ filp->f_it = &nd->intent; /* Has the filesystem initialised the file for us? */ if (filp->f_dentry == NULL) filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL);Index: LINUX-SRC-TREE/fs/stat.c===================================================================--- LINUX-SRC-TREE.orig/fs/stat.c+++ LINUX-SRC-TREE/fs/stat.c@@ -38,7 +38,7 @@ void generic_fillattr(struct inode *inod EXPORT_SYMBOL(generic_fillattr); -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)+int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat) { struct inode *inode = dentry->d_inode; int retval;@@ -47,6 +47,8 @@ int vfs_getattr(struct vfsmount *mnt, st if (retval) return retval; + if (inode->i_op->getattr_it)+ return inode->i_op->getattr_it(mnt, dentry, it, stat); if (inode->i_op->getattr) return inode->i_op->getattr(mnt, dentry, stat); @@ -61,6 +63,11 @@ int vfs_getattr(struct vfsmount *mnt, st return 0; } +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)+{+ return vfs_getattr_it(mnt, dentry, NULL, stat);+}+ EXPORT_SYMBOL(vfs_getattr); int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat)@@ -68,9 +75,10 @@ int vfs_stat_fd(int dfd, char __user *na struct nameidata nd; int error; - error = __user_walk_fd(dfd, name, LOOKUP_FOLLOW, &nd);+ intent_init(&nd.intent, IT_GETATTR);+ error = __user_walk_fd_it(dfd, name, LOOKUP_FOLLOW, &nd); if (!error) {- error = vfs_getattr(nd.mnt, nd.dentry, stat);+ error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat); path_release(&nd); } return error;@@ -88,9 +96,10 @@ int vfs_lstat_fd(int dfd, char __user *n struct nameidata nd; int error; - error = __user_walk_fd(dfd, name, 0, &nd);+ intent_init(&nd.intent, IT_GETATTR);+ error = __user_walk_fd_it(dfd, name, 0, &nd); if (!error) {- error = vfs_getattr(nd.mnt, nd.dentry, stat);+ error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat); path_release(&nd); } return error;@@ -107,9 +116,12 @@ int vfs_fstat(unsigned int fd, struct ks { struct file *f = fget(fd); int error = -EBADF;+ struct nameidata nd;+ intent_init(&nd.intent, IT_GETATTR); if (f) {- error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);+ error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);+ intent_release(&nd.intent); fput(f); } return error;Index: LINUX-SRC-TREE/include/linux/dcache.h===================================================================--- LINUX-SRC-TREE.orig/include/linux/dcache.h+++ LINUX-SRC-TREE/include/linux/dcache.h@@ -36,6 +36,9 @@ struct qstr { const unsigned char *name; }; +struct inode;+#include <linux/namei.h>+ struct dentry_stat_t { int nr_dentry; int nr_unused;Index: LINUX-SRC-TREE/include/linux/fs.h===================================================================--- LINUX-SRC-TREE.orig/include/linux/fs.h+++ LINUX-SRC-TREE/include/linux/fs.h@@ -61,6 +61,7 @@ extern int dir_notify_enable; #define FMODE_READ 1 #define FMODE_WRITE 2+#define FMODE_EXEC 16 /* Internal kernel extensions */ #define FMODE_LSEEK 4@@ -272,6 +273,8 @@ typedef void (dio_iodone_t)(struct kiocb #define ATTR_KILL_SUID 2048 #define ATTR_KILL_SGID 4096 #define ATTR_FILE 8192+#define ATTR_RAW 16384 /* file system, not vfs will massage attrs */+#define ATTR_FROM_OPEN 65536 /* called from open path, ie O_TRUNC */ #define ATTR_NO_BLOCK 32768 /* Return EAGAIN and don't block on long truncates */ /*@@ -517,6 +520,7 @@ struct inode { struct block_device *i_bdev; struct cdev *i_cdev; int i_cindex;+ void *i_filterdata; __u32 i_generation; @@ -664,6 +668,7 @@ struct file { spinlock_t f_ep_lock; #endif /* #ifdef CONFIG_EPOLL */ struct address_space *f_mapping;+ struct lookup_intent *f_it; }; extern spinlock_t files_lock; #define file_list_lock() spin_lock(&files_lock);@@ -1059,20 +1064,29 @@ struct inode_operations { int (*create) (struct inode *,struct dentry *,int, struct nameidata *); struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *); int (*link) (struct dentry *,struct inode *,struct dentry *);+ int (*link_raw) (struct nameidata *,struct nameidata *); int (*unlink) (struct inode *,struct dentry *);+ int (*unlink_raw) (struct nameidata *); int (*symlink) (struct inode *,struct dentry *,const char *);+ int (*symlink_raw) (struct nameidata *,const char *); int (*mkdir) (struct inode *,struct dentry *,int);+ int (*mkdir_raw) (struct nameidata *,int); int (*rmdir) (struct inode *,struct dentry *);+ int (*rmdir_raw) (struct nameidata *); int (*mknod) (struct inode *,struct dentry *,int,dev_t);+ int (*mknod_raw) (struct nameidata *,int,dev_t); int (*rename) (struct inode *, struct dentry *, struct inode *, struct dentry *);+ int (*rename_raw) (struct nameidata *, struct nameidata *); int (*readlink) (struct dentry *, char __user *,int); void * (*follow_link) (struct dentry *, struct nameidata *); void (*put_link) (struct dentry *, struct nameidata *, void *); void (*truncate) (struct inode *); int (*permission) (struct inode *, int, struct nameidata *); int (*setattr) (struct dentry *, struct iattr *);+ int (*setattr_raw) (struct inode *, struct iattr *); int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);+ int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *); int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); ssize_t (*listxattr) (struct dentry *, char *, size_t);@@ -1113,6 +1127,7 @@ struct super_operations { int (*remount_fs) (struct super_block *, int *, char *); void (*clear_inode) (struct inode *); void (*umount_begin) (struct super_block *);+ void (*umount_lustre) (struct super_block *); int (*show_options)(struct seq_file *, struct vfsmount *); @@ -1322,6 +1337,7 @@ extern int may_umount_tree(struct vfsmou extern int may_umount(struct vfsmount *); extern void umount_tree(struct vfsmount *, int, struct list_head *); extern void release_mounts(struct list_head *);+struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data); extern long do_mount(char *, char *, char *, unsigned long, void *); extern struct vfsmount *copy_tree(struct vfsmount *, struct dentry *, int); extern void mnt_set_mountpoint(struct vfsmount *, struct dentry *,@@ -1378,11 +1394,12 @@ static inline int break_lease(struct ino /* fs/open.c */ extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,- struct file *filp);+ struct file *filp, int called_from_open); extern long do_sys_open(int fdf, const char __user *filename, int flags, int mode); extern struct file *filp_open(const char *, int, int); extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);+extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *); extern int filp_close(struct file *, fl_owner_t id); extern char * getname(const char __user *); Index: LINUX-SRC-TREE/include/linux/mount.h===================================================================--- LINUX-SRC-TREE.orig/include/linux/mount.h+++ LINUX-SRC-TREE/include/linux/mount.h@@ -46,6 +46,8 @@ struct vfsmount { struct list_head mnt_slave; /* slave list entry */ struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ struct namespace *mnt_namespace; /* containing namespace */+ struct list_head mnt_lustre_list; /* GNS mount list */+ unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */ int mnt_pinned; }; Index: LINUX-SRC-TREE/include/linux/namei.h===================================================================--- LINUX-SRC-TREE.orig/include/linux/namei.h+++ LINUX-SRC-TREE/include/linux/namei.h@@ -5,10 +5,39 @@ struct vfsmount; +#define IT_OPEN (1)+#define IT_CREAT (1<<1)+#define IT_READDIR (1<<2)+#define IT_GETATTR (1<<3)+#define IT_LOOKUP (1<<4)+#define IT_UNLINK (1<<5)+#define IT_TRUNC (1<<6)+#define IT_GETXATTR (1<<7)++struct lustre_intent_data {+ int it_disposition;+ int it_status;+ __u64 it_lock_handle;+ void *it_data;+ int it_lock_mode;+};++#define INTENT_MAGIC 0x19620323++#define it_flags flags+#define it_create_mode create_mode+#define lookup_intent open_intent+ struct open_intent {- int flags;- int create_mode;- struct file *file;+ int it_magic;+ void (*it_op_release)(struct open_intent *);+ int it_op;+ int flags;+ int create_mode;+ struct file *file;+ union {+ struct lustre_intent_data lustre;+ } d; }; enum { MAX_NESTED_LINKS = 8 };@@ -22,12 +51,23 @@ struct nameidata { unsigned depth; char *saved_names[MAX_NESTED_LINKS + 1]; - /* Intent data */- union {- struct open_intent open;- } intent;+ struct lookup_intent intent; }; +static inline void intent_reset_fs_part(struct lookup_intent *it)+{+ memset(&it->d, 0, sizeof(it->d));+ it->it_magic = INTENT_MAGIC;+ it->it_op_release = NULL;+}++static inline void intent_init(struct lookup_intent *it, int op)+{+ memset(it, 0, sizeof(*it));+ it->it_magic = INTENT_MAGIC;+ it->it_op = op;+}+ /* * Type of the last component on LOOKUP_PARENT */@@ -48,6 +88,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA #define LOOKUP_PARENT 16 #define LOOKUP_NOALT 32 #define LOOKUP_REVAL 64+#define LOOKUP_LAST (0x1000)+#define LOOKUP_LINK_NOTLAST (0x2000) /* * Intent data */@@ -57,18 +99,29 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *)); extern int FASTCALL(__user_walk_fd(int dfd, const char __user *, unsigned, struct nameidata *));+extern int FASTCALL(__user_walk_fd_it(int dfd, const char __user *, unsigned, struct nameidata *)); #define user_path_walk(name,nd) \ __user_walk_fd(AT_FDCWD, name, LOOKUP_FOLLOW, nd) #define user_path_walk_link(name,nd) \ __user_walk_fd(AT_FDCWD, name, 0, nd)++extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));+#define user_path_walk_it(name,nd) \+ __user_walk_it(name, LOOKUP_FOLLOW, nd)+#define user_path_walk_link_it(name,nd) \+ __user_walk_it(name, 0, nd)+extern void intent_release(struct lookup_intent *);+ extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));+extern int FASTCALL(path_lookup_it(const char *, unsigned, struct nameidata *)); extern int FASTCALL(path_walk(const char *, struct nameidata *)); extern int FASTCALL(link_path_walk(const char *, struct nameidata *)); extern void path_release(struct nameidata *); extern void path_release_on_umount(struct nameidata *); extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);-extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);+extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, + int open_flags, int create_mode); extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry, int (*open)(struct inode *, struct file *)); extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -