Received: by 10.192.165.156 with SMTP id m28csp212640imm; Sun, 15 Apr 2018 21:20:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Udn6L/M0aXaRsq2nocFchgYY2Yr5tZyQO/2wkmxqtWWJ5stj3FQau6X2VW9tdlIwNT8yI X-Received: by 10.98.9.72 with SMTP id e69mr20166209pfd.197.1523852441631; Sun, 15 Apr 2018 21:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523852441; cv=none; d=google.com; s=arc-20160816; b=gY13/442iFvN12K3UCSqJ8jDprXRB4bhD6QAcepdKjS7gyOWB6Q6N37P+aDYwmiiVm JJbrfJwX3axbb2xTOBKftMemt6r+qdBBXd1AAu6lDiwHGxMHdqqX/yYsdaAnuSGttt8g Bt1Tp41l2uwzFFLEJZKtUAH3e9Fp5Hsu8CUYeutuCMJJW8zS6tcp2pziRMqn9vx8C4Lf EBc50Vkln+Bk0qNQ3qjQsE8E0rc6NIFUgEbnFhxm0rnrWHNVxw20+wsucFQWm6xAxvKf AD8ed2aPe0rn02JY1kfgZI62r0ZCeZDOGfYLaa6GsyOiB2csEpLAsYLNaP9ZdA5+/ByX wvlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ghxq4WioX9NMhQBt09vGBexNEkPuy+r28KRwePZoK64=; b=gw/19cc4VsRjFG2IbudaWHNmdRp5J091kws+gaVvP/m9QN2VZU/uFatrBf3a3p2Cbr SBei2OjBi0Z2hslGCzNUWDIjieeScIC2GaVFUAqucQKemG7X5b+xMy8qsP8omZ3//aFr 1TJ69Wr3UNHDXX4WItWvxQOvjC8I6HF31QijlxJG/A6wrCmyA9VPeS4T6tbITF6VnFku aPtSS6jRXywBae0MCzgprXeTBemNvyTjBl7rWoIAZ8poVYrsgz76Us7pcCSSVPer97bB IFOmtvogLd1jui99SG8sgj3jCTbMMU2eHOd6CoYTiitasZW0Mg/RU0TkjxugV3Rixpym Inag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si8809570pgn.406.2018.04.15.21.20.27; Sun, 15 Apr 2018 21:20:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754018AbeDPESz (ORCPT + 99 others); Mon, 16 Apr 2018 00:18:55 -0400 Received: from smtp4.ccs.ornl.gov ([160.91.203.40]:35548 "EHLO smtp4.ccs.ornl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753149AbeDPEPU (ORCPT ); Mon, 16 Apr 2018 00:15:20 -0400 Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id BAD141005193; Mon, 16 Apr 2018 00:15:12 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id B73391F8; Mon, 16 Apr 2018 00:15:12 -0400 (EDT) From: James Simmons To: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Oleg Drokin , NeilBrown Cc: Linux Kernel Mailing List , Lustre Development List , Niu Yawei , Bobi Jam , James Simmons Subject: [PATCH 07/22] staging: lustre: llite: refactor lustre.lov xattr handling Date: Mon, 16 Apr 2018 00:14:56 -0400 Message-Id: <1523852111-17321-8-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523852111-17321-1-git-send-email-jsimmons@infradead.org> References: <1523852111-17321-1-git-send-email-jsimmons@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niu Yawei The function ll_xattr_set() contains special code to handle the lustre specific xattr lustre.lov. Move all this code to a new function ll_setstripe_ea(). Signed-off-by: Bobi Jam Signed-off-by: Niu Yawei Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8998 Reviewed-on: https://review.whamcloud.com/24851 Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Jinshan Xiong Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/xattr.c | 131 +++++++++++++++------------- 1 file changed, 69 insertions(+), 62 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 55a19a5..1b462e4 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -186,6 +186,73 @@ static int get_hsm_state(struct inode *inode, u32 *hus_states) return rc; } +static int ll_setstripe_ea(struct dentry *dentry, struct lov_user_md *lump, + size_t size) +{ + struct inode *inode = d_inode(dentry); + int rc = 0; + + if (size != 0 && size < sizeof(struct lov_user_md)) + return -EINVAL; + + /* + * It is possible to set an xattr to a "" value of zero size. + * For this case we are going to treat it as a removal. + */ + if (!size && lump) + lump = NULL; + + /* Attributes that are saved via getxattr will always have + * the stripe_offset as 0. Instead, the MDS should be + * allowed to pick the starting OST index. b=17846 + */ + if (lump && lump->lmm_stripe_offset == 0) + lump->lmm_stripe_offset = -1; + + /* Avoid anyone directly setting the RELEASED flag. */ + if (lump && (lump->lmm_pattern & LOV_PATTERN_F_RELEASED)) { + /* Only if we have a released flag check if the file + * was indeed archived. + */ + u32 state = HS_NONE; + + rc = get_hsm_state(inode, &state); + if (rc) + return rc; + + if (!(state & HS_ARCHIVED)) { + CDEBUG(D_VFSTRACE, + "hus_states state = %x, pattern = %x\n", + state, lump->lmm_pattern); + /* + * Here the state is: real file is not + * archived but user is requesting to set + * the RELEASED flag so we mask off the + * released flag from the request + */ + lump->lmm_pattern ^= LOV_PATTERN_F_RELEASED; + } + } + + if (lump && S_ISREG(inode->i_mode)) { + __u64 it_flags = FMODE_WRITE; + int lum_size; + + lum_size = ll_lov_user_md_size(lump); + if (lum_size < 0 || size < lum_size) + return 0; /* b=10667: ignore error */ + + rc = ll_lov_setstripe_ea_info(inode, dentry, it_flags, lump, + lum_size); + /* b=10667: rc always be 0 here for now */ + rc = 0; + } else if (S_ISDIR(inode->i_mode)) { + rc = ll_dir_setstripe(inode, lump, 0); + } + + return rc; +} + static int ll_xattr_set(const struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, const char *name, const void *value, size_t size, @@ -198,73 +265,13 @@ static int ll_xattr_set(const struct xattr_handler *handler, PFID(ll_inode2fid(inode)), inode, name); if (!strcmp(name, "lov")) { - struct lov_user_md *lump = (struct lov_user_md *)value; int op_type = flags == XATTR_REPLACE ? LPROC_LL_REMOVEXATTR : LPROC_LL_SETXATTR; - int rc = 0; ll_stats_ops_tally(ll_i2sbi(inode), op_type, 1); - if (size != 0 && size < sizeof(struct lov_user_md)) - return -EINVAL; - - /* - * It is possible to set an xattr to a "" value of zero size. - * For this case we are going to treat it as a removal. - */ - if (!size && lump) - lump = NULL; - - /* Attributes that are saved via getxattr will always have - * the stripe_offset as 0. Instead, the MDS should be - * allowed to pick the starting OST index. b=17846 - */ - if (lump && lump->lmm_stripe_offset == 0) - lump->lmm_stripe_offset = -1; - - /* Avoid anyone directly setting the RELEASED flag. */ - if (lump && (lump->lmm_pattern & LOV_PATTERN_F_RELEASED)) { - /* Only if we have a released flag check if the file - * was indeed archived. - */ - u32 state = HS_NONE; - - rc = get_hsm_state(inode, &state); - if (rc) - return rc; - - if (!(state & HS_ARCHIVED)) { - CDEBUG(D_VFSTRACE, - "hus_states state = %x, pattern = %x\n", - state, lump->lmm_pattern); - /* - * Here the state is: real file is not - * archived but user is requesting to set - * the RELEASED flag so we mask off the - * released flag from the request - */ - lump->lmm_pattern ^= LOV_PATTERN_F_RELEASED; - } - } - - if (lump && S_ISREG(inode->i_mode)) { - __u64 it_flags = FMODE_WRITE; - int lum_size; - - lum_size = ll_lov_user_md_size(lump); - if (lum_size < 0 || size < lum_size) - return 0; /* b=10667: ignore error */ - - rc = ll_lov_setstripe_ea_info(inode, dentry, it_flags, - lump, lum_size); - /* b=10667: rc always be 0 here for now */ - rc = 0; - } else if (S_ISDIR(inode->i_mode)) { - rc = ll_dir_setstripe(inode, lump, 0); - } - - return rc; - + return ll_setstripe_ea(dentry, (struct lov_user_md *)value, + size); } else if (!strcmp(name, "lma") || !strcmp(name, "link")) { ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1); return 0; -- 1.8.3.1