All of lore.kernel.org
 help / color / mirror / Atom feed
* [lustre-devel] [PATCH 00/32] Another bunch of lustre patches.
@ 2019-03-14  0:11 NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 01/32] lustre: remove outdated comments about ->ap_* functions NeilBrown
                   ` (31 more replies)
  0 siblings, 32 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

There are two parts of this series worth highlighting.

Lustre's "memory descriptors" allow a payload to be described as
either a list of iov - virtual address based - or bvec - page based.
This results in lots of duplication at various levels of the stack.
At the bottom of the stack, the virtual addresses get mapped to
pages.  So it is cleaner to do that mapping at the top of the stack
and pass only pages down.

So this patchset results in lnet_libmd and lnet_msg only supporting
bvec.
ksock_tx still supports a single iov for the header, but otherwise
only handles bvec.
lnet_md supports a single virtual address or a list of bvec, as that
is all the client needs. When the server is added we can add back
support for a list of iov if it is still needed.

The other change involves CONFIG_FS_POSIX_ACL.
This is a config option that enables a library of support software.
While lustre is out-of-tree and being built to fit a pre-existing
config it makes sense to test that config option.
When lustre is in-tree, it does not.  lustre can select that config
option if it wants to.
The approach I have taken for now is to introduce
CONFIG_LUSTRE_FS_POSIX_ACL, and select CONFIG_FS_POSIX_ACL if the new
config is selected.
Possibly we should make Posix ACL support non-optional.  Some
filesystems do that, but most seem to have a config option.
I'd be interested in other people's thoughts on the pros and cons.

Thanks,
NeilBrown


---

NeilBrown (32):
      lustre: remove outdated comments about ->ap_* functions.
      lustre: ptlrpc: remove ptlrpc_prep_bulk_frag
      lustre: ptlrpc: make ptlrpc_bulk_frag_ops always const.
      lustre: ptlrpc: remove inline on non-inlined functions.
      lustre: ptlrpc: drop support for KVEC bulk descriptors.
      lustre: ptlrpc: discard BULK_BUF types
      lustre: ptlrpc: remove *GET*KIOV macros and fields.
      lustre: ptlrpc: simplify bd_vec access.
      lustre: lnet: discard LNET_MD_PHYS
      lustre: lnet: discard LNET_MD_IOVEC
      lustre: lnet: don't embed whole lnet_md in lnet_event
      lustre: lnet: merge lnet_md_alloc into lnet_md_build.
      lustre: lnet: always put a page list into struct lnet_libmd.
      lustre: lnet: discard kvec option from lnet_libmd.
      lustre: lnet: remove msg_iov from lnet_msg.
      lustre: lnet: simplify ksock_tx.
      lustre: socklnd: discard tx_iov.
      lustre: socklnd: don't fall-back to tcp_sendpage.
      lustre: socklnd: discard kiblnd_setup_rd_iov
      lustre: lnet: discard lnet_kvaddr_to_page
      lustre: ptlrpc: discard a server-only waitq.
      lustre: ptlrpc: simplify locking in ptlrpc_add_rqs_to_pool()
      lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t
      lustre: ptlrpc: discard cb_list and ptlrpc_set_cbdata;
      lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args()
      lustre: ptlrpc: don't use list_for_each_entry_safe unnecessarily.
      lustre: don't call unshare_fs_struct()
      lustre: don't declare extern variables in C files.
      lustre: introduce CONFIG_LUSTRE_FS_POSIX_ACL
      lustre: remove some "#ifdef CONFIG*" from .c files.
      lustre: mdc: create mdc_acl.c
      lustre: mgc: remove llog_process_lock


 .../staging/lustre/include/linux/lnet/lib-lnet.h   |   29 ---
 .../staging/lustre/include/linux/lnet/lib-types.h  |    6 -
 .../lustre/include/uapi/linux/lnet/lnet-types.h    |   25 +-
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |  123 +----------
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h    |   17 --
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   69 ++----
 .../lustre/lnet/klnds/socklnd/socklnd_lib.c        |   28 +--
 .../lustre/lnet/klnds/socklnd/socklnd_proto.c      |   17 +-
 drivers/staging/lustre/lnet/lnet/api-ni.c          |    4 
 drivers/staging/lustre/lnet/lnet/lib-md.c          |  220 +++++++-------------
 drivers/staging/lustre/lnet/lnet/lib-move.c        |   21 --
 drivers/staging/lustre/lnet/lnet/lib-msg.c         |    4 
 drivers/staging/lustre/lnet/lnet/lo.c              |   17 --
 drivers/staging/lustre/lnet/lnet/peer.c            |   10 -
 drivers/staging/lustre/lnet/lnet/router.c          |    2 
 drivers/staging/lustre/lnet/selftest/rpc.c         |    5 
 drivers/staging/lustre/lustre/Kconfig              |   11 +
 drivers/staging/lustre/lustre/include/lustre_acl.h |    6 -
 drivers/staging/lustre/lustre/include/lustre_net.h |   96 +--------
 drivers/staging/lustre/lustre/include/obd.h        |   32 ++-
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    3 
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 
 drivers/staging/lustre/lustre/llite/Makefile       |    2 
 .../staging/lustre/lustre/llite/llite_internal.h   |   33 +++
 drivers/staging/lustre/lustre/llite/llite_lib.c    |   39 +---
 drivers/staging/lustre/lustre/llite/xattr.c        |    4 
 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_locks.c      |    7 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |   67 +-----
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |    8 -
 drivers/staging/lustre/lustre/obdclass/llog.c      |    3 
 drivers/staging/lustre/lustre/osc/osc_internal.h   |    4 
 drivers/staging/lustre/lustre/osc/osc_io.c         |    3 
 drivers/staging/lustre/lustre/osc/osc_page.c       |    4 
 drivers/staging/lustre/lustre/osc/osc_request.c    |   31 +--
 drivers/staging/lustre/lustre/ptlrpc/client.c      |  151 ++++----------
 drivers/staging/lustre/lustre/ptlrpc/events.c      |   22 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c      |   21 +-
 drivers/staging/lustre/lustre/ptlrpc/pers.c        |   21 +-
 .../staging/lustre/lustre/ptlrpc/ptlrpc_module.c   |    5 
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c     |    6 -
 drivers/staging/lustre/lustre/ptlrpc/recover.c     |   14 +
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c    |   18 +-
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c   |   12 -
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    4 
 47 files changed, 450 insertions(+), 835 deletions(-)
 create mode 100644 drivers/staging/lustre/lustre/mdc/mdc_acl.c

--
Signature

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 01/32] lustre: remove outdated comments about ->ap_* functions.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 02/32] lustre: ptlrpc: remove ptlrpc_prep_bulk_frag NeilBrown
                   ` (30 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

->ap_make_ready, ->ap_completion, ap_refresh count all no longer
exist.
So remove these comments.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd.h      |    9 +--------
 drivers/staging/lustre/lustre/osc/osc_internal.h |    4 ++--
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 93a47cf0ef68..faf2ea623a09 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -224,14 +224,7 @@ struct client_obd {
 	 */
 	/*
 	 * ->cl_loi_list_lock protects consistency of
-	 * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and
-	 * ->ap_completion() call-backs are executed under this lock. As we
-	 * cannot guarantee that these call-backs never block on all platforms
-	 * (as a matter of fact they do block on Mac OS X), type of
-	 * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux
-	 * and blocking mutex on Mac OS X. (Alternative is to make this lock
-	 * blocking everywhere, but we don't want to slow down fast-path of
-	 * our main platform.)
+	 * ->cl_loi_{ready,read,write}_list.
 	 *
 	 * NB by Jinshan: though field names are still _loi_, but actually
 	 * osc_object{}s are in the list.
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
index 40333655a01d..21955687ec5f 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -43,13 +43,13 @@ extern struct ptlrpc_request_pool *osc_rq_pool;
 struct lu_env;
 
 enum async_flags {
-	ASYNC_READY		= 0x1, /* ap_make_ready will not be
+	ASYNC_READY		= 0x1, /* osc_make_ready will not be
 					* called before this page is
 					* added to an rpc
 					*/
 	ASYNC_URGENT		= 0x2, /* page must be put into an RPC
 					* before return */
-	ASYNC_COUNT_STABLE	= 0x4, /* ap_refresh_count will not be
+	ASYNC_COUNT_STABLE	= 0x4, /* osc_refresh_count will not be
 					* called to give the caller a
 					* chance to update or cancel
 					* the size of the io

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 02/32] lustre: ptlrpc: remove ptlrpc_prep_bulk_frag
  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 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 03/32] lustre: ptlrpc: make ptlrpc_bulk_frag_ops always const NeilBrown
                   ` (29 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This function is never used, best to discard it.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |    2 --
 drivers/staging/lustre/lustre/ptlrpc/client.c      |   23 --------------------
 2 files changed, 25 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index 1cf0f127203a..bb251769bf72 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1867,8 +1867,6 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req,
 					      unsigned int portal,
 					      const struct ptlrpc_bulk_frag_ops *ops);
 
-int ptlrpc_prep_bulk_frag(struct ptlrpc_bulk_desc *desc,
-			  void *frag, int len);
 void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
 			     struct page *page, int pageoffset, int len,
 			     int pin);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index e24c9c5eb90d..7170a2ce1bb6 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -230,29 +230,6 @@ void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
 }
 EXPORT_SYMBOL(__ptlrpc_prep_bulk_page);
 
-int ptlrpc_prep_bulk_frag(struct ptlrpc_bulk_desc *desc,
-			  void *frag, int len)
-{
-	struct kvec *iovec;
-
-	LASSERT(desc->bd_iov_count < desc->bd_max_iov);
-	LASSERT(frag);
-	LASSERT(len > 0);
-	LASSERT(ptlrpc_is_bulk_desc_kvec(desc->bd_type));
-
-	iovec = &BD_GET_KVEC(desc, desc->bd_iov_count);
-
-	desc->bd_nob += len;
-
-	iovec->iov_base = frag;
-	iovec->iov_len = len;
-
-	desc->bd_iov_count++;
-
-	return desc->bd_nob;
-}
-EXPORT_SYMBOL(ptlrpc_prep_bulk_frag);
-
 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
 {
 	LASSERT(desc->bd_iov_count != LI_POISON); /* not freed already */

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 03/32] lustre: ptlrpc: make ptlrpc_bulk_frag_ops always const.
  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 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 09/32] lustre: lnet: discard LNET_MD_PHYS NeilBrown
                   ` (28 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

There is one place where a non-const pointer to this struct
exists, and that causes a cast to be required.

Make it always const, and discard the cast.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |    2 +-
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index bb251769bf72..430ad8bb2226 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1222,7 +1222,7 @@ struct ptlrpc_bulk_desc {
 	struct obd_import		*bd_import;
 	/** Back pointer to the request */
 	struct ptlrpc_request		*bd_req;
-	struct ptlrpc_bulk_frag_ops	*bd_frag_ops;
+	const struct ptlrpc_bulk_frag_ops *bd_frag_ops;
 	wait_queue_head_t		bd_waitq;     /* server side only WQ */
 	int				bd_iov_count; /* # entries in bd_iov */
 	int				bd_max_iov;   /* allocated size of bd_iov */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 7170a2ce1bb6..c17fde56d004 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -150,7 +150,7 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
 	desc->bd_portal = portal;
 	desc->bd_type = type;
 	desc->bd_md_count = 0;
-	desc->bd_frag_ops = (struct ptlrpc_bulk_frag_ops *)ops;
+	desc->bd_frag_ops = ops;
 	LASSERT(max_brw > 0);
 	desc->bd_md_max_brw = min(max_brw, PTLRPC_BULK_OPS_COUNT);
 	/*

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 04/32] lustre: ptlrpc: remove inline on non-inlined functions.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (3 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 09/32] lustre: lnet: discard LNET_MD_PHYS NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 11/32] lustre: lnet: don't embed whole lnet_md in lnet_event NeilBrown
                   ` (26 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

These three functions are never inlined.  The only time they
are used, their address is taken, and this forces them to
be compiled as stand-alone functions.  So having the "inline"
declaration is misleading.

Move the functions to the place where their address is used, and
remove the 'inline' tag.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |   21 -------------------
 drivers/staging/lustre/lustre/ptlrpc/client.c      |   22 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index 430ad8bb2226..591c4edaa10e 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1870,30 +1870,9 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req,
 void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
 			     struct page *page, int pageoffset, int len,
 			     int pin);
-static inline void ptlrpc_prep_bulk_page_pin(struct ptlrpc_bulk_desc *desc,
-					     struct page *page, int pageoffset,
-					     int len)
-{
-	__ptlrpc_prep_bulk_page(desc, page, pageoffset, len, 1);
-}
-
-static inline void ptlrpc_prep_bulk_page_nopin(struct ptlrpc_bulk_desc *desc,
-					       struct page *page, int pageoffset,
-					       int len)
-{
-	__ptlrpc_prep_bulk_page(desc, page, pageoffset, len, 0);
-}
 
 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *bulk);
 
-static inline void ptlrpc_release_bulk_page_pin(struct ptlrpc_bulk_desc *desc)
-{
-	int i;
-
-	for (i = 0; i < desc->bd_iov_count ; i++)
-		put_page(BD_GET_KIOV(desc, i).bv_page);
-}
-
 void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
 				      struct obd_import *imp);
 u64 ptlrpc_next_xid(void);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index c17fde56d004..a602fa4e5340 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -48,6 +48,28 @@
 
 #include "ptlrpc_internal.h"
 
+static void ptlrpc_prep_bulk_page_pin(struct ptlrpc_bulk_desc *desc,
+				      struct page *page, int pageoffset,
+				      int len)
+{
+	__ptlrpc_prep_bulk_page(desc, page, pageoffset, len, 1);
+}
+
+static void ptlrpc_prep_bulk_page_nopin(struct ptlrpc_bulk_desc *desc,
+					struct page *page, int pageoffset,
+					int len)
+{
+	__ptlrpc_prep_bulk_page(desc, page, pageoffset, len, 0);
+}
+
+static void ptlrpc_release_bulk_page_pin(struct ptlrpc_bulk_desc *desc)
+{
+	int i;
+
+	for (i = 0; i < desc->bd_iov_count ; i++)
+		put_page(BD_GET_KIOV(desc, i).bv_page);
+}
+
 const struct ptlrpc_bulk_frag_ops ptlrpc_bulk_kiov_pin_ops = {
 	.add_kiov_frag		= ptlrpc_prep_bulk_page_pin,
 	.release_frags		= ptlrpc_release_bulk_page_pin,

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 05/32] lustre: ptlrpc: drop support for KVEC bulk descriptors.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (6 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 07/32] lustre: ptlrpc: remove *GET*KIOV macros and fields NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 10/32] lustre: lnet: discard LNET_MD_IOVEC NeilBrown
                   ` (23 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

All ptlrpc bulk descriptors created are KIOV, none are KVEC.
So don't bother passing PTLRPC_BULK_BUF_KIOV through to
ptlrpc_new_bulk(), just assume it.

This is a first step to removing the KVEC support, which is
unnecessary duplication.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |    2 +-
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    2 +-
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |    2 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    |    2 +-
 drivers/staging/lustre/lustre/ptlrpc/client.c      |   21 +++++---------------
 5 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index 591c4edaa10e..a01ab99a2b5c 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1212,7 +1212,7 @@ struct ptlrpc_bulk_desc {
 	spinlock_t			bd_lock;
 	/** Import generation when request for this bulk was sent */
 	int				bd_import_generation;
-	/** {put,get}{source,sink}{kvec,kiov} */
+	/** {put,get}{source,sink}kiov} */
 	enum ptlrpc_bulk_op_type	bd_type;
 	/** LNet portal for this bulk */
 	u32				bd_portal;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 6f933b511366..451e6c94c7e8 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -915,7 +915,7 @@ static int mdc_getpage(struct obd_export *exp, const struct lu_fid *fid,
 	ptlrpc_at_set_req_timeout(req);
 
 	desc = ptlrpc_prep_bulk_imp(req, npages, 1,
-				    PTLRPC_BULK_PUT_SINK | PTLRPC_BULK_BUF_KIOV,
+				    PTLRPC_BULK_PUT_SINK,
 				    MDS_BULK_PORTAL,
 				    &ptlrpc_bulk_kiov_pin_ops);
 	if (!desc) {
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 6daadf24b894..a805705f357e 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1387,7 +1387,7 @@ static int mgc_process_recover_log(struct obd_device *obd,
 
 	/* allocate bulk transfer descriptor */
 	desc = ptlrpc_prep_bulk_imp(req, nrpages, 1,
-				    PTLRPC_BULK_PUT_SINK | PTLRPC_BULK_BUF_KIOV,
+				    PTLRPC_BULK_PUT_SINK,
 				    MGS_BULK_PORTAL,
 				    &ptlrpc_bulk_kiov_pin_ops);
 	if (!desc) {
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 9484b9a90483..88302ff795ae 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -1171,7 +1171,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
 		req, page_count,
 		cli->cl_import->imp_connect_data.ocd_brw_size >> LNET_MTU_BITS,
 		(opc == OST_WRITE ? PTLRPC_BULK_GET_SOURCE :
-		 PTLRPC_BULK_PUT_SINK) | PTLRPC_BULK_BUF_KIOV, OST_BULK_PORTAL,
+		 PTLRPC_BULK_PUT_SINK), OST_BULK_PORTAL,
 		&ptlrpc_bulk_kiov_pin_ops);
 
 	if (!desc) {
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index a602fa4e5340..53f49c6408cc 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -145,32 +145,21 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
 	struct ptlrpc_bulk_desc *desc;
 	int i;
 
-	/* ensure that only one of KIOV or IOVEC is set but not both */
-	LASSERT((ptlrpc_is_bulk_desc_kiov(type) && ops->add_kiov_frag) ||
-		(ptlrpc_is_bulk_desc_kvec(type) && ops->add_iov_frag));
-
 	desc = kzalloc(sizeof(*desc), GFP_NOFS);
 	if (!desc)
 		return NULL;
 
-	if (type & PTLRPC_BULK_BUF_KIOV) {
-		GET_KIOV(desc) = kcalloc(nfrags, sizeof(*GET_KIOV(desc)),
-					 GFP_NOFS);
-		if (!GET_KIOV(desc))
-			goto free_desc;
-	} else {
-		GET_KVEC(desc) = kcalloc(nfrags, sizeof(*GET_KVEC(desc)),
-					 GFP_NOFS);
-		if (!GET_KVEC(desc))
-			goto free_desc;
-	}
+	GET_KIOV(desc) = kcalloc(nfrags, sizeof(*GET_KIOV(desc)),
+				 GFP_NOFS);
+	if (!GET_KIOV(desc))
+		goto free_desc;
 
 	spin_lock_init(&desc->bd_lock);
 	init_waitqueue_head(&desc->bd_waitq);
 	desc->bd_max_iov = nfrags;
 	desc->bd_iov_count = 0;
 	desc->bd_portal = portal;
-	desc->bd_type = type;
+	desc->bd_type = type | PTLRPC_BULK_BUF_KIOV;
 	desc->bd_md_count = 0;
 	desc->bd_frag_ops = ops;
 	LASSERT(max_brw > 0);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 06/32] lustre: ptlrpc: discard BULK_BUF types
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (9 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 08/32] lustre: ptlrpc: simplify bd_vec access NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 12/32] lustre: lnet: merge lnet_md_alloc into lnet_md_build NeilBrown
                   ` (20 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

Now that all BULK bufs are KIOV, we can discard all the
tests for this, and discard the flags themselves.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |   14 --------------
 drivers/staging/lustre/lustre/osc/osc_page.c       |    2 --
 drivers/staging/lustre/lustre/ptlrpc/client.c      |   12 +++---------
 drivers/staging/lustre/lustre/ptlrpc/pers.c        |   18 +++++-------------
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c    |    2 --
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c   |    2 --
 6 files changed, 8 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index a01ab99a2b5c..1bf2c61c1fd4 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1110,8 +1110,6 @@ enum ptlrpc_bulk_op_type {
 	PTLRPC_BULK_OP_PASSIVE	= 0x00000002,
 	PTLRPC_BULK_OP_PUT	= 0x00000004,
 	PTLRPC_BULK_OP_GET	= 0x00000008,
-	PTLRPC_BULK_BUF_KVEC	= 0x00000010,
-	PTLRPC_BULK_BUF_KIOV	= 0x00000020,
 	PTLRPC_BULK_GET_SOURCE	= PTLRPC_BULK_OP_PASSIVE | PTLRPC_BULK_OP_GET,
 	PTLRPC_BULK_PUT_SINK	= PTLRPC_BULK_OP_PASSIVE | PTLRPC_BULK_OP_PUT,
 	PTLRPC_BULK_GET_SINK	= PTLRPC_BULK_OP_ACTIVE | PTLRPC_BULK_OP_GET,
@@ -1143,18 +1141,6 @@ static inline bool ptlrpc_is_bulk_put_source(enum ptlrpc_bulk_op_type type)
 	return (type & PTLRPC_BULK_PUT_SOURCE) == PTLRPC_BULK_PUT_SOURCE;
 }
 
-static inline bool ptlrpc_is_bulk_desc_kvec(enum ptlrpc_bulk_op_type type)
-{
-	return ((type & PTLRPC_BULK_BUF_KVEC) | (type & PTLRPC_BULK_BUF_KIOV))
-		== PTLRPC_BULK_BUF_KVEC;
-}
-
-static inline bool ptlrpc_is_bulk_desc_kiov(enum ptlrpc_bulk_op_type type)
-{
-	return ((type & PTLRPC_BULK_BUF_KVEC) | (type & PTLRPC_BULK_BUF_KIOV))
-		== PTLRPC_BULK_BUF_KIOV;
-}
-
 static inline bool ptlrpc_is_bulk_op_active(enum ptlrpc_bulk_op_type type)
 {
 	return ((type & PTLRPC_BULK_OP_ACTIVE) |
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index ce911b82512d..e7ee97337bd4 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -860,8 +860,6 @@ static inline void unstable_page_accounting(struct ptlrpc_bulk_desc *desc,
 	int count = 0;
 	int i;
 
-	LASSERT(ptlrpc_is_bulk_desc_kiov(desc->bd_type));
-
 	for (i = 0; i < page_count; i++) {
 		pg_data_t *pgdat = page_pgdat(BD_GET_KIOV(desc, i).bv_page);
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 53f49c6408cc..16ccf2e47d84 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -159,7 +159,7 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
 	desc->bd_max_iov = nfrags;
 	desc->bd_iov_count = 0;
 	desc->bd_portal = portal;
-	desc->bd_type = type | PTLRPC_BULK_BUF_KIOV;
+	desc->bd_type = type;
 	desc->bd_md_count = 0;
 	desc->bd_frag_ops = ops;
 	LASSERT(max_brw > 0);
@@ -224,7 +224,6 @@ void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
 	LASSERT(pageoffset >= 0);
 	LASSERT(len > 0);
 	LASSERT(pageoffset + len <= PAGE_SIZE);
-	LASSERT(ptlrpc_is_bulk_desc_kiov(desc->bd_type));
 
 	kiov = &BD_GET_KIOV(desc, desc->bd_iov_count);
 
@@ -248,8 +247,7 @@ void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
 	LASSERT((desc->bd_export != NULL) ^ (desc->bd_import != NULL));
 	LASSERT(desc->bd_frag_ops);
 
-	if (ptlrpc_is_bulk_desc_kiov(desc->bd_type))
-		sptlrpc_enc_pool_put_pages(desc);
+	sptlrpc_enc_pool_put_pages(desc);
 
 	if (desc->bd_export)
 		class_export_put(desc->bd_export);
@@ -259,11 +257,7 @@ void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
 	if (desc->bd_frag_ops->release_frags)
 		desc->bd_frag_ops->release_frags(desc);
 
-	if (ptlrpc_is_bulk_desc_kiov(desc->bd_type))
-		kfree(GET_KIOV(desc));
-	else
-		kfree(GET_KVEC(desc));
-
+	kfree(GET_KIOV(desc));
 	kfree(desc);
 }
 EXPORT_SYMBOL(ptlrpc_free_bulk);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c
index 2466868afb9c..fbc36be51a91 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pers.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c
@@ -56,17 +56,9 @@ void ptlrpc_fill_bulk_md(struct lnet_md *md, struct ptlrpc_bulk_desc *desc,
 	md->length = max(0, desc->bd_iov_count - mdidx * LNET_MAX_IOV);
 	md->length = min_t(unsigned int, LNET_MAX_IOV, md->length);
 
-	if (ptlrpc_is_bulk_desc_kiov(desc->bd_type)) {
-		md->options |= LNET_MD_KIOV;
-		if (GET_ENC_KIOV(desc))
-			md->start = &BD_GET_ENC_KIOV(desc, offset);
-		else
-			md->start = &BD_GET_KIOV(desc, offset);
-	} else {
-		md->options |= LNET_MD_IOVEC;
-		if (GET_ENC_KVEC(desc))
-			md->start = &BD_GET_ENC_KVEC(desc, offset);
-		else
-			md->start = &BD_GET_KVEC(desc, offset);
-	}
+	md->options |= LNET_MD_KIOV;
+	if (GET_ENC_KIOV(desc))
+		md->start = &BD_GET_ENC_KIOV(desc, offset);
+	else
+		md->start = &BD_GET_KIOV(desc, offset);
 }
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index 74cfdd8e486b..c3dbcebc16fc 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
@@ -336,8 +336,6 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
 	int p_idx, g_idx;
 	int i;
 
-	LASSERT(ptlrpc_is_bulk_desc_kiov(desc->bd_type));
-
 	if (!GET_ENC_KIOV(desc))
 		return;
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 021bf7fcf559..0c431eb60ea5 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -155,8 +155,6 @@ static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc)
 	char *ptr;
 	unsigned int off, i;
 
-	LASSERT(ptlrpc_is_bulk_desc_kiov(desc->bd_type));
-
 	for (i = 0; i < desc->bd_iov_count; i++) {
 		if (!BD_GET_KIOV(desc, i).bv_len)
 			continue;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 07/32] lustre: ptlrpc: remove *GET*KIOV macros and fields.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (5 preceding siblings ...)
  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 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 05/32] lustre: ptlrpc: drop support for KVEC bulk descriptors NeilBrown
                   ` (24 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

The bd_vec and bd_enc_vec fields are no longer used,
so discard the fields and macros that access them.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |   34 +++++++-------------
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index 1bf2c61c1fd4..e2cf456fc1cd 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1224,30 +1224,20 @@ struct ptlrpc_bulk_desc {
 	/** array of associated MDs */
 	struct lnet_handle_md		bd_mds[PTLRPC_BULK_OPS_COUNT];
 
-	union {
-		struct {
-			/*
-			 * encrypt iov, size is either 0 or bd_iov_count.
-			 */
-			struct bio_vec *bd_enc_vec;
-			struct bio_vec *bd_vec;	/* Array of bio_vecs */
-		} bd_kiov;
-
-		struct {
-			struct kvec *bd_enc_kvec;
-			struct kvec *bd_kvec;	/* Array of kvecs */
-		} bd_kvec;
-	} bd_u;
+	struct {
+		/*
+		 * encrypt iov, size is either 0 or bd_iov_count.
+		 */
+		struct bio_vec *bd_enc_vec;
+		struct bio_vec *bd_vec;	/* Array of bio_vecs */
+	} bd_kiov;
+
 };
 
-#define GET_KIOV(desc)			((desc)->bd_u.bd_kiov.bd_vec)
-#define BD_GET_KIOV(desc, i)		((desc)->bd_u.bd_kiov.bd_vec[i])
-#define GET_ENC_KIOV(desc)		((desc)->bd_u.bd_kiov.bd_enc_vec)
-#define BD_GET_ENC_KIOV(desc, i)	((desc)->bd_u.bd_kiov.bd_enc_vec[i])
-#define GET_KVEC(desc)			((desc)->bd_u.bd_kvec.bd_kvec)
-#define BD_GET_KVEC(desc, i)		((desc)->bd_u.bd_kvec.bd_kvec[i])
-#define GET_ENC_KVEC(desc)		((desc)->bd_u.bd_kvec.bd_enc_kvec)
-#define BD_GET_ENC_KVEC(desc, i)	((desc)->bd_u.bd_kvec.bd_enc_kvec[i])
+#define GET_KIOV(desc)			((desc)->bd_kiov.bd_vec)
+#define BD_GET_KIOV(desc, i)		((desc)->bd_kiov.bd_vec[i])
+#define GET_ENC_KIOV(desc)		((desc)->bd_kiov.bd_enc_vec)
+#define BD_GET_ENC_KIOV(desc, i)	((desc)->bd_kiov.bd_enc_vec[i])
 
 enum {
 	SVC_STOPPED     = 1 << 0,

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 08/32] lustre: ptlrpc: simplify bd_vec access.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (8 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 10/32] lustre: lnet: discard LNET_MD_IOVEC NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 06/32] lustre: ptlrpc: discard BULK_BUF types NeilBrown
                   ` (21 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

Now that there are no kvecs in ptlrpc_bulk_desc, only bdvecs, we can
simplify the access, discarding the containing struct and the macros,
and just accessing the fields directly.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |   17 +++++------------
 drivers/staging/lustre/lustre/osc/osc_page.c       |    2 +-
 drivers/staging/lustre/lustre/ptlrpc/client.c      |   12 ++++++------
 drivers/staging/lustre/lustre/ptlrpc/pers.c        |    6 +++---
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c    |   16 ++++++++--------
 drivers/staging/lustre/lustre/ptlrpc/sec_plain.c   |   10 +++++-----
 6 files changed, 28 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index e2cf456fc1cd..d14840b4aeb0 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1224,21 +1224,14 @@ struct ptlrpc_bulk_desc {
 	/** array of associated MDs */
 	struct lnet_handle_md		bd_mds[PTLRPC_BULK_OPS_COUNT];
 
-	struct {
-		/*
-		 * encrypt iov, size is either 0 or bd_iov_count.
-		 */
-		struct bio_vec *bd_enc_vec;
-		struct bio_vec *bd_vec;	/* Array of bio_vecs */
-	} bd_kiov;
+	/*
+	 * encrypt iov, size is either 0 or bd_iov_count.
+	 */
+	struct bio_vec *bd_enc_vec;
+	struct bio_vec *bd_vec;	/* Array of bio_vecs */
 
 };
 
-#define GET_KIOV(desc)			((desc)->bd_kiov.bd_vec)
-#define BD_GET_KIOV(desc, i)		((desc)->bd_kiov.bd_vec[i])
-#define GET_ENC_KIOV(desc)		((desc)->bd_kiov.bd_enc_vec)
-#define BD_GET_ENC_KIOV(desc, i)	((desc)->bd_kiov.bd_enc_vec[i])
-
 enum {
 	SVC_STOPPED     = 1 << 0,
 	SVC_STOPPING    = 1 << 1,
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index e7ee97337bd4..1ee0a7682a5b 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -861,7 +861,7 @@ static inline void unstable_page_accounting(struct ptlrpc_bulk_desc *desc,
 	int i;
 
 	for (i = 0; i < page_count; i++) {
-		pg_data_t *pgdat = page_pgdat(BD_GET_KIOV(desc, i).bv_page);
+		pg_data_t *pgdat = page_pgdat(desc->bd_vec[i].bv_page);
 
 		if (likely(pgdat == last)) {
 			++count;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 16ccf2e47d84..a148b1e54712 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -67,7 +67,7 @@ static void ptlrpc_release_bulk_page_pin(struct ptlrpc_bulk_desc *desc)
 	int i;
 
 	for (i = 0; i < desc->bd_iov_count ; i++)
-		put_page(BD_GET_KIOV(desc, i).bv_page);
+		put_page(desc->bd_vec[i].bv_page);
 }
 
 const struct ptlrpc_bulk_frag_ops ptlrpc_bulk_kiov_pin_ops = {
@@ -149,9 +149,9 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
 	if (!desc)
 		return NULL;
 
-	GET_KIOV(desc) = kcalloc(nfrags, sizeof(*GET_KIOV(desc)),
-				 GFP_NOFS);
-	if (!GET_KIOV(desc))
+	desc->bd_vec = kcalloc(nfrags, sizeof(desc->bd_vec[0]),
+			       GFP_NOFS);
+	if (!desc->bd_vec)
 		goto free_desc;
 
 	spin_lock_init(&desc->bd_lock);
@@ -225,7 +225,7 @@ void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
 	LASSERT(len > 0);
 	LASSERT(pageoffset + len <= PAGE_SIZE);
 
-	kiov = &BD_GET_KIOV(desc, desc->bd_iov_count);
+	kiov = &desc->bd_vec[desc->bd_iov_count];
 
 	desc->bd_nob += len;
 
@@ -257,7 +257,7 @@ void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
 	if (desc->bd_frag_ops->release_frags)
 		desc->bd_frag_ops->release_frags(desc);
 
-	kfree(GET_KIOV(desc));
+	kfree(desc->bd_vec);
 	kfree(desc);
 }
 EXPORT_SYMBOL(ptlrpc_free_bulk);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c
index fbc36be51a91..948ece11970f 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pers.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c
@@ -57,8 +57,8 @@ void ptlrpc_fill_bulk_md(struct lnet_md *md, struct ptlrpc_bulk_desc *desc,
 	md->length = min_t(unsigned int, LNET_MAX_IOV, md->length);
 
 	md->options |= LNET_MD_KIOV;
-	if (GET_ENC_KIOV(desc))
-		md->start = &BD_GET_ENC_KIOV(desc, offset);
+	if (desc->bd_enc_vec)
+		md->start = &desc->bd_enc_vec[offset];
 	else
-		md->start = &BD_GET_KIOV(desc, offset);
+		md->start = &desc->bd_vec[offset];
 }
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index c3dbcebc16fc..dc2dab8a8d60 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
@@ -336,7 +336,7 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
 	int p_idx, g_idx;
 	int i;
 
-	if (!GET_ENC_KIOV(desc))
+	if (!desc->bd_enc_vec)
 		return;
 
 	LASSERT(desc->bd_iov_count > 0);
@@ -351,12 +351,12 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
 	LASSERT(page_pools.epp_pools[p_idx]);
 
 	for (i = 0; i < desc->bd_iov_count; i++) {
-		LASSERT(BD_GET_ENC_KIOV(desc, i).bv_page);
+		LASSERT(desc->bd_enc_vec[i].bv_page);
 		LASSERT(g_idx != 0 || page_pools.epp_pools[p_idx]);
 		LASSERT(!page_pools.epp_pools[p_idx][g_idx]);
 
 		page_pools.epp_pools[p_idx][g_idx] =
-			BD_GET_ENC_KIOV(desc, i).bv_page;
+			desc->bd_enc_vec[i].bv_page;
 
 		if (++g_idx == PAGES_PER_POOL) {
 			p_idx++;
@@ -370,8 +370,8 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
 
 	spin_unlock(&page_pools.epp_lock);
 
-	kfree(GET_ENC_KIOV(desc));
-	GET_ENC_KIOV(desc) = NULL;
+	kfree(desc->bd_enc_vec);
+	desc->bd_enc_vec = NULL;
 }
 
 static inline void enc_pools_alloc(void)
@@ -552,10 +552,10 @@ int sptlrpc_get_bulk_checksum(struct ptlrpc_bulk_desc *desc, u8 alg,
 
 	for (i = 0; i < desc->bd_iov_count; i++) {
 		cfs_crypto_hash_update_page(hdesc,
-					    BD_GET_KIOV(desc, i).bv_page,
-					    BD_GET_KIOV(desc, i).bv_offset &
+					    desc->bd_vec[i].bv_page,
+					    desc->bd_vec[i].bv_offset &
 					    ~PAGE_MASK,
-					    BD_GET_KIOV(desc, i).bv_len);
+					    desc->bd_vec[i].bv_len);
 	}
 
 	if (hashsize > buflen) {
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index 0c431eb60ea5..988cbba491cf 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -156,13 +156,13 @@ static void corrupt_bulk_data(struct ptlrpc_bulk_desc *desc)
 	unsigned int off, i;
 
 	for (i = 0; i < desc->bd_iov_count; i++) {
-		if (!BD_GET_KIOV(desc, i).bv_len)
+		if (!desc->bd_vec[i].bv_len)
 			continue;
 
-		ptr = kmap(BD_GET_KIOV(desc, i).bv_page);
-		off = BD_GET_KIOV(desc, i).bv_offset & ~PAGE_MASK;
+		ptr = kmap(desc->bd_vec[i].bv_page);
+		off = desc->bd_vec[i].bv_offset & ~PAGE_MASK;
 		ptr[off] ^= 0x1;
-		kunmap(BD_GET_KIOV(desc, i).bv_page);
+		kunmap(desc->bd_vec[i].bv_page);
 		return;
 	}
 }
@@ -354,7 +354,7 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx,
 
 	/* fix the actual data size */
 	for (i = 0, nob = 0; i < desc->bd_iov_count; i++) {
-		struct bio_vec bv_desc = BD_GET_KIOV(desc, i);
+		struct bio_vec bv_desc = desc->bd_vec[i];
 
 		if (bv_desc.bv_len + nob > desc->bd_nob_transferred)
 			bv_desc.bv_len = desc->bd_nob_transferred - nob;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 09/32] lustre: lnet: discard LNET_MD_PHYS
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (2 preceding siblings ...)
  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 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 04/32] lustre: ptlrpc: remove inline on non-inlined functions NeilBrown
                   ` (27 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This macro has no value and is never set.
It claims "compatibility with Cray Portals".  If
that becomes a real issue in the future, it can be re-introduced.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/include/uapi/linux/lnet/lnet-types.h    |    3 ---
 drivers/staging/lustre/lustre/ptlrpc/pers.c        |    3 +--
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
index 956af3c53cfc..9f912503a24c 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
@@ -543,9 +543,6 @@ struct lnet_md {
 /** See lnet_md::options. */
 #define LNET_MD_BULK_HANDLE	(1 << 9)
 
-/* For compatibility with Cray Portals */
-#define LNET_MD_PHYS		0
-
 /** Infinite threshold on MD operations. See lnet_md::threshold */
 #define LNET_MD_THRESH_INF	(-1)
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c
index 948ece11970f..6efa37ba7ded 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pers.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c
@@ -50,8 +50,7 @@ void ptlrpc_fill_bulk_md(struct lnet_md *md, struct ptlrpc_bulk_desc *desc,
 
 	LASSERT(mdidx < desc->bd_md_max_brw);
 	LASSERT(desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES);
-	LASSERT(!(md->options & (LNET_MD_IOVEC | LNET_MD_KIOV |
-				 LNET_MD_PHYS)));
+	LASSERT(!(md->options & (LNET_MD_IOVEC | LNET_MD_KIOV)));
 
 	md->length = max(0, desc->bd_iov_count - mdidx * LNET_MAX_IOV);
 	md->length = min_t(unsigned int, LNET_MAX_IOV, md->length);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 10/32] lustre: lnet: discard LNET_MD_IOVEC
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (7 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 05/32] lustre: ptlrpc: drop support for KVEC bulk descriptors NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 08/32] lustre: ptlrpc: simplify bd_vec access NeilBrown
                   ` (22 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This flag is never set, so discard it.
lnet_md memory descriptors are either a single virtual
address, or a list of bvec.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |    2 +
 .../lustre/include/uapi/linux/lnet/lnet-types.h    |   13 +-------
 drivers/staging/lustre/lnet/lnet/lib-md.c          |   31 ++------------------
 drivers/staging/lustre/lustre/ptlrpc/pers.c        |    2 +
 4 files changed, 7 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index e60c446fbb27..c6a9a5fb3c96 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -200,7 +200,7 @@ lnet_md_alloc(struct lnet_md *umd)
 		niov = umd->length;
 		size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
 	} else {
-		niov = umd->options & LNET_MD_IOVEC ? umd->length : 1;
+		niov = 1;
 		size = offsetof(struct lnet_libmd, md_iov.iov[niov]);
 	}
 
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
index 9f912503a24c..e66f8861ecf0 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
@@ -416,11 +416,6 @@ struct lnet_md {
 	 * the number of entries in the array. The length can't be bigger
 	 * than LNET_MAX_IOV. The struct bio_vec is used to describe page-based
 	 * fragments that are not necessarily mapped in virtual memory.
-	 * - LNET_MD_IOVEC bit set: The start field points to the starting
-	 * address of an array of struct iovec and the length field specifies
-	 * the number of entries in the array. The length can't be bigger
-	 * than LNET_MAX_IOV. The struct iovec is used to describe fragments
-	 * that have virtual addresses.
 	 * - Otherwise: The memory region is contiguous. The start field
 	 * specifies the starting address for the memory region and the
 	 * length field specifies its length.
@@ -475,14 +470,12 @@ struct lnet_md {
 	 *   The data sent in the REPLY serves as an implicit acknowledgment.
 	 * - LNET_MD_KIOV: The start and length fields specify an array of
 	 *   struct bio_vec.
-	 * - LNET_MD_IOVEC: The start and length fields specify an array of
-	 *   struct iovec.
 	 * - LNET_MD_MAX_SIZE: The max_size field is valid.
 	 * - LNET_MD_BULK_HANDLE: The bulk_handle field is valid.
 	 *
 	 * Note:
-	 * - LNET_MD_KIOV or LNET_MD_IOVEC allows for a scatter/gather
-	 *   capability for memory descriptors. They can't be both set.
+	 * - LNET_MD_KIOV allows for a scatter/gather
+	 *   capability for memory descriptors.
 	 * - When LNET_MD_MAX_SIZE is set, the total length of the memory
 	 *   region (i.e. sum of all fragment lengths) must not be less than
 	 *   \a max_size.
@@ -535,8 +528,6 @@ struct lnet_md {
 /** See lnet_md::options. */
 #define LNET_MD_ACK_DISABLE	(1 << 5)
 /** See lnet_md::options. */
-#define LNET_MD_IOVEC		(1 << 6)
-/** See lnet_md::options. */
 #define LNET_MD_MAX_SIZE	(1 << 7)
 /** See lnet_md::options. */
 #define LNET_MD_KIOV		(1 << 8)
diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c
index 33a59fb93414..acc6b239d391 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -190,32 +190,7 @@ lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink)
 	lmd->md_flags = (unlink == LNET_UNLINK) ? LNET_MD_FLAG_AUTO_UNLINK : 0;
 	lmd->md_bulk_handle = umd->bulk_handle;
 
-	if (umd->options & LNET_MD_IOVEC) {
-		if (umd->options & LNET_MD_KIOV) /* Can't specify both */
-			return -EINVAL;
-
-		niov = umd->length;
-		lmd->md_niov = umd->length;
-		memcpy(lmd->md_iov.iov, umd->start,
-		       niov * sizeof(lmd->md_iov.iov[0]));
-
-		for (i = 0; i < (int)niov; i++) {
-			/* We take the base address on trust */
-			/* invalid length */
-			if (lmd->md_iov.iov[i].iov_len <= 0)
-				return -EINVAL;
-
-			total_length += lmd->md_iov.iov[i].iov_len;
-		}
-
-		lmd->md_length = total_length;
-
-		if ((umd->options & LNET_MD_MAX_SIZE) && /* use max size */
-		    (umd->max_size < 0 ||
-		     umd->max_size > total_length)) /* illegal max_size */
-			return -EINVAL;
-
-	} else if (umd->options & LNET_MD_KIOV) {
+	if (umd->options & LNET_MD_KIOV) {
 		niov = umd->length;
 		lmd->md_niov = umd->length;
 		memcpy(lmd->md_iov.kiov, umd->start,
@@ -302,7 +277,7 @@ lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_md *umd)
 	 */
 	umd->start = lmd->md_start;
 	umd->length = !(lmd->md_options &
-		      (LNET_MD_IOVEC | LNET_MD_KIOV)) ?
+			LNET_MD_KIOV) ?
 		      lmd->md_length : lmd->md_niov;
 	umd->threshold = lmd->md_threshold;
 	umd->max_size = lmd->md_max_size;
@@ -320,7 +295,7 @@ lnet_md_validate(struct lnet_md *umd)
 		return -EINVAL;
 	}
 
-	if ((umd->options & (LNET_MD_KIOV | LNET_MD_IOVEC)) &&
+	if ((umd->options & LNET_MD_KIOV) &&
 	    umd->length > LNET_MAX_IOV) {
 		CERROR("Invalid option: too many fragments %u, %d max\n",
 		       umd->length, LNET_MAX_IOV);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c
index 6efa37ba7ded..feef72801640 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pers.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c
@@ -50,7 +50,7 @@ void ptlrpc_fill_bulk_md(struct lnet_md *md, struct ptlrpc_bulk_desc *desc,
 
 	LASSERT(mdidx < desc->bd_md_max_brw);
 	LASSERT(desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES);
-	LASSERT(!(md->options & (LNET_MD_IOVEC | LNET_MD_KIOV)));
+	LASSERT(!(md->options & LNET_MD_KIOV));
 
 	md->length = max(0, desc->bd_iov_count - mdidx * LNET_MAX_IOV);
 	md->length = min_t(unsigned int, LNET_MAX_IOV, md->length);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 11/32] lustre: lnet: don't embed whole lnet_md in lnet_event
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (4 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 04/32] lustre: ptlrpc: remove inline on non-inlined functions NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 07/32] lustre: ptlrpc: remove *GET*KIOV macros and fields NeilBrown
                   ` (25 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

Of the several fields that are copied into the lnet_md which is
embedded in an lnet_event, only three are ever used:
  start, user_ptr, md_options

Rather than allocating space for the whole structure, copying only
some in, and then using even few; just store the fields that are
needed.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |    2 +-
 .../lustre/include/uapi/linux/lnet/lnet-types.h    |    9 +++++---
 drivers/staging/lustre/lnet/lnet/api-ni.c          |    4 ++--
 drivers/staging/lustre/lnet/lnet/lib-md.c          |   19 ++++-------------
 drivers/staging/lustre/lnet/lnet/lib-msg.c         |    4 ++--
 drivers/staging/lustre/lnet/lnet/peer.c            |   10 +++++----
 drivers/staging/lustre/lnet/lnet/router.c          |    2 +-
 drivers/staging/lustre/lnet/selftest/rpc.c         |    5 +++--
 drivers/staging/lustre/lustre/ptlrpc/events.c      |   22 ++++++++++----------
 9 files changed, 34 insertions(+), 43 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index c6a9a5fb3c96..7275d517df5a 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -628,7 +628,7 @@ void lnet_copy_kiov2iter(struct iov_iter *to,
 void lnet_me_unlink(struct lnet_me *me);
 
 void lnet_md_unlink(struct lnet_libmd *md);
-void lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_md *umd);
+void lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_event *ev);
 struct page *lnet_kvaddr_to_page(unsigned long vaddr);
 int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset);
 
diff --git a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
index e66f8861ecf0..9e6baf3058fe 100644
--- a/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
+++ b/drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h
@@ -624,11 +624,12 @@ struct lnet_event {
 	 */
 	struct lnet_handle_md	md_handle;
 	/**
-	 * A snapshot of the state of the MD immediately after the event has
-	 * been processed. In particular, the threshold field in md will
-	 * reflect the value of the threshold after the operation occurred.
+	 * A snapshot of relevant state of the MD immediately after the event
+	 * has been processed.
 	 */
-	struct lnet_md		md;
+	void			*md_start;
+	void			*md_user_ptr;
+	unsigned int		md_options;
 	/**
 	 * 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT.
 	 * \see LNetPut
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 12b3c4445905..13a874e630fe 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1135,7 +1135,7 @@ lnet_ping_target_destroy(void)
 static void
 lnet_ping_target_event_handler(struct lnet_event *event)
 {
-	struct lnet_ping_buffer *pbuf = event->md.user_ptr;
+	struct lnet_ping_buffer *pbuf = event->md_user_ptr;
 
 	if (event->unlinked)
 		lnet_ping_buffer_decref(pbuf);
@@ -1404,7 +1404,7 @@ int lnet_push_target_resize(void)
 
 static void lnet_push_target_event_handler(struct lnet_event *ev)
 {
-	struct lnet_ping_buffer *pbuf = ev->md.user_ptr;
+	struct lnet_ping_buffer *pbuf = ev->md_user_ptr;
 
 	if (pbuf->pb_info.pi_magic == __swab32(LNET_PROTO_PING_MAGIC))
 		lnet_swap_pinginfo(pbuf);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c
index acc6b239d391..fdca4655206e 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -268,22 +268,11 @@ lnet_md_link(struct lnet_libmd *md, struct lnet_handle_eq eq_handle, int cpt)
 
 /* must be called with lnet_res_lock held */
 void
-lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_md *umd)
+lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_event *ev)
 {
-	/* NB this doesn't copy out all the iov entries so when a
-	 * discontiguous MD is copied out, the target gets to know the
-	 * original iov pointer (in start) and the number of entries it had
-	 * and that's all.
-	 */
-	umd->start = lmd->md_start;
-	umd->length = !(lmd->md_options &
-			LNET_MD_KIOV) ?
-		      lmd->md_length : lmd->md_niov;
-	umd->threshold = lmd->md_threshold;
-	umd->max_size = lmd->md_max_size;
-	umd->options = lmd->md_options;
-	umd->user_ptr = lmd->md_user_ptr;
-	lnet_eq2handle(&umd->eq_handle, lmd->md_eq);
+	ev->md_start = lmd->md_start;
+	ev->md_options = lmd->md_options;
+	ev->md_user_ptr = lmd->md_user_ptr;
 }
 
 static int
diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c
index 02620fe2a0fa..a5f3aa4c9561 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-msg.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c
@@ -47,7 +47,7 @@ lnet_build_unlink_event(struct lnet_libmd *md, struct lnet_event *ev)
 	ev->status = 0;
 	ev->unlinked = 1;
 	ev->type = LNET_EVENT_UNLINK;
-	lnet_md_deconstruct(md, &ev->md);
+	lnet_md_deconstruct(md, ev);
 	lnet_md2handle(&ev->md_handle, md);
 }
 
@@ -360,7 +360,7 @@ lnet_msg_attach_md(struct lnet_msg *msg, struct lnet_libmd *md,
 
 	/* build umd in event */
 	lnet_md2handle(&msg->msg_ev.md_handle, md);
-	lnet_md_deconstruct(md, &msg->msg_ev.md);
+	lnet_md_deconstruct(md, &msg->msg_ev);
 }
 
 void
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index ade7f23b3bf4..3938e741a7a0 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -1774,7 +1774,7 @@ static void lnet_peer_discovery_complete(struct lnet_peer *lp)
  */
 void lnet_peer_push_event(struct lnet_event *ev)
 {
-	struct lnet_ping_buffer *pbuf = ev->md.user_ptr;
+	struct lnet_ping_buffer *pbuf = ev->md_user_ptr;
 	struct lnet_peer *lp;
 
 	/* lnet_find_peer() adds a refcount */
@@ -2059,7 +2059,7 @@ lnet_discovery_event_ack(struct lnet_peer *lp, struct lnet_event *ev)
 {
 	struct lnet_ping_buffer *pbuf;
 
-	pbuf = LNET_PING_INFO_TO_BUFFER(ev->md.start);
+	pbuf = LNET_PING_INFO_TO_BUFFER(ev->md_start);
 	spin_lock(&lp->lp_lock);
 	lp->lp_state &= ~LNET_PEER_PUSH_SENT;
 	lp->lp_push_error = ev->status;
@@ -2096,7 +2096,7 @@ lnet_discovery_event_reply(struct lnet_peer *lp, struct lnet_event *ev)
 		goto out;
 	}
 
-	pbuf = LNET_PING_INFO_TO_BUFFER(ev->md.start);
+	pbuf = LNET_PING_INFO_TO_BUFFER(ev->md_start);
 	if (pbuf->pb_info.pi_magic == __swab32(LNET_PROTO_PING_MAGIC))
 		lnet_swap_pinginfo(pbuf);
 
@@ -2278,7 +2278,7 @@ lnet_discovery_event_unlink(struct lnet_peer *lp, struct lnet_event *ev)
  */
 static void lnet_discovery_event_handler(struct lnet_event *event)
 {
-	struct lnet_peer *lp = event->md.user_ptr;
+	struct lnet_peer *lp = event->md_user_ptr;
 	struct lnet_ping_buffer *pbuf;
 	int rc;
 
@@ -2308,7 +2308,7 @@ static void lnet_discovery_event_handler(struct lnet_event *event)
 	}
 	lnet_net_lock(LNET_LOCK_EX);
 	if (event->unlinked) {
-		pbuf = LNET_PING_INFO_TO_BUFFER(event->md.start);
+		pbuf = LNET_PING_INFO_TO_BUFFER(event->md_start);
 		lnet_ping_buffer_decref(pbuf);
 		lnet_peer_decref_locked(lp);
 	}
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index bcde61d2a984..31481b4a7ed3 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -748,7 +748,7 @@ lnet_parse_rc_info(struct lnet_rc_data *rcd)
 static void
 lnet_router_checker_event(struct lnet_event *event)
 {
-	struct lnet_rc_data *rcd = event->md.user_ptr;
+	struct lnet_rc_data *rcd = event->md_user_ptr;
 	struct lnet_peer_ni *lp;
 
 	LASSERT(rcd);
diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c
index abb6f8fb011e..6dc80ec07c4c 100644
--- a/drivers/staging/lustre/lnet/selftest/rpc.c
+++ b/drivers/staging/lustre/lnet/selftest/rpc.c
@@ -1403,7 +1403,7 @@ static void
 srpc_lnet_ev_handler(struct lnet_event *ev)
 {
 	struct srpc_service_cd *scd;
-	struct srpc_event *rpcev = ev->md.user_ptr;
+	struct srpc_event *rpcev = ev->md_user_ptr;
 	struct srpc_client_rpc *crpc;
 	struct srpc_server_rpc *srpc;
 	struct srpc_buffer *buffer;
@@ -1480,7 +1480,8 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 		LASSERT(ev->type != LNET_EVENT_UNLINK ||
 			sv->sv_shuttingdown);
 
-		buffer = container_of(ev->md.start, struct srpc_buffer, buf_msg);
+		buffer = container_of(ev->md_start, struct srpc_buffer,
+				      buf_msg);
 		buffer->buf_peer = ev->source;
 		buffer->buf_self = ev->target.nid;
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c
index 0c16a2c9d2ed..5bb5fb2b7354 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/events.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/events.c
@@ -50,7 +50,7 @@ struct lnet_handle_eq ptlrpc_eq_h;
  */
 void request_out_callback(struct lnet_event *ev)
 {
-	struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+	struct ptlrpc_cb_id *cbid = ev->md_user_ptr;
 	struct ptlrpc_request *req = cbid->cbid_arg;
 	bool wakeup = false;
 
@@ -89,18 +89,18 @@ void request_out_callback(struct lnet_event *ev)
  */
 void reply_in_callback(struct lnet_event *ev)
 {
-	struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+	struct ptlrpc_cb_id *cbid = ev->md_user_ptr;
 	struct ptlrpc_request *req = cbid->cbid_arg;
 
 	DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status);
 
 	LASSERT(ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK);
-	LASSERT(ev->md.start == req->rq_repbuf);
+	LASSERT(ev->md_start == req->rq_repbuf);
 	LASSERT(ev->offset + ev->mlength <= req->rq_repbuf_len);
 	/* We've set LNET_MD_MANAGE_REMOTE for all outgoing requests
 	 * for adaptive timeouts' early reply.
 	 */
-	LASSERT((ev->md.options & LNET_MD_MANAGE_REMOTE) != 0);
+	LASSERT((ev->md_options & LNET_MD_MANAGE_REMOTE) != 0);
 
 	spin_lock(&req->rq_lock);
 
@@ -179,7 +179,7 @@ void reply_in_callback(struct lnet_event *ev)
  */
 void client_bulk_callback(struct lnet_event *ev)
 {
-	struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+	struct ptlrpc_cb_id *cbid = ev->md_user_ptr;
 	struct ptlrpc_bulk_desc *desc = cbid->cbid_arg;
 	struct ptlrpc_request *req;
 
@@ -292,7 +292,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt,
  */
 void request_in_callback(struct lnet_event *ev)
 {
-	struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+	struct ptlrpc_cb_id *cbid = ev->md_user_ptr;
 	struct ptlrpc_request_buffer_desc *rqbd = cbid->cbid_arg;
 	struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt;
 	struct ptlrpc_service *service = svcpt->scp_service;
@@ -300,8 +300,8 @@ void request_in_callback(struct lnet_event *ev)
 
 	LASSERT(ev->type == LNET_EVENT_PUT ||
 		ev->type == LNET_EVENT_UNLINK);
-	LASSERT((char *)ev->md.start >= rqbd->rqbd_buffer);
-	LASSERT((char *)ev->md.start + ev->offset + ev->mlength <=
+	LASSERT((char *)ev->md_start >= rqbd->rqbd_buffer);
+	LASSERT((char *)ev->md_start + ev->offset + ev->mlength <=
 		rqbd->rqbd_buffer + service->srv_buf_size);
 
 	CDEBUG((ev->status == 0) ? D_NET : D_ERROR,
@@ -338,7 +338,7 @@ void request_in_callback(struct lnet_event *ev)
 	 * size to non-zero if this was a successful receive.
 	 */
 	req->rq_xid = ev->match_bits;
-	req->rq_reqbuf = ev->md.start + ev->offset;
+	req->rq_reqbuf = ev->md_start + ev->offset;
 	if (ev->type == LNET_EVENT_PUT && ev->status == 0)
 		req->rq_reqdata_len = ev->mlength;
 	ktime_get_real_ts64(&req->rq_arrival_time);
@@ -395,7 +395,7 @@ void request_in_callback(struct lnet_event *ev)
  */
 void reply_out_callback(struct lnet_event *ev)
 {
-	struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+	struct ptlrpc_cb_id *cbid = ev->md_user_ptr;
 	struct ptlrpc_reply_state *rs = cbid->cbid_arg;
 	struct ptlrpc_service_part *svcpt = rs->rs_svcpt;
 
@@ -435,7 +435,7 @@ void reply_out_callback(struct lnet_event *ev)
 
 static void ptlrpc_master_callback(struct lnet_event *ev)
 {
-	struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
+	struct ptlrpc_cb_id *cbid = ev->md_user_ptr;
 	void (*callback)(struct lnet_event *ev) = cbid->cbid_fn;
 
 	/* Honestly, it's best to find out early. */

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 12/32] lustre: lnet: merge lnet_md_alloc into lnet_md_build.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (10 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 06/32] lustre: ptlrpc: discard BULK_BUF types NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 15/32] lustre: lnet: remove msg_iov from lnet_msg NeilBrown
                   ` (19 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

lnet_md_alloc is only called twice, each time immediately before a
call to lnet_md_build, and these are the only calls to
lnet_md_build().

So simplify the code by merging lnet_md_alloc into lnet_md_build.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |   26 --------
 drivers/staging/lustre/lnet/lnet/lib-md.c          |   63 ++++++++++++--------
 2 files changed, 38 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index 7275d517df5a..fca1c19a3c84 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -189,32 +189,6 @@ lnet_net_lock_current(void)
 
 #define MAX_PORTALS		64
 
-static inline struct lnet_libmd *
-lnet_md_alloc(struct lnet_md *umd)
-{
-	struct lnet_libmd *md;
-	unsigned int size;
-	unsigned int niov;
-
-	if (umd->options & LNET_MD_KIOV) {
-		niov = umd->length;
-		size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
-	} else {
-		niov = 1;
-		size = offsetof(struct lnet_libmd, md_iov.iov[niov]);
-	}
-
-	md = kzalloc(size, GFP_NOFS);
-	if (md) {
-		/* Set here in case of early free */
-		md->md_options = umd->options;
-		md->md_niov = niov;
-		INIT_LIST_HEAD(&md->md_list);
-	}
-
-	return md;
-}
-
 struct lnet_libhandle *lnet_res_lh_lookup(struct lnet_res_container *rec,
 					  u64 cookie);
 void lnet_res_lh_initialize(struct lnet_res_container *rec,
diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c
index fdca4655206e..26c560a1e8b9 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -171,12 +171,29 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 	return cpt;
 }
 
-static int
-lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink)
+static struct lnet_libmd *
+lnet_md_build(struct lnet_md *umd, int unlink)
 {
 	int i;
 	unsigned int niov;
 	int total_length = 0;
+	struct lnet_libmd *lmd;
+	unsigned int size;
+
+	if (umd->options & LNET_MD_KIOV) {
+		niov = umd->length;
+		size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
+	} else {
+		niov = 1;
+		size = offsetof(struct lnet_libmd, md_iov.iov[niov]);
+	}
+
+	lmd = kzalloc(size, GFP_NOFS);
+	if (!lmd)
+		return ERR_PTR(-ENOMEM);
+
+	lmd->md_niov = niov;
+	INIT_LIST_HEAD(&lmd->md_list);
 
 	lmd->md_me = NULL;
 	lmd->md_start = umd->start;
@@ -199,8 +216,10 @@ lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink)
 		for (i = 0; i < (int)niov; i++) {
 			/* We take the page pointer on trust */
 			if (lmd->md_iov.kiov[i].bv_offset +
-			    lmd->md_iov.kiov[i].bv_len > PAGE_SIZE)
-				return -EINVAL; /* invalid length */
+			    lmd->md_iov.kiov[i].bv_len > PAGE_SIZE) {
+				kfree(lmd);
+				return ERR_PTR(-EINVAL); /* invalid length */
+			}
 
 			total_length += lmd->md_iov.kiov[i].bv_len;
 		}
@@ -209,8 +228,10 @@ lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink)
 
 		if ((umd->options & LNET_MD_MAX_SIZE) && /* max size used */
 		    (umd->max_size < 0 ||
-		     umd->max_size > total_length)) /* illegal max_size */
-			return -EINVAL;
+		     umd->max_size > total_length)) { /* illegal max_size */
+			kfree(lmd);
+			return ERR_PTR(-EINVAL);
+		}
 	} else {   /* contiguous */
 		lmd->md_length = umd->length;
 		niov = 1;
@@ -220,11 +241,13 @@ lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink)
 
 		if ((umd->options & LNET_MD_MAX_SIZE) && /* max size used */
 		    (umd->max_size < 0 ||
-		     umd->max_size > (int)umd->length)) /* illegal max_size */
-			return -EINVAL;
+		     umd->max_size > (int)umd->length)) { /* illegal max_size */
+			kfree(lmd);
+			return ERR_PTR(-EINVAL);
+		}
 	}
 
-	return 0;
+	return lmd;
 }
 
 /* must be called with resource lock held */
@@ -341,13 +364,9 @@ LNetMDAttach(struct lnet_handle_me meh, struct lnet_md umd,
 		return -EINVAL;
 	}
 
-	md = lnet_md_alloc(&umd);
-	if (!md)
-		return -ENOMEM;
-
-	rc = lnet_md_build(md, &umd, unlink);
-	if (rc)
-		goto out_free;
+	md = lnet_md_build(&umd, unlink);
+	if (IS_ERR(md))
+		return PTR_ERR(md);
 
 	cpt = lnet_cpt_of_cookie(meh.cookie);
 
@@ -381,7 +400,6 @@ LNetMDAttach(struct lnet_handle_me meh, struct lnet_md umd,
 
 out_unlock:
 	lnet_res_unlock(cpt);
-out_free:
 	kfree(md);
 	return rc;
 }
@@ -421,13 +439,9 @@ LNetMDBind(struct lnet_md umd, enum lnet_unlink unlink,
 		return -EINVAL;
 	}
 
-	md = lnet_md_alloc(&umd);
-	if (!md)
-		return -ENOMEM;
-
-	rc = lnet_md_build(md, &umd, unlink);
-	if (rc)
-		goto out_free;
+	md = lnet_md_build(&umd, unlink);
+	if (IS_ERR(md))
+		return PTR_ERR(md);
 
 	cpt = lnet_res_lock_current();
 
@@ -442,7 +456,6 @@ LNetMDBind(struct lnet_md umd, enum lnet_unlink unlink,
 
 out_unlock:
 	lnet_res_unlock(cpt);
-out_free:
 	kfree(md);
 
 	return rc;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 13/32] lustre: lnet: always put a page list into struct lnet_libmd.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (13 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 14/32] lustre: lnet: discard kvec option from lnet_libmd NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 17/32] lustre: socklnd: discard tx_iov NeilBrown
                   ` (16 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

'struct lnet_libmd' is only created in lnet_md_build().
It can be given a list of pages or a virtual address.
In the latter case, the memory will eventually be
split into a list of pages.
It is cleaner to split it into a list of pages early
so that all lower levels only need to handle one type: a page list.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lnet/lnet/lib-md.c |   43 ++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c
index 26c560a1e8b9..970db903552d 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -180,14 +180,13 @@ lnet_md_build(struct lnet_md *umd, int unlink)
 	struct lnet_libmd *lmd;
 	unsigned int size;
 
-	if (umd->options & LNET_MD_KIOV) {
+	if (umd->options & LNET_MD_KIOV)
 		niov = umd->length;
-		size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
-	} else {
-		niov = 1;
-		size = offsetof(struct lnet_libmd, md_iov.iov[niov]);
-	}
+	else
+		niov = DIV_ROUND_UP(offset_in_page(umd->start) + umd->length,
+				    PAGE_SIZE);
 
+	size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
 	lmd = kzalloc(size, GFP_NOFS);
 	if (!lmd)
 		return ERR_PTR(-ENOMEM);
@@ -208,8 +207,6 @@ lnet_md_build(struct lnet_md *umd, int unlink)
 	lmd->md_bulk_handle = umd->bulk_handle;
 
 	if (umd->options & LNET_MD_KIOV) {
-		niov = umd->length;
-		lmd->md_niov = umd->length;
 		memcpy(lmd->md_iov.kiov, umd->start,
 		       niov * sizeof(lmd->md_iov.kiov[0]));
 
@@ -232,12 +229,29 @@ lnet_md_build(struct lnet_md *umd, int unlink)
 			kfree(lmd);
 			return ERR_PTR(-EINVAL);
 		}
-	} else {   /* contiguous */
-		lmd->md_length = umd->length;
-		niov = 1;
-		lmd->md_niov = 1;
-		lmd->md_iov.iov[0].iov_base = umd->start;
-		lmd->md_iov.iov[0].iov_len = umd->length;
+	} else {   /* contiguous - split into pages */
+		void *pa = umd->start;
+		int len = umd->length;
+
+		lmd->md_length = len;
+		i = 0;
+		while (len) {
+			struct page *p;
+			int plen;
+
+			if (is_vmalloc_addr(pa))
+				p = vmalloc_to_page(pa);
+			else
+				p = virt_to_page(pa);
+			plen = min_t(int, len, PAGE_SIZE - offset_in_page(pa));
+
+			lmd->md_iov.kiov[i].bv_page = p;
+			lmd->md_iov.kiov[i].bv_offset = offset_in_page(pa);
+			lmd->md_iov.kiov[i].bv_len = plen;
+			len -= plen;
+			pa += plen;
+			i += 1;
+		}
 
 		if ((umd->options & LNET_MD_MAX_SIZE) && /* max size used */
 		    (umd->max_size < 0 ||
@@ -245,6 +259,7 @@ lnet_md_build(struct lnet_md *umd, int unlink)
 			kfree(lmd);
 			return ERR_PTR(-EINVAL);
 		}
+		lmd->md_options |= LNET_MD_KIOV;
 	}
 
 	return lmd;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 14/32] lustre: lnet: discard kvec option from lnet_libmd.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (12 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 15/32] lustre: lnet: remove msg_iov from lnet_msg NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 13/32] lustre: lnet: always put a page list into struct lnet_libmd NeilBrown
                   ` (17 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

The 'struct kvec' field in 'struct lnet_libmd' is no
longer set - the memory is always presented as pages.
So remove that option and the union that contained
iov and kiov.

Rename md_iov.kiov to  md_kiov.
Discard all code that made use of md_iov.iov.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-types.h  |    5 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |   14 +---
 drivers/staging/lustre/lnet/lnet/lib-md.c          |   79 +++++---------------
 drivers/staging/lustre/lnet/lnet/lib-move.c        |    5 -
 4 files changed, 25 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index 60f9c286fe8c..e4a3e747389a 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -168,10 +168,7 @@ struct lnet_libmd {
 	struct lnet_eq		*md_eq;
 	unsigned int		 md_niov;	/* # frags */
 	struct lnet_handle_md	 md_bulk_handle;
-	union {
-		struct kvec	iov[LNET_MAX_IOV];
-		struct bio_vec	kiov[LNET_MAX_IOV];
-	} md_iov;
+	struct bio_vec		 md_kiov[LNET_MAX_IOV];
 };
 
 #define LNET_MD_FLAG_ZOMBIE		BIT(0)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 3579d90df98d..bd9810652d09 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1584,16 +1584,10 @@ kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 
 		ibmsg = tx->tx_msg;
 		rd = &ibmsg->ibm_u.get.ibgm_rd;
-		if (!(lntmsg->msg_md->md_options & LNET_MD_KIOV))
-			rc = kiblnd_setup_rd_iov(ni, tx, rd,
-						 lntmsg->msg_md->md_niov,
-						 lntmsg->msg_md->md_iov.iov,
-						 0, lntmsg->msg_md->md_length);
-		else
-			rc = kiblnd_setup_rd_kiov(ni, tx, rd,
-						  lntmsg->msg_md->md_niov,
-						  lntmsg->msg_md->md_iov.kiov,
-						  0, lntmsg->msg_md->md_length);
+		rc = kiblnd_setup_rd_kiov(ni, tx, rd,
+					  lntmsg->msg_md->md_niov,
+					  lntmsg->msg_md->md_kiov,
+					  0, lntmsg->msg_md->md_length);
 		if (rc) {
 			CERROR("Can't setup GET sink for %s: %d\n",
 			       libcfs_nid2str(target.nid), rc);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c
index 970db903552d..4c6d14aa2139 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -98,6 +98,7 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 {
 	int cpt = CFS_CPT_ANY;
 	unsigned int niov;
+	struct bio_vec *kiov = md->md_kiov;
 
 	/*
 	 * if the md_options has a bulk handle then we want to look at the
@@ -112,61 +113,19 @@ int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 
 	niov = md->md_niov;
 
-	/*
-	 * There are three cases to handle:
-	 *  1. The MD is using lnet_kiov_t
-	 *  2. The MD is using struct kvec
-	 *  3. Contiguous buffer allocated via vmalloc
-	 *
-	 *  in case 2 we can use virt_to_page() macro to get the page
-	 *  address of the memory kvec describes.
-	 *
-	 *  in case 3 use is_vmalloc_addr() and vmalloc_to_page()
-	 *
-	 * The offset provided can be within the first iov/kiov entry or
-	 * it could go beyond it. In that case we need to make sure to
-	 * look at the page which actually contains the data that will be
-	 * DMAed.
-	 */
-	if ((md->md_options & LNET_MD_KIOV) != 0) {
-		struct bio_vec *kiov = md->md_iov.kiov;
-
-		while (offset >= kiov->bv_len) {
-			offset -= kiov->bv_len;
-			niov--;
-			kiov++;
-			if (niov == 0) {
-				CERROR("offset %d goes beyond kiov\n", offset);
-				goto out;
-			}
-		}
-
-		cpt = cfs_cpt_of_node(lnet_cpt_table(),
-				      page_to_nid(kiov->bv_page));
-	} else {
-		struct kvec *iov = md->md_iov.iov;
-		unsigned long vaddr;
-		struct page *page;
-
-		while (offset >= iov->iov_len) {
-			offset -= iov->iov_len;
-			niov--;
-			iov++;
-			if (niov == 0) {
-				CERROR("offset %d goes beyond iov\n", offset);
-				goto out;
-			}
-		}
-
-		vaddr = ((unsigned long)iov->iov_base) + offset;
-		page = lnet_kvaddr_to_page(vaddr);
-		if (!page) {
-			CERROR("Couldn't resolve vaddr 0x%lx to page\n", vaddr);
+	while (offset >= kiov->bv_len) {
+		offset -= kiov->bv_len;
+		niov--;
+		kiov++;
+		if (niov == 0) {
+			CERROR("offset %d goes beyond kiov\n", offset);
 			goto out;
 		}
-		cpt = cfs_cpt_of_node(lnet_cpt_table(), page_to_nid(page));
 	}
 
+	cpt = cfs_cpt_of_node(lnet_cpt_table(),
+			      page_to_nid(kiov->bv_page));
+
 out:
 	return cpt;
 }
@@ -186,7 +145,7 @@ lnet_md_build(struct lnet_md *umd, int unlink)
 		niov = DIV_ROUND_UP(offset_in_page(umd->start) + umd->length,
 				    PAGE_SIZE);
 
-	size = offsetof(struct lnet_libmd, md_iov.kiov[niov]);
+	size = offsetof(struct lnet_libmd, md_kiov[niov]);
 	lmd = kzalloc(size, GFP_NOFS);
 	if (!lmd)
 		return ERR_PTR(-ENOMEM);
@@ -207,18 +166,18 @@ lnet_md_build(struct lnet_md *umd, int unlink)
 	lmd->md_bulk_handle = umd->bulk_handle;
 
 	if (umd->options & LNET_MD_KIOV) {
-		memcpy(lmd->md_iov.kiov, umd->start,
-		       niov * sizeof(lmd->md_iov.kiov[0]));
+		memcpy(lmd->md_kiov, umd->start,
+		       niov * sizeof(lmd->md_kiov[0]));
 
 		for (i = 0; i < (int)niov; i++) {
 			/* We take the page pointer on trust */
-			if (lmd->md_iov.kiov[i].bv_offset +
-			    lmd->md_iov.kiov[i].bv_len > PAGE_SIZE) {
+			if (lmd->md_kiov[i].bv_offset +
+			    lmd->md_kiov[i].bv_len > PAGE_SIZE) {
 				kfree(lmd);
 				return ERR_PTR(-EINVAL); /* invalid length */
 			}
 
-			total_length += lmd->md_iov.kiov[i].bv_len;
+			total_length += lmd->md_kiov[i].bv_len;
 		}
 
 		lmd->md_length = total_length;
@@ -245,9 +204,9 @@ lnet_md_build(struct lnet_md *umd, int unlink)
 				p = virt_to_page(pa);
 			plen = min_t(int, len, PAGE_SIZE - offset_in_page(pa));
 
-			lmd->md_iov.kiov[i].bv_page = p;
-			lmd->md_iov.kiov[i].bv_offset = offset_in_page(pa);
-			lmd->md_iov.kiov[i].bv_len = plen;
+			lmd->md_kiov[i].bv_page = p;
+			lmd->md_kiov[i].bv_offset = offset_in_page(pa);
+			lmd->md_kiov[i].bv_len = plen;
 			len -= plen;
 			pa += plen;
 			i += 1;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index 17f1c4a1029c..2938a56cee02 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -519,10 +519,7 @@ lnet_setpayloadbuffer(struct lnet_msg *msg)
 	LASSERT(!msg->msg_kiov);
 
 	msg->msg_niov = md->md_niov;
-	if (md->md_options & LNET_MD_KIOV)
-		msg->msg_kiov = md->md_iov.kiov;
-	else
-		msg->msg_iov = md->md_iov.iov;
+	msg->msg_kiov = md->md_kiov;
 }
 
 void

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 15/32] lustre: lnet: remove msg_iov from lnet_msg.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (11 preceding siblings ...)
  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 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 14/32] lustre: lnet: discard kvec option from lnet_libmd NeilBrown
                   ` (18 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This field is never set, so remove it and remove all
uses of it.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-types.h  |    1 -
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |   30 ++++-----------
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   39 ++++++--------------
 drivers/staging/lustre/lnet/lnet/lib-move.c        |   16 ++------
 drivers/staging/lustre/lnet/lnet/lo.c              |   17 +++------
 5 files changed, 27 insertions(+), 76 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h
index e4a3e747389a..23fbbc47bfec 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-types.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h
@@ -114,7 +114,6 @@ struct lnet_msg {
 	unsigned int		 msg_wanted;
 	unsigned int		 msg_offset;
 	unsigned int		 msg_niov;
-	struct kvec		*msg_iov;
 	struct bio_vec		*msg_kiov;
 
 	struct lnet_event	 msg_ev;
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index bd9810652d09..51eb20ed3326 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1522,7 +1522,6 @@ kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 	int target_is_router = lntmsg->msg_target_is_router;
 	int routing = lntmsg->msg_routing;
 	unsigned int payload_niov = lntmsg->msg_niov;
-	struct kvec *payload_iov = lntmsg->msg_iov;
 	struct bio_vec *payload_kiov = lntmsg->msg_kiov;
 	unsigned int payload_offset = lntmsg->msg_offset;
 	unsigned int payload_nob = lntmsg->msg_len;
@@ -1543,17 +1542,11 @@ kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 
 	/* Thread context */
 	LASSERT(!in_interrupt());
-	/* payload is either all vaddrs or all pages */
-	LASSERT(!(payload_kiov && payload_iov));
+	LASSERT(payload_kiov);
 
-	if (payload_kiov)
-		iov_iter_bvec(&from, WRITE,
-			      payload_kiov, payload_niov,
-			      payload_nob + payload_offset);
-	else
-		iov_iter_kvec(&from, WRITE,
-			      payload_iov, payload_niov,
-			      payload_nob + payload_offset);
+	iov_iter_bvec(&from, WRITE,
+		      payload_kiov, payload_niov,
+		      payload_nob + payload_offset);
 
 	iov_iter_advance(&from, payload_offset);
 
@@ -1629,14 +1622,9 @@ kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 			return -ENOMEM;
 		}
 
-		if (!payload_kiov)
-			rc = kiblnd_setup_rd_iov(ni, tx, tx->tx_rd,
-						 payload_niov, payload_iov,
-						 payload_offset, payload_nob);
-		else
-			rc = kiblnd_setup_rd_kiov(ni, tx, tx->tx_rd,
-						  payload_niov, payload_kiov,
-						  payload_offset, payload_nob);
+		rc = kiblnd_setup_rd_kiov(ni, tx, tx->tx_rd,
+					  payload_niov, payload_kiov,
+					  payload_offset, payload_nob);
 		if (rc) {
 			CERROR("Can't setup PUT src for %s: %d\n",
 			       libcfs_nid2str(target.nid), rc);
@@ -1690,7 +1678,6 @@ kiblnd_reply(struct lnet_ni *ni, struct kib_rx *rx, struct lnet_msg *lntmsg)
 {
 	struct lnet_process_id target = lntmsg->msg_target;
 	unsigned int niov = lntmsg->msg_niov;
-	struct kvec *iov = lntmsg->msg_iov;
 	struct bio_vec *kiov = lntmsg->msg_kiov;
 	unsigned int offset = lntmsg->msg_offset;
 	unsigned int nob = lntmsg->msg_len;
@@ -1706,9 +1693,6 @@ kiblnd_reply(struct lnet_ni *ni, struct kib_rx *rx, struct lnet_msg *lntmsg)
 
 	if (!nob)
 		rc = 0;
-	else if (!kiov)
-		rc = kiblnd_setup_rd_iov(ni, tx, tx->tx_rd,
-					 niov, iov, offset, nob);
 	else
 		rc = kiblnd_setup_rd_kiov(ni, tx, tx->tx_rd,
 					  niov, kiov, offset, nob);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index cbba90c6b9da..ce61d06f3d79 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -867,7 +867,6 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 	int type = lntmsg->msg_type;
 	struct lnet_process_id target = lntmsg->msg_target;
 	unsigned int payload_niov = lntmsg->msg_niov;
-	struct kvec *payload_iov = lntmsg->msg_iov;
 	struct bio_vec *payload_kiov = lntmsg->msg_kiov;
 	unsigned int payload_offset = lntmsg->msg_offset;
 	unsigned int payload_nob = lntmsg->msg_len;
@@ -884,16 +883,10 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 
 	LASSERT(!payload_nob || payload_niov > 0);
 	LASSERT(payload_niov <= LNET_MAX_IOV);
-	/* payload is either all vaddrs or all pages */
-	LASSERT(!(payload_kiov && payload_iov));
 	LASSERT(!in_interrupt());
 
-	if (payload_iov)
-		desc_size = offsetof(struct ksock_tx,
-				     tx_frags.virt.iov[1 + payload_niov]);
-	else
-		desc_size = offsetof(struct ksock_tx,
-				     tx_frags.paged.kiov[payload_niov]);
+	desc_size = offsetof(struct ksock_tx,
+			     tx_frags.paged.kiov[payload_niov]);
 
 	if (lntmsg->msg_vmflush)
 		mpflag = memalloc_noreclaim_save();
@@ -909,25 +902,15 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 	tx->tx_conn = NULL;		     /* set when assigned a conn */
 	tx->tx_lnetmsg = lntmsg;
 
-	if (payload_iov) {
-		tx->tx_kiov = NULL;
-		tx->tx_nkiov = 0;
-		tx->tx_iov = tx->tx_frags.virt.iov;
-		tx->tx_niov = 1 +
-			      lnet_extract_iov(payload_niov, &tx->tx_iov[1],
-					       payload_niov, payload_iov,
-					       payload_offset, payload_nob);
-	} else {
-		tx->tx_niov = 1;
-		tx->tx_iov = &tx->tx_frags.paged.iov;
-		tx->tx_kiov = tx->tx_frags.paged.kiov;
-		tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
-						 payload_niov, payload_kiov,
-						 payload_offset, payload_nob);
-
-		if (payload_nob >= *ksocknal_tunables.ksnd_zc_min_payload)
-			tx->tx_zc_capable = 1;
-	}
+	tx->tx_niov = 1;
+	tx->tx_iov = &tx->tx_frags.paged.iov;
+	tx->tx_kiov = tx->tx_frags.paged.kiov;
+	tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
+					 payload_niov, payload_kiov,
+					 payload_offset, payload_nob);
+
+	if (payload_nob >= *ksocknal_tunables.ksnd_zc_min_payload)
+		tx->tx_zc_capable = 1;
 
 	tx->tx_msg.ksm_csum = 0;
 	tx->tx_msg.ksm_type = KSOCK_MSG_LNET;
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index 2938a56cee02..a074807f4d86 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -466,7 +466,6 @@ lnet_ni_recv(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
 	     unsigned int rlen)
 {
 	unsigned int niov = 0;
-	struct kvec *iov = NULL;
 	struct bio_vec *kiov = NULL;
 	struct iov_iter to;
 	int rc;
@@ -486,21 +485,16 @@ lnet_ni_recv(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
 
 		if (mlen) {
 			niov = msg->msg_niov;
-			iov = msg->msg_iov;
 			kiov = msg->msg_kiov;
 
 			LASSERT(niov > 0);
-			LASSERT(!iov != !kiov);
+			LASSERT(kiov);
 		}
 	}
 
-	if (iov) {
-		iov_iter_kvec(&to, READ, iov, niov, mlen + offset);
-		iov_iter_advance(&to, offset);
-	} else {
-		iov_iter_bvec(&to, READ, kiov, niov, mlen + offset);
-		iov_iter_advance(&to, offset);
-	}
+	iov_iter_bvec(&to, READ, kiov, niov, mlen + offset);
+	iov_iter_advance(&to, offset);
+
 	rc = ni->ni_net->net_lnd->lnd_recv(ni, private, msg, delayed, &to, rlen);
 	if (rc < 0)
 		lnet_finalize(msg, rc);
@@ -515,7 +509,6 @@ lnet_setpayloadbuffer(struct lnet_msg *msg)
 	LASSERT(!msg->msg_routing);
 	LASSERT(md);
 	LASSERT(!msg->msg_niov);
-	LASSERT(!msg->msg_iov);
 	LASSERT(!msg->msg_kiov);
 
 	msg->msg_niov = md->md_niov;
@@ -835,7 +828,6 @@ lnet_post_routed_recv_locked(struct lnet_msg *msg, int do_recv)
 	struct lnet_rtrbufpool *rbp;
 	struct lnet_rtrbuf *rb;
 
-	LASSERT(!msg->msg_iov);
 	LASSERT(!msg->msg_kiov);
 	LASSERT(!msg->msg_niov);
 	LASSERT(msg->msg_routing);
diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c
index c8a1eb62c430..f7af2f1d8f80 100644
--- a/drivers/staging/lustre/lnet/lnet/lo.c
+++ b/drivers/staging/lustre/lnet/lnet/lo.c
@@ -49,18 +49,11 @@ lolnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
 	struct lnet_msg *sendmsg = private;
 
 	if (lntmsg) {		   /* not discarding */
-		if (sendmsg->msg_iov)
-			lnet_copy_iov2iter(to,
-					   sendmsg->msg_niov,
-					   sendmsg->msg_iov,
-					   sendmsg->msg_offset,
-					   iov_iter_count(to));
-		else
-			lnet_copy_kiov2iter(to,
-					    sendmsg->msg_niov,
-					    sendmsg->msg_kiov,
-					    sendmsg->msg_offset,
-					    iov_iter_count(to));
+		lnet_copy_kiov2iter(to,
+				    sendmsg->msg_niov,
+				    sendmsg->msg_kiov,
+				    sendmsg->msg_offset,
+				    iov_iter_count(to));
 
 		lnet_finalize(lntmsg, 0);
 	}

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 16/32] lustre: lnet: simplify ksock_tx.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (18 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 20/32] lustre: lnet: discard lnet_kvaddr_to_page NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 21/32] lustre: ptlrpc: discard a server-only waitq NeilBrown
                   ` (11 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

The tx_frags union in 'struct ksock_tx' is largely unnecessary.
The payload is always bio_vec, the only kvec is a header.
So replace the union with just those two fields.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h    |   14 ++++----------
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |    8 ++++----
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index add2744c9d8d..738c7cd2b484 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -289,18 +289,12 @@ struct ksock_tx {				/* transmit packet */
 	time64_t		tx_deadline;	/* when (in secs) tx times out */
 	struct ksock_msg	tx_msg;		/* socklnd message buffer */
 	int			tx_desc_size;	/* size of this descriptor */
-	union {
-		struct {
-			struct kvec	iov;	/* virt hdr */
-			struct bio_vec	kiov[0];/* paged payload */
-		} paged;
-		struct {
-			struct kvec	iov[1];	/* virt hdr + payload */
-		} virt;
-	} tx_frags;
+
+	struct kvec		tx_hdr;		/* virt hdr */
+	struct bio_vec		tx_payload[0];	/* paged payload */
 };
 
-#define KSOCK_NOOP_TX_SIZE (offsetof(struct ksock_tx, tx_frags.paged.kiov[0]))
+#define KSOCK_NOOP_TX_SIZE (offsetof(struct ksock_tx, tx_payload[0]))
 
 /* network zero copy callback descriptor embedded in struct ksock_tx */
 
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index ce61d06f3d79..f137c875ed66 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -78,7 +78,7 @@ ksocknal_alloc_tx_noop(u64 cookie, int nonblk)
 	tx->tx_lnetmsg = NULL;
 	tx->tx_kiov = NULL;
 	tx->tx_nkiov = 0;
-	tx->tx_iov = tx->tx_frags.virt.iov;
+	tx->tx_iov = &tx->tx_hdr;
 	tx->tx_niov = 1;
 	tx->tx_nonblk = nonblk;
 
@@ -886,7 +886,7 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 	LASSERT(!in_interrupt());
 
 	desc_size = offsetof(struct ksock_tx,
-			     tx_frags.paged.kiov[payload_niov]);
+			     tx_payload[payload_niov]);
 
 	if (lntmsg->msg_vmflush)
 		mpflag = memalloc_noreclaim_save();
@@ -903,8 +903,8 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 	tx->tx_lnetmsg = lntmsg;
 
 	tx->tx_niov = 1;
-	tx->tx_iov = &tx->tx_frags.paged.iov;
-	tx->tx_kiov = tx->tx_frags.paged.kiov;
+	tx->tx_iov = &tx->tx_hdr;
+	tx->tx_kiov = tx->tx_payload;
 	tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
 					 payload_niov, payload_kiov,
 					 payload_offset, payload_nob);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 17/32] lustre: socklnd: discard tx_iov.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (14 preceding siblings ...)
  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 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 19/32] lustre: socklnd: discard kiblnd_setup_rd_iov NeilBrown
                   ` (15 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

tx_iov always points to tx_hdr, so we can discard tx_iov,
and just use &tx_hdr.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lnet/klnds/socklnd/socklnd.h    |    3 +-
 .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c |   34 +++++++++-----------
 .../lustre/lnet/klnds/socklnd/socklnd_lib.c        |   20 +++++-------
 .../lustre/lnet/klnds/socklnd/socklnd_proto.c      |   17 ++++++----
 4 files changed, 34 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index 738c7cd2b484..c57b80232c1b 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -276,7 +276,6 @@ struct ksock_tx {				/* transmit packet */
 	int			tx_nob;		/* # packet bytes */
 	int			tx_resid;	/* residual bytes */
 	int			tx_niov;	/* # packet iovec frags */
-	struct kvec		*tx_iov;	/* packet iovec frags */
 	int			tx_nkiov;	/* # packet page frags */
 	unsigned short		tx_zc_aborted;	/* aborted ZC request */
 	unsigned short		tx_zc_capable:1;/* payload is large enough for ZC */
@@ -684,7 +683,7 @@ void ksocknal_lib_reset_callback(struct socket *sock, struct ksock_conn *conn);
 void ksocknal_lib_push_conn(struct ksock_conn *conn);
 int ksocknal_lib_get_conn_addrs(struct ksock_conn *conn);
 int ksocknal_lib_setup_sock(struct socket *so);
-int ksocknal_lib_send_iov(struct ksock_conn *conn, struct ksock_tx *tx);
+int ksocknal_lib_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx);
 int ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx);
 void ksocknal_lib_eager_ack(struct ksock_conn *conn);
 int ksocknal_lib_recv(struct ksock_conn *conn);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index f137c875ed66..d3fd7735649e 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -78,7 +78,6 @@ ksocknal_alloc_tx_noop(u64 cookie, int nonblk)
 	tx->tx_lnetmsg = NULL;
 	tx->tx_kiov = NULL;
 	tx->tx_nkiov = 0;
-	tx->tx_iov = &tx->tx_hdr;
 	tx->tx_niov = 1;
 	tx->tx_nonblk = nonblk;
 
@@ -108,16 +107,16 @@ ksocknal_free_tx(struct ksock_tx *tx)
 }
 
 static int
-ksocknal_send_iov(struct ksock_conn *conn, struct ksock_tx *tx)
+ksocknal_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx)
 {
-	struct kvec *iov = tx->tx_iov;
+	struct kvec *iov = &tx->tx_hdr;
 	int nob;
 	int rc;
 
 	LASSERT(tx->tx_niov > 0);
 
-	/* Never touch tx->tx_iov inside ksocknal_lib_send_iov() */
-	rc = ksocknal_lib_send_iov(conn, tx);
+	/* Never change tx->tx_hdr inside ksocknal_lib_send_hdr() */
+	rc = ksocknal_lib_send_hdr(conn, tx);
 
 	if (rc <= 0)			    /* sent nothing? */
 		return rc;
@@ -127,19 +126,17 @@ ksocknal_send_iov(struct ksock_conn *conn, struct ksock_tx *tx)
 	tx->tx_resid -= nob;
 
 	/* "consume" iov */
-	do {
-		LASSERT(tx->tx_niov > 0);
 
-		if (nob < (int)iov->iov_len) {
-			iov->iov_base = (void *)((char *)iov->iov_base + nob);
-			iov->iov_len -= nob;
-			return rc;
-		}
+	LASSERT(tx->tx_niov == 1);
 
-		nob -= iov->iov_len;
-		tx->tx_iov = ++iov;
-		tx->tx_niov--;
-	} while (nob);
+	if (nob < (int)iov->iov_len) {
+		iov->iov_base = (void *)((char *)iov->iov_base + nob);
+		iov->iov_len -= nob;
+		return rc;
+	}
+
+	LASSERT(nob == iov->iov_len);
+	tx->tx_niov--;
 
 	return rc;
 }
@@ -206,7 +203,7 @@ ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx)
 			ksocknal_data.ksnd_enomem_tx--;
 			rc = -EAGAIN;
 		} else if (tx->tx_niov) {
-			rc = ksocknal_send_iov(conn, tx);
+			rc = ksocknal_send_hdr(conn, tx);
 		} else {
 			rc = ksocknal_send_kiov(conn, tx);
 		}
@@ -648,7 +645,7 @@ ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
 	 * We always expect at least 1 mapped fragment containing the
 	 * complete ksocknal message header.
 	 */
-	LASSERT(lnet_iov_nob(tx->tx_niov, tx->tx_iov) +
+	LASSERT(lnet_iov_nob(tx->tx_niov, &tx->tx_hdr) +
 		lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) ==
 		(unsigned int)tx->tx_nob);
 	LASSERT(tx->tx_niov >= 1);
@@ -903,7 +900,6 @@ ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 	tx->tx_lnetmsg = lntmsg;
 
 	tx->tx_niov = 1;
-	tx->tx_iov = &tx->tx_hdr;
 	tx->tx_kiov = tx->tx_payload;
 	tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
 					 payload_niov, payload_kiov,
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
index a190869eb5b2..a4dc384c298e 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
@@ -73,11 +73,11 @@ ksocknal_lib_zc_capable(struct ksock_conn *conn)
 }
 
 int
-ksocknal_lib_send_iov(struct ksock_conn *conn, struct ksock_tx *tx)
+ksocknal_lib_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx)
 {
 	struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
 	struct socket *sock = conn->ksnc_sock;
-	int nob, i;
+	int nob;
 
 	if (*ksocknal_tunables.ksnd_enable_csum	&&		/* checksum enabled */
 	    conn->ksnc_proto == &ksocknal_protocol_v2x &&	/* V2.x connection */
@@ -85,15 +85,15 @@ ksocknal_lib_send_iov(struct ksock_conn *conn, struct ksock_tx *tx)
 	    !tx->tx_msg.ksm_csum)				/* not checksummed */
 		ksocknal_lib_csum_tx(tx);
 
-	for (nob = i = 0; i < tx->tx_niov; i++)
-		nob += tx->tx_iov[i].iov_len;
+	if (tx->tx_niov)
+		nob += tx->tx_hdr.iov_len;
 
 	if (!list_empty(&conn->ksnc_tx_queue) ||
 	    nob < tx->tx_resid)
 		msg.msg_flags |= MSG_MORE;
 
 	iov_iter_kvec(&msg.msg_iter, WRITE,
-		      tx->tx_iov, tx->tx_niov, nob);
+		      &tx->tx_hdr, tx->tx_niov, nob);
 	return sock_sendmsg(sock, &msg);
 }
 
@@ -208,14 +208,14 @@ ksocknal_lib_csum_tx(struct ksock_tx *tx)
 	u32 csum;
 	void *base;
 
-	LASSERT(tx->tx_iov[0].iov_base == &tx->tx_msg);
+	LASSERT(tx->tx_hdr.iov_base == &tx->tx_msg);
 	LASSERT(tx->tx_conn);
 	LASSERT(tx->tx_conn->ksnc_proto == &ksocknal_protocol_v2x);
 
 	tx->tx_msg.ksm_csum = 0;
 
-	csum = crc32_le(~0, tx->tx_iov[0].iov_base,
-			tx->tx_iov[0].iov_len);
+	csum = crc32_le(~0, tx->tx_hdr.iov_base,
+			tx->tx_hdr.iov_len);
 
 	if (tx->tx_kiov) {
 		for (i = 0; i < tx->tx_nkiov; i++) {
@@ -226,10 +226,6 @@ ksocknal_lib_csum_tx(struct ksock_tx *tx)
 
 			kunmap(tx->tx_kiov[i].bv_page);
 		}
-	} else {
-		for (i = 1; i < tx->tx_niov; i++)
-			csum = crc32_le(csum, tx->tx_iov[i].iov_base,
-					tx->tx_iov[i].iov_len);
 	}
 
 	if (*ksocknal_tunables.ksnd_inject_csum_error) {
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
index fca63763c260..7f32946e922f 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
@@ -721,8 +721,8 @@ ksocknal_pack_msg_v1(struct ksock_tx *tx)
 	LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
 	LASSERT(tx->tx_lnetmsg);
 
-	tx->tx_iov[0].iov_base = &tx->tx_lnetmsg->msg_hdr;
-	tx->tx_iov[0].iov_len = sizeof(struct lnet_hdr);
+	tx->tx_hdr.iov_base = &tx->tx_lnetmsg->msg_hdr;
+	tx->tx_hdr.iov_len = sizeof(struct lnet_hdr);
 
 	tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr);
 	tx->tx_resid = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr);
@@ -731,21 +731,24 @@ ksocknal_pack_msg_v1(struct ksock_tx *tx)
 static void
 ksocknal_pack_msg_v2(struct ksock_tx *tx)
 {
-	tx->tx_iov[0].iov_base = &tx->tx_msg;
+	tx->tx_hdr.iov_base = &tx->tx_msg;
 
 	if (tx->tx_lnetmsg) {
 		LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
 
 		tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
-		tx->tx_iov[0].iov_len = sizeof(struct ksock_msg);
+		tx->tx_hdr.iov_len = sizeof(struct ksock_msg);
 		tx->tx_nob = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
 		tx->tx_resid = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
 	} else {
 		LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
-		tx->tx_iov[0].iov_len = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr);
-		tx->tx_nob = offsetof(struct ksock_msg,  ksm_u.lnetmsg.ksnm_hdr);
-		tx->tx_resid = offsetof(struct ksock_msg,  ksm_u.lnetmsg.ksnm_hdr);
+		tx->tx_hdr.iov_len = offsetof(struct ksock_msg,
+					      ksm_u.lnetmsg.ksnm_hdr);
+		tx->tx_nob = offsetof(struct ksock_msg,
+				      ksm_u.lnetmsg.ksnm_hdr);
+		tx->tx_resid = offsetof(struct ksock_msg,
+					ksm_u.lnetmsg.ksnm_hdr);
 	}
 	/*
 	 * Don't checksum before start sending, because packet can be

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 18/32] lustre: socklnd: don't fall-back to tcp_sendpage.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (16 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 19/32] lustre: socklnd: discard kiblnd_setup_rd_iov NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 20/32] lustre: lnet: discard lnet_kvaddr_to_page NeilBrown
                   ` (13 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

sk_prot->sendpage is never NULL, so there is no
need for a fallback to tcp_sendpage.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/lnet/klnds/socklnd/socklnd_lib.c        |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
index a4dc384c298e..2b5430452a73 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c
@@ -123,12 +123,8 @@ ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx)
 		    fragsize < tx->tx_resid)
 			msgflg |= MSG_MORE;
 
-		if (sk->sk_prot->sendpage) {
-			rc = sk->sk_prot->sendpage(sk, page,
-						   offset, fragsize, msgflg);
-		} else {
-			rc = tcp_sendpage(sk, page, offset, fragsize, msgflg);
-		}
+		rc = sk->sk_prot->sendpage(sk, page,
+					   offset, fragsize, msgflg);
 	} else {
 		struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
 		int i;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 19/32] lustre: socklnd: discard kiblnd_setup_rd_iov
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (15 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 17/32] lustre: socklnd: discard tx_iov NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 18/32] lustre: socklnd: don't fall-back to tcp_sendpage NeilBrown
                   ` (14 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

The 'to' passed to lnd_recv is *always* ITER_BVEC, so
we can discard kiblnd_setup_rd_iov().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |   79 +-------------------
 1 file changed, 4 insertions(+), 75 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 51eb20ed3326..9f6879046b72 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -664,71 +664,6 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	return -EINVAL;
 }
 
-static int
-kiblnd_setup_rd_iov(struct lnet_ni *ni, struct kib_tx *tx,
-		    struct kib_rdma_desc *rd, unsigned int niov,
-		    const struct kvec *iov, int offset, int nob)
-{
-	struct kib_net *net = ni->ni_data;
-	struct page *page;
-	struct scatterlist *sg;
-	unsigned long vaddr;
-	int fragnob;
-	int page_offset;
-
-	LASSERT(nob > 0);
-	LASSERT(niov > 0);
-	LASSERT(net);
-
-	while (offset >= iov->iov_len) {
-		offset -= iov->iov_len;
-		niov--;
-		iov++;
-		LASSERT(niov > 0);
-	}
-
-	sg = tx->tx_frags;
-	do {
-		LASSERT(niov > 0);
-
-		vaddr = ((unsigned long)iov->iov_base) + offset;
-		page_offset = vaddr & (PAGE_SIZE - 1);
-		page = lnet_kvaddr_to_page(vaddr);
-		if (!page) {
-			CERROR("Can't find page\n");
-			return -EFAULT;
-		}
-
-		fragnob = min((int)(iov->iov_len - offset), nob);
-		fragnob = min(fragnob, (int)PAGE_SIZE - page_offset);
-
-		if ((fragnob < (int)PAGE_SIZE - page_offset) && (niov > 1)) {
-			CDEBUG(D_NET,
-			       "fragnob %d < available page %d: with remaining %d iovs\n",
-			       fragnob, (int)PAGE_SIZE - page_offset, niov);
-			tx->tx_gaps = true;
-		}
-
-		sg_set_page(sg, page, fragnob, page_offset);
-		sg = sg_next(sg);
-		if (!sg) {
-			CERROR("lacking enough sg entries to map tx\n");
-			return -EFAULT;
-		}
-
-		if (offset + fragnob < iov->iov_len) {
-			offset += fragnob;
-		} else {
-			offset = 0;
-			iov++;
-			niov--;
-		}
-		nob -= fragnob;
-	} while (nob > 0);
-
-	return kiblnd_map_tx(ni, tx, rd, sg - tx->tx_frags);
-}
-
 static int
 kiblnd_setup_rd_kiov(struct lnet_ni *ni, struct kib_tx *tx,
 		     struct kib_rdma_desc *rd, int nkiov,
@@ -1795,16 +1730,10 @@ kiblnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
 
 		txmsg = tx->tx_msg;
 		rd = &txmsg->ibm_u.putack.ibpam_rd;
-		if (!(to->type & ITER_BVEC))
-			rc = kiblnd_setup_rd_iov(ni, tx, rd,
-						 to->nr_segs, to->kvec,
-						 to->iov_offset,
-						 iov_iter_count(to));
-		else
-			rc = kiblnd_setup_rd_kiov(ni, tx, rd,
-						  to->nr_segs, to->bvec,
-						  to->iov_offset,
-						  iov_iter_count(to));
+		rc = kiblnd_setup_rd_kiov(ni, tx, rd,
+					  to->nr_segs, to->bvec,
+					  to->iov_offset,
+					  iov_iter_count(to));
 		if (rc) {
 			CERROR("Can't setup PUT sink for %s: %d\n",
 			       libcfs_nid2str(conn->ibc_peer->ibp_nid), rc);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 20/32] lustre: lnet: discard lnet_kvaddr_to_page
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (17 preceding siblings ...)
  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 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 16/32] lustre: lnet: simplify ksock_tx NeilBrown
                   ` (12 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This function is no longer used, so discard it.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |    1 -
 drivers/staging/lustre/lnet/lnet/lib-md.c          |    9 ---------
 2 files changed, 10 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index fca1c19a3c84..ca5ce2520c47 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -603,7 +603,6 @@ void lnet_me_unlink(struct lnet_me *me);
 
 void lnet_md_unlink(struct lnet_libmd *md);
 void lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_event *ev);
-struct page *lnet_kvaddr_to_page(unsigned long vaddr);
 int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset);
 
 void lnet_register_lnd(struct lnet_lnd *lnd);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c
index 4c6d14aa2139..c61f0286b21b 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -85,15 +85,6 @@ lnet_md_unlink(struct lnet_libmd *md)
 	kfree(md);
 }
 
-struct page *lnet_kvaddr_to_page(unsigned long vaddr)
-{
-	if (is_vmalloc_addr((void *)vaddr))
-		return vmalloc_to_page((void *)vaddr);
-
-	return kmap_to_page((void *)vaddr);
-}
-EXPORT_SYMBOL(lnet_kvaddr_to_page);
-
 int lnet_cpt_of_md(struct lnet_libmd *md, unsigned int offset)
 {
 	int cpt = CFS_CPT_ANY;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 21/32] lustre: ptlrpc: discard a server-only waitq.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (19 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 16/32] lustre: lnet: simplify ksock_tx NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 25/32] lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args() NeilBrown
                   ` (10 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This is needed on the client.  The server should probably
be used wait_var_event() / wake_up_var().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |    1 -
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index d14840b4aeb0..73d50fe39501 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1209,7 +1209,6 @@ struct ptlrpc_bulk_desc {
 	/** Back pointer to the request */
 	struct ptlrpc_request		*bd_req;
 	const struct ptlrpc_bulk_frag_ops *bd_frag_ops;
-	wait_queue_head_t		bd_waitq;     /* server side only WQ */
 	int				bd_iov_count; /* # entries in bd_iov */
 	int				bd_max_iov;   /* allocated size of bd_iov */
 	int				bd_nob;	      /* # bytes covered */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index a148b1e54712..baf2b05e2f5c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -155,7 +155,6 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
 		goto free_desc;
 
 	spin_lock_init(&desc->bd_lock);
-	init_waitqueue_head(&desc->bd_waitq);
 	desc->bd_max_iov = nfrags;
 	desc->bd_iov_count = 0;
 	desc->bd_portal = portal;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 22/32] lustre: ptlrpc: simplify locking in ptlrpc_add_rqs_to_pool()
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (22 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 27/32] lustre: don't call unshare_fs_struct() NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 28/32] lustre: don't declare extern variables in C files NeilBrown
                   ` (7 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This spinlock is only needed in this function to
protect the list_add_tail(), so make that more
obvious.

This change means that prp_rq_size is set outside of the spinlock, but
as it is only ever read outside of the spinlock, that cannot matter.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ptlrpc/client.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index baf2b05e2f5c..2514a142e799 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -521,13 +521,11 @@ int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
 		 "Trying to change pool size with nonempty pool from %d to %d bytes\n",
 		 pool->prp_rq_size, size);
 
-	spin_lock(&pool->prp_lock);
 	pool->prp_rq_size = size;
 	for (i = 0; i < num_rq; i++) {
 		struct ptlrpc_request *req;
 		struct lustre_msg *msg;
 
-		spin_unlock(&pool->prp_lock);
 		req = ptlrpc_request_cache_alloc(GFP_KERNEL);
 		if (!req)
 			return i;
@@ -541,8 +539,8 @@ int ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
 		req->rq_pool = pool;
 		spin_lock(&pool->prp_lock);
 		list_add_tail(&req->rq_list, &pool->prp_req_list);
+		spin_unlock(&pool->prp_lock);
 	}
-	spin_unlock(&pool->prp_lock);
 	return num_rq;
 }
 EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 23/32] lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (25 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 24/32] lustre: ptlrpc: discard cb_list and ptlrpc_set_cbdata; NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-04-03 20:26   ` Andreas Dilger
  2019-03-14  0:11 ` [lustre-devel] [PATCH 26/32] lustre: ptlrpc: don't use list_for_each_entry_safe unnecessarily NeilBrown
                   ` (4 subsequent siblings)
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This variable is treated like ant atomic64_t,
so change it's type and simplify the code.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ptlrpc/client.c |   39 ++++++-------------------
 1 file changed, 10 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 2514a142e799..ddf44c854200 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -2999,8 +2999,7 @@ void ptlrpc_abort_set(struct ptlrpc_request_set *set)
 	}
 }
 
-static u64 ptlrpc_last_xid;
-static spinlock_t ptlrpc_last_xid_lock;
+static atomic64_t ptlrpc_last_xid;
 
 /**
  * Initialize the XID for the node.  This is common among all requests on
@@ -3021,19 +3020,20 @@ static spinlock_t ptlrpc_last_xid_lock;
 void ptlrpc_init_xid(void)
 {
 	time64_t now = ktime_get_real_seconds();
+	u64 xid;
 
-	spin_lock_init(&ptlrpc_last_xid_lock);
 	if (now < YEAR_2004) {
-		get_random_bytes(&ptlrpc_last_xid, sizeof(ptlrpc_last_xid));
-		ptlrpc_last_xid >>= 2;
-		ptlrpc_last_xid |= (1ULL << 61);
+		get_random_bytes(&xid, sizeof(xid));
+		xid >>= 2;
+		xid |= (1ULL << 61);
 	} else {
-		ptlrpc_last_xid = (u64)now << 20;
+		xid = (u64)now << 20;
 	}
 
 	/* Always need to be aligned to a power-of-two for multi-bulk BRW */
 	BUILD_BUG_ON(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) != 0);
-	ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK;
+	xid &= PTLRPC_BULK_OPS_MASK;
+	atomic64_set(&ptlrpc_last_xid, xid);
 }
 
 /**
@@ -3050,14 +3050,7 @@ void ptlrpc_init_xid(void)
  */
 u64 ptlrpc_next_xid(void)
 {
-	u64 next;
-
-	spin_lock(&ptlrpc_last_xid_lock);
-	next = ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
-	ptlrpc_last_xid = next;
-	spin_unlock(&ptlrpc_last_xid_lock);
-
-	return next;
+	return atomic64_add_return(PTLRPC_BULK_OPS_COUNT, &ptlrpc_last_xid);
 }
 
 /**
@@ -3131,19 +3124,7 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req)
  */
 u64 ptlrpc_sample_next_xid(void)
 {
-#if BITS_PER_LONG == 32
-	/* need to avoid possible word tearing on 32-bit systems */
-	u64 next;
-
-	spin_lock(&ptlrpc_last_xid_lock);
-	next = ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
-	spin_unlock(&ptlrpc_last_xid_lock);
-
-	return next;
-#else
-	/* No need to lock, since returned value is racy anyways */
-	return ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
-#endif
+	return atomic64_read(&ptlrpc_last_xid) + PTLRPC_BULK_OPS_COUNT;
 }
 EXPORT_SYMBOL(ptlrpc_sample_next_xid);
 

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 24/32] lustre: ptlrpc: discard cb_list and ptlrpc_set_cbdata;
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (24 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 28/32] lustre: don't declare extern variables in C files NeilBrown
@ 2019-03-14  0:11 ` 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
                   ` (5 subsequent siblings)
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This field is never set, and no objects of the struct
are ever created, so both can be discarded.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |   18 ------------------
 drivers/staging/lustre/lustre/ptlrpc/client.c      |   13 -------------
 2 files changed, 31 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index 73d50fe39501..8c61b02a0ae5 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -356,12 +356,6 @@ struct ptlrpc_request_set {
 	wait_queue_head_t	*set_wakeup_ptr;
 	/** List of requests in the set */
 	struct list_head	set_requests;
-	/**
-	 * List of completion callbacks to be called when the set is completed
-	 * This is only used if @set_interpret is NULL.
-	 * Links struct ptlrpc_set_cbdata.
-	 */
-	struct list_head	set_cblist;
 	/** Completion callback, if only one. */
 	set_interpreter_func	set_interpret;
 	/** opaq argument passed to completion @set_interpret callback. */
@@ -386,18 +380,6 @@ struct ptlrpc_request_set {
 	void			*set_producer_arg;
 };
 
-/**
- * Description of a single ptrlrpc_set callback
- */
-struct ptlrpc_set_cbdata {
-	/** List linkage item */
-	struct list_head	psc_item;
-	/** Pointer to interpreting function */
-	set_interpreter_func    psc_interpret;
-	/** Opaq argument to pass to the callback */
-	void			*psc_data;
-};
-
 struct ptlrpc_bulk_desc;
 struct ptlrpc_service_part;
 struct ptlrpc_service;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index ddf44c854200..1ee1ad4ca088 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -932,7 +932,6 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void)
 	atomic_set(&set->set_remaining, 0);
 	spin_lock_init(&set->set_new_req_lock);
 	INIT_LIST_HEAD(&set->set_new_requests);
-	INIT_LIST_HEAD(&set->set_cblist);
 	set->set_max_inflight = UINT_MAX;
 	set->set_producer = NULL;
 	set->set_producer_arg = NULL;
@@ -2297,18 +2296,6 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
 		int (*interpreter)(struct ptlrpc_request_set *set, void *, int) =
 			set->set_interpret;
 		rc = interpreter(set, set->set_arg, rc);
-	} else {
-		struct ptlrpc_set_cbdata *cbdata, *n;
-		int err;
-
-		list_for_each_entry_safe(cbdata, n,
-					 &set->set_cblist, psc_item) {
-			list_del_init(&cbdata->psc_item);
-			err = cbdata->psc_interpret(set, cbdata->psc_data, rc);
-			if (err && !rc)
-				rc = err;
-			kfree(cbdata);
-		}
 	}
 
 	return rc;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 25/32] lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args()
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (20 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 21/32] lustre: ptlrpc: discard a server-only waitq NeilBrown
@ 2019-03-14  0:11 ` 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
                   ` (9 subsequent siblings)
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

Every call to ptlrpc_req_async_args() should be preceded by a
BUILD_BUG_ON(), though two aren't.

To improve maintainability, include the BUILD_BUG_ON into the
ptlrpc_req_async_args() macro.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/lustre_net.h |    7 +++--
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    3 +-
 drivers/staging/lustre/lustre/mdc/mdc_locks.c      |    7 ++---
 drivers/staging/lustre/lustre/osc/osc_io.c         |    3 +-
 drivers/staging/lustre/lustre/osc/osc_request.c    |   29 +++++++-------------
 drivers/staging/lustre/lustre/ptlrpc/client.c      |    6 +---
 drivers/staging/lustre/lustre/ptlrpc/import.c      |    3 +-
 7 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index 8c61b02a0ae5..f1326a0286ba 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -277,8 +277,11 @@
  */
 #define OST_MAXREQSIZE		(16 * 1024)
 
-/* Macro to hide a typecast. */
-#define ptlrpc_req_async_args(req) ((void *)&req->rq_async_args)
+/* Macro to hide a typecast and BUILD_BUG. */
+#define ptlrpc_req_async_args(_var, req) ({				\
+		BUILD_BUG_ON(sizeof(*_var) > sizeof(req->rq_async_args)); \
+		(typeof(_var))&req->rq_async_args;			\
+	})
 
 struct ptlrpc_replay_async_args {
 	int		praa_old_state;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index fbb12f540dbd..a1e86a495076 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1986,8 +1986,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
 	LDLM_DEBUG(lock, "replaying lock:");
 
 	atomic_inc(&req->rq_import->imp_replay_inflight);
-	BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
-	aa = ptlrpc_req_async_args(req);
+	aa = ptlrpc_req_async_args(aa, req);
 	aa->lock_handle = body->lock_handle[0];
 	req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret;
 	ptlrpcd_add_req(req);
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index 430c422ed627..9c3f4e9d7a34 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -48,8 +48,8 @@
 #include "mdc_internal.h"
 
 struct mdc_getattr_args {
-	struct obd_export	   *ga_exp;
-	struct md_enqueue_info      *ga_minfo;
+	struct obd_export	*ga_exp;
+	struct md_enqueue_info	*ga_minfo;
 };
 
 int it_open_error(int phase, struct lookup_intent *it)
@@ -1266,8 +1266,7 @@ int mdc_intent_getattr_async(struct obd_export *exp,
 		return rc;
 	}
 
-	BUILD_BUG_ON(sizeof(*ga) > sizeof(req->rq_async_args));
-	ga = ptlrpc_req_async_args(req);
+	ga = ptlrpc_req_async_args(ga, req);
 	ga->ga_exp = exp;
 	ga->ga_minfo = minfo;
 
diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
index 0b9ed01658e6..efeb94b7dc15 100644
--- a/drivers/staging/lustre/lustre/osc/osc_io.c
+++ b/drivers/staging/lustre/lustre/osc/osc_io.c
@@ -696,8 +696,7 @@ static int osc_io_data_version_start(const struct lu_env *env,
 
 	ptlrpc_request_set_replen(req);
 	req->rq_interpret_reply = osc_data_version_interpret;
-	BUILD_BUG_ON(sizeof(*dva) > sizeof(req->rq_async_args));
-	dva = ptlrpc_req_async_args(req);
+	dva = ptlrpc_req_async_args(dva, req);
 	dva->dva_oio = oio;
 
 	ptlrpcd_add_req(req);
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 88302ff795ae..72437da1d892 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -259,8 +259,7 @@ int osc_setattr_async(struct obd_export *exp, struct obdo *oa,
 		req->rq_interpret_reply =
 			(ptlrpc_interpterer_t)osc_setattr_interpret;
 
-		BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args));
-		sa = ptlrpc_req_async_args(req);
+		sa = ptlrpc_req_async_args(sa, req);
 		sa->sa_oa = oa;
 		sa->sa_upcall = upcall;
 		sa->sa_cookie = cookie;
@@ -344,8 +343,7 @@ int osc_ladvise_base(struct obd_export *exp, struct obdo *oa,
 	}
 
 	req->rq_interpret_reply = osc_ladvise_interpret;
-	BUILD_BUG_ON(sizeof(*la) > sizeof(req->rq_async_args));
-	la = ptlrpc_req_async_args(req);
+	la = ptlrpc_req_async_args(la, req);
 	la->la_oa = oa;
 	la->la_upcall = upcall;
 	la->la_cookie = cookie;
@@ -438,8 +436,7 @@ int osc_punch_base(struct obd_export *exp, struct obdo *oa,
 	ptlrpc_request_set_replen(req);
 
 	req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret;
-	BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args));
-	sa = ptlrpc_req_async_args(req);
+	sa = ptlrpc_req_async_args(sa, req);
 	sa->sa_oa = oa;
 	sa->sa_upcall = upcall;
 	sa->sa_cookie = cookie;
@@ -516,8 +513,7 @@ int osc_sync_base(struct osc_object *obj, struct obdo *oa,
 	ptlrpc_request_set_replen(req);
 	req->rq_interpret_reply = osc_sync_interpret;
 
-	BUILD_BUG_ON(sizeof(*fa) > sizeof(req->rq_async_args));
-	fa = ptlrpc_req_async_args(req);
+	fa = ptlrpc_req_async_args(fa, req);
 	fa->fa_obj = obj;
 	fa->fa_oa = oa;
 	fa->fa_upcall = upcall;
@@ -1302,8 +1298,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
 	}
 	ptlrpc_request_set_replen(req);
 
-	BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
-	aa = ptlrpc_req_async_args(req);
+	aa = ptlrpc_req_async_args(aa, req);
 	aa->aa_oa = oa;
 	aa->aa_requested_nob = requested_nob;
 	aa->aa_nio_count = niocount;
@@ -1650,7 +1645,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
 	new_req->rq_generation_set = 1;
 	new_req->rq_import_generation = request->rq_import_generation;
 
-	new_aa = ptlrpc_req_async_args(new_req);
+	new_aa = ptlrpc_req_async_args(new_aa, new_req);
 
 	INIT_LIST_HEAD(&new_aa->aa_oaps);
 	list_splice_init(&aa->aa_oaps, &new_aa->aa_oaps);
@@ -1973,8 +1968,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
 	cl_req_attr_set(env, osc2cl(obj), crattr);
 	lustre_msg_set_jobid(req->rq_reqmsg, crattr->cra_jobid);
 
-	BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
-	aa = ptlrpc_req_async_args(req);
+	aa = ptlrpc_req_async_args(aa, req);
 	INIT_LIST_HEAD(&aa->aa_oaps);
 	list_splice_init(&rpc_list, &aa->aa_oaps);
 	INIT_LIST_HEAD(&aa->aa_exts);
@@ -2251,8 +2245,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
 		if (!rc) {
 			struct osc_enqueue_args *aa;
 
-			BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
-			aa = ptlrpc_req_async_args(req);
+			aa = ptlrpc_req_async_args(aa, req);
 			aa->oa_exp = exp;
 			aa->oa_mode = einfo->ei_mode;
 			aa->oa_type = einfo->ei_type;
@@ -2405,8 +2398,7 @@ static int osc_statfs_async(struct obd_export *exp,
 	}
 
 	req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_statfs_interpret;
-	BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
-	aa = ptlrpc_req_async_args(req);
+	aa = ptlrpc_req_async_args(aa, req);
 	aa->aa_oi = oinfo;
 
 	ptlrpc_set_add_req(rqset, req);
@@ -2610,8 +2602,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
 		struct osc_brw_async_args *aa;
 		struct obdo *oa;
 
-		BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
-		aa = ptlrpc_req_async_args(req);
+		aa = ptlrpc_req_async_args(aa, req);
 		oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
 		if (!oa) {
 			ptlrpc_req_finished(req);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 1ee1ad4ca088..476435633694 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -2878,8 +2878,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req)
 
 	LASSERT(req->rq_import->imp_state == LUSTRE_IMP_REPLAY);
 
-	LASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
-	aa = ptlrpc_req_async_args(req);
+	aa = ptlrpc_req_async_args(aa, req);
 	memset(aa, 0, sizeof(*aa));
 
 	/* Prepare request to be resent with ptlrpcd */
@@ -3209,8 +3208,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,
 	req->rq_no_resend = 1;
 	req->rq_pill.rc_fmt = (void *)&worker_format;
 
-	BUILD_BUG_ON(sizeof(*args) > sizeof(req->rq_async_args));
-	args = ptlrpc_req_async_args(req);
+	args = ptlrpc_req_async_args(args, req);
 	args->cb = cb;
 	args->cbdata = cbdata;
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index a68b870faad2..db4ed6dbf362 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -690,8 +690,7 @@ int ptlrpc_connect_import(struct obd_import *imp)
 	ptlrpc_request_set_replen(request);
 	request->rq_interpret_reply = ptlrpc_connect_interpret;
 
-	BUILD_BUG_ON(sizeof(*aa) > sizeof(request->rq_async_args));
-	aa = ptlrpc_req_async_args(request);
+	aa = ptlrpc_req_async_args(aa, request);
 	memset(aa, 0, sizeof(*aa));
 
 	aa->pcaa_peer_committed = committed_before_reconnect;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 26/32] lustre: ptlrpc: don't use list_for_each_entry_safe unnecessarily.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (26 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 23/32] lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-03-14  0:11 ` [lustre-devel] [PATCH 30/32] lustre: remove some "#ifdef CONFIG*" from .c files NeilBrown
                   ` (3 subsequent siblings)
  31 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

list_for_each_entry_safe() is only needed if the body of the
loop might change the list, or if it might drop a lock that would
otherwise prevent the list from being changed.

When the body does neither of these, list_for_each_entry() should be
preferred as it makes the behaviour of the loop more clear to readers.

In each of the cases changed there, the list cannot change while the
loop proceeds.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ptlrpc/client.c  |   10 +++++-----
 drivers/staging/lustre/lustre/ptlrpc/import.c  |   14 +++++++-------
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c |    4 ++--
 drivers/staging/lustre/lustre/ptlrpc/recover.c |   14 +++++++-------
 4 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 476435633694..71bb563765cc 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -2916,7 +2916,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req)
  */
 void ptlrpc_abort_inflight(struct obd_import *imp)
 {
-	struct ptlrpc_request *req, *n;
+	struct ptlrpc_request *req;
 
 	/*
 	 * Make sure that no new requests get processed for this import.
@@ -2930,7 +2930,7 @@ void ptlrpc_abort_inflight(struct obd_import *imp)
 	 * locked?  Also, how do we know if the requests on the list are
 	 * being freed at this time?
 	 */
-	list_for_each_entry_safe(req, n, &imp->imp_sending_list, rq_list) {
+	list_for_each_entry(req, &imp->imp_sending_list, rq_list) {
 		DEBUG_REQ(D_RPCTRACE, req, "inflight");
 
 		spin_lock(&req->rq_lock);
@@ -2942,7 +2942,7 @@ void ptlrpc_abort_inflight(struct obd_import *imp)
 		spin_unlock(&req->rq_lock);
 	}
 
-	list_for_each_entry_safe(req, n, &imp->imp_delayed_list, rq_list) {
+	list_for_each_entry(req, &imp->imp_delayed_list, rq_list) {
 		DEBUG_REQ(D_RPCTRACE, req, "aborting waiting req");
 
 		spin_lock(&req->rq_lock);
@@ -2969,9 +2969,9 @@ void ptlrpc_abort_inflight(struct obd_import *imp)
  */
 void ptlrpc_abort_set(struct ptlrpc_request_set *set)
 {
-	struct ptlrpc_request *req, *tmp;
+	struct ptlrpc_request *req;
 
-	list_for_each_entry_safe(req, tmp, &set->set_requests, rq_set_chain) {
+	list_for_each_entry(req, &set->set_requests, rq_set_chain) {
 		spin_lock(&req->rq_lock);
 		if (req->rq_phase != RQ_PHASE_RPC) {
 			spin_unlock(&req->rq_lock);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index db4ed6dbf362..26a976865fbd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -244,11 +244,11 @@ ptlrpc_inflight_deadline(struct ptlrpc_request *req, time64_t now)
 static unsigned int ptlrpc_inflight_timeout(struct obd_import *imp)
 {
 	time64_t now = ktime_get_real_seconds();
-	struct ptlrpc_request *req, *n;
+	struct ptlrpc_request *req;
 	unsigned int timeout = 0;
 
 	spin_lock(&imp->imp_lock);
-	list_for_each_entry_safe(req, n, &imp->imp_sending_list, rq_list)
+	list_for_each_entry(req, &imp->imp_sending_list, rq_list)
 		timeout = max(ptlrpc_inflight_deadline(req, now), timeout);
 
 	spin_unlock(&imp->imp_lock);
@@ -263,7 +263,7 @@ static unsigned int ptlrpc_inflight_timeout(struct obd_import *imp)
  */
 void ptlrpc_invalidate_import(struct obd_import *imp)
 {
-	struct ptlrpc_request *req, *n;
+	struct ptlrpc_request *req;
 	unsigned int timeout;
 	int rc;
 
@@ -335,13 +335,13 @@ void ptlrpc_invalidate_import(struct obd_import *imp)
 				 */
 				rc = 0;
 			} else {
-				list_for_each_entry_safe(req, n,
-							 &imp->imp_sending_list, rq_list) {
+				list_for_each_entry(req, &imp->imp_sending_list,
+						    rq_list) {
 					DEBUG_REQ(D_ERROR, req,
 						  "still on sending list");
 				}
-				list_for_each_entry_safe(req, n,
-							 &imp->imp_delayed_list, rq_list) {
+				list_for_each_entry(req, &imp->imp_delayed_list,
+						    rq_list) {
 					DEBUG_REQ(D_ERROR, req,
 						  "still on delayed list");
 				}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index f0ac2962d64a..c295e9943bf7 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -200,12 +200,12 @@ ptlrpcd_select_pc(struct ptlrpc_request *req)
 static int ptlrpcd_steal_rqset(struct ptlrpc_request_set *des,
 			       struct ptlrpc_request_set *src)
 {
-	struct ptlrpc_request *req, *tmp;
+	struct ptlrpc_request *req;
 	int rc = 0;
 
 	spin_lock(&src->set_new_req_lock);
 	if (likely(!list_empty(&src->set_new_requests))) {
-		list_for_each_entry_safe(req, tmp, &src->set_new_requests, rq_set_chain)
+		list_for_each_entry(req, &src->set_new_requests, rq_set_chain)
 			req->rq_set = des;
 
 		list_splice_init(&src->set_new_requests, &des->set_requests);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c
index af672ab5b212..f33e4c541a17 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/recover.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c
@@ -66,7 +66,7 @@ void ptlrpc_initiate_recovery(struct obd_import *imp)
 int ptlrpc_replay_next(struct obd_import *imp, int *inflight)
 {
 	int rc = 0;
-	struct ptlrpc_request *req = NULL, *pos;
+	struct ptlrpc_request *req = NULL;
 	u64 last_transno;
 
 	*inflight = 0;
@@ -120,8 +120,8 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight)
 	if (!req) {
 		struct ptlrpc_request *tmp;
 
-		list_for_each_entry_safe(tmp, pos, &imp->imp_replay_list,
-					 rq_replay_list) {
+		list_for_each_entry(tmp, &imp->imp_replay_list,
+				    rq_replay_list) {
 			if (tmp->rq_transno > last_transno) {
 				req = tmp;
 				break;
@@ -172,7 +172,7 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight)
  */
 int ptlrpc_resend(struct obd_import *imp)
 {
-	struct ptlrpc_request *req, *next;
+	struct ptlrpc_request *req;
 
 	/* As long as we're in recovery, nothing should be added to the sending
 	 * list, so we don't need to hold the lock during this iteration and
@@ -186,7 +186,7 @@ int ptlrpc_resend(struct obd_import *imp)
 		return -1;
 	}
 
-	list_for_each_entry_safe(req, next, &imp->imp_sending_list, rq_list) {
+	list_for_each_entry(req, &imp->imp_sending_list, rq_list) {
 		LASSERTF((long)req > PAGE_SIZE && req != LP_POISON,
 			 "req %p bad\n", req);
 		LASSERTF(req->rq_type != LI_POISON, "req %p freed\n", req);
@@ -211,10 +211,10 @@ int ptlrpc_resend(struct obd_import *imp)
  */
 void ptlrpc_wake_delayed(struct obd_import *imp)
 {
-	struct ptlrpc_request *req, *pos;
+	struct ptlrpc_request *req;
 
 	spin_lock(&imp->imp_lock);
-	list_for_each_entry_safe(req, pos, &imp->imp_delayed_list, rq_list) {
+	list_for_each_entry(req, &imp->imp_delayed_list, rq_list) {
 		DEBUG_REQ(D_HA, req, "waking (set %p):", req->rq_set);
 		ptlrpc_client_wake_req(req);
 	}

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 27/32] lustre: don't call unshare_fs_struct()
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (21 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 25/32] lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args() NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-04-03 20:30   ` Andreas Dilger
  2019-03-14  0:11 ` [lustre-devel] [PATCH 22/32] lustre: ptlrpc: simplify locking in ptlrpc_add_rqs_to_pool() NeilBrown
                   ` (8 subsequent siblings)
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

A kthread runs with the same fs_struct as init.
It is only helpful to unshare this if the thread
will change one of the fields in the fs_struct:
 root directory
 current working directory
 umask.

No lustre kthread changes any of these, so there is
no need to call unshare_fs_struct().

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/obdclass/llog.c  |    3 ---
 drivers/staging/lustre/lustre/ptlrpc/import.c  |    3 ---
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c |    2 --
 drivers/staging/lustre/lustre/ptlrpc/service.c |    4 ----
 4 files changed, 12 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index a34b1a7108b7..ebb6c03ef038 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -45,7 +45,6 @@
 #define DEBUG_SUBSYSTEM S_LOG
 
 #include <linux/kthread.h>
-#include <linux/fs_struct.h>
 #include <llog_swab.h>
 #include <lustre_log.h>
 #include <obd_class.h>
@@ -399,8 +398,6 @@ static int llog_process_thread_daemonize(void *arg)
 	struct lu_env env;
 	int rc;
 
-	unshare_fs_struct();
-
 	/* client env has no keys, tags is just 0 */
 	rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD);
 	if (rc)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 26a976865fbd..b2a57d2bdde7 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -38,7 +38,6 @@
 #define DEBUG_SUBSYSTEM S_RPC
 
 #include <linux/kthread.h>
-#include <linux/fs_struct.h>
 #include <obd_support.h>
 #include <lustre_ha.h>
 #include <lustre_net.h>
@@ -1328,8 +1327,6 @@ static int ptlrpc_invalidate_import_thread(void *data)
 {
 	struct obd_import *imp = data;
 
-	unshare_fs_struct();
-
 	CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n",
 	       imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd),
 	       imp->imp_connection->c_remote_uuid.uuid);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index c295e9943bf7..b02e6c50bae1 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -53,7 +53,6 @@
 #define DEBUG_SUBSYSTEM S_RPC
 
 #include <linux/kthread.h>
-#include <linux/fs_struct.h>
 #include <linux/libcfs/libcfs.h>
 #include <linux/libcfs/libcfs_cpu.h>
 #include <linux/libcfs/libcfs_string.h>
@@ -389,7 +388,6 @@ static int ptlrpcd(void *arg)
 	int rc = 0;
 	int exit = 0;
 
-	unshare_fs_struct();
 	if (cfs_cpt_bind(cfs_cpt_tab, pc->pc_cpt) != 0)
 		CWARN("Failed to bind %s on CPT %d\n", pc->pc_name, pc->pc_cpt);
 
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index c6b95c721167..571f0455e7b0 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -34,7 +34,6 @@
 #define DEBUG_SUBSYSTEM S_RPC
 
 #include <linux/kthread.h>
-#include <linux/fs_struct.h>
 #include <obd_support.h>
 #include <obd_class.h>
 #include <lustre_net.h>
@@ -2029,7 +2028,6 @@ static int ptlrpc_main(void *arg)
 	int counter = 0, rc = 0;
 
 	thread->t_pid = current->pid;
-	unshare_fs_struct();
 
 	/* NB: we will call cfs_cpt_bind() for all threads, because we
 	 * might want to run lustre server only on a subset of system CPUs,
@@ -2230,8 +2228,6 @@ static int ptlrpc_hr_main(void *arg)
 	LIST_HEAD(replies);
 	int rc;
 
-	unshare_fs_struct();
-
 	rc = cfs_cpt_bind(ptlrpc_hr.hr_cpt_table, hrp->hrp_cpt);
 	if (rc != 0) {
 		char threadname[20];

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 28/32] lustre: don't declare extern variables in C files.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (23 preceding siblings ...)
  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 ` 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
                   ` (6 subsequent siblings)
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

'extern' declarations should only appear in .h files.
All these names are declared in .h files as needed,
and these duplicate declarations in .c files can
be removed.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 --
 drivers/staging/lustre/lustre/ptlrpc/import.c      |    1 -
 .../staging/lustre/lustre/ptlrpc/ptlrpc_module.c   |    5 -----
 3 files changed, 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index d79f70d17220..82ec936a6e80 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -681,8 +681,6 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
 }
 EXPORT_SYMBOL(ldlm_namespace_new);
 
-extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
-
 /**
  * Cancel and destroy all locks on a resource.
  *
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index b2a57d2bdde7..a6f15429eda2 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -1558,7 +1558,6 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
 EXPORT_SYMBOL(ptlrpc_disconnect_import);
 
 /* Adaptive Timeout utils */
-extern unsigned int at_min, at_max, at_history;
 
 /*
  *Update at_current with the specified value (bounded by at_min and at_max),
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
index 5c32b657b3b5..76018805f0ce 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
@@ -40,11 +40,6 @@
 
 #include "ptlrpc_internal.h"
 
-extern spinlock_t ptlrpc_last_xid_lock;
-#if RS_DEBUG
-extern spinlock_t ptlrpc_rs_debug_lock;
-#endif
-
 DEFINE_MUTEX(ptlrpc_startup);
 static int ptlrpc_active = 0;
 

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 29/32] lustre: introduce CONFIG_LUSTRE_FS_POSIX_ACL
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (29 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 32/32] lustre: mgc: remove llog_process_lock NeilBrown
@ 2019-03-14  0:11 ` 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
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

Lustre (or any file system) should not conditionally
compile code based on CONFIG_FS_POSIX_ACL.  This config
option enables library support.
A file system can define it's own config option,
which then selects CONFIG_FS_POSIX_ACL (if needed).  It should
act on its own option, not the library one.

This patch makes that change.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/Kconfig              |   11 +++++++++++
 drivers/staging/lustre/lustre/include/lustre_acl.h |    6 +++---
 drivers/staging/lustre/lustre/include/obd.h        |    2 +-
 drivers/staging/lustre/lustre/llite/Makefile       |    2 +-
 .../staging/lustre/lustre/llite/llite_internal.h   |    4 ++--
 drivers/staging/lustre/lustre/llite/llite_lib.c    |   10 +++++-----
 drivers/staging/lustre/lustre/llite/xattr.c        |    4 ++--
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    6 +++---
 8 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig
index ccb78a945995..2ea3f2456b0f 100644
--- a/drivers/staging/lustre/lustre/Kconfig
+++ b/drivers/staging/lustre/lustre/Kconfig
@@ -30,6 +30,17 @@ config LUSTRE_FS
 
 	  See also http://wiki.lustre.org/
 
+config LUSTRE_FS_POSIX_ACL
+	bool "Lustre POSIX Access Control Lists"
+	depends on LUSTRE_FS
+	select FS_POSIX_ACL
+	help
+	  POSIX Access Control Lists (ACLs) support permissions for users and
+	  groups beyond the owner/group/world scheme.
+	  Lustre can support these ACLs.
+
+	  In in doubt, say Y.
+
 config LUSTRE_DEBUG_EXPENSIVE_CHECK
 	bool "Enable Lustre DEBUG checks"
 	depends on LUSTRE_FS
diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h b/drivers/staging/lustre/lustre/include/lustre_acl.h
index e7575a172b5f..e1f373d2e6cb 100644
--- a/drivers/staging/lustre/lustre/include/lustre_acl.h
+++ b/drivers/staging/lustre/lustre/include/lustre_acl.h
@@ -36,7 +36,7 @@
 
 #include <linux/fs.h>
 #include <linux/dcache.h>
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 #include <linux/posix_acl_xattr.h>
 
 #define LUSTRE_POSIX_ACL_MAX_ENTRIES	32
@@ -44,8 +44,8 @@
 	(sizeof(struct posix_acl_xattr_header) +				\
 	 LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(struct posix_acl_xattr_entry))
 
-#else /* ! CONFIG_FS_POSIX_ACL */
+#else /* ! CONFIG_LUSTRE_FS_POSIX_ACL */
 #define LUSTRE_POSIX_ACL_MAX_SIZE_OLD 0
-#endif /* CONFIG_FS_POSIX_ACL */
+#endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
 
 #endif
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index faf2ea623a09..6c984732d9c2 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -872,7 +872,7 @@ struct lustre_md {
 	struct mdt_body			*body;
 	struct lu_buf			 layout;
 	struct lmv_stripe_md		*lmv;
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 	struct posix_acl		*posix_acl;
 #endif
 	struct mdt_remote_perm		*remote_perm;
diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile
index 7d0225476362..b6698af044f6 100644
--- a/drivers/staging/lustre/lustre/llite/Makefile
+++ b/drivers/staging/lustre/lustre/llite/Makefile
@@ -10,4 +10,4 @@ lustre-y := dcache.o dir.o file.o llite_lib.o llite_nfs.o \
 	    vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o \
 	    lproc_llite.o
 
-lustre-$(CONFIG_FS_POSIX_ACL) += acl.o
+lustre-$(CONFIG_LUSTRE_FS_POSIX_ACL) += acl.o
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index c8860904bdd4..83053459f9c7 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -814,13 +814,13 @@ int ll_release_openhandle(struct inode *inode, struct lookup_intent *it);
 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
+#ifdef CONFIG_LUSTRE_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);
 #else
 #define ll_get_acl NULL
 #define ll_set_acl NULL
-#endif /* CONFIG_FS_POSIX_ACL */
+#endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
 
 int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
 	       const char *name, int namelen);
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index cfe8105fe138..e55a4e0f68bf 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -209,7 +209,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 
 	if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
 		data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 	data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK |
 				   OBD_CONNECT_LARGE_ACL;
 #endif
@@ -512,7 +512,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 	ptlrpc_req_finished(request);
 
 	if (IS_ERR(root)) {
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 		if (lmd.posix_acl) {
 			posix_acl_release(lmd.posix_acl);
 			lmd.posix_acl = NULL;
@@ -1394,7 +1394,7 @@ void ll_clear_inode(struct inode *inode)
 
 	ll_xattr_cache_destroy(inode);
 
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 	forget_all_cached_acls(inode);
 	if (lli->lli_posix_acl) {
 		posix_acl_release(lli->lli_posix_acl);
@@ -1825,7 +1825,7 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md)
 			return rc;
 	}
 
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 	if (body->mbo_valid & OBD_MD_FLACL) {
 		spin_lock(&lli->lli_lock);
 		if (lli->lli_posix_acl)
@@ -2239,7 +2239,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
 					     sbi->ll_flags & LL_SBI_32BIT_API),
 				 &md);
 		if (IS_ERR(*inode)) {
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 			if (md.posix_acl) {
 				posix_acl_release(md.posix_acl);
 				md.posix_acl = NULL;
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index a1d27061ac19..c1f6c38350d7 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -433,7 +433,7 @@ static int ll_xattr_get_common(const struct xattr_handler *handler,
 	    !strcmp(name, "selinux"))
 		return -EOPNOTSUPP;
 
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 	/* posix acl is under protection of LOOKUP lock. when calling to this,
 	 * we just have path resolution to the target inode, so we have great
 	 * chance that cached ACL is uptodate.
@@ -676,7 +676,7 @@ const struct xattr_handler *ll_xattr_handlers[] = {
 	&ll_user_xattr_handler,
 	&ll_trusted_xattr_handler,
 	&ll_security_xattr_handler,
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 	&ll_acl_access_xattr_handler,
 	&ll_acl_default_xattr_handler,
 #endif
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 451e6c94c7e8..b54c5f1418ae 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -408,7 +408,7 @@ static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
 				req);
 }
 
-#ifdef CONFIG_FS_POSIX_ACL
+#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;
@@ -535,7 +535,7 @@ static int mdc_get_lustre_md(struct obd_export *exp,
 			rc = mdc_unpack_acl(req, md);
 			if (rc)
 				goto out;
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 		} else {
 			md->posix_acl = NULL;
 #endif
@@ -544,7 +544,7 @@ static int mdc_get_lustre_md(struct obd_export *exp,
 
 out:
 	if (rc) {
-#ifdef CONFIG_FS_POSIX_ACL
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 		posix_acl_release(md->posix_acl);
 #endif
 	}

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 30/32] lustre: remove some "#ifdef CONFIG*" from .c files.
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (27 preceding siblings ...)
  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 ` 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
                   ` (2 subsequent siblings)
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

It is Linux policy to avoid #ifdef in C files where
convenient - .h files are OK.

This patch defines a few inline functions which differ
depending on CONFIG_LUSTRE_FS_POSIX_ACL, and removes
some #ifdefs from .c files.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/include/obd.h        |   21 +++++++++++
 .../staging/lustre/lustre/llite/llite_internal.h   |   29 +++++++++++++++
 drivers/staging/lustre/lustre/llite/llite_lib.c    |   39 ++++----------------
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |    8 ++--
 4 files changed, 61 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 6c984732d9c2..354f7d64e08a 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -37,6 +37,8 @@
 #include <linux/kobject.h>
 #include <linux/spinlock.h>
 #include <linux/sysfs.h>
+#include <linux/fs.h>
+#include <linux/posix_acl.h>
 
 #include <uapi/linux/lustre/lustre_idl.h>
 #include <lustre_lib.h>
@@ -878,6 +880,25 @@ struct lustre_md {
 	struct mdt_remote_perm		*remote_perm;
 };
 
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
+static inline void lmd_clear_acl(struct lustre_md *md)
+{
+	if (md->posix_acl) {
+		posix_acl_release(md->posix_acl);
+		md->posix_acl = NULL;
+	}
+}
+
+#define OBD_CONNECT_ACL_FLAGS	\
+	(OBD_CONNECT_ACL | OBD_CONNECT_UMASK | OBD_CONNECT_LARGE_ACL)
+#else
+static inline void lmd_clear_acl(struct lustre_md *md)
+{
+}
+
+#define OBD_CONNECT_ACL_FLAGS	(0)
+#endif
+
 struct md_open_data {
 	struct obd_client_handle	*mod_och;
 	struct ptlrpc_request		*mod_open_req;
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 83053459f9c7..95ec46779c41 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -246,6 +246,35 @@ struct ll_inode_info {
 	struct list_head		lli_xattrs;/* ll_xattr_entry->xe_list */
 };
 
+#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
+static inline void lli_clear_acl(struct ll_inode_info *lli)
+{
+	if (lli->lli_posix_acl) {
+		posix_acl_release(lli->lli_posix_acl);
+		lli->lli_posix_acl = NULL;
+	}
+}
+
+static inline void lli_replace_acl(struct ll_inode_info *lli,
+				   struct lustre_md *md)
+{
+	spin_lock(&lli->lli_lock);
+	if (lli->lli_posix_acl)
+		posix_acl_release(lli->lli_posix_acl);
+	lli->lli_posix_acl = md->posix_acl;
+	spin_unlock(&lli->lli_lock);
+}
+#else
+static inline void lli_clear_acl(struct ll_inode_info *lli)
+{
+}
+
+static inline void lli_replace_acl(struct ll_inode_info *lli,
+				   struct lustre_md *md)
+{
+}
+#endif
+
 static inline u32 ll_layout_version_get(struct ll_inode_info *lli)
 {
 	u32 gen;
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index e55a4e0f68bf..d4325b49b924 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -209,10 +209,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 
 	if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
 		data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-	data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK |
-				   OBD_CONNECT_LARGE_ACL;
-#endif
+
+	data->ocd_connect_flags |= OBD_CONNECT_ACL_FLAGS;
 
 	if (OBD_FAIL_CHECK(OBD_FAIL_MDC_LIGHTWEIGHT))
 		/* flag mdc connection as lightweight, only used for test
@@ -512,12 +510,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 	ptlrpc_req_finished(request);
 
 	if (IS_ERR(root)) {
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-		if (lmd.posix_acl) {
-			posix_acl_release(lmd.posix_acl);
-			lmd.posix_acl = NULL;
-		}
-#endif
+		lmd_clear_acl(&lmd);
 		err = -EBADF;
 		CERROR("lustre_lite: bad iget4 for root\n");
 		goto out_root;
@@ -1394,13 +1387,8 @@ void ll_clear_inode(struct inode *inode)
 
 	ll_xattr_cache_destroy(inode);
 
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
 	forget_all_cached_acls(inode);
-	if (lli->lli_posix_acl) {
-		posix_acl_release(lli->lli_posix_acl);
-		lli->lli_posix_acl = NULL;
-	}
-#endif
+	lli_clear_acl(lli);
 	lli->lli_inode_magic = LLI_INODE_DEAD;
 
 	if (S_ISDIR(inode->i_mode))
@@ -1825,15 +1813,9 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md)
 			return rc;
 	}
 
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-	if (body->mbo_valid & OBD_MD_FLACL) {
-		spin_lock(&lli->lli_lock);
-		if (lli->lli_posix_acl)
-			posix_acl_release(lli->lli_posix_acl);
-		lli->lli_posix_acl = md->posix_acl;
-		spin_unlock(&lli->lli_lock);
-	}
-#endif
+	if (body->mbo_valid & OBD_MD_FLACL)
+		lli_replace_acl(lli, md);
+
 	inode->i_ino = cl_fid_build_ino(&body->mbo_fid1,
 					sbi->ll_flags & LL_SBI_32BIT_API);
 	inode->i_generation = cl_fid_build_gen(&body->mbo_fid1);
@@ -2239,12 +2221,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
 					     sbi->ll_flags & LL_SBI_32BIT_API),
 				 &md);
 		if (IS_ERR(*inode)) {
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-			if (md.posix_acl) {
-				posix_acl_release(md.posix_acl);
-				md.posix_acl = NULL;
-			}
-#endif
+			lmd_clear_acl(&md);
 			rc = PTR_ERR(*inode);
 			CERROR("new_inode -fatal: rc %d\n", rc);
 			goto out;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index b54c5f1418ae..a0b74244f295 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -543,11 +543,9 @@ static int mdc_get_lustre_md(struct obd_export *exp,
 	}
 
 out:
-	if (rc) {
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-		posix_acl_release(md->posix_acl);
-#endif
-	}
+	if (rc)
+		lmd_clear_acl(md);
+
 	return rc;
 }
 

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 31/32] lustre: mdc: create mdc_acl.c
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (30 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 29/32] lustre: introduce CONFIG_LUSTRE_FS_POSIX_ACL NeilBrown
@ 2019-03-14  0:11 ` NeilBrown
  2019-04-03 20:47   ` Andreas Dilger
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

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>
---
 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)

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 32/32] lustre: mgc: remove llog_process_lock
  2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
                   ` (28 preceding siblings ...)
  2019-03-14  0:11 ` [lustre-devel] [PATCH 30/32] lustre: remove some "#ifdef CONFIG*" from .c files NeilBrown
@ 2019-03-14  0:11 ` 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-03-14  0:11 ` [lustre-devel] [PATCH 31/32] lustre: mdc: create mdc_acl.c NeilBrown
  31 siblings, 1 reply; 44+ messages in thread
From: NeilBrown @ 2019-03-14  0:11 UTC (permalink / raw)
  To: lustre-devel

This mutex is never used, so remove it.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index a805705f357e..b2b20b41ed25 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -383,8 +383,6 @@ config_log_add(struct obd_device *obd, char *logname,
 	return ERR_PTR(rc);
 }
 
-static DEFINE_MUTEX(llog_process_lock);
-
 static inline void config_mark_cld_stop(struct config_llog_data *cld)
 {
 	if (!cld)
@@ -1535,9 +1533,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc,
 	__llog_ctxt_put(env, ctxt);
 
 	/*
-	 * update settings on existing OBDs. doing it inside
-	 * of llog_process_lock so no device is attaching/detaching
-	 * in parallel.
+	 * update settings on existing OBDs.
 	 * the logname must be <fsname>-sptlrpc
 	 */
 	if (sptlrpc_started) {

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 23/32] lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t
  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
  0 siblings, 1 reply; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:26 UTC (permalink / raw)
  To: lustre-devel

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> This variable is treated like ant atomic64_t,
> so change it's type and simplify the code.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

I can't comment on all the LNet changes, but this looks reasonable.

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

> ---
> drivers/staging/lustre/lustre/ptlrpc/client.c |   39 ++++++-------------------
> 1 file changed, 10 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
> index 2514a142e799..ddf44c854200 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/client.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
> @@ -2999,8 +2999,7 @@ void ptlrpc_abort_set(struct ptlrpc_request_set *set)
> 	}
> }
> 
> -static u64 ptlrpc_last_xid;
> -static spinlock_t ptlrpc_last_xid_lock;
> +static atomic64_t ptlrpc_last_xid;
> 
> /**
>  * Initialize the XID for the node.  This is common among all requests on
> @@ -3021,19 +3020,20 @@ static spinlock_t ptlrpc_last_xid_lock;
> void ptlrpc_init_xid(void)
> {
> 	time64_t now = ktime_get_real_seconds();
> +	u64 xid;
> 
> -	spin_lock_init(&ptlrpc_last_xid_lock);
> 	if (now < YEAR_2004) {
> -		get_random_bytes(&ptlrpc_last_xid, sizeof(ptlrpc_last_xid));
> -		ptlrpc_last_xid >>= 2;
> -		ptlrpc_last_xid |= (1ULL << 61);
> +		get_random_bytes(&xid, sizeof(xid));
> +		xid >>= 2;
> +		xid |= (1ULL << 61);
> 	} else {
> -		ptlrpc_last_xid = (u64)now << 20;
> +		xid = (u64)now << 20;
> 	}
> 
> 	/* Always need to be aligned to a power-of-two for multi-bulk BRW */
> 	BUILD_BUG_ON(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) != 0);
> -	ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK;
> +	xid &= PTLRPC_BULK_OPS_MASK;
> +	atomic64_set(&ptlrpc_last_xid, xid);
> }
> 
> /**
> @@ -3050,14 +3050,7 @@ void ptlrpc_init_xid(void)
>  */
> u64 ptlrpc_next_xid(void)
> {
> -	u64 next;
> -
> -	spin_lock(&ptlrpc_last_xid_lock);
> -	next = ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
> -	ptlrpc_last_xid = next;
> -	spin_unlock(&ptlrpc_last_xid_lock);
> -
> -	return next;
> +	return atomic64_add_return(PTLRPC_BULK_OPS_COUNT, &ptlrpc_last_xid);
> }
> 
> /**
> @@ -3131,19 +3124,7 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req)
>  */
> u64 ptlrpc_sample_next_xid(void)
> {
> -#if BITS_PER_LONG == 32
> -	/* need to avoid possible word tearing on 32-bit systems */
> -	u64 next;
> -
> -	spin_lock(&ptlrpc_last_xid_lock);
> -	next = ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
> -	spin_unlock(&ptlrpc_last_xid_lock);
> -
> -	return next;
> -#else
> -	/* No need to lock, since returned value is racy anyways */
> -	return ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
> -#endif
> +	return atomic64_read(&ptlrpc_last_xid) + PTLRPC_BULK_OPS_COUNT;
> }
> EXPORT_SYMBOL(ptlrpc_sample_next_xid);
> 
> 
> 

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

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 27/32] lustre: don't call unshare_fs_struct()
  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
  0 siblings, 1 reply; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:30 UTC (permalink / raw)
  To: lustre-devel

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> A kthread runs with the same fs_struct as init.
> It is only helpful to unshare this if the thread
> will change one of the fields in the fs_struct:
> root directory
> current working directory
> umask.
> 
> No lustre kthread changes any of these, so there is
> no need to call unshare_fs_struct().
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

I recall one of the issues ages ago is that when the kthreads are
started in the context of "mount" that they would use the same
CWD as the mount process, which may be undesirable (e.g. it will
prevent unmounting that filesystem).

It is entirely possible that things have changed since this was
written, but worthwhile to mention.

> ---
> drivers/staging/lustre/lustre/obdclass/llog.c  |    3 ---
> drivers/staging/lustre/lustre/ptlrpc/import.c  |    3 ---
> drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c |    2 --
> drivers/staging/lustre/lustre/ptlrpc/service.c |    4 ----
> 4 files changed, 12 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
> index a34b1a7108b7..ebb6c03ef038 100644
> --- a/drivers/staging/lustre/lustre/obdclass/llog.c
> +++ b/drivers/staging/lustre/lustre/obdclass/llog.c
> @@ -45,7 +45,6 @@
> #define DEBUG_SUBSYSTEM S_LOG
> 
> #include <linux/kthread.h>
> -#include <linux/fs_struct.h>
> #include <llog_swab.h>
> #include <lustre_log.h>
> #include <obd_class.h>
> @@ -399,8 +398,6 @@ static int llog_process_thread_daemonize(void *arg)
> 	struct lu_env env;
> 	int rc;
> 
> -	unshare_fs_struct();
> -
> 	/* client env has no keys, tags is just 0 */
> 	rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD);
> 	if (rc)
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index 26a976865fbd..b2a57d2bdde7 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -38,7 +38,6 @@
> #define DEBUG_SUBSYSTEM S_RPC
> 
> #include <linux/kthread.h>
> -#include <linux/fs_struct.h>
> #include <obd_support.h>
> #include <lustre_ha.h>
> #include <lustre_net.h>
> @@ -1328,8 +1327,6 @@ static int ptlrpc_invalidate_import_thread(void *data)
> {
> 	struct obd_import *imp = data;
> 
> -	unshare_fs_struct();
> -
> 	CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n",
> 	       imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd),
> 	       imp->imp_connection->c_remote_uuid.uuid);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
> index c295e9943bf7..b02e6c50bae1 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
> @@ -53,7 +53,6 @@
> #define DEBUG_SUBSYSTEM S_RPC
> 
> #include <linux/kthread.h>
> -#include <linux/fs_struct.h>
> #include <linux/libcfs/libcfs.h>
> #include <linux/libcfs/libcfs_cpu.h>
> #include <linux/libcfs/libcfs_string.h>
> @@ -389,7 +388,6 @@ static int ptlrpcd(void *arg)
> 	int rc = 0;
> 	int exit = 0;
> 
> -	unshare_fs_struct();
> 	if (cfs_cpt_bind(cfs_cpt_tab, pc->pc_cpt) != 0)
> 		CWARN("Failed to bind %s on CPT %d\n", pc->pc_name, pc->pc_cpt);
> 
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
> index c6b95c721167..571f0455e7b0 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
> @@ -34,7 +34,6 @@
> #define DEBUG_SUBSYSTEM S_RPC
> 
> #include <linux/kthread.h>
> -#include <linux/fs_struct.h>
> #include <obd_support.h>
> #include <obd_class.h>
> #include <lustre_net.h>
> @@ -2029,7 +2028,6 @@ static int ptlrpc_main(void *arg)
> 	int counter = 0, rc = 0;
> 
> 	thread->t_pid = current->pid;
> -	unshare_fs_struct();
> 
> 	/* NB: we will call cfs_cpt_bind() for all threads, because we
> 	 * might want to run lustre server only on a subset of system CPUs,
> @@ -2230,8 +2228,6 @@ static int ptlrpc_hr_main(void *arg)
> 	LIST_HEAD(replies);
> 	int rc;
> 
> -	unshare_fs_struct();
> -
> 	rc = cfs_cpt_bind(ptlrpc_hr.hr_cpt_table, hrp->hrp_cpt);
> 	if (rc != 0) {
> 		char threadname[20];
> 
> 

Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 28/32] lustre: don't declare extern variables in C files.
  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
  0 siblings, 0 replies; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:43 UTC (permalink / raw)
  To: lustre-devel

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> 'extern' declarations should only appear in .h files.
> All these names are declared in .h files as needed,
> and these duplicate declarations in .c files can
> be removed.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Totally agree on this.  It can be a source of hard-to-find bugs.

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


> ---
> drivers/staging/lustre/lustre/ldlm/ldlm_resource.c |    2 --
> drivers/staging/lustre/lustre/ptlrpc/import.c      |    1 -
> .../staging/lustre/lustre/ptlrpc/ptlrpc_module.c   |    5 -----
> 3 files changed, 8 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> index d79f70d17220..82ec936a6e80 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
> @@ -681,8 +681,6 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
> }
> EXPORT_SYMBOL(ldlm_namespace_new);
> 
> -extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);
> -
> /**
>  * Cancel and destroy all locks on a resource.
>  *
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index b2a57d2bdde7..a6f15429eda2 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -1558,7 +1558,6 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
> EXPORT_SYMBOL(ptlrpc_disconnect_import);
> 
> /* Adaptive Timeout utils */
> -extern unsigned int at_min, at_max, at_history;
> 
> /*
>  *Update at_current with the specified value (bounded by at_min and at_max),
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
> index 5c32b657b3b5..76018805f0ce 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c
> @@ -40,11 +40,6 @@
> 
> #include "ptlrpc_internal.h"
> 
> -extern spinlock_t ptlrpc_last_xid_lock;
> -#if RS_DEBUG
> -extern spinlock_t ptlrpc_rs_debug_lock;
> -#endif
> -
> DEFINE_MUTEX(ptlrpc_startup);
> static int ptlrpc_active = 0;
> 
> 
> 

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

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 29/32] lustre: introduce CONFIG_LUSTRE_FS_POSIX_ACL
  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
  0 siblings, 0 replies; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:44 UTC (permalink / raw)
  To: lustre-devel

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> Lustre (or any file system) should not conditionally
> compile code based on CONFIG_FS_POSIX_ACL.  This config
> option enables library support.
> A file system can define it's own config option,
> which then selects CONFIG_FS_POSIX_ACL (if needed).  It should
> act on its own option, not the library one.
> 
> This patch makes that change.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

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

> ---
> drivers/staging/lustre/lustre/Kconfig              |   11 +++++++++++
> drivers/staging/lustre/lustre/include/lustre_acl.h |    6 +++---
> drivers/staging/lustre/lustre/include/obd.h        |    2 +-
> drivers/staging/lustre/lustre/llite/Makefile       |    2 +-
> .../staging/lustre/lustre/llite/llite_internal.h   |    4 ++--
> drivers/staging/lustre/lustre/llite/llite_lib.c    |   10 +++++-----
> drivers/staging/lustre/lustre/llite/xattr.c        |    4 ++--
> drivers/staging/lustre/lustre/mdc/mdc_request.c    |    6 +++---
> 8 files changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig
> index ccb78a945995..2ea3f2456b0f 100644
> --- a/drivers/staging/lustre/lustre/Kconfig
> +++ b/drivers/staging/lustre/lustre/Kconfig
> @@ -30,6 +30,17 @@ config LUSTRE_FS
> 
> 	  See also http://wiki.lustre.org/
> 
> +config LUSTRE_FS_POSIX_ACL
> +	bool "Lustre POSIX Access Control Lists"
> +	depends on LUSTRE_FS
> +	select FS_POSIX_ACL
> +	help
> +	  POSIX Access Control Lists (ACLs) support permissions for users and
> +	  groups beyond the owner/group/world scheme.
> +	  Lustre can support these ACLs.
> +
> +	  In in doubt, say Y.
> +
> config LUSTRE_DEBUG_EXPENSIVE_CHECK
> 	bool "Enable Lustre DEBUG checks"
> 	depends on LUSTRE_FS
> diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h b/drivers/staging/lustre/lustre/include/lustre_acl.h
> index e7575a172b5f..e1f373d2e6cb 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_acl.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_acl.h
> @@ -36,7 +36,7 @@
> 
> #include <linux/fs.h>
> #include <linux/dcache.h>
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> #include <linux/posix_acl_xattr.h>
> 
> #define LUSTRE_POSIX_ACL_MAX_ENTRIES	32
> @@ -44,8 +44,8 @@
> 	(sizeof(struct posix_acl_xattr_header) +				\
> 	 LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(struct posix_acl_xattr_entry))
> 
> -#else /* ! CONFIG_FS_POSIX_ACL */
> +#else /* ! CONFIG_LUSTRE_FS_POSIX_ACL */
> #define LUSTRE_POSIX_ACL_MAX_SIZE_OLD 0
> -#endif /* CONFIG_FS_POSIX_ACL */
> +#endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
> 
> #endif
> diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
> index faf2ea623a09..6c984732d9c2 100644
> --- a/drivers/staging/lustre/lustre/include/obd.h
> +++ b/drivers/staging/lustre/lustre/include/obd.h
> @@ -872,7 +872,7 @@ struct lustre_md {
> 	struct mdt_body			*body;
> 	struct lu_buf			 layout;
> 	struct lmv_stripe_md		*lmv;
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 	struct posix_acl		*posix_acl;
> #endif
> 	struct mdt_remote_perm		*remote_perm;
> diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile
> index 7d0225476362..b6698af044f6 100644
> --- a/drivers/staging/lustre/lustre/llite/Makefile
> +++ b/drivers/staging/lustre/lustre/llite/Makefile
> @@ -10,4 +10,4 @@ lustre-y := dcache.o dir.o file.o llite_lib.o llite_nfs.o \
> 	    vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o \
> 	    lproc_llite.o
> 
> -lustre-$(CONFIG_FS_POSIX_ACL) += acl.o
> +lustre-$(CONFIG_LUSTRE_FS_POSIX_ACL) += acl.o
> diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
> index c8860904bdd4..83053459f9c7 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_internal.h
> +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
> @@ -814,13 +814,13 @@ int ll_release_openhandle(struct inode *inode, struct lookup_intent *it);
> 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
> +#ifdef CONFIG_LUSTRE_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);
> #else
> #define ll_get_acl NULL
> #define ll_set_acl NULL
> -#endif /* CONFIG_FS_POSIX_ACL */
> +#endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
> 
> int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
> 	       const char *name, int namelen);
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index cfe8105fe138..e55a4e0f68bf 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -209,7 +209,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
> 
> 	if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
> 		data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 	data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK |
> 				   OBD_CONNECT_LARGE_ACL;
> #endif
> @@ -512,7 +512,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
> 	ptlrpc_req_finished(request);
> 
> 	if (IS_ERR(root)) {
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 		if (lmd.posix_acl) {
> 			posix_acl_release(lmd.posix_acl);
> 			lmd.posix_acl = NULL;
> @@ -1394,7 +1394,7 @@ void ll_clear_inode(struct inode *inode)
> 
> 	ll_xattr_cache_destroy(inode);
> 
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 	forget_all_cached_acls(inode);
> 	if (lli->lli_posix_acl) {
> 		posix_acl_release(lli->lli_posix_acl);
> @@ -1825,7 +1825,7 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md)
> 			return rc;
> 	}
> 
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 	if (body->mbo_valid & OBD_MD_FLACL) {
> 		spin_lock(&lli->lli_lock);
> 		if (lli->lli_posix_acl)
> @@ -2239,7 +2239,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
> 					     sbi->ll_flags & LL_SBI_32BIT_API),
> 				 &md);
> 		if (IS_ERR(*inode)) {
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 			if (md.posix_acl) {
> 				posix_acl_release(md.posix_acl);
> 				md.posix_acl = NULL;
> diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
> index a1d27061ac19..c1f6c38350d7 100644
> --- a/drivers/staging/lustre/lustre/llite/xattr.c
> +++ b/drivers/staging/lustre/lustre/llite/xattr.c
> @@ -433,7 +433,7 @@ static int ll_xattr_get_common(const struct xattr_handler *handler,
> 	    !strcmp(name, "selinux"))
> 		return -EOPNOTSUPP;
> 
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 	/* posix acl is under protection of LOOKUP lock. when calling to this,
> 	 * we just have path resolution to the target inode, so we have great
> 	 * chance that cached ACL is uptodate.
> @@ -676,7 +676,7 @@ const struct xattr_handler *ll_xattr_handlers[] = {
> 	&ll_user_xattr_handler,
> 	&ll_trusted_xattr_handler,
> 	&ll_security_xattr_handler,
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 	&ll_acl_access_xattr_handler,
> 	&ll_acl_default_xattr_handler,
> #endif
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> index 451e6c94c7e8..b54c5f1418ae 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> @@ -408,7 +408,7 @@ static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
> 				req);
> }
> 
> -#ifdef CONFIG_FS_POSIX_ACL
> +#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;
> @@ -535,7 +535,7 @@ static int mdc_get_lustre_md(struct obd_export *exp,
> 			rc = mdc_unpack_acl(req, md);
> 			if (rc)
> 				goto out;
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 		} else {
> 			md->posix_acl = NULL;
> #endif
> @@ -544,7 +544,7 @@ static int mdc_get_lustre_md(struct obd_export *exp,
> 
> out:
> 	if (rc) {
> -#ifdef CONFIG_FS_POSIX_ACL
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 		posix_acl_release(md->posix_acl);
> #endif
> 	}
> 
> 

Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 30/32] lustre: remove some "#ifdef CONFIG*" from .c files.
  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
  0 siblings, 0 replies; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:45 UTC (permalink / raw)
  To: lustre-devel

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> It is Linux policy to avoid #ifdef in C files where
> convenient - .h files are OK.
> 
> This patch defines a few inline functions which differ
> depending on CONFIG_LUSTRE_FS_POSIX_ACL, and removes
> some #ifdefs from .c files.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

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

> ---
> drivers/staging/lustre/lustre/include/obd.h        |   21 +++++++++++
> .../staging/lustre/lustre/llite/llite_internal.h   |   29 +++++++++++++++
> drivers/staging/lustre/lustre/llite/llite_lib.c    |   39 ++++----------------
> drivers/staging/lustre/lustre/mdc/mdc_request.c    |    8 ++--
> 4 files changed, 61 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
> index 6c984732d9c2..354f7d64e08a 100644
> --- a/drivers/staging/lustre/lustre/include/obd.h
> +++ b/drivers/staging/lustre/lustre/include/obd.h
> @@ -37,6 +37,8 @@
> #include <linux/kobject.h>
> #include <linux/spinlock.h>
> #include <linux/sysfs.h>
> +#include <linux/fs.h>
> +#include <linux/posix_acl.h>
> 
> #include <uapi/linux/lustre/lustre_idl.h>
> #include <lustre_lib.h>
> @@ -878,6 +880,25 @@ struct lustre_md {
> 	struct mdt_remote_perm		*remote_perm;
> };
> 
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> +static inline void lmd_clear_acl(struct lustre_md *md)
> +{
> +	if (md->posix_acl) {
> +		posix_acl_release(md->posix_acl);
> +		md->posix_acl = NULL;
> +	}
> +}
> +
> +#define OBD_CONNECT_ACL_FLAGS	\
> +	(OBD_CONNECT_ACL | OBD_CONNECT_UMASK | OBD_CONNECT_LARGE_ACL)
> +#else
> +static inline void lmd_clear_acl(struct lustre_md *md)
> +{
> +}
> +
> +#define OBD_CONNECT_ACL_FLAGS	(0)
> +#endif
> +
> struct md_open_data {
> 	struct obd_client_handle	*mod_och;
> 	struct ptlrpc_request		*mod_open_req;
> diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
> index 83053459f9c7..95ec46779c41 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_internal.h
> +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
> @@ -246,6 +246,35 @@ struct ll_inode_info {
> 	struct list_head		lli_xattrs;/* ll_xattr_entry->xe_list */
> };
> 
> +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> +static inline void lli_clear_acl(struct ll_inode_info *lli)
> +{
> +	if (lli->lli_posix_acl) {
> +		posix_acl_release(lli->lli_posix_acl);
> +		lli->lli_posix_acl = NULL;
> +	}
> +}
> +
> +static inline void lli_replace_acl(struct ll_inode_info *lli,
> +				   struct lustre_md *md)
> +{
> +	spin_lock(&lli->lli_lock);
> +	if (lli->lli_posix_acl)
> +		posix_acl_release(lli->lli_posix_acl);
> +	lli->lli_posix_acl = md->posix_acl;
> +	spin_unlock(&lli->lli_lock);
> +}
> +#else
> +static inline void lli_clear_acl(struct ll_inode_info *lli)
> +{
> +}
> +
> +static inline void lli_replace_acl(struct ll_inode_info *lli,
> +				   struct lustre_md *md)
> +{
> +}
> +#endif
> +
> static inline u32 ll_layout_version_get(struct ll_inode_info *lli)
> {
> 	u32 gen;
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index e55a4e0f68bf..d4325b49b924 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -209,10 +209,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
> 
> 	if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
> 		data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
> -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> -	data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK |
> -				   OBD_CONNECT_LARGE_ACL;
> -#endif
> +
> +	data->ocd_connect_flags |= OBD_CONNECT_ACL_FLAGS;
> 
> 	if (OBD_FAIL_CHECK(OBD_FAIL_MDC_LIGHTWEIGHT))
> 		/* flag mdc connection as lightweight, only used for test
> @@ -512,12 +510,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
> 	ptlrpc_req_finished(request);
> 
> 	if (IS_ERR(root)) {
> -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> -		if (lmd.posix_acl) {
> -			posix_acl_release(lmd.posix_acl);
> -			lmd.posix_acl = NULL;
> -		}
> -#endif
> +		lmd_clear_acl(&lmd);
> 		err = -EBADF;
> 		CERROR("lustre_lite: bad iget4 for root\n");
> 		goto out_root;
> @@ -1394,13 +1387,8 @@ void ll_clear_inode(struct inode *inode)
> 
> 	ll_xattr_cache_destroy(inode);
> 
> -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> 	forget_all_cached_acls(inode);
> -	if (lli->lli_posix_acl) {
> -		posix_acl_release(lli->lli_posix_acl);
> -		lli->lli_posix_acl = NULL;
> -	}
> -#endif
> +	lli_clear_acl(lli);
> 	lli->lli_inode_magic = LLI_INODE_DEAD;
> 
> 	if (S_ISDIR(inode->i_mode))
> @@ -1825,15 +1813,9 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md)
> 			return rc;
> 	}
> 
> -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> -	if (body->mbo_valid & OBD_MD_FLACL) {
> -		spin_lock(&lli->lli_lock);
> -		if (lli->lli_posix_acl)
> -			posix_acl_release(lli->lli_posix_acl);
> -		lli->lli_posix_acl = md->posix_acl;
> -		spin_unlock(&lli->lli_lock);
> -	}
> -#endif
> +	if (body->mbo_valid & OBD_MD_FLACL)
> +		lli_replace_acl(lli, md);
> +
> 	inode->i_ino = cl_fid_build_ino(&body->mbo_fid1,
> 					sbi->ll_flags & LL_SBI_32BIT_API);
> 	inode->i_generation = cl_fid_build_gen(&body->mbo_fid1);
> @@ -2239,12 +2221,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
> 					     sbi->ll_flags & LL_SBI_32BIT_API),
> 				 &md);
> 		if (IS_ERR(*inode)) {
> -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> -			if (md.posix_acl) {
> -				posix_acl_release(md.posix_acl);
> -				md.posix_acl = NULL;
> -			}
> -#endif
> +			lmd_clear_acl(&md);
> 			rc = PTR_ERR(*inode);
> 			CERROR("new_inode -fatal: rc %d\n", rc);
> 			goto out;
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> index b54c5f1418ae..a0b74244f295 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
> @@ -543,11 +543,9 @@ static int mdc_get_lustre_md(struct obd_export *exp,
> 	}
> 
> out:
> -	if (rc) {
> -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
> -		posix_acl_release(md->posix_acl);
> -#endif
> -	}
> +	if (rc)
> +		lmd_clear_acl(md);
> +
> 	return rc;
> }
> 
> 
> 

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

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 31/32] lustre: mdc: create mdc_acl.c
  2019-03-14  0:11 ` [lustre-devel] [PATCH 31/32] lustre: mdc: create mdc_acl.c NeilBrown
@ 2019-04-03 20:47   ` Andreas Dilger
  0 siblings, 0 replies; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:47 UTC (permalink / raw)
  To: lustre-devel

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

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 32/32] lustre: mgc: remove llog_process_lock
  2019-03-14  0:11 ` [lustre-devel] [PATCH 32/32] lustre: mgc: remove llog_process_lock NeilBrown
@ 2019-04-03 20:47   ` Andreas Dilger
  0 siblings, 0 replies; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:47 UTC (permalink / raw)
  To: lustre-devel

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> This mutex is never used, so remove it.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

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

> ---
> drivers/staging/lustre/lustre/mgc/mgc_request.c |    6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
> index a805705f357e..b2b20b41ed25 100644
> --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
> +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
> @@ -383,8 +383,6 @@ config_log_add(struct obd_device *obd, char *logname,
> 	return ERR_PTR(rc);
> }
> 
> -static DEFINE_MUTEX(llog_process_lock);
> -
> static inline void config_mark_cld_stop(struct config_llog_data *cld)
> {
> 	if (!cld)
> @@ -1535,9 +1533,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc,
> 	__llog_ctxt_put(env, ctxt);
> 
> 	/*
> -	 * update settings on existing OBDs. doing it inside
> -	 * of llog_process_lock so no device is attaching/detaching
> -	 * in parallel.
> +	 * update settings on existing OBDs.
> 	 * the logname must be <fsname>-sptlrpc
> 	 */
> 	if (sptlrpc_started) {
> 
> 

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

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 25/32] lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args()
  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
  0 siblings, 0 replies; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:49 UTC (permalink / raw)
  To: lustre-devel

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> Every call to ptlrpc_req_async_args() should be preceded by a
> BUILD_BUG_ON(), though two aren't.
> 
> To improve maintainability, include the BUILD_BUG_ON into the
> ptlrpc_req_async_args() macro.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

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

> ---
> drivers/staging/lustre/lustre/include/lustre_net.h |    7 +++--
> drivers/staging/lustre/lustre/ldlm/ldlm_request.c  |    3 +-
> drivers/staging/lustre/lustre/mdc/mdc_locks.c      |    7 ++---
> drivers/staging/lustre/lustre/osc/osc_io.c         |    3 +-
> drivers/staging/lustre/lustre/osc/osc_request.c    |   29 +++++++-------------
> drivers/staging/lustre/lustre/ptlrpc/client.c      |    6 +---
> drivers/staging/lustre/lustre/ptlrpc/import.c      |    3 +-
> 7 files changed, 23 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
> index 8c61b02a0ae5..f1326a0286ba 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_net.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_net.h
> @@ -277,8 +277,11 @@
>  */
> #define OST_MAXREQSIZE		(16 * 1024)
> 
> -/* Macro to hide a typecast. */
> -#define ptlrpc_req_async_args(req) ((void *)&req->rq_async_args)
> +/* Macro to hide a typecast and BUILD_BUG. */
> +#define ptlrpc_req_async_args(_var, req) ({				\
> +		BUILD_BUG_ON(sizeof(*_var) > sizeof(req->rq_async_args)); \
> +		(typeof(_var))&req->rq_async_args;			\
> +	})
> 
> struct ptlrpc_replay_async_args {
> 	int		praa_old_state;
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> index fbb12f540dbd..a1e86a495076 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
> @@ -1986,8 +1986,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
> 	LDLM_DEBUG(lock, "replaying lock:");
> 
> 	atomic_inc(&req->rq_import->imp_replay_inflight);
> -	BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
> -	aa = ptlrpc_req_async_args(req);
> +	aa = ptlrpc_req_async_args(aa, req);
> 	aa->lock_handle = body->lock_handle[0];
> 	req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret;
> 	ptlrpcd_add_req(req);
> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
> index 430c422ed627..9c3f4e9d7a34 100644
> --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
> +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
> @@ -48,8 +48,8 @@
> #include "mdc_internal.h"
> 
> struct mdc_getattr_args {
> -	struct obd_export	   *ga_exp;
> -	struct md_enqueue_info      *ga_minfo;
> +	struct obd_export	*ga_exp;
> +	struct md_enqueue_info	*ga_minfo;
> };
> 
> int it_open_error(int phase, struct lookup_intent *it)
> @@ -1266,8 +1266,7 @@ int mdc_intent_getattr_async(struct obd_export *exp,
> 		return rc;
> 	}
> 
> -	BUILD_BUG_ON(sizeof(*ga) > sizeof(req->rq_async_args));
> -	ga = ptlrpc_req_async_args(req);
> +	ga = ptlrpc_req_async_args(ga, req);
> 	ga->ga_exp = exp;
> 	ga->ga_minfo = minfo;
> 
> diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c
> index 0b9ed01658e6..efeb94b7dc15 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_io.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_io.c
> @@ -696,8 +696,7 @@ static int osc_io_data_version_start(const struct lu_env *env,
> 
> 	ptlrpc_request_set_replen(req);
> 	req->rq_interpret_reply = osc_data_version_interpret;
> -	BUILD_BUG_ON(sizeof(*dva) > sizeof(req->rq_async_args));
> -	dva = ptlrpc_req_async_args(req);
> +	dva = ptlrpc_req_async_args(dva, req);
> 	dva->dva_oio = oio;
> 
> 	ptlrpcd_add_req(req);
> diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
> index 88302ff795ae..72437da1d892 100644
> --- a/drivers/staging/lustre/lustre/osc/osc_request.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_request.c
> @@ -259,8 +259,7 @@ int osc_setattr_async(struct obd_export *exp, struct obdo *oa,
> 		req->rq_interpret_reply =
> 			(ptlrpc_interpterer_t)osc_setattr_interpret;
> 
> -		BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args));
> -		sa = ptlrpc_req_async_args(req);
> +		sa = ptlrpc_req_async_args(sa, req);
> 		sa->sa_oa = oa;
> 		sa->sa_upcall = upcall;
> 		sa->sa_cookie = cookie;
> @@ -344,8 +343,7 @@ int osc_ladvise_base(struct obd_export *exp, struct obdo *oa,
> 	}
> 
> 	req->rq_interpret_reply = osc_ladvise_interpret;
> -	BUILD_BUG_ON(sizeof(*la) > sizeof(req->rq_async_args));
> -	la = ptlrpc_req_async_args(req);
> +	la = ptlrpc_req_async_args(la, req);
> 	la->la_oa = oa;
> 	la->la_upcall = upcall;
> 	la->la_cookie = cookie;
> @@ -438,8 +436,7 @@ int osc_punch_base(struct obd_export *exp, struct obdo *oa,
> 	ptlrpc_request_set_replen(req);
> 
> 	req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret;
> -	BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args));
> -	sa = ptlrpc_req_async_args(req);
> +	sa = ptlrpc_req_async_args(sa, req);
> 	sa->sa_oa = oa;
> 	sa->sa_upcall = upcall;
> 	sa->sa_cookie = cookie;
> @@ -516,8 +513,7 @@ int osc_sync_base(struct osc_object *obj, struct obdo *oa,
> 	ptlrpc_request_set_replen(req);
> 	req->rq_interpret_reply = osc_sync_interpret;
> 
> -	BUILD_BUG_ON(sizeof(*fa) > sizeof(req->rq_async_args));
> -	fa = ptlrpc_req_async_args(req);
> +	fa = ptlrpc_req_async_args(fa, req);
> 	fa->fa_obj = obj;
> 	fa->fa_oa = oa;
> 	fa->fa_upcall = upcall;
> @@ -1302,8 +1298,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
> 	}
> 	ptlrpc_request_set_replen(req);
> 
> -	BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
> -	aa = ptlrpc_req_async_args(req);
> +	aa = ptlrpc_req_async_args(aa, req);
> 	aa->aa_oa = oa;
> 	aa->aa_requested_nob = requested_nob;
> 	aa->aa_nio_count = niocount;
> @@ -1650,7 +1645,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
> 	new_req->rq_generation_set = 1;
> 	new_req->rq_import_generation = request->rq_import_generation;
> 
> -	new_aa = ptlrpc_req_async_args(new_req);
> +	new_aa = ptlrpc_req_async_args(new_aa, new_req);
> 
> 	INIT_LIST_HEAD(&new_aa->aa_oaps);
> 	list_splice_init(&aa->aa_oaps, &new_aa->aa_oaps);
> @@ -1973,8 +1968,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
> 	cl_req_attr_set(env, osc2cl(obj), crattr);
> 	lustre_msg_set_jobid(req->rq_reqmsg, crattr->cra_jobid);
> 
> -	BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
> -	aa = ptlrpc_req_async_args(req);
> +	aa = ptlrpc_req_async_args(aa, req);
> 	INIT_LIST_HEAD(&aa->aa_oaps);
> 	list_splice_init(&rpc_list, &aa->aa_oaps);
> 	INIT_LIST_HEAD(&aa->aa_exts);
> @@ -2251,8 +2245,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
> 		if (!rc) {
> 			struct osc_enqueue_args *aa;
> 
> -			BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
> -			aa = ptlrpc_req_async_args(req);
> +			aa = ptlrpc_req_async_args(aa, req);
> 			aa->oa_exp = exp;
> 			aa->oa_mode = einfo->ei_mode;
> 			aa->oa_type = einfo->ei_type;
> @@ -2405,8 +2398,7 @@ static int osc_statfs_async(struct obd_export *exp,
> 	}
> 
> 	req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_statfs_interpret;
> -	BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
> -	aa = ptlrpc_req_async_args(req);
> +	aa = ptlrpc_req_async_args(aa, req);
> 	aa->aa_oi = oinfo;
> 
> 	ptlrpc_set_add_req(rqset, req);
> @@ -2610,8 +2602,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
> 		struct osc_brw_async_args *aa;
> 		struct obdo *oa;
> 
> -		BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args));
> -		aa = ptlrpc_req_async_args(req);
> +		aa = ptlrpc_req_async_args(aa, req);
> 		oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS);
> 		if (!oa) {
> 			ptlrpc_req_finished(req);
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
> index 1ee1ad4ca088..476435633694 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/client.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
> @@ -2878,8 +2878,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req)
> 
> 	LASSERT(req->rq_import->imp_state == LUSTRE_IMP_REPLAY);
> 
> -	LASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
> -	aa = ptlrpc_req_async_args(req);
> +	aa = ptlrpc_req_async_args(aa, req);
> 	memset(aa, 0, sizeof(*aa));
> 
> 	/* Prepare request to be resent with ptlrpcd */
> @@ -3209,8 +3208,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,
> 	req->rq_no_resend = 1;
> 	req->rq_pill.rc_fmt = (void *)&worker_format;
> 
> -	BUILD_BUG_ON(sizeof(*args) > sizeof(req->rq_async_args));
> -	args = ptlrpc_req_async_args(req);
> +	args = ptlrpc_req_async_args(args, req);
> 	args->cb = cb;
> 	args->cbdata = cbdata;
> 
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
> index a68b870faad2..db4ed6dbf362 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
> @@ -690,8 +690,7 @@ int ptlrpc_connect_import(struct obd_import *imp)
> 	ptlrpc_request_set_replen(request);
> 	request->rq_interpret_reply = ptlrpc_connect_interpret;
> 
> -	BUILD_BUG_ON(sizeof(*aa) > sizeof(request->rq_async_args));
> -	aa = ptlrpc_req_async_args(request);
> +	aa = ptlrpc_req_async_args(aa, request);
> 	memset(aa, 0, sizeof(*aa));
> 
> 	aa->pcaa_peer_committed = committed_before_reconnect;
> 
> 

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

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 24/32] lustre: ptlrpc: discard cb_list and ptlrpc_set_cbdata;
  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
  0 siblings, 0 replies; 44+ messages in thread
From: Andreas Dilger @ 2019-04-03 20:53 UTC (permalink / raw)
  To: lustre-devel

On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
> 
> This field is never set, and no objects of the struct
> are ever created, so both can be discarded.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

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

> ---
> drivers/staging/lustre/lustre/include/lustre_net.h |   18 ------------------
> drivers/staging/lustre/lustre/ptlrpc/client.c      |   13 -------------
> 2 files changed, 31 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
> index 73d50fe39501..8c61b02a0ae5 100644
> --- a/drivers/staging/lustre/lustre/include/lustre_net.h
> +++ b/drivers/staging/lustre/lustre/include/lustre_net.h
> @@ -356,12 +356,6 @@ struct ptlrpc_request_set {
> 	wait_queue_head_t	*set_wakeup_ptr;
> 	/** List of requests in the set */
> 	struct list_head	set_requests;
> -	/**
> -	 * List of completion callbacks to be called when the set is completed
> -	 * This is only used if @set_interpret is NULL.
> -	 * Links struct ptlrpc_set_cbdata.
> -	 */
> -	struct list_head	set_cblist;
> 	/** Completion callback, if only one. */
> 	set_interpreter_func	set_interpret;
> 	/** opaq argument passed to completion @set_interpret callback. */
> @@ -386,18 +380,6 @@ struct ptlrpc_request_set {
> 	void			*set_producer_arg;
> };
> 
> -/**
> - * Description of a single ptrlrpc_set callback
> - */
> -struct ptlrpc_set_cbdata {
> -	/** List linkage item */
> -	struct list_head	psc_item;
> -	/** Pointer to interpreting function */
> -	set_interpreter_func    psc_interpret;
> -	/** Opaq argument to pass to the callback */
> -	void			*psc_data;
> -};
> -
> struct ptlrpc_bulk_desc;
> struct ptlrpc_service_part;
> struct ptlrpc_service;
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
> index ddf44c854200..1ee1ad4ca088 100644
> --- a/drivers/staging/lustre/lustre/ptlrpc/client.c
> +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
> @@ -932,7 +932,6 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void)
> 	atomic_set(&set->set_remaining, 0);
> 	spin_lock_init(&set->set_new_req_lock);
> 	INIT_LIST_HEAD(&set->set_new_requests);
> -	INIT_LIST_HEAD(&set->set_cblist);
> 	set->set_max_inflight = UINT_MAX;
> 	set->set_producer = NULL;
> 	set->set_producer_arg = NULL;
> @@ -2297,18 +2296,6 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
> 		int (*interpreter)(struct ptlrpc_request_set *set, void *, int) =
> 			set->set_interpret;
> 		rc = interpreter(set, set->set_arg, rc);
> -	} else {
> -		struct ptlrpc_set_cbdata *cbdata, *n;
> -		int err;
> -
> -		list_for_each_entry_safe(cbdata, n,
> -					 &set->set_cblist, psc_item) {
> -			list_del_init(&cbdata->psc_item);
> -			err = cbdata->psc_interpret(set, cbdata->psc_data, rc);
> -			if (err && !rc)
> -				rc = err;
> -			kfree(cbdata);
> -		}
> 	}
> 
> 	return rc;
> 
> 

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

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 23/32] lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t
  2019-04-03 20:26   ` Andreas Dilger
@ 2019-04-03 23:46     ` NeilBrown
  0 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-04-03 23:46 UTC (permalink / raw)
  To: lustre-devel

On Wed, Apr 03 2019, Andreas Dilger wrote:

> On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
>> 
>> This variable is treated like ant atomic64_t,
>> so change it's type and simplify the code.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> I can't comment on all the LNet changes, but this looks reasonable.

Who should I ask to review the LNet changes?  I have quite a few more
pending (though some I'm not really happy with yet).

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

Thanks,
NeilBrown

>
>> ---
>> drivers/staging/lustre/lustre/ptlrpc/client.c |   39 ++++++-------------------
>> 1 file changed, 10 insertions(+), 29 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
>> index 2514a142e799..ddf44c854200 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/client.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
>> @@ -2999,8 +2999,7 @@ void ptlrpc_abort_set(struct ptlrpc_request_set *set)
>> 	}
>> }
>> 
>> -static u64 ptlrpc_last_xid;
>> -static spinlock_t ptlrpc_last_xid_lock;
>> +static atomic64_t ptlrpc_last_xid;
>> 
>> /**
>>  * Initialize the XID for the node.  This is common among all requests on
>> @@ -3021,19 +3020,20 @@ static spinlock_t ptlrpc_last_xid_lock;
>> void ptlrpc_init_xid(void)
>> {
>> 	time64_t now = ktime_get_real_seconds();
>> +	u64 xid;
>> 
>> -	spin_lock_init(&ptlrpc_last_xid_lock);
>> 	if (now < YEAR_2004) {
>> -		get_random_bytes(&ptlrpc_last_xid, sizeof(ptlrpc_last_xid));
>> -		ptlrpc_last_xid >>= 2;
>> -		ptlrpc_last_xid |= (1ULL << 61);
>> +		get_random_bytes(&xid, sizeof(xid));
>> +		xid >>= 2;
>> +		xid |= (1ULL << 61);
>> 	} else {
>> -		ptlrpc_last_xid = (u64)now << 20;
>> +		xid = (u64)now << 20;
>> 	}
>> 
>> 	/* Always need to be aligned to a power-of-two for multi-bulk BRW */
>> 	BUILD_BUG_ON(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) != 0);
>> -	ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK;
>> +	xid &= PTLRPC_BULK_OPS_MASK;
>> +	atomic64_set(&ptlrpc_last_xid, xid);
>> }
>> 
>> /**
>> @@ -3050,14 +3050,7 @@ void ptlrpc_init_xid(void)
>>  */
>> u64 ptlrpc_next_xid(void)
>> {
>> -	u64 next;
>> -
>> -	spin_lock(&ptlrpc_last_xid_lock);
>> -	next = ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
>> -	ptlrpc_last_xid = next;
>> -	spin_unlock(&ptlrpc_last_xid_lock);
>> -
>> -	return next;
>> +	return atomic64_add_return(PTLRPC_BULK_OPS_COUNT, &ptlrpc_last_xid);
>> }
>> 
>> /**
>> @@ -3131,19 +3124,7 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req)
>>  */
>> u64 ptlrpc_sample_next_xid(void)
>> {
>> -#if BITS_PER_LONG == 32
>> -	/* need to avoid possible word tearing on 32-bit systems */
>> -	u64 next;
>> -
>> -	spin_lock(&ptlrpc_last_xid_lock);
>> -	next = ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
>> -	spin_unlock(&ptlrpc_last_xid_lock);
>> -
>> -	return next;
>> -#else
>> -	/* No need to lock, since returned value is racy anyways */
>> -	return ptlrpc_last_xid + PTLRPC_BULK_OPS_COUNT;
>> -#endif
>> +	return atomic64_read(&ptlrpc_last_xid) + PTLRPC_BULK_OPS_COUNT;
>> }
>> EXPORT_SYMBOL(ptlrpc_sample_next_xid);
>> 
>> 
>> 
>
> Cheers, Andreas
> ---
> Andreas Dilger
> Principal Lustre Architect
> Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190404/737e6bb0/attachment.sig>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [lustre-devel] [PATCH 27/32] lustre: don't call unshare_fs_struct()
  2019-04-03 20:30   ` Andreas Dilger
@ 2019-04-03 23:56     ` NeilBrown
  0 siblings, 0 replies; 44+ messages in thread
From: NeilBrown @ 2019-04-03 23:56 UTC (permalink / raw)
  To: lustre-devel

On Wed, Apr 03 2019, Andreas Dilger wrote:

> On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
>> 
>> A kthread runs with the same fs_struct as init.
>> It is only helpful to unshare this if the thread
>> will change one of the fields in the fs_struct:
>> root directory
>> current working directory
>> umask.
>> 
>> No lustre kthread changes any of these, so there is
>> no need to call unshare_fs_struct().
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> I recall one of the issues ages ago is that when the kthreads are
> started in the context of "mount" that they would use the same
> CWD as the mount process, which may be undesirable (e.g. it will
> prevent unmounting that filesystem).
>
> It is entirely possible that things have changed since this was
> written, but worthwhile to mention.

That sounds familiar .....
We used to have a function "daemonize()" which would disconnect a kernel
thread from anything it had inherited.  That was dropped in 3.8.
New kthreads are always forked from kthreadd, which is pid 2 (on my
desktop).  They cannot inherit anything from the thread that requested
them except what is explicitly passed.

So yes, it used to be as you say (though there were "kthreads" back
then), but it hasn't been that way for a while.

Thanks,
NeilBrown

>
>> ---
>> drivers/staging/lustre/lustre/obdclass/llog.c  |    3 ---
>> drivers/staging/lustre/lustre/ptlrpc/import.c  |    3 ---
>> drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c |    2 --
>> drivers/staging/lustre/lustre/ptlrpc/service.c |    4 ----
>> 4 files changed, 12 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
>> index a34b1a7108b7..ebb6c03ef038 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/llog.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/llog.c
>> @@ -45,7 +45,6 @@
>> #define DEBUG_SUBSYSTEM S_LOG
>> 
>> #include <linux/kthread.h>
>> -#include <linux/fs_struct.h>
>> #include <llog_swab.h>
>> #include <lustre_log.h>
>> #include <obd_class.h>
>> @@ -399,8 +398,6 @@ static int llog_process_thread_daemonize(void *arg)
>> 	struct lu_env env;
>> 	int rc;
>> 
>> -	unshare_fs_struct();
>> -
>> 	/* client env has no keys, tags is just 0 */
>> 	rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD);
>> 	if (rc)
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
>> index 26a976865fbd..b2a57d2bdde7 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
>> @@ -38,7 +38,6 @@
>> #define DEBUG_SUBSYSTEM S_RPC
>> 
>> #include <linux/kthread.h>
>> -#include <linux/fs_struct.h>
>> #include <obd_support.h>
>> #include <lustre_ha.h>
>> #include <lustre_net.h>
>> @@ -1328,8 +1327,6 @@ static int ptlrpc_invalidate_import_thread(void *data)
>> {
>> 	struct obd_import *imp = data;
>> 
>> -	unshare_fs_struct();
>> -
>> 	CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n",
>> 	       imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd),
>> 	       imp->imp_connection->c_remote_uuid.uuid);
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
>> index c295e9943bf7..b02e6c50bae1 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
>> @@ -53,7 +53,6 @@
>> #define DEBUG_SUBSYSTEM S_RPC
>> 
>> #include <linux/kthread.h>
>> -#include <linux/fs_struct.h>
>> #include <linux/libcfs/libcfs.h>
>> #include <linux/libcfs/libcfs_cpu.h>
>> #include <linux/libcfs/libcfs_string.h>
>> @@ -389,7 +388,6 @@ static int ptlrpcd(void *arg)
>> 	int rc = 0;
>> 	int exit = 0;
>> 
>> -	unshare_fs_struct();
>> 	if (cfs_cpt_bind(cfs_cpt_tab, pc->pc_cpt) != 0)
>> 		CWARN("Failed to bind %s on CPT %d\n", pc->pc_name, pc->pc_cpt);
>> 
>> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
>> index c6b95c721167..571f0455e7b0 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
>> @@ -34,7 +34,6 @@
>> #define DEBUG_SUBSYSTEM S_RPC
>> 
>> #include <linux/kthread.h>
>> -#include <linux/fs_struct.h>
>> #include <obd_support.h>
>> #include <obd_class.h>
>> #include <lustre_net.h>
>> @@ -2029,7 +2028,6 @@ static int ptlrpc_main(void *arg)
>> 	int counter = 0, rc = 0;
>> 
>> 	thread->t_pid = current->pid;
>> -	unshare_fs_struct();
>> 
>> 	/* NB: we will call cfs_cpt_bind() for all threads, because we
>> 	 * might want to run lustre server only on a subset of system CPUs,
>> @@ -2230,8 +2228,6 @@ static int ptlrpc_hr_main(void *arg)
>> 	LIST_HEAD(replies);
>> 	int rc;
>> 
>> -	unshare_fs_struct();
>> -
>> 	rc = cfs_cpt_bind(ptlrpc_hr.hr_cpt_table, hrp->hrp_cpt);
>> 	if (rc != 0) {
>> 		char threadname[20];
>> 
>> 
>
> Cheers, Andreas
> ---
> Andreas Dilger
> CTO Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190404/8d50d395/attachment.sig>

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2019-04-03 23:56 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.