gfs2: Switch to generic xattr handlers
Subsystems (2)
Andreas Gruenbacher
maintainerPATCH 1/1 gfs2: Switch to generic xattr handlers
Move the pre- and postamble code in gfs2_{get,set,remove}xattr into the handlers in gfs2_xattr_handlers. Replace the generic POSIX ACL handlers in there with gfs2-specific versions that wrap the generic handlers into the pre- and postamble code. With that, gfs2_{get,set,remove}xattr can be removed and replaced with the generic inode operations.
--- fs/gfs2/inode.c | 79 ++++------------------------ fs/gfs2/xattr.c | 112 ++++++++++++++++++++++++++++++++++++---- fs/posix_acl.c | 9 ++-- include/linux/posix_acl_xattr.h | 8 +++ 4 files changed, 126 insertions(+), 82 deletions(-)
fs/gfs2/inode.c +9 -70
@@ -1948,67 +1948,6 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,return 0 ; } -static int gfs2_setxattr (struct dentry *dentry,const char *name, -const void *data,size_t size,int flags) -{ -struct inode *inode =d_inode (dentry); -struct gfs2_inode *ip =GFS2_I (inode); -struct gfs2_holder gh; -int ret; - -gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); - ret =gfs2_glock_nq (&gh); -if (ret ==0 ) { - ret =gfs2_rsqa_alloc (ip); -if (ret ==0 ) - ret =generic_setxattr (dentry, name, data, size, flags); -gfs2_glock_dq (&gh); - } -gfs2_holder_uninit (&gh); -return ret; -} - -static ssize_t gfs2_getxattr (struct dentry *dentry,const char *name, -void *data,size_t size) -{ -struct inode *inode =d_inode (dentry); -struct gfs2_inode *ip =GFS2_I (inode); -struct gfs2_holder gh; -int ret; - -/* For selinux during lookup */ -if (gfs2_glock_is_locked_by_me (ip->i_gl)) -return generic_getxattr (dentry, name, data, size); - -gfs2_holder_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &gh); - ret =gfs2_glock_nq (&gh); -if (ret ==0 ) { - ret =generic_getxattr (dentry, name, data, size); -gfs2_glock_dq (&gh); - } -gfs2_holder_uninit (&gh); -return ret; -} - -static int gfs2_removexattr (struct dentry *dentry,const char *name) -{ -struct inode *inode =d_inode (dentry); -struct gfs2_inode *ip =GFS2_I (inode); -struct gfs2_holder gh; -int ret; - -gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); - ret =gfs2_glock_nq (&gh); -if (ret ==0 ) { - ret =gfs2_rsqa_alloc (ip); -if (ret ==0 ) - ret =generic_removexattr (dentry, name); -gfs2_glock_dq (&gh); - } -gfs2_holder_uninit (&gh); -return ret; -} -static int gfs2_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo,u64 start,u64 len) {
@@ -2055,10 +1994,10 @@ const struct inode_operations gfs2_file_iops = { .permission = gfs2_permission, .setattr = gfs2_setattr, .getattr = gfs2_getattr, - .setxattr = gfs2_setxattr, - .getxattr = gfs2_getxattr, + .setxattr = generic_setxattr, + .getxattr = generic_getxattr, .listxattr = gfs2_listxattr, - .removexattr = gfs2_removexattr, + .removexattr = generic_removexattr, .fiemap = gfs2_fiemap, .get_acl = gfs2_get_acl, .set_acl = gfs2_set_acl,
@@ -2077,10 +2016,10 @@ const struct inode_operations gfs2_dir_iops = { .permission = gfs2_permission, .setattr = gfs2_setattr, .getattr = gfs2_getattr, - .setxattr = gfs2_setxattr, - .getxattr = gfs2_getxattr, + .setxattr = generic_setxattr, + .getxattr = generic_getxattr, .listxattr = gfs2_listxattr, - .removexattr = gfs2_removexattr, + .removexattr = generic_removexattr, .fiemap = gfs2_fiemap, .get_acl = gfs2_get_acl, .set_acl = gfs2_set_acl,
@@ -2093,10 +2032,10 @@ const struct inode_operations gfs2_symlink_iops = { .permission = gfs2_permission, .setattr = gfs2_setattr, .getattr = gfs2_getattr, - .setxattr = gfs2_setxattr, - .getxattr = gfs2_getxattr, + .setxattr = generic_setxattr, + .getxattr = generic_getxattr, .listxattr = gfs2_listxattr, - .removexattr = gfs2_removexattr, + .removexattr = generic_removexattr, .fiemap = gfs2_fiemap, };
fs/gfs2/xattr.c +103 -9
144 lines not on this page · raw message
fs/posix_acl.c +6 -3
@@ -703,7 +703,7 @@ posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl, }EXPORT_SYMBOL (posix_acl_to_xattr); -static int +int posix_acl_xattr_get (const struct xattr_handler *handler,struct dentry *dentry,const char *name,void *value,size_t size)
@@ -727,8 +727,9 @@ posix_acl_xattr_get(const struct xattr_handler *handler,return error; } +EXPORT_SYMBOL (posix_acl_xattr_get); -static int +int posix_acl_xattr_set (const struct xattr_handler *handler,struct dentry *dentry,const char *name,const void *value,size_t size,int flags)
@@ -764,12 +765,14 @@ out:posix_acl_release (acl);return ret; } +EXPORT_SYMBOL (posix_acl_xattr_set); -static bool +bool posix_acl_xattr_list (struct dentry *dentry) {return IS_POSIXACL (d_backing_inode (dentry)); } +EXPORT_SYMBOL (posix_acl_xattr_list);const struct xattr_handler posix_acl_access_xattr_handler = { .name =XATTR_NAME_POSIX_ACL_ACCESS ,
include/linux/posix_acl_xattr.h +8 -0
@@ -53,6 +53,14 @@ struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,int posix_acl_to_xattr (struct user_namespace *user_ns,const struct posix_acl *acl,void *buffer,size_t size); +int posix_acl_xattr_get (const struct xattr_handler *handler, +struct dentry *dentry,const char *name, +void *value,size_t size); +int posix_acl_xattr_set (const struct xattr_handler *handler, +struct dentry *dentry,const char *name, +const void *value,size_t size,int flags); +bool posix_acl_xattr_list (struct dentry *dentry); +extern const struct xattr_handler posix_acl_access_xattr_handler;extern const struct xattr_handler posix_acl_default_xattr_handler;
Signature · 1 line
2.5.5
PATCH 1/1 gfs2: Switch to generic xattr handlers
----- Original Message -----
Quoted 8 lines
Move the pre- and postamble code in gfs2_{get,set,remove}xattr into the handlers in
gfs2_xattr_handlers. Replace the generic POSIX ACL handlers in there with gfs2-specific versions that wrap the generic handlers into the pre- and postamble code. With that, gfs2_{get,set,remove}xattr can be removed and replaced with the generic inode operations.Signed-off-by Andreas Gruenbacher <[email protected]>---
Hi Andreas,
The patch looks good to me.
Regards,
Bob Peterson
Red Hat File Systems