Re: [Cluster-devel] [PATCH] gfs2: Switch to generic xattr handlers

2016-04-12 Thread Bob Peterson
- Original Message -
> 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 
> ---

Hi Andreas,

The patch looks good to me.

Regards,

Bob Peterson
Red Hat File Systems



[Cluster-devel] [PATCH] gfs2: Switch to generic xattr handlers

2016-04-12 Thread Andreas Gruenbacher
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 
---
 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(-)

diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index bb30f9a..3398342 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -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, );
-   ret = gfs2_glock_nq();
-   if (ret == 0) {
-   ret = gfs2_rsqa_alloc(ip);
-   if (ret == 0)
-   ret = generic_setxattr(dentry, name, data, size, flags);
-   gfs2_glock_dq();
-   }
-   gfs2_holder_uninit();
-   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, );
-   ret = gfs2_glock_nq();
-   if (ret == 0) {
-   ret = generic_getxattr(dentry, name, data, size);
-   gfs2_glock_dq();
-   }
-   gfs2_holder_uninit();
-   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, );
-   ret = gfs2_glock_nq();
-   if (ret == 0) {
-   ret = gfs2_rsqa_alloc(ip);
-   if (ret == 0)
-   ret = generic_removexattr(dentry, name);
-   gfs2_glock_dq();
-   }
-   gfs2_holder_uninit();
-   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,
 };
 
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index e8dfb47..5d12485 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -583,13 +583,11 @@ out:
  *
  * Returns: actual size of data on success, -errno on error
  */
-static int gfs2_xattr_get(const struct xattr_handler *handler,
- struct dentry *dentry, const char *name,
- void *buffer, size_t size)
+static int