From 311e8d539b1932593462de428c46ea176b8905db Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Tue, 14 Nov 2017 10:12:33 +0800 Subject: [PATCH] LU-10030 llite: extend inode flags into GET/SETXATTR ioctl 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 Reviewed-on: https://review.whamcloud.com/30072 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Yingjin Qian --- lustre/llite/file.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index f2a7f1d..d640b0d 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2689,6 +2689,7 @@ int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd, 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))) @@ -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 cl_object *obj; /* 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); + op_data->op_attr_flags = fsxattr.fsx_xflags; 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); + 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); -- 1.8.3.1