⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vfs_intent-2.6-rhel4.patch

📁 非常经典的一个分布式系统
💻 PATCH
📖 第 1 页 / 共 3 页
字号:
+	if (inode->i_op->setattr_raw) {+		struct inode_operations *op = dentry->d_inode->i_op;++		newattrs.ia_uid = user;+		newattrs.ia_gid = group;+		newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;+		newattrs.ia_valid |= ATTR_RAW;+		error = op->setattr_raw(inode, &newattrs);+		/* the file system wants to use normal vfs path now */+		if (error != -EOPNOTSUPP)+			return error;+	} 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 		goto out; 	newattrs.ia_valid =  ATTR_CTIME;@@ -692,6 +735,7 @@ static int chown_common(struct dentry *  	} 	if (!S_ISDIR(inode->i_mode)) 		newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;+ 	down(&inode->i_sem); 	error = notify_change(dentry, &newattrs); 	up(&inode->i_sem);@@ -739,8 +783,6 @@ asmlinkage long sys_fchown(unsigned int  	return error; } -static struct file *__dentry_open(struct dentry *, struct vfsmount *, int, struct file *);- /*  * Note that while the flag value (low two bits) for sys_open means:  *	00 - read-only@@ -758,8 +800,9 @@ static struct file *__dentry_open(struct struct file *filp_open(const char * filename, int flags, int mode) { 	int namei_flags, error;+	struct file * temp_filp; 	struct nameidata nd;-	struct file *f;+	intent_init(&nd.intent, IT_OPEN);  	namei_flags = flags; 	if ((namei_flags+1) & O_ACCMODE)@@ -767,16 +810,11 @@ struct file *filp_open(const char * file 	if (namei_flags & O_TRUNC) 		namei_flags |= 2; -	error = -ENFILE;-	f = get_empty_filp();-	if (f == NULL)-		return ERR_PTR(error);- 	error = open_namei(filename, namei_flags, mode, &nd);-	if (!error)-		return __dentry_open(nd.dentry, nd.mnt, flags, f);--	put_filp(f);+	if (!error) {+		temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);+		return temp_filp;+	}	 	return ERR_PTR(error); } @@ -784,29 +822,27 @@ EXPORT_SYMBOL(filp_open);  struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) {-	int error;-	struct file *f;+	struct lookup_intent it;+	intent_init(&it, IT_LOOKUP); -	error = -ENFILE;-	f = get_empty_filp();-	if (f == NULL) {-		dput(dentry);-		mntput(mnt);-		return ERR_PTR(error);-	}--	return __dentry_open(dentry, mnt, flags, f);+	return dentry_open_it(dentry, mnt, flags, &it); }  EXPORT_SYMBOL(dentry_open); -static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, struct file *f)+struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it) {+	struct file *f; 	struct inode *inode; 	int error; +	error = -ENFILE;+	f = get_empty_filp();+	if (!f)+		goto cleanup_dentry; 	f->f_flags = flags; 	f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;+	f->f_it = it; 	inode = dentry->d_inode; 	if (f->f_mode & FMODE_WRITE) { 		error = get_write_access(inode);@@ -825,6 +861,7 @@ static struct file *__dentry_open(struct 		error = f->f_op->open(inode,f); 		if (error) 			goto cleanup_all;+		intent_release(it); 	} 	f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); @@ -849,6 +886,8 @@ cleanup_all: 	f->f_vfsmnt = NULL; cleanup_file: 	put_filp(f);+cleanup_dentry:+	intent_release(it); 	dput(dentry); 	mntput(mnt); 	return ERR_PTR(error);diff -rup RH_2_6_9_55.orig/fs/stat.c RH_2_6_9_55/fs/stat.c--- RH_2_6_9_55.orig/fs/stat.c+++ RH_2_6_9_55/fs/stat.c@@ -37,7 +37,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;@@ -46,6 +46,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); @@ -62,7 +64,7 @@ int vfs_getattr(struct vfsmount *mnt, st  EXPORT_SYMBOL(vfs_getattr); -int vfs_getattr64(struct vfsmount *mnt, struct dentry *dentry, struct kstat64 *stat)+int vfs_getattr64_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat64 *stat) {	struct inode *inode = dentry->d_inode;	int retval;@@ -79,6 +81,13 @@ int vfs_getattr64(struct vfsmount *mnt, 		return ixop->getattr64(mnt, dentry, stat);	}+	if (inode->i_op->getattr_it) {+		retval = inode->i_op->getattr_it(mnt, dentry, it, (struct kstat *) stat);+		if (retval == 0)+			stat->ino64 = stat->ino;+		return retval;+	}+	if (inode->i_op->getattr) {		retval = inode->i_op->getattr(mnt, dentry, (struct kstat *) stat);		if (retval == 0)@@ -98,16 +107,28 @@ int vfs_getattr64(struct vfsmount *mnt, 	return 0; }+ EXPORT_SYMBOL(vfs_getattr64);+int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)+{+	return vfs_getattr_it(mnt, dentry, NULL, stat);+}++int vfs_getattr64(struct vfsmount *mnt, struct dentry *dentry, struct kstat64 *stat)+{+	return vfs_getattr64_it(mnt, dentry, NULL, stat);+}+ int vfs_stat(char __user *name, struct kstat *stat) { 	struct nameidata nd; 	int error;+	intent_init(&nd.intent, IT_GETATTR); -	error = user_path_walk(name, &nd);+	error = user_path_walk_it(name, &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;@@ -119,10 +140,11 @@ int vfs_lstat(char __user *name, struct  { 	struct nameidata nd; 	int error;+	intent_init(&nd.intent, IT_GETATTR); -	error = user_path_walk_link(name, &nd);+	error = user_path_walk_link_it(name, &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;@@ -134,9 +156,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;@@ -148,10 +173,11 @@ int vfs_stat64(char __user *name, struct {	struct nameidata nd;	int error;+	intent_init(&nd.intent, IT_GETATTR);	error = user_path_walk(name, &nd);	if (!error) {-		error = vfs_getattr64(nd.mnt, nd.dentry, stat);+		error = vfs_getattr64_it(nd.mnt, nd.dentry, &nd.intent, stat);		path_release(&nd);	}	return error;@@ -163,10 +189,11 @@ int vfs_lstat64(char __user *name, struc {	struct nameidata nd;	int error;+	intent_init(&nd.intent, IT_GETATTR);	error = user_path_walk_link(name, &nd);	if (!error) {-		error = vfs_getattr64(nd.mnt, nd.dentry, stat);+		error = vfs_getattr64_it(nd.mnt, nd.dentry, &nd.intent, stat);		path_release(&nd);	}	return error;@@ -178,9 +205,11 @@ int vfs_fstat64(unsigned int fd, struct  {	struct file *f = fget(fd);	int error = -EBADF;+	struct nameidata nd;+	intent_init(&nd.intent, IT_GETATTR);	if (f) {-		error = vfs_getattr64(f->f_vfsmnt, f->f_dentry, stat);+		error = vfs_getattr64_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);		fput(f);	}	return error;diff -rup RH_2_6_9_55.orig/include/linux/dcache.h RH_2_6_9_55/include/linux/dcache.h--- RH_2_6_9_55.orig/include/linux/dcache.h+++ RH_2_6_9_55/include/linux/dcache.h@@ -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>@@ -37,6 +38,8 @@ struct qstr { 	const unsigned char *name; }; +#include <linux/namei.h>+ struct dentry_stat_t { 	int nr_dentry; 	int nr_unused;diff -rup RH_2_6_9_55.orig/include/linux/fs.h RH_2_6_9_55/include/linux/fs.h--- RH_2_6_9_55.orig/include/linux/fs.h+++ RH_2_6_9_55/include/linux/fs.h@@ -266,6 +266,8 @@ typedef void (dio_iodone_t)(struct inode #define ATTR_ATTR_FLAG	1024 #define ATTR_KILL_SUID	2048 #define ATTR_KILL_SGID	4096+#define ATTR_RAW       	8192    /* file system, not vfs will massage attrs */+#define ATTR_FROM_OPEN 	16384    /* called from open path, ie O_TRUNC */  /*  * This is the Inode Attributes structure, used for notify_change().  It@@ -464,6 +466,7 @@ struct inode { 	struct block_device	*i_bdev; 	struct cdev		*i_cdev; 	int			i_cindex;+	void			*i_filterdata;  	__u32			i_generation; @@ -597,6 +600,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);@@ -967,20 +971,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); 	int (*follow_link) (struct dentry *, struct nameidata *); 	void (*put_link) (struct dentry *, struct nameidata *); 	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);@@ -1025,6 +1038,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 *); };@@ -1217,6 +1231,7 @@ extern int unregister_filesystem(struct  extern struct vfsmount *kern_mount(struct file_system_type *); extern int may_umount_tree(struct vfsmount *); extern int may_umount(struct vfsmount *);+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 int vfs_statfs(struct super_block *, struct kstatfs *);@@ -1277,10 +1292,10 @@ static inline int break_lease(struct ino }  /* fs/open.c */- extern int do_truncate(struct dentry *, loff_t start, unsigned int); 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 *); diff -rup RH_2_6_9_55.orig/include/linux/mount.h RH_2_6_9_55/include/linux/mount.h--- RH_2_6_9_55.orig/include/linux/mount.h+++ RH_2_6_9_55/include/linux/mount.h@@ -34,6 +34,7 @@ struct vfsmount 	struct list_head mnt_list; 	struct list_head mnt_fslink;	/* link in fs-specific expiry list */ 	struct namespace *mnt_namespace; /* containing namespace */+	unsigned long mnt_last_used;	/* for GNS auto-umount (jiffies) */ };  static inline struct vfsmount *mntget(struct vfsmount *mnt)diff -rup RH_2_6_9_55.orig/include/linux/namei.h RH_2_6_9_55/include/linux/namei.h--- RH_2_6_9_55.orig/include/linux/namei.h+++ RH_2_6_9_55/include/linux/namei.h@@ -2,14 +2,55 @@ #define _LINUX_NAMEI_H  #include <linux/linkage.h>+#include <linux/string.h>  struct vfsmount;+struct nameidata; -struct open_intent {-	int	flags;-	int	create_mode;+/* intent opcodes */+#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+struct lookup_intent {+	int	it_magic;+	void	(*it_op_release)(struct lookup_intent *);+	int	it_op;+	int	it_flags;+	int	it_create_mode;+	union {+		struct lustre_intent_data lustre;+	} d;+};++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;+}+ enum { MAX_NESTED_LINKS = 8 };  struct nameidata {@@ -21,10 +62,7 @@ struct nameidata { 	unsigned	depth; 	char *saved_names[MAX_NESTED_LINKS + 1]; -	/* Intent data */-	union {-		struct open_intent open;-	} intent;+	struct lookup_intent intent; };  /*@@ -47,6 +85,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA #define LOOKUP_NOALT		32 #define LOOKUP_ATOMIC		64 #define LOOKUP_REVAL		128+#define LOOKUP_LAST		(0x1000)+#define LOOKUP_LINK_NOTLAST	(0x2000)  /*  * Intent data@@ -56,11 +96,18 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA #define LOOKUP_ACCESS		(0x0400)  extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));+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 *); #define user_path_walk(name,nd) \ 	__user_walk(name, LOOKUP_FOLLOW, nd) #define user_path_walk_link(name,nd) \ 	__user_walk(name, 0, nd) 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 *);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -