Whamcloud - gitweb
LU-10030 llite: extend inode flags into GET/SETXATTR ioctl 72/30072/2
authorWang Shilong <wshilong@ddn.com>
Tue, 14 Nov 2017 02:12:33 +0000 (10:12 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 22 Nov 2017 03:55:42 +0000 (03:55 +0000)
This is very useful for projet quota tools to save RPC call
to change project inherit attribute together with project ID.

Change-Id: I5b545bf2c5c601b552a85322c80994dabbca0b12
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/30072
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
lustre/llite/file.c

index f2a7f1d..d640b0d 100644 (file)
@@ -2689,6 +2689,7 @@ int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd,
                           sizeof(fsxattr)))
                RETURN(-EFAULT);
 
                           sizeof(fsxattr)))
                RETURN(-EFAULT);
 
+       fsxattr.fsx_xflags = ll_inode_to_ext_flags(inode->i_flags);
        fsxattr.fsx_projid = ll_i2info(inode)->lli_projid;
        if (copy_to_user((struct fsxattr __user *)arg,
                         &fsxattr, sizeof(fsxattr)))
        fsxattr.fsx_projid = ll_i2info(inode)->lli_projid;
        if (copy_to_user((struct fsxattr __user *)arg,
                         &fsxattr, sizeof(fsxattr)))
@@ -2705,6 +2706,7 @@ int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
        struct ptlrpc_request *req = NULL;
        int rc = 0;
        struct fsxattr fsxattr;
        struct ptlrpc_request *req = NULL;
        int rc = 0;
        struct fsxattr fsxattr;
+       struct cl_object *obj;
 
        /* only root could change project ID */
        if (!cfs_capable(CFS_CAP_SYS_ADMIN))
 
        /* only root could change project ID */
        if (!cfs_capable(CFS_CAP_SYS_ADMIN))
@@ -2720,12 +2722,26 @@ int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
                           sizeof(fsxattr)))
                GOTO(out_fsxattr1, rc = -EFAULT);
 
                           sizeof(fsxattr)))
                GOTO(out_fsxattr1, rc = -EFAULT);
 
+       op_data->op_attr_flags = fsxattr.fsx_xflags;
        op_data->op_projid = fsxattr.fsx_projid;
        op_data->op_projid = fsxattr.fsx_projid;
-       op_data->op_attr.ia_valid |= MDS_ATTR_PROJID;
+       op_data->op_attr.ia_valid |= (MDS_ATTR_PROJID | ATTR_ATTR_FLAG);
        rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
                        0, &req);
        ptlrpc_req_finished(req);
 
        rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
                        0, &req);
        ptlrpc_req_finished(req);
 
+       obj = ll_i2info(inode)->lli_clob;
+       if (obj) {
+               struct iattr *attr;
+
+               inode->i_flags = ll_ext_to_inode_flags(fsxattr.fsx_xflags);
+               OBD_ALLOC_PTR(attr);
+               if (attr == NULL)
+                       GOTO(out_fsxattr1, rc = -ENOMEM);
+               attr->ia_valid = ATTR_ATTR_FLAG;
+               rc = cl_setattr_ost(obj, attr, fsxattr.fsx_xflags);
+
+               OBD_FREE_PTR(attr);
+       }
 out_fsxattr1:
        ll_finish_md_op_data(op_data);
        RETURN(rc);
 out_fsxattr1:
        ll_finish_md_op_data(op_data);
        RETURN(rc);