Whamcloud - gitweb
LU-11165 llite: set iflags and catch error from md_setattr() properly 60/32860/5
authorWang Shilong <wshilong@ddn.com>
Mon, 23 Jul 2018 23:45:59 +0000 (07:45 +0800)
committerOleg Drokin <green@whamcloud.com>
Sun, 16 Sep 2018 06:41:52 +0000 (06:41 +0000)
As John Hammond pointed out:
In ll_ioctl_fssetxattr() we may discard errors from md_setattr().
And we only set the local i_flags when lli_clob is not NULL.

This patch tried to address above problems.

Test-Parameters: trivial testlist=sanity-quota
Change-Id: Ib65ec61932b00f71367a8da6be67e3f94ebd5005
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/32860
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/file.c

index b7c3a63..46bc2ac 100644 (file)
@@ -3074,6 +3074,7 @@ int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
        int rc = 0;
        struct fsxattr fsxattr;
        struct cl_object *obj;
+       struct iattr *attr;
        int flags;
 
        /* only root could change project ID */
@@ -3088,7 +3089,7 @@ int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
        if (copy_from_user(&fsxattr,
                           (const struct fsxattr __user *)arg,
                           sizeof(fsxattr)))
-               GOTO(out_fsxattr1, rc = -EFAULT);
+               GOTO(out_fsxattr, rc = -EFAULT);
 
        flags = ll_xflags_to_inode_flags(fsxattr.fsx_xflags);
        op_data->op_attr_flags = ll_inode_to_ext_flags(flags);
@@ -3099,21 +3100,21 @@ int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
        rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
                        0, &req);
        ptlrpc_req_finished(req);
-
+       if (rc)
+               GOTO(out_fsxattr, rc);
+       ll_update_inode_flags(inode, op_data->op_attr_flags);
        obj = ll_i2info(inode)->lli_clob;
-       if (obj) {
-               struct iattr *attr;
+       if (obj == NULL)
+               GOTO(out_fsxattr, rc);
 
-               ll_update_inode_flags(inode, op_data->op_attr_flags);
-               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_ALLOC_PTR(attr);
+       if (attr == NULL)
+               GOTO(out_fsxattr, rc = -ENOMEM);
 
-               OBD_FREE_PTR(attr);
-       }
-out_fsxattr1:
+       attr->ia_valid = ATTR_ATTR_FLAG;
+       rc = cl_setattr_ost(obj, attr, fsxattr.fsx_xflags);
+       OBD_FREE_PTR(attr);
+out_fsxattr:
        ll_finish_md_op_data(op_data);
        RETURN(rc);
 }