From ecc46547d1277520d12c388112faad9b45732d6c Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Tue, 24 Jul 2018 07:45:59 +0800 Subject: [PATCH] LU-11165 llite: set iflags and catch error from md_setattr() properly 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 Reviewed-on: https://review.whamcloud.com/32860 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/llite/file.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index b7c3a63..46bc2ac 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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); } -- 1.8.3.1