📄 vfs_intent-2.6-fc5.patch
字号:
@@ -1626,7 +1723,9 @@ dir = nd->dentry; nd->flags &= ~LOOKUP_PARENT; mutex_lock(&dir->d_inode->i_mutex);+ nd->flags |= LOOKUP_LAST; path.dentry = lookup_hash(nd);+ nd->flags &= ~LOOKUP_LAST; path.mnt = nd->mnt; do_last:@@ -1685,7 +1784,7 @@ exit_dput: dput_path(&path, nd); exit:- if (!IS_ERR(nd->intent.open.file))+ if (!IS_ERR(nd->intent.file)) release_open_intent(nd); path_release(nd); return error;@@ -1728,7 +1827,9 @@ } dir = nd->dentry; mutex_lock(&dir->d_inode->i_mutex);+ nd->flags |= LOOKUP_LAST; path.dentry = lookup_hash(nd);+ nd->flags &= ~LOOKUP_LAST; path.mnt = nd->mnt; __putname(nd->last.name); goto do_last;@@ -2240,6 +2341,8 @@ int error; char * to; + intent_init(&nd.intent, IT_LOOKUP);+ intent_init(&old_nd.intent, IT_LOOKUP); if (flags != 0) return -EINVAL; @@ -2247,7 +2350,7 @@ if (IS_ERR(to)) return PTR_ERR(to); - error = __user_walk_fd(olddfd, oldname, 0, &old_nd);+ error = __user_walk_fd_it(olddfd, oldname, 0, &old_nd); if (error) goto exit; error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd);Index: linux-2.6.15-fc5/fs/stat.c===================================================================--- linux-2.6.15-fc5.orig/fs/stat.c 2006-05-31 04:08:20.000000000 +0800+++ linux-2.6.15-fc5/fs/stat.c 2006-05-31 17:24:35.000000000 +0800@@ -38,7 +38,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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-2.6.15-fc5/fs/namespace.c===================================================================--- linux-2.6.15-fc5.orig/fs/namespace.c 2006-05-31 04:08:33.000000000 +0800+++ linux-2.6.15-fc5/fs/namespace.c 2006-05-31 17:24:35.000000000 +0800@@ -74,6 +74,7 @@ INIT_LIST_HEAD(&mnt->mnt_share); INIT_LIST_HEAD(&mnt->mnt_slave_list); INIT_LIST_HEAD(&mnt->mnt_slave);+ INIT_LIST_HEAD(&mnt->mnt_lustre_list); if (name) { int size = strlen(name) + 1; char *newname = kmalloc(size, GFP_KERNEL);@@ -154,6 +155,7 @@ static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd) {+ memset(old_nd, 0, sizeof(*old_nd)); old_nd->dentry = mnt->mnt_mountpoint; old_nd->mnt = mnt->mnt_parent; mnt->mnt_parent = mnt;@@ -272,6 +274,9 @@ { struct super_block *sb = mnt->mnt_sb; dput(mnt->mnt_root);+ spin_lock(&dcache_lock);+ list_del(&mnt->mnt_lustre_list);+ spin_unlock(&dcache_lock); free_vfsmnt(mnt); deactivate_super(sb); }@@ -538,6 +543,8 @@ */ lock_kernel();+ if (sb->s_op->umount_lustre)+ sb->s_op->umount_lustre(sb); if ((flags & MNT_FORCE) && sb->s_op->umount_begin) sb->s_op->umount_begin(sb); unlock_kernel();@@ -870,6 +877,7 @@ return err; if (!old_name || !*old_name) return -EINVAL;+ intent_init(&old_nd.intent, IT_LOOKUP); err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd); if (err) return err;@@ -955,6 +963,7 @@ return -EPERM; if (!old_name || !*old_name) return -EINVAL;+ intent_init(&old_nd.intent, IT_LOOKUP); err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd); if (err) return err;@@ -1270,6 +1279,7 @@ int retval = 0; int mnt_flags = 0; + intent_init(&nd.intent, IT_LOOKUP); /* Discard magic */ if ((flags & MS_MGC_MSK) == MS_MGC_VAL) flags &= ~MS_MGC_MSK;Index: linux-2.6.15-fc5/fs/exec.c===================================================================--- linux-2.6.15-fc5.orig/fs/exec.c 2006-05-31 04:08:33.000000000 +0800+++ linux-2.6.15-fc5/fs/exec.c 2006-05-31 17:24:35.000000000 +0800@@ -127,7 +127,9 @@ struct nameidata nd; int error; - error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ);+ intent_init(&nd.intent, IT_OPEN);+ error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, + FMODE_READ | FMODE_EXEC); if (error) goto out; @@ -477,7 +479,9 @@ int err; struct file *file; - err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ);+ intent_init(&nd.intent, IT_OPEN);+ err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, + FMODE_READ | FMODE_EXEC); file = ERR_PTR(err); if (!err) {Index: linux-2.6.15-fc5/include/linux/dcache.h===================================================================--- linux-2.6.15-fc5.orig/include/linux/dcache.h 2006-05-31 04:08:33.000000000 +0800+++ linux-2.6.15-fc5/include/linux/dcache.h 2006-05-31 17:24:41.000000000 +0800@@ -4,6 +4,7 @@ #ifdef __KERNEL__ #include <asm/atomic.h>+#include <linux/string.h> #include <linux/list.h> #include <linux/spinlock.h> #include <linux/cache.h>@@ -36,6 +37,8 @@ const unsigned char *name; }; +#include <linux/namei.h>+ struct dentry_stat_t { int nr_dentry; int nr_unused;Index: linux-2.6.15-fc5/include/linux/fs.h===================================================================--- linux-2.6.15-fc5.orig/include/linux/fs.h 2006-05-31 04:08:33.000000000 +0800+++ linux-2.6.15-fc5/include/linux/fs.h 2006-05-31 17:24:35.000000000 +0800@@ -59,6 +59,7 @@ #define FMODE_READ 1 #define FMODE_WRITE 2+#define FMODE_EXEC 4 /* Internal kernel extensions */ #define FMODE_LSEEK 4@@ -265,6 +266,8 @@ #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 32768 /* called from open path, ie O_TRUNC */ /* * This is the Inode Attributes structure, used for notify_change(). It@@ -499,6 +502,7 @@ struct block_device *i_bdev; struct cdev *i_cdev; int i_cindex;+ void *i_filterdata; __u32 i_generation; @@ -646,6 +650,7 @@ 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);@@ -1043,7 +1048,9 @@ 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);@@ -1084,6 +1091,7 @@ 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 *); @@ -1286,6 +1294,7 @@ 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 *,@@ -1347,6 +1356,7 @@ 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-2.6.15-fc5/include/linux/namei.h===================================================================--- linux-2.6.15-fc5.orig/include/linux/namei.h 2006-05-31 04:08:39.000000000 +0800+++ linux-2.6.15-fc5/include/linux/namei.h 2006-05-31 17:24:35.000000000 +0800@@ -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,16 @@ 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_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 */@@ -49,7 +82,8 @@ #define LOOKUP_NOALT 32 #define LOOKUP_REVAL 64 #define LOOKUP_ATOMIC 128-+#define LOOKUP_LAST (0x1000)+#define LOOKUP_LINK_NOTLAST (0x2000) /* * Intent data */@@ -59,10 +93,19 @@ 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_walk(const char *, struct nameidata *)); extern int FASTCALL(link_path_walk(const char *, struct nameidata *));Index: linux-2.6.15-fc5/include/linux/mount.h===================================================================--- linux-2.6.15-fc5.orig/include/linux/mount.h 2006-05-31 04:08:22.000000000 +0800+++ linux-2.6.15-fc5/include/linux/mount.h 2006-05-31 17:24:35.000000000 +0800@@ -46,6 +46,8 @@ 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; };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -