Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp757650imm; Tue, 15 May 2018 08:45:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr6JlLOqovp0zilNR+9mNpHhuxYKeuhWpvGgiIBbxSwyAZoEAd4qD4bsXkCmQhwO9DXVZjf X-Received: by 2002:a63:8dca:: with SMTP id z193-v6mr12531404pgd.418.1526399119585; Tue, 15 May 2018 08:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526399119; cv=none; d=google.com; s=arc-20160816; b=q847gor6r93jsHRJiKsTe+i5TaxqW0CXWmb5WCw4wTucSEqge7uRgyDUXx+SYE2YIy u9bApqn0O8RbOOd2SeyuN/OQeD3AR2CNr9fDCBsJrKP0ZeDXu/AgoeM3GGWW5YUfCVG5 l38fakt6uygKJOmE6lY9zh60wD8AZjsZXhMjnSRwLrARoulUSyXEdgtWPXQZmHQiO1t4 iWY4IPnjrJfAusFPnXL5jI5FfZm0hIRH9t6g6Q+1kcDQRd89ZjQcTPiGOE7EThdw1uGn eS4OArCmQCca3rU5HW5Lhd/7cnXvkzdJSEnEstQcEHO0EeGPy81T+IHDDkbscNGmD5Lk dbYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=u4f2hyxalIHtjWxSI1NyKWYqL8Qjc3XPhp7SYdReCFk=; b=kJ8/BFa3jb1K4OHsurUzacYCVuVnkjRZhFX/D+9pEN+nxu2SWVN44Zh23qrZ7uH587 TAnjzDHvZhtA3RVKEgG7E3j37uwEpeuWHvUxO420pbGDCFIkUApYSa67jK2Ps0lIuZPK vnDTBbN3qnsFJMJPiPwWXsS6brTAr92iWaR+Kz1ikO7lNgsMFPl7DZtDQRoZW+L6KYeD an5rENEWbl0CSDDH0lbSBLP+4CvE9OT1RoCvJdA9ssF2+8I5rN+dKpTZp38MFkb3+sTz kRcLeWj0JZFWRF3pdQAE95ePErXy7j+9NPdu37Fa9kfXXu92oy8eKR2JfV0qKfj7Ural 0ijg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=qJ/rNbVS; 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 c21-v6si215931pgw.657.2018.05.15.08.44.34; Tue, 15 May 2018 08:45:19 -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; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=qJ/rNbVS; 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 S1753251AbeEOPBh (ORCPT + 99 others); Tue, 15 May 2018 11:01:37 -0400 Received: from casper.infradead.org ([85.118.1.10]:33298 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752102AbeEOPBf (ORCPT ); Tue, 15 May 2018 11:01:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Message-ID:In-Reply-To:Subject:cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=u4f2hyxalIHtjWxSI1NyKWYqL8Qjc3XPhp7SYdReCFk=; b=qJ/rNbVSnXzpzIsSXeiBpJGDC K2ky8Mumnxoz+jX6e2IIjbondSIAawrMjht366YRM/C7Ck0TCCjb0u3E20VGcLcH7VKi+t50VQJAa TdpRBSxuAvqZK4FC4xOprenF3TLiO2paID0GX7sEeOPRx40kJeRjTYkYc6oewfrQXsaSlM2vfWBlj 9JN+x3i7XuAXVFsxrn3wjyeXBWVChLypyRcfAHh2KdmPqot4C4i2PHVxi6YUwGFxL9e5oBvwauSZX lWX3kfDEPYzlAY8v+0HDaU3W2um2l66HXQswPL1lg6k5NuBmOFhf56ij+pnPf/C2eUxQSWEogO3EC dfTDGl+Ug==; Received: from jsimmons (helo=localhost) by casper.infradead.org with local-esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIbSD-0005Lm-0T; Tue, 15 May 2018 15:01:30 +0000 Date: Tue, 15 May 2018 16:01:28 +0100 (BST) From: James Simmons To: NeilBrown cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Oleg Drokin , Linux Kernel Mailing List , Lustre Development List , Dmitry Eremin , "John L. Hammond" , James Simmons Subject: Re: [PATCH v2 1/5] staging: lustre: llite: add support set_acl method in inode operations In-Reply-To: <878t8l7ext.fsf@notabene.neil.brown.name> Message-ID: References: <1526350623-4616-1-git-send-email-jsimmons@infradead.org> <1526350623-4616-2-git-send-email-jsimmons@infradead.org> <878t8l7ext.fsf@notabene.neil.brown.name> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180515_160129_039667_2E2B8083 X-CRM114-Status: GOOD ( 31.39 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 NO_RELAYS Informational: message was not relayed via SMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mon, May 14 2018, James Simmons wrote: > > > From: Dmitry Eremin > > > > Linux kernel v3.14 adds set_acl method to inode operations. > > This patch adds support to Lustre for proper acl management. > > > > Signed-off-by: Dmitry Eremin > > Signed-off-by: John L. Hammond > > Signed-off-by: James Simmons > > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183 > > Reviewed-on: https://review.whamcloud.com/25965 > > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10541 > > Reviewed-on: https://review.whamcloud.com/31588 > > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10926 > > Reviewed-on: https://review.whamcloud.com/32045 > > Reviewed-by: Bob Glossman > > Reviewed-by: James Simmons > > Reviewed-by: Andreas Dilger > > Reviewed-by: Dmitry Eremin > > Reviewed-by: Oleg Drokin > > Signed-off-by: James Simmons > > --- > > Changelog: > > > > v1) Initial patch ported to staging tree > > v2) Fixed up goto handling and avoid BUG() when calling > > forget_cached_acl()with invalid type as pointed out by Dan Carpenter > > > > drivers/staging/lustre/lustre/llite/file.c | 62 ++++++++++++++++++++++ > > .../staging/lustre/lustre/llite/llite_internal.h | 4 ++ > > drivers/staging/lustre/lustre/llite/namei.c | 10 +++- > > 3 files changed, 74 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c > > index 0026fde..64a5698 100644 > > --- a/drivers/staging/lustre/lustre/llite/file.c > > +++ b/drivers/staging/lustre/lustre/llite/file.c > > @@ -3030,6 +3030,7 @@ static int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > > return rc; > > } > > > > +#ifdef CONFIG_FS_POSIX_ACL > > Using #ifdef in .c files is generally discouraged. > The "standard" approach here is: > - put the acl code in a separate file (acl.c) > - optionally include it via the Make file > lustre-$(CONFIG_FS_POSIX_ACL) += acl.o > > - in the header where ll_get_acl and ll_set_acl are declared have > #ifdef CONFIG_FS_POSIX_ACL > declare the functions > #else > #define ll_get_acl NULL > #define ll_set_acl NULL > #endif > > Now as this is staging and that is (presumably) an upstream patch > lightly improved it is probably fine to include the patch as-is, > but in that case we will probably want to fix it up later. So you want Lustre to be like everyone else :-) Okay I will fix up and send a new patch series. > Thanks, > NeilBrown > > > struct posix_acl *ll_get_acl(struct inode *inode, int type) > > { > > struct ll_inode_info *lli = ll_i2info(inode); > > @@ -3043,6 +3044,64 @@ struct posix_acl *ll_get_acl(struct inode *inode, int type) > > return acl; > > } > > > > +int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type) > > +{ > > + struct ll_sb_info *sbi = ll_i2sbi(inode); > > + struct ptlrpc_request *req = NULL; > > + const char *name = NULL; > > + size_t value_size = 0; > > + char *value = NULL; > > + int rc; > > + > > + switch (type) { > > + case ACL_TYPE_ACCESS: > > + name = XATTR_NAME_POSIX_ACL_ACCESS; > > + if (acl) > > + rc = posix_acl_update_mode(inode, &inode->i_mode, &acl); > > + break; > > + > > + case ACL_TYPE_DEFAULT: > > + name = XATTR_NAME_POSIX_ACL_DEFAULT; > > + if (!S_ISDIR(inode->i_mode)) > > + rc = acl ? -EACCES : 0; > > + break; > > + > > + default: > > + rc = -EINVAL; > > + break; > > + } > > + if (rc) > > + return rc; > > + > > + if (acl) { > > + value_size = posix_acl_xattr_size(acl->a_count); > > + value = kmalloc(value_size, GFP_NOFS); > > + if (!value) { > > + rc = -ENOMEM; > > + goto out; > > + } > > + > > + rc = posix_acl_to_xattr(&init_user_ns, acl, value, value_size); > > + if (rc < 0) > > + goto out_value; > > + } > > + > > + rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), > > + value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM, > > + name, value, value_size, 0, 0, 0, &req); > > + > > + ptlrpc_req_finished(req); > > +out_value: > > + kfree(value); > > +out: > > + if (rc) > > + forget_cached_acl(inode, type); > > + else > > + set_cached_acl(inode, type, acl); > > + return rc; > > +} > > +#endif /* CONFIG_FS_POSIX_ACL */ > > + > > int ll_inode_permission(struct inode *inode, int mask) > > { > > struct ll_sb_info *sbi; > > @@ -3164,7 +3223,10 @@ int ll_inode_permission(struct inode *inode, int mask) > > .permission = ll_inode_permission, > > .listxattr = ll_listxattr, > > .fiemap = ll_fiemap, > > +#ifdef CONFIG_FS_POSIX_ACL > > .get_acl = ll_get_acl, > > + .set_acl = ll_set_acl, > > +#endif > > }; > > > > /* dynamic ioctl number support routines */ > > diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h > > index 6504850..2280327 100644 > > --- a/drivers/staging/lustre/lustre/llite/llite_internal.h > > +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h > > @@ -754,7 +754,11 @@ enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits, > > int ll_md_real_close(struct inode *inode, fmode_t fmode); > > int ll_getattr(const struct path *path, struct kstat *stat, > > u32 request_mask, unsigned int flags); > > +#ifdef CONFIG_FS_POSIX_ACL > > struct posix_acl *ll_get_acl(struct inode *inode, int type); > > +int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type); > > +#endif /* CONFIG_FS_POSIX_ACL */ > > + > > int ll_migrate(struct inode *parent, struct file *file, int mdtidx, > > const char *name, int namelen); > > int ll_get_fid_by_name(struct inode *parent, const char *name, > > diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c > > index 9ac7f09..b41f189 100644 > > --- a/drivers/staging/lustre/lustre/llite/namei.c > > +++ b/drivers/staging/lustre/lustre/llite/namei.c > > @@ -1195,7 +1195,10 @@ static int ll_rename(struct inode *src, struct dentry *src_dchild, > > .getattr = ll_getattr, > > .permission = ll_inode_permission, > > .listxattr = ll_listxattr, > > - .get_acl = ll_get_acl, > > +#ifdef CONFIG_FS_POSIX_ACL > > + .get_acl = ll_get_acl, > > + .set_acl = ll_set_acl, > > +#endif > > }; > > > > const struct inode_operations ll_special_inode_operations = { > > @@ -1203,5 +1206,8 @@ static int ll_rename(struct inode *src, struct dentry *src_dchild, > > .getattr = ll_getattr, > > .permission = ll_inode_permission, > > .listxattr = ll_listxattr, > > - .get_acl = ll_get_acl, > > +#ifdef CONFIG_FS_POSIX_ACL > > + .get_acl = ll_get_acl, > > + .set_acl = ll_set_acl, > > +#endif > > }; > > -- > > 1.8.3.1 >