All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@whamcloud.com>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 31/32] lustre: mdc: create mdc_acl.c
Date: Wed, 3 Apr 2019 20:47:15 +0000	[thread overview]
Message-ID: <C7E3D55D-531A-4F6E-AB4D-3D1BFE9F50F5@whamcloud.com> (raw)
In-Reply-To: <155252231217.26912.1851699923338684554.stgit@noble.brown>

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> This new C file contains acl related code so it can be
> conditionally compiled.
> 
> The only use of CONFIG_LUSTRE_FS_POSIX_ACL in a C file is
> now in xattr.c which is not convenient to avoid.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>

> ---
> drivers/staging/lustre/lustre/mdc/Makefile       |    1 
> drivers/staging/lustre/lustre/mdc/mdc_acl.c      |   48 +++++++++++++++++++
> drivers/staging/lustre/lustre/mdc/mdc_internal.h |   10 ++++
> drivers/staging/lustre/lustre/mdc/mdc_request.c  |   57 +---------------------
> 4 files changed, 61 insertions(+), 55 deletions(-)
> create mode 100644 drivers/staging/lustre/lustre/mdc/mdc_acl.c
> 
> diff --git a/drivers/staging/lustre/lustre/mdc/Makefile b/drivers/staging/lustre/lustre/mdc/Makefile
> index 5f48e91b9839..137a4413c268 100644
> --- a/drivers/staging/lustre/lustre/mdc/Makefile
> +++ b/drivers/staging/lustre/lustre/mdc/Makefile
> @@ -3,3 +3,4 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include
> 
> obj-$(CONFIG_LUSTRE_FS) += mdc.o
> mdc-y := mdc_changelog.o mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o lproc_mdc.o
> +mdc-$(CONFIG_LUSTRE_FS_POSIX_ACL) += mdc_acl.o
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_acl.c b/drivers/staging/lustre/lustre/mdc/mdc_acl.c
> new file mode 100644
> index 000000000000..045235ad703a
> --- /dev/null
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_acl.c
> @@ -0,0 +1,48 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <lustre_acl.h>
> +
> +#include "mdc_internal.h"
> +
> +int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
> +{
> +	struct req_capsule *pill = &req->rq_pill;
> +	struct mdt_body	*body = md->body;
> +	struct posix_acl *acl;
> +	void *buf;
> +	int rc;
> +
> +	/* for ACL, it's possible that FLACL is set but aclsize is zero.
> +	 * only when aclsize != 0 there's an actual segment for ACL
> +	 * in reply buffer.
> +	 */
> +	if (!body->mbo_aclsize) {
> +		md->posix_acl = NULL;
> +		return 0;
> +	}
> +
> +	buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->mbo_aclsize);
> +
> +	if (!buf)
> +		return -EPROTO;
> +
> +	acl = posix_acl_from_xattr(&init_user_ns, buf, body->mbo_aclsize);
> +	if (!acl)
> +		return 0;
> +
> +	if (IS_ERR(acl)) {
> +		rc = PTR_ERR(acl);
> +		CERROR("convert xattr to acl: %d\n", rc);
> +		return rc;
> +	}
> +
> +	rc = posix_acl_valid(&init_user_ns, acl);
> +	if (rc) {
> +		CERROR("validate acl: %d\n", rc);
> +		posix_acl_release(acl);
> +		return rc;
> +	}
> +
> +	md->posix_acl = acl;
> +	return 0;
> +}
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h
> index 2b849e8166b2..20beff384add 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h
> @@ -141,6 +141,16 @@ static inline int mdc_prep_elc_req(struct obd_export *exp,
> 				 count);
> }
> 
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> +int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md);
> +#else
> +static inline
> +int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
> +{
> +	return 0;
> +}
> +#endif
> +
> static inline unsigned long hash_x_index(u64 hash, int hash64)
> {
> 	if (BITS_PER_LONG == 32 && hash64)
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> index a0b74244f295..7d4450ef8740 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> @@ -408,46 +408,6 @@ static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
> 				req);
> }
> 
> -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> -static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
> -{
> -	struct req_capsule *pill = &req->rq_pill;
> -	struct mdt_body	*body = md->body;
> -	struct posix_acl *acl;
> -	void *buf;
> -	int rc;
> -
> -	if (!body->mbo_aclsize)
> -		return 0;
> -
> -	buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->mbo_aclsize);
> -
> -	if (!buf)
> -		return -EPROTO;
> -
> -	acl = posix_acl_from_xattr(&init_user_ns, buf, body->mbo_aclsize);
> -	if (!acl)
> -		return 0;
> -
> -	if (IS_ERR(acl)) {
> -		rc = PTR_ERR(acl);
> -		CERROR("convert xattr to acl: %d\n", rc);
> -		return rc;
> -	}
> -
> -	rc = posix_acl_valid(&init_user_ns, acl);
> -	if (rc) {
> -		CERROR("validate acl: %d\n", rc);
> -		posix_acl_release(acl);
> -		return rc;
> -	}
> -
> -	md->posix_acl = acl;
> -	return 0;
> -}
> -#else
> -#define mdc_unpack_acl(req, md) 0
> -#endif
> 
> static int mdc_get_lustre_md(struct obd_export *exp,
> 			     struct ptlrpc_request *req,
> @@ -526,21 +486,8 @@ static int mdc_get_lustre_md(struct obd_export *exp,
> 	}
> 	rc = 0;
> 
> -	if (md->body->mbo_valid & OBD_MD_FLACL) {
> -		/* for ACL, it's possible that FLACL is set but aclsize is zero.
> -		 * only when aclsize != 0 there's an actual segment for ACL
> -		 * in reply buffer.
> -		 */
> -		if (md->body->mbo_aclsize) {
> -			rc = mdc_unpack_acl(req, md);
> -			if (rc)
> -				goto out;
> -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> -		} else {
> -			md->posix_acl = NULL;
> -#endif
> -		}
> -	}
> +	if (md->body->mbo_valid & OBD_MD_FLACL)
> +		rc = mdc_unpack_acl(req, md);
> 
> out:
> 	if (rc)
> 
> 

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud

      reply	other threads:[~2019-04-03 20:47 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 01/32] lustre: remove outdated comments about ->ap_* functions NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 02/32] lustre: ptlrpc: remove ptlrpc_prep_bulk_frag NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 03/32] lustre: ptlrpc: make ptlrpc_bulk_frag_ops always const NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 09/32] lustre: lnet: discard LNET_MD_PHYS NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 04/32] lustre: ptlrpc: remove inline on non-inlined functions NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 11/32] lustre: lnet: don't embed whole lnet_md in lnet_event NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 07/32] lustre: ptlrpc: remove *GET*KIOV macros and fields NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 05/32] lustre: ptlrpc: drop support for KVEC bulk descriptors NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 10/32] lustre: lnet: discard LNET_MD_IOVEC NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 08/32] lustre: ptlrpc: simplify bd_vec access NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 06/32] lustre: ptlrpc: discard BULK_BUF types NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 12/32] lustre: lnet: merge lnet_md_alloc into lnet_md_build NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 15/32] lustre: lnet: remove msg_iov from lnet_msg NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 14/32] lustre: lnet: discard kvec option from lnet_libmd NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 13/32] lustre: lnet: always put a page list into struct lnet_libmd NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 17/32] lustre: socklnd: discard tx_iov NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 19/32] lustre: socklnd: discard kiblnd_setup_rd_iov NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 18/32] lustre: socklnd: don't fall-back to tcp_sendpage NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 20/32] lustre: lnet: discard lnet_kvaddr_to_page NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 16/32] lustre: lnet: simplify ksock_tx NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 21/32] lustre: ptlrpc: discard a server-only waitq NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 25/32] lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args() NeilBrown
2019-04-03 20:49   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 27/32] lustre: don't call unshare_fs_struct() NeilBrown
2019-04-03 20:30   ` Andreas Dilger
2019-04-03 23:56     ` NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 22/32] lustre: ptlrpc: simplify locking in ptlrpc_add_rqs_to_pool() NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 28/32] lustre: don't declare extern variables in C files NeilBrown
2019-04-03 20:43   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 24/32] lustre: ptlrpc: discard cb_list and ptlrpc_set_cbdata; NeilBrown
2019-04-03 20:53   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 23/32] lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t NeilBrown
2019-04-03 20:26   ` Andreas Dilger
2019-04-03 23:46     ` NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 26/32] lustre: ptlrpc: don't use list_for_each_entry_safe unnecessarily NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 30/32] lustre: remove some "#ifdef CONFIG*" from .c files NeilBrown
2019-04-03 20:45   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 32/32] lustre: mgc: remove llog_process_lock NeilBrown
2019-04-03 20:47   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 29/32] lustre: introduce CONFIG_LUSTRE_FS_POSIX_ACL NeilBrown
2019-04-03 20:44   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 31/32] lustre: mdc: create mdc_acl.c NeilBrown
2019-04-03 20:47   ` Andreas Dilger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C7E3D55D-531A-4F6E-AB4D-3D1BFE9F50F5@whamcloud.com \
    --to=adilger@whamcloud.com \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.