Another bunch of lustre patches.
cover Another bunch of lustre patches.
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
PATCH 1/32 lustre: remove outdated comments about ->ap_* functions.
->ap_make_ready, ->ap_completion, ap_refresh count all no longer exist.
So remove these comments.
--- drivers/staging/lustre/lustre/include/obd.h | 9 +-------- drivers/staging/lustre/lustre/osc/osc_internal.h | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/include/obd.h +1 -8
@@ -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.
drivers/staging/lustre/lustre/osc/osc_internal.h +2 -2
@@ -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
PATCH 2/32 lustre: ptlrpc: remove ptlrpc_prep_bulk_frag
In reply to NeilBrownThis function is never used, best to discard it.
--- drivers/staging/lustre/lustre/include/lustre_net.h | 2 -- drivers/staging/lustre/lustre/ptlrpc/client.c | 23 -------------------- 2 files changed, 25 deletions(-)
drivers/staging/lustre/lustre/include/lustre_net.h +0 -2
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/client.c +0 -23
@@ -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 */
PATCH 3/32 lustre: ptlrpc: make ptlrpc_bulk_frag_ops always const.
In reply to NeilBrownThere 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.
--- drivers/staging/lustre/lustre/include/lustre_net.h | 2 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lustre/include/lustre_net.h +1 -1
@@ -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 */
drivers/staging/lustre/lustre/ptlrpc/client.c +1 -1
@@ -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 );/*
PATCH 4/32 lustre: ptlrpc: remove inline on non-inlined functions.
In reply to NeilBrownThese 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.
--- drivers/staging/lustre/lustre/include/lustre_net.h | 21 ------------------- drivers/staging/lustre/lustre/ptlrpc/client.c | 22 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 21 deletions(-)
drivers/staging/lustre/lustre/include/lustre_net.h +0 -21
@@ -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 );
drivers/staging/lustre/lustre/ptlrpc/client.c +22 -0
@@ -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,
PATCH 5/32 lustre: ptlrpc: drop support for KVEC bulk descriptors.
In reply to NeilBrownAll 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.
--- 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(-)
drivers/staging/lustre/lustre/include/lustre_net.h +1 -1
@@ -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;
drivers/staging/lustre/lustre/mdc/mdc_request.c +1 -1
@@ -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) {
drivers/staging/lustre/lustre/mgc/mgc_request.c +1 -1
@@ -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) {
drivers/staging/lustre/lustre/osc/osc_request.c +1 -1
@@ -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) {
drivers/staging/lustre/lustre/ptlrpc/client.c +5 -16
@@ -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 );
PATCH 6/32 lustre: ptlrpc: discard BULK_BUF types
In reply to NeilBrownNow that all BULK bufs are KIOV, we can discard all the tests for this, and discard the flags themselves.
--- 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(-)
drivers/staging/lustre/lustre/include/lustre_net.h +0 -14
@@ -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) |
drivers/staging/lustre/lustre/osc/osc_page.c +0 -2
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/client.c +3 -9
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/pers.c +5 -13
@@ -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); }
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +0 -2
@@ -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 ;
drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +0 -2
@@ -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 ;
PATCH 7/32 lustre: ptlrpc: remove *GET*KIOV macros and fields.
In reply to NeilBrownThe bd_vec and bd_enc_vec fields are no longer used, so discard the fields and macros that access them.
--- drivers/staging/lustre/lustre/include/lustre_net.h | 34 +++++++------------- 1 file changed, 12 insertions(+), 22 deletions(-)
drivers/staging/lustre/lustre/include/lustre_net.h +12 -22
@@ -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 ,
PATCH 8/32 lustre: ptlrpc: simplify bd_vec access.
In reply to NeilBrownNow 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.
--- 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(-)
drivers/staging/lustre/lustre/include/lustre_net.h +5 -12
@@ -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 ,
drivers/staging/lustre/lustre/osc/osc_page.c +1 -1
@@ -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;
drivers/staging/lustre/lustre/ptlrpc/client.c +6 -6
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/pers.c +3 -3
@@ -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]; }
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +8 -8
@@ -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) {
drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +5 -5
@@ -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;
PATCH 9/32 lustre: lnet: discard LNET_MD_PHYS
In reply to NeilBrownThis 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.
--- .../lustre/include/uapi/linux/lnet/lnet-types.h | 3 --- drivers/staging/lustre/lustre/ptlrpc/pers.c | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h +0 -3
@@ -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)
drivers/staging/lustre/lustre/ptlrpc/pers.c +1 -2
@@ -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);
PATCH 10/32 lustre: lnet: discard LNET_MD_IOVEC
In reply to NeilBrownThis flag is never set, so discard it. lnet_md memory descriptors are either a single virtual address, or a list of bvec.
--- .../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(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +1 -1
@@ -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]); }
drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h +2 -11
@@ -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)
drivers/staging/lustre/lnet/lnet/lib-md.c +3 -28
@@ -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 );
drivers/staging/lustre/lustre/ptlrpc/pers.c +1 -1
@@ -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);
PATCH 11/32 lustre: lnet: don't embed whole lnet_md in lnet_event
In reply to NeilBrownOf 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.
--- .../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(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +1 -1
@@ -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);
drivers/staging/lustre/include/uapi/linux/lnet/lnet-types.h +5 -4
@@ -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
drivers/staging/lustre/lnet/lnet/api-ni.c +2 -2
@@ -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);
drivers/staging/lustre/lnet/lnet/lib-md.c +4 -15
@@ -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
drivers/staging/lustre/lnet/lnet/lib-msg.c +2 -2
@@ -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
drivers/staging/lustre/lnet/lnet/peer.c +5 -5
@@ -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); }
drivers/staging/lustre/lnet/lnet/router.c +1 -1
@@ -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);
drivers/staging/lustre/lnet/selftest/rpc.c +3 -2
@@ -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;
drivers/staging/lustre/lustre/ptlrpc/events.c +11 -11
@@ -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. */
PATCH 12/32 lustre: lnet: merge lnet_md_alloc into lnet_md_build.
In reply to NeilBrownlnet_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.
--- .../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(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +0 -26
@@ -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,
drivers/staging/lustre/lnet/lnet/lib-md.c +38 -25
117 lines not on this page · raw message
PATCH 13/32 lustre: lnet: always put a page list into struct lnet_libmd.
In reply to NeilBrown'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.
--- drivers/staging/lustre/lnet/lnet/lib-md.c | 43 ++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 14 deletions(-)
drivers/staging/lustre/lnet/lnet/lib-md.c +29 -14
@@ -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;
PATCH 14/32 lustre: lnet: discard kvec option from lnet_libmd.
In reply to NeilBrownThe '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.
--- .../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(-)
drivers/staging/lustre/include/linux/lnet/lib-types.h +1 -4
@@ -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)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +4 -10
@@ -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);
drivers/staging/lustre/lnet/lnet/lib-md.c +19 -60
120 lines not on this page · raw message
drivers/staging/lustre/lnet/lnet/lib-move.c +1 -4
@@ -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
PATCH 15/32 lustre: lnet: remove msg_iov from lnet_msg.
In reply to NeilBrownThis field is never set, so remove it and remove all uses of it.
--- .../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(-)
drivers/staging/lustre/include/linux/lnet/lib-types.h +0 -1
@@ -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;
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +7 -23
@@ -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);
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +11 -28
@@ -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 ;
drivers/staging/lustre/lnet/lnet/lib-move.c +4 -12
@@ -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);
drivers/staging/lustre/lnet/lnet/lo.c +5 -12
@@ -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 ); }
PATCH 16/32 lustre: lnet: simplify ksock_tx.
In reply to NeilBrownThe 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.
--- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 14 ++++---------- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 ++++---- 2 files changed, 8 insertions(+), 14 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +4 -10
@@ -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 */
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +4 -4
@@ -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);
PATCH 17/32 lustre: socklnd: discard tx_iov.
In reply to NeilBrowntx_iov always points to tx_hdr, so we can discard tx_iov, and just use &tx_hdr.
--- .../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(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +1 -2
@@ -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);
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +15 -19
@@ -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,
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c +8 -12
@@ -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) {
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +10 -7
@@ -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
PATCH 18/32 lustre: socklnd: don't fall-back to tcp_sendpage.
In reply to NeilBrownsk_prot->sendpage is never NULL, so there is no
need for a fallback to tcp_sendpage.
--- .../lustre/lnet/klnds/socklnd/socklnd_lib.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c +2 -6
@@ -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;
PATCH 19/32 lustre: socklnd: discard kiblnd_setup_rd_iov
In reply to NeilBrownThe 'to' passed to lnd_recv is *always* ITER_BVEC, so we can discard kiblnd_setup_rd_iov().
--- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 79 +------------------- 1 file changed, 4 insertions(+), 75 deletions(-)
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +4 -75
@@ -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);
PATCH 20/32 lustre: lnet: discard lnet_kvaddr_to_page
In reply to NeilBrownThis function is no longer used, so discard it.
--- .../staging/lustre/include/linux/lnet/lib-lnet.h | 1 - drivers/staging/lustre/lnet/lnet/lib-md.c | 9 --------- 2 files changed, 10 deletions(-)
drivers/staging/lustre/include/linux/lnet/lib-lnet.h +0 -1
@@ -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);
drivers/staging/lustre/lnet/lnet/lib-md.c +0 -9
@@ -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 ;
PATCH 21/32 lustre: ptlrpc: discard a server-only waitq.
In reply to NeilBrownThis is needed on the client. The server should probably be used wait_var_event() / wake_up_var().
--- drivers/staging/lustre/lustre/include/lustre_net.h | 1 - drivers/staging/lustre/lustre/ptlrpc/client.c | 1 - 2 files changed, 2 deletions(-)
drivers/staging/lustre/lustre/include/lustre_net.h +0 -1
@@ -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 */
drivers/staging/lustre/lustre/ptlrpc/client.c +0 -1
@@ -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;
PATCH 22/32 lustre: ptlrpc: simplify locking in ptlrpc_add_rqs_to_pool()
In reply to NeilBrownThis 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.
--- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/client.c +1 -3
@@ -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);
PATCH 23/32 lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t
In reply to NeilBrownThis variable is treated like ant atomic64_t,
so change it's type and simplify the code.
--- drivers/staging/lustre/lustre/ptlrpc/client.c | 39 ++++++------------------- 1 file changed, 10 insertions(+), 29 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/client.c +10 -29
@@ -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);
PATCH 23/32 lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t
Quoted 5 lines · NeilBrown
This variable is treated like ant
atomic64_t,
so change it's type and simplify the code.Signed-off-by NeilBrown <[email protected]>
I can't comment on all the LNet changes, but this looks reasonable.
Quoted 74 lines
---
drivers/staging/lustre/lustre/ptlrpc/client.c| 39 ++++++-------------------1 file changed, 10 insertions(+), 29 deletions(-)drivers/staging/lustre/lustre/ptlrpc/client.c +9
-23@@ -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);
drivers/staging/lustre/lustre/ptlrpc/client.c void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req) · line 3130
Quoted 10 lines
drivers/staging/lustre/lustre/ptlrpc/client.c +1
-6- -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
PATCH 23/32 lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t
Quoted 8 lines · Andreas Dilger
Quoted 5 lines · NeilBrown
This variable is treated like ant
atomic64_t,
so change it's type and simplify the code.Signed-off-by NeilBrown <[email protected]>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).
Quoted 2 lines
Reviewed-by Andreas Dilger <[email protected]>
Thanks,
NeilBrown
Quoted 83 lines
Quoted 83 lines
---
drivers/staging/lustre/lustre/ptlrpc/client.c| 39 ++++++-------------------1 file changed, 10 insertions(+), 29 deletions(-)drivers/staging/lustre/lustre/ptlrpc/client.c +10
-29@@ -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);
Quoted 8 lines
Quoted 2 lines
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>
PATCH 24/32 lustre: ptlrpc: discard cb_list and ptlrpc_set_cbdata;
In reply to NeilBrownThis field is never set, and no objects of the struct are ever created, so both can be discarded.
--- drivers/staging/lustre/lustre/include/lustre_net.h | 18 ------------------ drivers/staging/lustre/lustre/ptlrpc/client.c | 13 ------------- 2 files changed, 31 deletions(-)
drivers/staging/lustre/lustre/include/lustre_net.h +0 -18
@@ -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 ;
drivers/staging/lustre/lustre/ptlrpc/client.c +0 -13
@@ -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;
PATCH 24/32 lustre: ptlrpc: discard cb_list and ptlrpc_set_cbdata;
Quoted 5 lines · NeilBrown
This field is never set, and no objects of the struct are ever created, so both can be discarded.
Signed-off-by NeilBrown <[email protected]>
Quoted 64 lines
---
drivers/staging/lustre/lustre/include/lustre_net.h | 18 ------------------ drivers/staging/lustre/lustre/ptlrpc/client.c | 13 ------------- 2 files changed, 31 deletions(-)drivers/staging/lustre/lustre/include/lustre_net.h +0
-18@@ -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 ;drivers/staging/lustre/lustre/ptlrpc/client.c +0
-6@@ -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,
drivers/staging/lustre/lustre/ptlrpc/client.c int ptlrpc_set_wait(struct ptlrpc_request_set *set) · line 2301
Quoted 10 lines
drivers/staging/lustre/lustre/ptlrpc/client.c +0
-7- &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
PATCH 25/32 lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args()
In reply to NeilBrownEvery 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.
--- 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(-)
drivers/staging/lustre/lustre/include/lustre_net.h +5 -2
@@ -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;
drivers/staging/lustre/lustre/ldlm/ldlm_request.c +1 -2
@@ -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);
drivers/staging/lustre/lustre/mdc/mdc_locks.c +3 -4
@@ -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;
drivers/staging/lustre/lustre/osc/osc_io.c +1 -2
@@ -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);
drivers/staging/lustre/lustre/osc/osc_request.c +10 -19
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/client.c +2 -4
@@ -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;
drivers/staging/lustre/lustre/ptlrpc/import.c +1 -2
@@ -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;
PATCH 25/32 lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args()
Quoted 8 lines · NeilBrown
Every call to
ptlrpc_req_async_args()should be preceded by aBUILD_BUG_ON(), though two aren't.To improve maintainability, include the
BUILD_BUG_ONinto theptlrpc_req_async_args()macro.Signed-off-by NeilBrown <[email protected]>
Quoted 215 lines
---
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(-)drivers/staging/lustre/lustre/include/lustre_net.h +5
-2@@ -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;drivers/staging/lustre/lustre/ldlm/ldlm_request.c +1
-2@@ -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);drivers/staging/lustre/lustre/mdc/mdc_locks.c +3
-4@@ -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;drivers/staging/lustre/lustre/osc/osc_io.c +1
-2@@ -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);drivers/staging/lustre/lustre/osc/osc_request.c +10
-19@@ -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);drivers/staging/lustre/lustre/ptlrpc/client.c +2
-4@@ -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;drivers/staging/lustre/lustre/ptlrpc/import.c +0
-0
drivers/staging/lustre/lustre/ptlrpc/import.c int ptlrpc_connect_import(struct obd_import *imp) · line 696
Quoted 9 lines
drivers/staging/lustre/lustre/ptlrpc/import.c +1
-2@@ -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
PATCH 26/32 lustre: ptlrpc: don't use list_for_each_entry_safe unnecessarily.
In reply to NeilBrownlist_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.
--- 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(-)
drivers/staging/lustre/lustre/ptlrpc/client.c +5 -5
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/import.c +7 -7
@@ -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" ); }
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +2 -2
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/recover.c +7 -7
@@ -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); }
PATCH 27/32 lustre: don't call unshare_fs_struct()
In reply to NeilBrownA 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().
--- 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(-)
drivers/staging/lustre/lustre/obdclass/llog.c +0 -3
@@ -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)
drivers/staging/lustre/lustre/ptlrpc/import.c +0 -3
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +0 -2
@@ -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);
drivers/staging/lustre/lustre/ptlrpc/service.c +0 -4
@@ -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 ];
PATCH 27/32 lustre: don't call unshare_fs_struct()
Quoted 8 lines · NeilBrown
A kthread runs with the same
fs_structas init.
It is only helpful to unshare this if the thread
will change one of the fields in thefs_struct:
root directory
current working directory
umask.
Quoted 4 lines
No lustre kthread changes any of these, so there is no need to call
unshare_fs_struct().Signed-off-by NeilBrown <[email protected]>
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.
Quoted 92 lines
---
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(-)drivers/staging/lustre/lustre/obdclass/llog.c +0
-3@@ -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)drivers/staging/lustre/lustre/ptlrpc/import.c +0
-3@@ -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);drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +0
-2@@ -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);drivers/staging/lustre/lustre/ptlrpc/service.c +0
-2@@ -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,
drivers/staging/lustre/lustre/ptlrpc/service.c static int ptlrpc_hr_main(void *arg) · line 2233
Quoted 8 lines
drivers/staging/lustre/lustre/ptlrpc/service.c +0
-2@@ -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
PATCH 27/32 lustre: don't call unshare_fs_struct()
Quoted 14 lines · Andreas Dilger
Quoted 8 lines · NeilBrown
A kthread runs with the same
fs_structas init.
It is only helpful to unshare this if the thread
will change one of the fields in thefs_struct:
root directory
current working directory
umask.Quoted 4 lines
No lustre kthread changes any of these, so there is no need to call
unshare_fs_struct().Signed-off-by NeilBrown <[email protected]>
Quoted 7 lines
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
Quoted 94 lines
Quoted 94 lines
---
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(-)drivers/staging/lustre/lustre/obdclass/llog.c +0
-3@@ -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)drivers/staging/lustre/lustre/ptlrpc/import.c +0
-3@@ -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);drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +0
-2@@ -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);drivers/staging/lustre/lustre/ptlrpc/service.c +0
-2@@ -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;
Quoted 12 lines
drivers/staging/lustre/lustre/ptlrpc/service.c static int ptlrpc_hr_main(void *arg) · line 2233
Quoted 7 lines
drivers/staging/lustre/lustre/ptlrpc/service.c +0
-2-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>
PATCH 28/32 lustre: don't declare extern variables in C files.
In reply to NeilBrown'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.
--- 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(-)
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +0 -2
@@ -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. *
drivers/staging/lustre/lustre/ptlrpc/import.c +0 -1
@@ -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),
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +0 -5
@@ -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 ;
PATCH 28/32 lustre: don't declare extern variables in C files.
Quoted 7 lines · NeilBrown
'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 <[email protected]>
Totally agree on this. It can be a source of hard-to-find bugs.
Quoted 39 lines
---
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(-)drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +0
-2@@ -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. * drivers/staging/lustre/lustre/ptlrpc/import.c +0
-1@@ -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), drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +0
-0@@ -40,11 +40,6 @@
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c line 45
Quoted 10 lines
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +0
-5#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
PATCH 29/32 lustre: introduce CONFIG_LUSTRE_FS_POSIX_ACL
In reply to NeilBrownLustre (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.
--- 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(-)
drivers/staging/lustre/lustre/Kconfig +11 -0
@@ -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
drivers/staging/lustre/lustre/include/lustre_acl.h +3 -3
@@ -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
drivers/staging/lustre/lustre/include/obd.h +1 -1
@@ -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;
drivers/staging/lustre/lustre/llite/Makefile +1 -1
@@ -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
drivers/staging/lustre/lustre/llite/llite_internal.h +2 -2
@@ -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);
drivers/staging/lustre/lustre/llite/llite_lib.c +5 -5
@@ -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 ;
drivers/staging/lustre/lustre/llite/xattr.c +2 -2
@@ -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
drivers/staging/lustre/lustre/mdc/mdc_request.c +3 -3
@@ -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 }
PATCH 29/32 lustre: introduce CONFIG_LUSTRE_FS_POSIX_ACL
Quoted 11 lines · NeilBrown
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 selectsCONFIG_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 <[email protected]>
Quoted 199 lines
---
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(-)drivers/staging/lustre/lustre/Kconfig +11
-0@@ -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 onLUSTRE_FSdrivers/staging/lustre/lustre/include/lustre_acl.h +3
-3@@ -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 drivers/staging/lustre/lustre/include/obd.h +1
-1@@ -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;drivers/staging/lustre/lustre/llite/Makefile +1
-1@@ -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.odrivers/staging/lustre/lustre/llite/llite_internal.h +2
-2@@ -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);drivers/staging/lustre/lustre/llite/llite_lib.c +5
-5@@ -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 ;drivers/staging/lustre/lustre/llite/xattr.c +2
-2@@ -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, #endifdrivers/staging/lustre/lustre/mdc/mdc_request.c +2
-2@@ -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) {drivers/staging/lustre/lustre/mdc/mdc_request.c +1
-1-#ifdef CONFIG_FS_POSIX_ACL +#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
Quoted 5 lines
posix_acl_release(md->posix_acl); #endif }
Cheers, Andreas
---
Andreas Dilger
CTO Whamcloud
PATCH 30/32 lustre: remove some "#ifdef CONFIG*" from .c files.
In reply to NeilBrownIt 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.
--- 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(-)
drivers/staging/lustre/lustre/include/obd.h +21 -0
@@ -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;
drivers/staging/lustre/lustre/llite/llite_internal.h +29 -0
@@ -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;
drivers/staging/lustre/lustre/llite/llite_lib.c +8 -31
@@ -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;
drivers/staging/lustre/lustre/mdc/mdc_request.c +3 -5
@@ -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; }
PATCH 30/32 lustre: remove some "#ifdef CONFIG*" from .c files.
Quoted 9 lines · NeilBrown
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 <[email protected]>
Quoted 181 lines
---
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(-)drivers/staging/lustre/lustre/include/obd.h +21
-0@@ -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;drivers/staging/lustre/lustre/llite/llite_internal.h +29
-0@@ -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;drivers/staging/lustre/lustre/llite/llite_lib.c +8
-31@@ -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;drivers/staging/lustre/lustre/mdc/mdc_request.c +0
-0@@ -543,11 +543,9 @@ static int mdc_get_lustre_md(struct obd_export *exp, }out:
drivers/staging/lustre/lustre/mdc/mdc_request.c +3
-5-if (rc) { -#ifdef CONFIG_LUSTRE_FS_POSIX_ACL -posix_acl_release (md->posix_acl); -#endif - } +if (rc) +lmd_clear_acl (md); +
Quoted 5 lines
return rc; }
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 31/32 lustre: mdc: create mdc_acl.c
In reply to NeilBrownThis 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.
--- 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
drivers/staging/lustre/lustre/mdc/Makefile +1 -0
@@ -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
drivers/staging/lustre/lustre/mdc/mdc_acl.c new file +48 -0
48 lines not on this page · raw message
drivers/staging/lustre/lustre/mdc/mdc_internal.h +10 -0
@@ -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)
drivers/staging/lustre/lustre/mdc/mdc_request.c +2 -55
69 lines not on this page · raw message
PATCH 31/32 lustre: mdc: create mdc_acl.c
Quoted 8 lines · NeilBrown
This new C file contains acl related code so it can be conditionally compiled.
The only use of
CONFIG_LUSTRE_FS_POSIX_ACLin a C file is now inxattr.cwhich is not convenient to avoid.Signed-off-by NeilBrown <[email protected]>
Quoted 166 lines
---
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.cdrivers/staging/lustre/lustre/mdc/Makefile +0
-0@@ -3,3 +3,4 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/includeobj-$(CONFIG_LUSTRE_FS) += mdc.o
mdc-y := mdc_changelog.o mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o lproc_mdc.odrivers/staging/lustre/lustre/mdc/Makefile +1
-0+mdc-$(CONFIG_LUSTRE_FS_POSIX_ACL) += mdc_acl.odrivers/staging/lustre/lustre/mdc/mdc_acl.c new file +48
-0@@ -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 ; +}drivers/staging/lustre/lustre/mdc/mdc_internal.h +10
-0@@ -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)drivers/staging/lustre/lustre/mdc/mdc_request.c +2
-55@@ -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:
Quoted 3 lines
if (rc)
Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
PATCH 32/32 lustre: mgc: remove llog_process_lock
In reply to NeilBrownThis mutex is never used, so remove it.
--- drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/staging/lustre/lustre/mgc/mgc_request.c +1 -5
@@ -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) {
PATCH 32/32 lustre: mgc: remove llog_process_lock
Quoted 4 lines · NeilBrown
This mutex is never used, so remove it.
Signed-off-by NeilBrown <[email protected]>
Quoted 20 lines
---
drivers/staging/lustre/lustre/mgc/mgc_request.c| 6 +-----1 file changed, 1 insertion(+), 5 deletions(-)drivers/staging/lustre/lustre/mgc/mgc_request.c +0
-2@@ -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)
drivers/staging/lustre/lustre/mgc/mgc_request.c static int mgc_process_cfg_log(struct obd_device *mgc, · line 1539
Quoted 10 lines
drivers/staging/lustre/lustre/mgc/mgc_request.c +1
-3@@ -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