From: Sergii Glushchenko Date: Tue, 29 Jan 2013 14:19:40 +0000 (+0200) Subject: LU-1431 ptlrpc: PTLRPC_BRW_MAX_SIZE usage cleanup. X-Git-Tag: 2.3.61~57 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=92c24af6c7c9d0836bf866975bc0a1d641a4a815 LU-1431 ptlrpc: PTLRPC_BRW_MAX_SIZE usage cleanup. Clean-up the layering in current code by eliminating direct usage of PTLRPC_BRW_MAX_SIZE macro outside of the ptlrpc module. This should help us acheive "floating" max brw size value across the cluster, which in turn should help with 4MB IO task. Signed-off-by: Sergii Glushchenko Reviewed-by: Alexey Lyashkov Reviewed-by: Alexander Zarochentsev Change-Id: Ib9f6265bd28f25c34b27eb6ad1a56a752b71a4ac Xyratex-bug-id: MRP-687 Reviewed-on: http://review.whamcloud.com/4876 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 309be8a..9094843 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -239,11 +239,10 @@ static int fld_req_handle(struct ptlrpc_request *req, *out = *in; /* For old 2.0 client, the 'lsr_flags' is uninitialized. - * Set it as 'LU_SEQ_RANGE_MDT' by default. - * Old 2.0 liblustre client cannot talk with new 2.1 server. */ - if (!(exp->exp_connect_flags & OBD_CONNECT_64BITHASH) && - !(exp->exp_connect_flags & OBD_CONNECT_MDS_MDS) && - !(exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) && + * Set it as 'LU_SEQ_RANGE_MDT' by default. */ + if (!(exp_connect_flags(exp) & OBD_CONNECT_64BITHASH) && + !(exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS) && + !(exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) && !exp->exp_libclient) out->lsr_flags = LU_SEQ_RANGE_MDT; diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index 686d4e9..d15974e 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -213,7 +213,7 @@ struct obd_statfs { #define LOV_POOLNAMEF "%.16s" #define LOV_MIN_STRIPE_BITS 16 /* maximum PAGE_SIZE (ia64), power of 2 */ -#define LOV_MIN_STRIPE_SIZE (1<exp_connect_data.ocd_connect_flags; +} + +static inline __u64 exp_connect_flags(struct obd_export *exp) +{ + return *exp_connect_flags_ptr(exp); +} + +static inline int exp_brw_size(struct obd_export *exp) +{ + LASSERT(exp != NULL); + if (exp_connect_flags(exp) & OBD_CONNECT_BRW_SIZE) + return exp->exp_connect_data.ocd_brw_size; + + return ONE_MB_BRW_SIZE; +} + static inline int exp_expired(struct obd_export *exp, cfs_duration_t age) { LASSERT(exp->exp_delayed); @@ -279,20 +299,20 @@ static inline int exp_expired(struct obd_export *exp, cfs_duration_t age) static inline int exp_connect_cancelset(struct obd_export *exp) { - LASSERT(exp != NULL); - return !!(exp->exp_connect_flags & OBD_CONNECT_CANCELSET); + LASSERT(exp != NULL); + return !!(exp_connect_flags(exp) & OBD_CONNECT_CANCELSET); } static inline int exp_connect_lru_resize(struct obd_export *exp) { - LASSERT(exp != NULL); - return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE); + LASSERT(exp != NULL); + return !!(exp_connect_flags(exp) & OBD_CONNECT_LRU_RESIZE); } static inline int exp_connect_rmtclient(struct obd_export *exp) { - LASSERT(exp != NULL); - return !!(exp->exp_connect_flags & OBD_CONNECT_RMT_CLIENT); + LASSERT(exp != NULL); + return !!(exp_connect_flags(exp) & OBD_CONNECT_RMT_CLIENT); } static inline int client_is_remote(struct obd_export *exp) @@ -305,20 +325,20 @@ static inline int client_is_remote(struct obd_export *exp) static inline int exp_connect_vbr(struct obd_export *exp) { - LASSERT(exp != NULL); - LASSERT(exp->exp_connection); - return !!(exp->exp_connect_flags & OBD_CONNECT_VBR); + LASSERT(exp != NULL); + LASSERT(exp->exp_connection); + return !!(exp_connect_flags(exp) & OBD_CONNECT_VBR); } static inline int exp_connect_som(struct obd_export *exp) { - LASSERT(exp != NULL); - return !!(exp->exp_connect_flags & OBD_CONNECT_SOM); + LASSERT(exp != NULL); + return !!(exp_connect_flags(exp) & OBD_CONNECT_SOM); } static inline int exp_connect_umask(struct obd_export *exp) { - return !!(exp->exp_connect_flags & OBD_CONNECT_UMASK); + return !!(exp_connect_flags(exp) & OBD_CONNECT_UMASK); } static inline int imp_connect_lru_resize(struct obd_import *imp) @@ -332,13 +352,13 @@ static inline int imp_connect_lru_resize(struct obd_import *imp) static inline int exp_connect_layout(struct obd_export *exp) { - return !!(exp->exp_connect_flags & OBD_CONNECT_LAYOUTLOCK); + return !!(exp_connect_flags(exp) & OBD_CONNECT_LAYOUTLOCK); } static inline bool exp_connect_lvb_type(struct obd_export *exp) { LASSERT(exp != NULL); - if (exp->exp_connect_flags & OBD_CONNECT_LVB_TYPE) + if (exp_connect_flags(exp) & OBD_CONNECT_LVB_TYPE) return true; else return false; diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index b87cf91..e5e7885 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -87,9 +87,15 @@ * CAVEAT EMPTOR, with multinet (i.e. routers forwarding between networks) * these limits are system wide and not interface-local. */ #define PTLRPC_MAX_BRW_BITS LNET_MTU_BITS -#define PTLRPC_MAX_BRW_SIZE (1<> CFS_PAGE_SHIFT) +#define ONE_MB_BRW_SIZE (1 << LNET_MTU_BITS) +#define MD_MAX_BRW_SIZE (1 << LNET_MTU_BITS) +#define MD_MAX_BRW_PAGES (MD_MAX_BRW_SIZE >> CFS_PAGE_SHIFT) +#define DT_MAX_BRW_SIZE (1 << LNET_MTU_BITS) +#define OFD_MAX_BRW_SIZE (1 << LNET_MTU_BITS) + /* When PAGE_SIZE is a constant, we can check our arithmetic here with cpp! */ #ifdef __KERNEL__ # if ((PTLRPC_MAX_BRW_PAGES & (PTLRPC_MAX_BRW_PAGES - 1)) != 0) diff --git a/lustre/include/obd_lov.h b/lustre/include/obd_lov.h index da88099..ebd50f3 100644 --- a/lustre/include/obd_lov.h +++ b/lustre/include/obd_lov.h @@ -37,6 +37,8 @@ #ifndef _OBD_LOV_H__ #define _OBD_LOV_H__ +#define LOV_DEFAULT_STRIPE_SIZE (1 << LNET_MTU_BITS) + static inline int lov_stripe_md_size(__u16 stripes) { return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 312ee13..0db5ccd 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -385,10 +385,10 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) #endif cfs_atomic_set(&cli->cl_resends, OSC_DEFAULT_RESENDS); - /* This value may be changed at connect time in - ptlrpc_connect_interpret. */ - cli->cl_max_pages_per_rpc = min((int)PTLRPC_MAX_BRW_PAGES, - (int)(1024 * 1024 >> CFS_PAGE_SHIFT)); + /* This value may be changed at connect time in + ptlrpc_connect_interpret. */ + cli->cl_max_pages_per_rpc = min((int)PTLRPC_MAX_BRW_PAGES, + (int)(LNET_MTU >> CFS_PAGE_SHIFT)); if (!strcmp(name, LUSTRE_MDC_NAME)) { cli->cl_max_rpcs_in_flight = MDC_MAX_RIF_DEFAULT; diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 747217b..cdd4c6d 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -112,20 +112,20 @@ void ldlm_convert_policy_to_wire(ldlm_type_t type, * Converts lock policy from on the wire lock_desc format to local format */ void ldlm_convert_policy_to_local(struct obd_export *exp, ldlm_type_t type, - const ldlm_wire_policy_data_t *wpolicy, - ldlm_policy_data_t *lpolicy) + const ldlm_wire_policy_data_t *wpolicy, + ldlm_policy_data_t *lpolicy) { - ldlm_policy_wire_to_local_t convert; - int new_client; + ldlm_policy_wire_to_local_t convert; + int new_client; - /** some badnes for 2.0.0 clients, but 2.0.0 isn't supported */ - new_client = (exp->exp_connect_flags & OBD_CONNECT_FULL20) != 0; - if (new_client) - convert = ldlm_policy_wire21_to_local[type - LDLM_MIN_TYPE]; - else - convert = ldlm_policy_wire18_to_local[type - LDLM_MIN_TYPE]; + /** some badness for 2.0.0 clients, but 2.0.0 isn't supported */ + new_client = (exp_connect_flags(exp) & OBD_CONNECT_FULL20) != 0; + if (new_client) + convert = ldlm_policy_wire21_to_local[type - LDLM_MIN_TYPE]; + else + convert = ldlm_policy_wire18_to_local[type - LDLM_MIN_TYPE]; - convert(wpolicy, lpolicy); + convert(wpolicy, lpolicy); } char *ldlm_it2str(int it) @@ -654,12 +654,12 @@ EXPORT_SYMBOL(__ldlm_handle2lock); */ void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc) { - struct obd_export *exp = lock->l_export?:lock->l_conn_export; - /* INODEBITS_INTEROP: If the other side does not support - * inodebits, reply with a plain lock descriptor. - */ - if ((lock->l_resource->lr_type == LDLM_IBITS) && - (exp && !(exp->exp_connect_flags & OBD_CONNECT_IBITS))) { + struct obd_export *exp = lock->l_export ?: lock->l_conn_export; + + /* INODEBITS_INTEROP: If the other side does not support + * inodebits, reply with a plain lock descriptor. */ + if ((lock->l_resource->lr_type == LDLM_IBITS) && + (exp && !(exp_connect_flags(exp) & OBD_CONNECT_IBITS))) { /* Make sure all the right bits are set in this lock we are going to pass to client */ LASSERTF(lock->l_policy_data.l_inodebits.bits == diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 4010c45..c331276 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -1224,7 +1224,7 @@ int ldlm_handle_enqueue0(struct ldlm_namespace *ns, GOTO(out, rc = -EFAULT); } - if (req->rq_export->exp_connect_flags & OBD_CONNECT_IBITS) { + if (exp_connect_flags(req->rq_export) & OBD_CONNECT_IBITS) { if (unlikely(dlm_req->lock_desc.l_resource.lr_type == LDLM_PLAIN)) { DEBUG_REQ(D_ERROR, req, @@ -1245,7 +1245,7 @@ int ldlm_handle_enqueue0(struct ldlm_namespace *ns, /* INODEBITS_INTEROP: Perform conversion from plain lock to * inodebits lock if client does not support them. */ - if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_IBITS) && + if (!(exp_connect_flags(req->rq_export) & OBD_CONNECT_IBITS) && (dlm_req->lock_desc.l_resource.lr_type == LDLM_PLAIN)) { dlm_req->lock_desc.l_resource.lr_type = LDLM_IBITS; dlm_req->lock_desc.l_policy_data.l_inodebits.bits = diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index f98c8dd..74d775d 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -643,14 +643,14 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, GOTO(cleanup, rc = -ENOMEM); LDLM_DEBUG(lock, "client-side enqueue, new resource"); } - if (with_policy) - if (!(type == LDLM_IBITS && !(exp->exp_connect_flags & - OBD_CONNECT_IBITS))) - /* We assume lock type cannot change on server*/ - ldlm_convert_policy_to_local(exp, - lock->l_resource->lr_type, - &reply->lock_desc.l_policy_data, - &lock->l_policy_data); + if (with_policy) + if (!(type == LDLM_IBITS && + !(exp_connect_flags(exp) & OBD_CONNECT_IBITS))) + /* We assume lock type cannot change on server*/ + ldlm_convert_policy_to_local(exp, + lock->l_resource->lr_type, + &reply->lock_desc.l_policy_data, + &lock->l_policy_data); if (type != LDLM_PLAIN) LDLM_DEBUG(lock,"client-side enqueue, new policy data"); } @@ -887,7 +887,8 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, * inodebits lock internally with both bits set. */ if (einfo->ei_type == LDLM_IBITS && - !(exp->exp_connect_flags & OBD_CONNECT_IBITS)) + !(exp_connect_flags(exp) & + OBD_CONNECT_IBITS)) lock->l_policy_data.l_inodebits.bits = MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE; diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index d0cfb2a..76d1fb1 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -165,7 +165,7 @@ static int ll_dir_filler(void *_hash, struct page *page0) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) hash "LPU64"\n", inode->i_ino, inode->i_generation, inode, hash); - LASSERT(max_pages > 0 && max_pages <= PTLRPC_MAX_BRW_PAGES); + LASSERT(max_pages > 0 && max_pages <= MD_MAX_BRW_PAGES); OBD_ALLOC(page_pool, sizeof(page) * max_pages); if (page_pool != NULL) { diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 45f2131..6e5aa43 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2536,7 +2536,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, /* XXX: Enable OBD_CONNECT_ATTRFID to reduce unnecessary getattr RPC. * But under CMD case, it caused some lock issues, should be fixed * with new CMD ibits lock. See bug 12718 */ - if (exp->exp_connect_flags & OBD_CONNECT_ATTRFID) { + if (exp_connect_flags(exp) & OBD_CONNECT_ATTRFID) { struct lookup_intent oit = { .it_op = IT_GETATTR }; struct md_op_data *op_data; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index a7cb341..f19b571 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -264,7 +264,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (sbi->ll_flags & LL_SBI_RMT_CLIENT) data->ocd_connect_flags |= OBD_CONNECT_RMT_CLIENT_FORCE; - data->ocd_brw_size = PTLRPC_MAX_BRW_SIZE; + data->ocd_brw_size = MD_MAX_BRW_SIZE; err = obd_connect(NULL, &sbi->ll_md_exp, obd, &sbi->ll_sb_uuid, data, NULL); if (err == -EBUSY) { @@ -278,6 +278,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, GOTO(out, err); } + sbi->ll_md_exp->exp_connect_data = *data; + /* For mount, we only need fs info from MDT0, and also in DNE, it * can make sure the client can be mounted as long as MDT0 is * avaible */ @@ -294,8 +296,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, * be non-zero, but if accessing an upgraded 2.1 server it will * have the correct flags filled in. * XXX: fill in the LMV exp_connect_flags from MDC(s). */ - valid = sbi->ll_md_exp->exp_connect_flags & CLIENT_CONNECT_MDT_REQD; - if (sbi->ll_md_exp->exp_connect_flags != 0 && + valid = exp_connect_flags(sbi->ll_md_exp) & CLIENT_CONNECT_MDT_REQD; + if (exp_connect_flags(sbi->ll_md_exp) != 0 && valid != CLIENT_CONNECT_MDT_REQD) { char *buf; @@ -374,10 +376,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (data->ocd_connect_flags & OBD_CONNECT_64BITHASH) sbi->ll_flags |= LL_SBI_64BIT_HASH; - if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) - sbi->ll_md_brw_size = data->ocd_brw_size; - else - sbi->ll_md_brw_size = CFS_PAGE_SIZE; + if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) + sbi->ll_md_brw_size = data->ocd_brw_size; + else + sbi->ll_md_brw_size = CFS_PAGE_SIZE; if (data->ocd_connect_flags & OBD_CONNECT_LAYOUTLOCK) { LCONSOLE_INFO("Layout lock feature supported.\n"); @@ -431,7 +433,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, obd->obd_upcall.onu_owner = &sbi->ll_lco; obd->obd_upcall.onu_upcall = cl_ocd_update; - data->ocd_brw_size = PTLRPC_MAX_BRW_SIZE; + data->ocd_brw_size = DT_MAX_BRW_SIZE; err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, data, NULL); @@ -447,6 +449,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, GOTO(out_md, err); } + sbi->ll_dt_exp->exp_connect_data = *data; + mutex_lock(&sbi->ll_lco.lco_lock); sbi->ll_lco.lco_flags = data->ocd_connect_flags; sbi->ll_lco.lco_md_exp = sbi->ll_md_exp; diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index 5f00ab2..4c58181 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -108,7 +108,7 @@ #include #include "llite_internal.h" -#define LLOOP_MAX_SEGMENTS PTLRPC_MAX_BRW_PAGES +#define LLOOP_MAX_SEGMENTS LNET_MAX_IOV /* Possible states of device */ enum { diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index e15c0dd..4214b94 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -371,7 +371,7 @@ static ssize_t ll_direct_IO_26_seg(const struct lu_env *env, struct cl_io *io, * then truncate this to be a full-sized RPC. For 4kB PAGE_SIZE this is * up to 22MB for 128kB kmalloc and up to 682MB for 4MB kmalloc. */ #define MAX_DIO_SIZE ((MAX_MALLOC / sizeof(struct brw_page) * CFS_PAGE_SIZE) & \ - ~(PTLRPC_MAX_BRW_SIZE - 1)) + ~(DT_MAX_BRW_SIZE - 1)) static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t file_offset, unsigned long nr_segs) diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 8fa6a3e..c8fda0a 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -174,8 +174,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, * the same. Otherwise one of MDTs runs wrong version or * something like this. --umka */ - obd->obd_self_export->exp_connect_flags = - conn_data->ocd_connect_flags; + obd->obd_self_export->exp_connect_data = *conn_data; } #if 0 else if (ev == OBD_NOTIFY_DISCON) { @@ -2069,10 +2068,8 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, */ rc = obd_get_info(env, lmv->tgts[0]->ltd_exp, keylen, key, vallen, val, NULL); - if (!rc && KEY_IS(KEY_CONN_DATA)) { - exp->exp_connect_flags = - ((struct obd_connect_data *)val)->ocd_connect_flags; - } + if (!rc && KEY_IS(KEY_CONN_DATA)) + exp->exp_connect_data = *(struct obd_connect_data *)val; RETURN(rc); } else if (KEY_IS(KEY_TGT_COUNT)) { *((int *)val) = lmv->desc.ld_tgt_count; diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 0800e53..b7460b4 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -892,10 +892,10 @@ int lod_verify_striping(struct lod_device *d, const struct lu_buf *buf, void lod_fix_desc_stripe_size(__u64 *val) { - if (*val < PTLRPC_MAX_BRW_SIZE) { + if (*val < LOV_DEFAULT_STRIPE_SIZE) { LCONSOLE_WARN("Increasing default stripe size to min %u\n", - PTLRPC_MAX_BRW_SIZE); - *val = PTLRPC_MAX_BRW_SIZE; + LOV_DEFAULT_STRIPE_SIZE); + *val = LOV_DEFAULT_STRIPE_SIZE; } else if (*val & (LOV_MIN_STRIPE_SIZE - 1)) { *val &= ~(LOV_MIN_STRIPE_SIZE - 1); LCONSOLE_WARN("Changing default stripe size to "LPU64" (a " diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 74cabb9..19c424c 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -721,16 +721,16 @@ static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) void lov_fix_desc_stripe_size(__u64 *val) { - if (*val < PTLRPC_MAX_BRW_SIZE) { - LCONSOLE_WARN("Increasing default stripe size to min %u\n", - PTLRPC_MAX_BRW_SIZE); - *val = PTLRPC_MAX_BRW_SIZE; - } else if (*val & (LOV_MIN_STRIPE_SIZE - 1)) { - *val &= ~(LOV_MIN_STRIPE_SIZE - 1); - LCONSOLE_WARN("Changing default stripe size to "LPU64" (a " - "multiple of %u)\n", - *val, LOV_MIN_STRIPE_SIZE); - } + if (*val < LOV_DEFAULT_STRIPE_SIZE) { + LCONSOLE_WARN("Increasing default stripe size to min %u\n", + LOV_DEFAULT_STRIPE_SIZE); + *val = LOV_DEFAULT_STRIPE_SIZE; + } else if (*val & (LOV_MIN_STRIPE_SIZE - 1)) { + *val &= ~(LOV_MIN_STRIPE_SIZE - 1); + LCONSOLE_WARN("Changing default stripe size to "LPU64" (a " + "multiple of %u)\n", + *val, LOV_MIN_STRIPE_SIZE); + } } void lov_fix_desc_stripe_count(__u32 *val) @@ -2524,7 +2524,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, if (!tgt || !tgt->ltd_exp) GOTO(out, rc = -ESRCH); - *((__u64*)val) = tgt->ltd_exp->exp_connect_flags; + *((__u64 *)val) = exp_connect_flags(tgt->ltd_exp); GOTO(out, rc = 0); } else if (KEY_IS(KEY_TGT_COUNT)) { *((int *)val) = lov->desc.ld_tgt_count; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index ec9a6d4..dc366af 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1829,13 +1829,14 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, OBD_FREE_PTR(oqctl); break; } - case LL_IOC_GET_CONNECT_FLAGS: { - if (cfs_copy_to_user(uarg, &exp->exp_connect_flags, - sizeof(__u64))) - GOTO(out, rc = -EFAULT); - else - GOTO(out, rc = 0); - } + case LL_IOC_GET_CONNECT_FLAGS: { + if (cfs_copy_to_user(uarg, + exp_connect_flags_ptr(exp), + sizeof(__u64))) + GOTO(out, rc = -EFAULT); + else + GOTO(out, rc = 0); + } default: CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd); GOTO(out, rc = -ENOTTY); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index fb1b55c..bdb13e1 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -259,7 +259,7 @@ int mdt_getstatus(struct mdt_thread_info *info) repbody->valid |= OBD_MD_FLID; if (mdt->mdt_opts.mo_mds_capa && - info->mti_exp->exp_connect_flags & OBD_CONNECT_MDS_CAPA) { + exp_connect_flags(info->mti_exp) & OBD_CONNECT_MDS_CAPA) { struct mdt_object *root; struct lustre_capa *capa; @@ -426,9 +426,9 @@ void mdt_client_compatibility(struct mdt_thread_info *info) struct lu_attr *la = &ma->ma_attr; ENTRY; - if (exp->exp_connect_flags & OBD_CONNECT_LAYOUTLOCK) - /* the client can deal with 16-bit lmm_stripe_count */ - RETURN_EXIT; + if (exp_connect_flags(exp) & OBD_CONNECT_LAYOUTLOCK) + /* the client can deal with 16-bit lmm_stripe_count */ + RETURN_EXIT; body = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY); @@ -832,8 +832,8 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, } } #ifdef CONFIG_FS_POSIX_ACL - else if ((req->rq_export->exp_connect_flags & OBD_CONNECT_ACL) && - (reqbody->valid & OBD_MD_FLACL)) { + else if ((exp_connect_flags(req->rq_export) & OBD_CONNECT_ACL) && + (reqbody->valid & OBD_MD_FLACL)) { buffer->lb_buf = req_capsule_server_get(pill, &RMF_ACL); buffer->lb_len = req_capsule_get_size(pill, &RMF_ACL, RCL_SERVER); @@ -859,9 +859,9 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, } #endif - if (reqbody->valid & OBD_MD_FLMDSCAPA && - info->mti_mdt->mdt_opts.mo_mds_capa && - info->mti_exp->exp_connect_flags & OBD_CONNECT_MDS_CAPA) { + if (reqbody->valid & OBD_MD_FLMDSCAPA && + info->mti_mdt->mdt_opts.mo_mds_capa && + exp_connect_flags(info->mti_exp) & OBD_CONNECT_MDS_CAPA) { struct lustre_capa *capa; capa = req_capsule_server_get(pill, &RMF_CAPA1); @@ -892,9 +892,9 @@ static int mdt_renew_capa(struct mdt_thread_info *info) * return directly, client will find body->valid OBD_MD_FLOSSCAPA * flag not set. */ - if (!obj || !info->mti_mdt->mdt_opts.mo_oss_capa || - !(info->mti_exp->exp_connect_flags & OBD_CONNECT_OSS_CAPA)) - RETURN(0); + if (!obj || !info->mti_mdt->mdt_opts.mo_oss_capa || + !(exp_connect_flags(info->mti_exp) & OBD_CONNECT_OSS_CAPA)) + RETURN(0); body = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY); LASSERT(body != NULL); @@ -1422,9 +1422,11 @@ int mdt_set_info(struct mdt_thread_info *info) spin_lock(&req->rq_export->exp_lock); if (*(__u32 *)val) - req->rq_export->exp_connect_flags |= OBD_CONNECT_RDONLY; + *exp_connect_flags_ptr(req->rq_export) |= + OBD_CONNECT_RDONLY; else - req->rq_export->exp_connect_flags &=~OBD_CONNECT_RDONLY; + *exp_connect_flags_ptr(req->rq_export) &= + ~OBD_CONNECT_RDONLY; spin_unlock(&req->rq_export->exp_lock); } else if (KEY_IS(KEY_CHANGELOG_CLEAR)) { @@ -1478,7 +1480,7 @@ int mdt_connect(struct mdt_thread_info *info) reply = req_capsule_server_get(info->mti_pill, &RMF_CONNECT_DATA); exp = req->rq_export; spin_lock(&exp->exp_lock); - exp->exp_connect_flags = reply->ocd_connect_flags; + *exp_connect_flags_ptr(exp) = reply->ocd_connect_flags; spin_unlock(&exp->exp_lock); rc = mdt_init_idmap(info); @@ -1517,9 +1519,9 @@ static int mdt_sendpage(struct mdt_thread_info *info, if (desc == NULL) RETURN(-ENOMEM); - if (!(exp->exp_connect_flags & OBD_CONNECT_BRW_SIZE)) + if (!(exp_connect_flags(exp) & OBD_CONNECT_BRW_SIZE)) /* old client requires reply size in it's PAGE_SIZE, - * which is rdpg->rp_count */ + * which is rdpg->rp_count */ nob = rdpg->rp_count; for (i = 0, tmpcount = nob; i < rdpg->rp_npages && tmpcount > 0; @@ -1565,10 +1567,10 @@ int mdt_readpage(struct mdt_thread_info *info) } rdpg->rp_attrs = reqbody->mode; - if (info->mti_exp->exp_connect_flags & OBD_CONNECT_64BITHASH) - rdpg->rp_attrs |= LUDA_64BITHASH; - rdpg->rp_count = min_t(unsigned int, reqbody->nlink, - PTLRPC_MAX_BRW_SIZE); + if (exp_connect_flags(info->mti_exp) & OBD_CONNECT_64BITHASH) + rdpg->rp_attrs |= LUDA_64BITHASH; + rdpg->rp_count = min_t(unsigned int, reqbody->nlink, + exp_brw_size(info->mti_exp)); rdpg->rp_npages = (rdpg->rp_count + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT; OBD_ALLOC(rdpg->rp_pages, rdpg->rp_npages * sizeof rdpg->rp_pages[0]); @@ -2001,7 +2003,7 @@ int mdt_obd_idx_read(struct mdt_thread_info *info) if (req_ii->ii_count <= 0) GOTO(out, rc = -EFAULT); rdpg->rp_count = min_t(unsigned int, req_ii->ii_count << LU_PAGE_SHIFT, - PTLRPC_MAX_BRW_SIZE); + exp_brw_size(info->mti_exp)); rdpg->rp_npages = (rdpg->rp_count + CFS_PAGE_SIZE -1) >> CFS_PAGE_SHIFT; /* allocate pages to store the containers */ @@ -2776,10 +2778,10 @@ static int mdt_req_handle(struct mdt_thread_info *info, rc = mdt_unpack_req_pack_rep(info, flags); } - if (rc == 0 && flags & MUTABOR && - req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY) - /* should it be rq_status? */ - rc = -EROFS; + if (rc == 0 && flags & MUTABOR && + exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY) + /* should it be rq_status? */ + rc = -EROFS; if (rc == 0 && flags & HABEO_CLAVIS) { struct ldlm_request *dlm_req; @@ -3752,9 +3754,9 @@ static int mdt_intent_opc(long itopc, struct mdt_thread_info *info, rc = mdt_unpack_req_pack_rep(info, flv->it_flags); if (rc == 0) { struct ptlrpc_request *req = mdt_info_req(info); - if (flv->it_flags & MUTABOR && - req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY) - RETURN(-EROFS); + if (flv->it_flags & MUTABOR && + exp_connect_flags(req->rq_export) & OBD_CONNECT_RDONLY) + RETURN(-EROFS); } if (rc == 0 && flv->it_act != NULL) { /* execute policy */ @@ -4918,12 +4920,12 @@ static int mdt_obd_set_info_async(const struct lu_env *env, * Compute the compatibility flags for a connection request based on * features mutually supported by client and server. * - * The obd_export::exp_connect_flags field in \a exp must not be updated - * here, otherwise a partially initialized value may be exposed. After - * the connection request is successfully processed, the top-level MDT - * connect request handler atomically updates the export connect flags - * from the obd_connect_data::ocd_connect_flags field of the reply. - * \see mdt_connect(). + * The obd_export::exp_connect_data.ocd_connect_flags field in \a exp + * must not be updated here, otherwise a partially initialized value may + * be exposed. After the connection request is successfully processed, + * the top-level MDT connect request handler atomically updates the export + * connect flags from the obd_connect_data::ocd_connect_flags field of the + * reply. \see mdt_connect(). * * \param exp the obd_export associated with this client/target pair * \param mdt the target device for the connection @@ -4960,7 +4962,7 @@ static int mdt_connect_internal(struct obd_export *exp, if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) { data->ocd_brw_size = min(data->ocd_brw_size, - (__u32)(PTLRPC_MAX_BRW_PAGES << CFS_PAGE_SHIFT)); + (__u32)MD_MAX_BRW_SIZE); if (data->ocd_brw_size == 0) { CERROR("%s: cli %s/%p ocd_connect_flags: "LPX64 " ocd_version: %x ocd_grant: %d " @@ -4976,17 +4978,19 @@ static int mdt_connect_internal(struct obd_export *exp, } } - /* NB: Disregard the rule against updating exp_connect_flags in this - * case, since tgt_client_new() needs to know if this is a lightweight - * connection, and it is safe to expose this flag before connection - * processing completes. */ + /* NB: Disregard the rule against updating + * exp_connect_data.ocd_connect_flags in this case, since + * tgt_client_new() needs to know if this is a lightweight + * connection, and it is safe to expose this flag before + * connection processing completes. */ if (data->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT) { spin_lock(&exp->exp_lock); - exp->exp_connect_flags |= OBD_CONNECT_LIGHTWEIGHT; + *exp_connect_flags_ptr(exp) |= OBD_CONNECT_LIGHTWEIGHT; spin_unlock(&exp->exp_lock); } data->ocd_version = LUSTRE_VERSION_CODE; + exp->exp_connect_data = *data; exp->exp_mdt_data.med_ibits_known = data->ocd_ibits_known; if ((data->ocd_connect_flags & OBD_CONNECT_FID) == 0) { diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 44a5d68..c70d8ae 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -557,8 +557,8 @@ static inline int req_is_replay(struct ptlrpc_request *req) static inline __u64 mdt_conn_flags(struct mdt_thread_info *info) { - LASSERT(info->mti_exp); - return info->mti_exp->exp_connect_flags; + LASSERT(info->mti_exp); + return exp_connect_flags(info->mti_exp); } static inline void mdt_object_get(const struct lu_env *env, @@ -1009,20 +1009,20 @@ void mdt_ck_timer_callback(unsigned long castmeharder); int mdt_capa_keys_init(const struct lu_env *env, struct mdt_device *mdt); static inline void mdt_set_capainfo(struct mdt_thread_info *info, int offset, - const struct lu_fid *fid, - struct lustre_capa *capa) + const struct lu_fid *fid, + struct lustre_capa *capa) { - struct md_capainfo *ci; + struct md_capainfo *ci; LASSERT(offset >= 0 && offset < MD_CAPAINFO_MAX); - if (!info->mti_mdt->mdt_opts.mo_mds_capa || - !(info->mti_exp->exp_connect_flags & OBD_CONNECT_MDS_CAPA)) - return; - - ci = md_capainfo(info->mti_env); - LASSERT(ci); - ci->mc_fid[offset] = *fid; - ci->mc_capa[offset] = capa; + if (!info->mti_mdt->mdt_opts.mo_mds_capa || + !(exp_connect_flags(info->mti_exp) & OBD_CONNECT_MDS_CAPA)) + return; + + ci = md_capainfo(info->mti_env); + LASSERT(ci); + ci->mc_fid[offset] = *fid; + ci->mc_capa[offset] = capa; } static inline void mdt_dump_capainfo(struct mdt_thread_info *info) diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 051421bb..e662147 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -690,9 +690,9 @@ int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo, repbody->valid |= OBD_MD_FLCOOKIE; } - if (info->mti_mdt->mdt_opts.mo_oss_capa && - info->mti_exp->exp_connect_flags & OBD_CONNECT_OSS_CAPA && - repbody->valid & OBD_MD_FLEASIZE) { + if (info->mti_mdt->mdt_opts.mo_oss_capa && + exp_connect_flags(info->mti_exp) & OBD_CONNECT_OSS_CAPA && + repbody->valid & OBD_MD_FLEASIZE) { struct lustre_capa *capa; capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA2); diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index deae5bb..e627580 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -885,8 +885,8 @@ static int lprocfs_wr_mdt_som(struct file *file, const char *buffer, cfs_list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain) { if (exp == obd->obd_self_export) continue; - if (exp->exp_connect_flags & OBD_CONNECT_MDS_MDS) - continue; + if (exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS) + continue; /* Some clients are already connected, skip the change */ LCONSOLE_INFO("%s is already connected, SOM will be %s on " "the next mount\n", exp->exp_client_uuid.uuid, @@ -1048,7 +1048,7 @@ void mdt_counter_incr(struct ptlrpc_request *req, int opcode) if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL) lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode); if (exp->exp_obd && exp->exp_obd->u.obt.obt_jobstats.ojs_hash && - (exp->exp_connect_flags & OBD_CONNECT_JOBSTATS)) + (exp_connect_flags(exp) & OBD_CONNECT_JOBSTATS)) lprocfs_job_stats_log(exp->exp_obd, lustre_msg_get_jobid(req->rq_reqmsg), opcode, 1); diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 81375ed..c9e5ecd 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -852,7 +852,7 @@ int mdt_finish_open(struct mdt_thread_info *info, } } #ifdef CONFIG_FS_POSIX_ACL - else if (exp->exp_connect_flags & OBD_CONNECT_ACL) { + else if (exp_connect_flags(exp) & OBD_CONNECT_ACL) { const struct lu_env *env = info->mti_env; struct md_object *next = mdt_object_child(o); struct lu_buf *buf = &info->mti_buf; @@ -882,8 +882,8 @@ int mdt_finish_open(struct mdt_thread_info *info, } #endif - if (info->mti_mdt->mdt_opts.mo_mds_capa && - exp->exp_connect_flags & OBD_CONNECT_MDS_CAPA) { + if (info->mti_mdt->mdt_opts.mo_mds_capa && + exp_connect_flags(exp) & OBD_CONNECT_MDS_CAPA) { struct lustre_capa *capa; capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA1); @@ -894,9 +894,9 @@ int mdt_finish_open(struct mdt_thread_info *info, RETURN(rc); repbody->valid |= OBD_MD_FLMDSCAPA; } - if (info->mti_mdt->mdt_opts.mo_oss_capa && - exp->exp_connect_flags & OBD_CONNECT_OSS_CAPA && - S_ISREG(lu_object_attr(&o->mot_obj.mo_lu))) { + if (info->mti_mdt->mdt_opts.mo_oss_capa && + exp_connect_flags(exp) & OBD_CONNECT_OSS_CAPA && + S_ISREG(lu_object_attr(&o->mot_obj.mo_lu))) { struct lustre_capa *capa; capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA2); @@ -912,11 +912,11 @@ int mdt_finish_open(struct mdt_thread_info *info, * If we are following a symlink, don't open; and do not return open * handle for special nodes as client required. */ - if (islnk || (!isreg && !isdir && - (req->rq_export->exp_connect_flags & OBD_CONNECT_NODEVOH))) { - lustre_msg_set_transno(req->rq_repmsg, 0); - RETURN(0); - } + if (islnk || (!isreg && !isdir && + (exp_connect_flags(req->rq_export) & OBD_CONNECT_NODEVOH))) { + lustre_msg_set_transno(req->rq_repmsg, 0); + RETURN(0); + } /* * We need to return the existing object's fid back, so it is done here, diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index cfefa30..9cd8549 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -433,7 +433,7 @@ static int mdt_last_rcvd_update(struct mdt_thread_info *mti, lcd->lcd_last_data = mti->mti_opdata; } - if ((mti->mti_exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0) { + if (exp_connect_flags(mti->mti_exp) & OBD_CONNECT_LIGHTWEIGHT) { /* Although lightweight (LW) connections have no slot in * last_rcvd, we still want to maintain the in-memory * lsd_client_data structure in order to properly handle reply diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 4d7aebf..b906337 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -66,8 +66,8 @@ static int mdt_create_pack_capa(struct mdt_thread_info *info, int rc, if (repbody->valid & OBD_MD_FLMDSCAPA) RETURN(rc); - if (rc == 0 && info->mti_mdt->mdt_opts.mo_mds_capa && - info->mti_exp->exp_connect_flags & OBD_CONNECT_MDS_CAPA) { + if (rc == 0 && info->mti_mdt->mdt_opts.mo_mds_capa && + exp_connect_flags(info->mti_exp) & OBD_CONNECT_MDS_CAPA) { struct lustre_capa *capa; capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA1); @@ -575,10 +575,10 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, mdt_pack_attr2body(info, repbody, &ma->ma_attr, mdt_object_fid(mo)); - if (info->mti_mdt->mdt_opts.mo_oss_capa && - info->mti_exp->exp_connect_flags & OBD_CONNECT_OSS_CAPA && - S_ISREG(lu_object_attr(&mo->mot_obj.mo_lu)) && - (ma->ma_attr.la_valid & LA_SIZE) && !som_au) { + if (info->mti_mdt->mdt_opts.mo_oss_capa && + exp_connect_flags(info->mti_exp) & OBD_CONNECT_OSS_CAPA && + S_ISREG(lu_object_attr(&mo->mot_obj.mo_lu)) && + (ma->ma_attr.la_valid & LA_SIZE) && !som_au) { struct lustre_capa *capa; capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA2); diff --git a/lustre/mdt/mdt_xattr.c b/lustre/mdt/mdt_xattr.c index 8185a55..1e2f157 100644 --- a/lustre/mdt/mdt_xattr.c +++ b/lustre/mdt/mdt_xattr.c @@ -69,9 +69,9 @@ static int mdt_getxattr_pack_reply(struct mdt_thread_info * info) if (!xattr_name) RETURN(-EFAULT); - if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_XATTR) && - !strncmp(xattr_name, user_string, sizeof(user_string) - 1)) - RETURN(-EOPNOTSUPP); + if (!(exp_connect_flags(req->rq_export) & OBD_CONNECT_XATTR) && + !strncmp(xattr_name, user_string, sizeof(user_string) - 1)) + RETURN(-EOPNOTSUPP); size = mo_xattr_get(info->mti_env, mdt_object_child(info->mti_object), @@ -312,8 +312,8 @@ int mdt_reint_setxattr(struct mdt_thread_info *info, if (strncmp(xattr_name, XATTR_USER_PREFIX, sizeof(XATTR_USER_PREFIX) - 1) == 0) { - if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_XATTR)) - GOTO(out, rc = -EOPNOTSUPP); + if (!(exp_connect_flags(req->rq_export) & OBD_CONNECT_XATTR)) + GOTO(out, rc = -EOPNOTSUPP); if (strcmp(xattr_name, XATTR_NAME_LOV) == 0) GOTO(out, rc = -EACCES); if (strcmp(xattr_name, XATTR_NAME_LMA) == 0) diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 048561d..f71cc48 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -73,11 +73,11 @@ static int mgs_connect(const struct lu_env *env, mgs_counter_incr(lexp, LPROC_MGS_CONNECT); - if (data != NULL) { - data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED; - lexp->exp_connect_flags = data->ocd_connect_flags; - data->ocd_version = LUSTRE_VERSION_CODE; - } + if (data != NULL) { + data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED; + data->ocd_version = LUSTRE_VERSION_CODE; + lexp->exp_connect_data = *data; + } rc = mgs_export_stats_init(obd, lexp, localdata); @@ -92,24 +92,24 @@ out: } static int mgs_reconnect(const struct lu_env *env, - struct obd_export *exp, struct obd_device *obd, - struct obd_uuid *cluuid, struct obd_connect_data *data, - void *localdata) + struct obd_export *exp, struct obd_device *obd, + struct obd_uuid *cluuid, struct obd_connect_data *data, + void *localdata) { - ENTRY; + ENTRY; - if (exp == NULL || obd == NULL || cluuid == NULL) - RETURN(-EINVAL); + if (exp == NULL || obd == NULL || cluuid == NULL) + RETURN(-EINVAL); - mgs_counter_incr(exp, LPROC_MGS_CONNECT); + mgs_counter_incr(exp, LPROC_MGS_CONNECT); - if (data != NULL) { - data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED; - exp->exp_connect_flags = data->ocd_connect_flags; - data->ocd_version = LUSTRE_VERSION_CODE; - } + if (data != NULL) { + data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED; + data->ocd_version = LUSTRE_VERSION_CODE; + exp->exp_connect_data = *data; + } - RETURN(mgs_export_stats_init(obd, exp, localdata)); + RETURN(mgs_export_stats_init(obd, exp, localdata)); } static int mgs_disconnect(struct obd_export *exp) diff --git a/lustre/mgs/mgs_nids.c b/lustre/mgs/mgs_nids.c index df792fc..52251fc3 100644 --- a/lustre/mgs/mgs_nids.c +++ b/lustre/mgs/mgs_nids.c @@ -877,14 +877,14 @@ int mgs_fsc_attach(const struct lu_env *env, struct obd_export *exp, if (new_fsc == NULL) RETURN(-ENOMEM); - CFS_INIT_LIST_HEAD(&new_fsc->mfc_export_list); - CFS_INIT_LIST_HEAD(&new_fsc->mfc_fsdb_list); - new_fsc->mfc_fsdb = fsdb; - new_fsc->mfc_export = class_export_get(exp); - new_fsc->mfc_ir_capable = - !!(exp->exp_connect_flags & OBD_CONNECT_IMP_RECOV); - - rc = -EEXIST; + CFS_INIT_LIST_HEAD(&new_fsc->mfc_export_list); + CFS_INIT_LIST_HEAD(&new_fsc->mfc_fsdb_list); + new_fsc->mfc_fsdb = fsdb; + new_fsc->mfc_export = class_export_get(exp); + new_fsc->mfc_ir_capable = !!(exp_connect_flags(exp) & + OBD_CONNECT_IMP_RECOV); + + rc = -EEXIST; mutex_lock(&fsdb->fsdb_mutex); /* tend to find it in export list because this list is shorter. */ diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index bb5d965..7c06088 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1170,7 +1170,7 @@ void class_export_recovery_cleanup(struct obd_export *exp) * obd_stale_clients counter, * lightweight exports are not counted */ if (exp->exp_failed && - (exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) == 0) + (exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) == 0) exp->exp_obd->obd_stale_clients++; } spin_unlock(&obd->obd_recovery_task_lock); diff --git a/lustre/ofd/ofd_capa.c b/lustre/ofd/ofd_capa.c index 23bba01..810f123 100644 --- a/lustre/ofd/ofd_capa.c +++ b/lustre/ofd/ofd_capa.c @@ -123,7 +123,7 @@ int ofd_auth_capa(struct obd_export *exp, struct lu_fid *fid, obd_seq seq, if (!filter->fo_fl_oss_capa) RETURN(0); - if (!(exp->exp_connect_flags & OBD_CONNECT_OSS_CAPA)) + if (!(exp_connect_flags(exp) & OBD_CONNECT_OSS_CAPA)) RETURN(0); if (capa == NULL) { diff --git a/lustre/ofd/ofd_grant.c b/lustre/ofd/ofd_grant.c index 0ce8a31..9194f74 100644 --- a/lustre/ofd/ofd_grant.c +++ b/lustre/ofd/ofd_grant.c @@ -42,8 +42,9 @@ #include "ofd_internal.h" -#define OFD_GRANT_CHUNK (2ULL * PTLRPC_MAX_BRW_SIZE) -#define OFD_GRANT_SHRINK_LIMIT (16ULL * OFD_GRANT_CHUNK) +#define OFD_GRANT_CHUNK (2ULL * DT_MAX_BRW_SIZE) +#define OFD_GRANT_CHUNK_EXP(rexp) (2ULL * exp_brw_size((rexp))) +#define OFD_GRANT_SHRINK_LIMIT(rexp) (16ULL * OFD_GRANT_CHUNK_EXP((rexp))) static inline obd_size ofd_grant_from_cli(struct obd_export *exp, struct ofd_device *ofd, obd_size val) @@ -73,7 +74,7 @@ static inline obd_size ofd_grant_chunk(struct obd_export *exp, if (exp && ofd_grant_compat(exp, ofd)) /* Try to grant enough space to send a full-size RPC */ - return PTLRPC_MAX_BRW_SIZE << + return exp_brw_size(exp) << (ofd->ofd_blockbits - COMPAT_BSIZE_SHIFT); return OFD_GRANT_CHUNK; } @@ -371,9 +372,9 @@ static void ofd_grant_shrink(struct obd_export *exp, long grant_shrink; LASSERT_SPIN_LOCKED(&ofd->ofd_grant_lock); - + LASSERT(exp); if (left_space >= ofd->ofd_tot_granted_clients * - OFD_GRANT_SHRINK_LIMIT) + OFD_GRANT_SHRINK_LIMIT(exp)) return; grant_shrink = ofd_grant_from_cli(exp, ofd, oa->o_grant); @@ -630,7 +631,7 @@ static long ofd_grant(struct obd_export *exp, obd_size curgrant, if (!grant) RETURN(0); - /* Allow >OFD_GRANT_CHUNK size when clients reconnect due to a + /* Allow >OFD_GRANT_CHUNK_EXP size when clients reconnect due to a * server reboot. */ if ((grant > grant_chunk) && (!obd->obd_recovering)) grant = grant_chunk; @@ -677,7 +678,7 @@ long ofd_grant_connect(const struct lu_env *env, struct obd_export *exp, int force = 0; /* can use cached data */ /* don't grant space to client with read-only access */ - if ((exp->exp_connect_flags & OBD_CONNECT_RDONLY) || + if ((exp_connect_flags(exp) & OBD_CONNECT_RDONLY) || ofd_grant_prohibit(exp, ofd)) return 0; diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 4756484..28c7d18e 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -91,7 +91,7 @@ static inline void ofd_counter_incr(struct obd_export *exp, int opcode, char *jobid, long amount) { if (exp->exp_obd && exp->exp_obd->u.obt.obt_jobstats.ojs_hash && - (exp->exp_connect_flags & OBD_CONNECT_JOBSTATS)) + (exp_connect_flags(exp) & OBD_CONNECT_JOBSTATS)) lprocfs_job_stats_log(exp->exp_obd, jobid, opcode, amount); if (exp->exp_nid_stats != NULL && @@ -433,7 +433,7 @@ static inline int ofd_grant_ratio_conv(int percentage) static inline int ofd_grant_param_supp(struct obd_export *exp) { - return !!(exp->exp_connect_flags & OBD_CONNECT_GRANT_PARAM); + return !!(exp_connect_flags(exp) & OBD_CONNECT_GRANT_PARAM); } /* Blocksize used for client not supporting OBD_CONNECT_GRANT_PARAM. diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index d32db3a..1f4c108 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -146,7 +146,7 @@ static int ofd_parse_connect_data(const struct lu_env *env, fed->fed_group = data->ocd_group; data->ocd_connect_flags &= OST_CONNECT_SUPPORTED; - exp->exp_connect_flags = data->ocd_connect_flags; + exp->exp_connect_data = *data; data->ocd_version = LUSTRE_VERSION_CODE; /* Kindly make sure the SKIP_ORPHAN flag is from MDS. */ @@ -165,7 +165,7 @@ static int ofd_parse_connect_data(const struct lu_env *env, data->ocd_grant_extent = ofd->ofd_dt_conf.ddp_grant_frag >> 10; } - if (exp->exp_connect_flags & OBD_CONNECT_GRANT) + if (exp_connect_flags(exp) & OBD_CONNECT_GRANT) data->ocd_grant = ofd_grant_connect(env, exp, data->ocd_grant); if (data->ocd_connect_flags & OBD_CONNECT_INDEX) { @@ -193,7 +193,7 @@ static int ofd_parse_connect_data(const struct lu_env *env, data->ocd_brw_size = 65536; } else if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) { data->ocd_brw_size = min(data->ocd_brw_size, - (__u32)(PTLRPC_MAX_BRW_PAGES << CFS_PAGE_SHIFT)); + (__u32)DT_MAX_BRW_SIZE); if (data->ocd_brw_size == 0) { CERROR("%s: cli %s/%p ocd_connect_flags: "LPX64 " ocd_version: %x ocd_grant: %d ocd_index: %u " @@ -409,7 +409,7 @@ static int ofd_destroy_export(struct obd_export *exp) ofd_grant_discard(exp); ofd_fmd_cleanup(exp); - if (exp->exp_connect_flags & OBD_CONNECT_GRANT_SHRINK) { + if (exp_connect_flags(exp) & OBD_CONNECT_GRANT_SHRINK) { if (ofd->ofd_tot_granted_clients > 0) ofd->ofd_tot_granted_clients --; } @@ -769,7 +769,7 @@ static int ofd_statfs(const struct lu_env *env, struct obd_export *exp, /* The QoS code on the MDS does not care about space reserved for * precreate, so take it out. */ - if (exp->exp_connect_flags & OBD_CONNECT_MDS) { + if (exp_connect_flags(exp) & OBD_CONNECT_MDS) { struct filter_export_data *fed; fed = &obd->obd_self_export->exp_filter_data; @@ -1115,7 +1115,7 @@ static int ofd_orphans_destroy(const struct lu_env *env, } LASSERT(exp != NULL); - skip_orphan = !!(exp->exp_connect_flags & OBD_CONNECT_SKIP_ORPHAN); + skip_orphan = !!(exp_connect_flags(exp) & OBD_CONNECT_SKIP_ORPHAN); last = ofd_seq_last_oid(oseq); LCONSOLE_INFO("%s: deleting orphan objects from "LPX64":"LPU64 diff --git a/lustre/ofd/ofd_trans.c b/lustre/ofd/ofd_trans.c index 3112a50..c88988fb 100644 --- a/lustre/ofd/ofd_trans.c +++ b/lustre/ofd/ofd_trans.c @@ -122,7 +122,7 @@ static int ofd_last_rcvd_update(struct ofd_thread_info *info, LASSERT(ofd); LASSERT(info->fti_exp); - if ((info->fti_exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0) + if (exp_connect_flags(info->fti_exp) & OBD_CONNECT_LIGHTWEIGHT) lw_client = true; fed = &info->fti_exp->exp_filter_data; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index c6cd621..936df67 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -216,9 +216,9 @@ static int osc_getattr_interpret(const struct lu_env *env, CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); lustre_get_wire_obdo(aa->aa_oi->oi_oa, &body->oa); - /* This should really be sent by the OST */ - aa->aa_oi->oi_oa->o_blksize = PTLRPC_MAX_BRW_SIZE; - aa->aa_oi->oi_oa->o_valid |= OBD_MD_FLBLKSZ; + /* This should really be sent by the OST */ + aa->aa_oi->oi_oa->o_blksize = DT_MAX_BRW_SIZE; + aa->aa_oi->oi_oa->o_valid |= OBD_MD_FLBLKSZ; } else { CDEBUG(D_INFO, "can't unpack ost_body\n"); rc = -EPROTO; @@ -295,9 +295,9 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); lustre_get_wire_obdo(oinfo->oi_oa, &body->oa); - /* This should really be sent by the OST */ - oinfo->oi_oa->o_blksize = PTLRPC_MAX_BRW_SIZE; - oinfo->oi_oa->o_valid |= OBD_MD_FLBLKSZ; + /* This should really be sent by the OST */ + oinfo->oi_oa->o_blksize = exp_brw_size(exp); + oinfo->oi_oa->o_valid |= OBD_MD_FLBLKSZ; EXIT; out: @@ -478,9 +478,9 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, lustre_get_wire_obdo(oa, &body->oa); - /* This should really be sent by the OST */ - oa->o_blksize = PTLRPC_MAX_BRW_SIZE; - oa->o_valid |= OBD_MD_FLBLKSZ; + /* This should really be sent by the OST */ + oa->o_blksize = exp_brw_size(exp); + oa->o_valid |= OBD_MD_FLBLKSZ; /* XXX LOV STACKING: the lsm that is passed to us from LOV does not * have valid lsm_oinfo data structs, so don't go touching that. @@ -988,7 +988,6 @@ int osc_shrink_grant_to_target(struct client_obd *cli, long target) RETURN(rc); } -#define GRANT_SHRINK_LIMIT PTLRPC_MAX_BRW_SIZE static int osc_should_shrink_grant(struct client_obd *client) { cfs_time_t time = cfs_time_current(); @@ -998,13 +997,16 @@ static int osc_should_shrink_grant(struct client_obd *client) OBD_CONNECT_GRANT_SHRINK) == 0) return 0; - if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) { - if (client->cl_import->imp_state == LUSTRE_IMP_FULL && - client->cl_avail_grant > GRANT_SHRINK_LIMIT) - return 1; - else - osc_update_next_shrink(client); - } + if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) { + int brw_size = exp_brw_size( + client->cl_import->imp_obd->obd_self_export); + + if (client->cl_import->imp_state == LUSTRE_IMP_FULL && + client->cl_avail_grant > brw_size) + return 1; + else + osc_update_next_shrink(client); + } return 0; } diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 6dfc652..98d6c37 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -1414,7 +1414,7 @@ do { \ OBD_CONNECT_RMT_CLIENT_FORCE | \ OBD_CONNECT_OSS_CAPA); \ spin_lock(&exp->exp_lock); \ - exp->exp_connect_flags = reply->ocd_connect_flags; \ + *exp_connect_flags_ptr(exp) = reply->ocd_connect_flags; \ spin_unlock(&exp->exp_lock); \ } while (0) @@ -1513,7 +1513,7 @@ static int ost_init_sec_level(struct ptlrpc_request *req) reply->ocd_connect_flags &= ~OBD_CONNECT_OSS_CAPA; spin_lock(&exp->exp_lock); - exp->exp_connect_flags = reply->ocd_connect_flags; + *exp_connect_flags_ptr(exp) = reply->ocd_connect_flags; spin_unlock(&exp->exp_lock); } break; @@ -2201,7 +2201,7 @@ int ost_handle(struct ptlrpc_request *req) RETURN(rc); if (req && req->rq_reqmsg && req->rq_export && - (req->rq_export->exp_connect_flags & OBD_CONNECT_JOBSTATS)) + (exp_connect_flags(req->rq_export) & OBD_CONNECT_JOBSTATS)) oti->oti_jobid = lustre_msg_get_jobid(req->rq_reqmsg); switch (lustre_msg_get_opc(req->rq_reqmsg)) { diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 1ae63c3..77653b7 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -834,10 +834,9 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, imp->imp_obd->obd_name); GOTO(out, rc = -ENODEV); } - old_connect_flags = exp->exp_connect_flags; - exp->exp_connect_flags = ocd->ocd_connect_flags; - imp->imp_obd->obd_self_export->exp_connect_flags = - ocd->ocd_connect_flags; + old_connect_flags = exp_connect_flags(exp); + exp->exp_connect_data = *ocd; + imp->imp_obd->obd_self_export->exp_connect_data = *ocd; class_export_put(exp); obd_import_event(imp->imp_obd, imp, IMP_EVENT_OCD); @@ -1093,12 +1092,12 @@ finish: imp->imp_connect_op == MGS_CONNECT) cli->cl_max_pages_per_rpc = 1; - /* Reset ns_connect_flags only for initial connect. It might be - * changed in while using FS and if we reset it in reconnect - * this leads to losing user settings done before such as - * disable lru_resize, etc. */ - if (old_connect_flags != exp->exp_connect_flags || - aa->pcaa_initial_connect) { + /* Reset ns_connect_flags only for initial connect. It might be + * changed in while using FS and if we reset it in reconnect + * this leads to losing user settings done before such as + * disable lru_resize, etc. */ + if (old_connect_flags != exp_connect_flags(exp) || + aa->pcaa_initial_connect) { CDEBUG(D_HA, "%s: Resetting ns_connect_flags to server " "flags: "LPX64"\n", imp->imp_obd->obd_name, ocd->ocd_connect_flags); diff --git a/lustre/quota/lquota_internal.h b/lustre/quota/lquota_internal.h index de3e294..1e53054 100644 --- a/lustre/quota/lquota_internal.h +++ b/lustre/quota/lquota_internal.h @@ -271,7 +271,7 @@ static inline void lqe_read_unlock(struct lquota_entry *lqe) /* minimum qunit size, 1K inode for metadata pool and 1MB for data pool */ #define LQUOTA_LEAST_QUNIT(type) \ - (type == LQUOTA_RES_MD ? (1 << 10) : toqb(PTLRPC_MAX_BRW_SIZE)) + (type == LQUOTA_RES_MD ? (1 << 10) : toqb(OFD_MAX_BRW_SIZE)) #define LQUOTA_OVER_FL(type) \ (type == USRQUOTA ? QUOTA_FL_OVER_USRQUOTA : QUOTA_FL_OVER_GRPQUOTA) diff --git a/lustre/quota/qsd_reint.c b/lustre/quota/qsd_reint.c index eefc3c1..ad2894f 100644 --- a/lustre/quota/qsd_reint.c +++ b/lustre/quota/qsd_reint.c @@ -197,7 +197,7 @@ static int qsd_reint_index(const struct lu_env *env, struct qsd_qtype_info *qqi, fid = global ? &qqi->qqi_fid : &qqi->qqi_slv_fid; /* let's do a 1MB bulk */ - npages = min_t(unsigned int, PTLRPC_MAX_BRW_SIZE, 1 << 20); + npages = min_t(unsigned int, OFD_MAX_BRW_SIZE, 1 << 20); npages /= CFS_PAGE_SIZE; /* allocate pages for bulk index read */ diff --git a/lustre/target/tgt_lastrcvd.c b/lustre/target/tgt_lastrcvd.c index b8da83f..259c470 100644 --- a/lustre/target/tgt_lastrcvd.c +++ b/lustre/target/tgt_lastrcvd.c @@ -455,7 +455,7 @@ int tgt_last_commit_cb_add(struct thandle *th, struct lu_target *tgt, OBD_FREE_PTR(ccb); } - if ((exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0) + if (exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) /* report failure to force synchronous operation */ return -EPERM; @@ -535,7 +535,7 @@ int tgt_client_new(const struct lu_env *env, struct obd_export *exp) mutex_init(&ted->ted_lcd_lock); - if ((exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0) + if (exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) RETURN(0); /* the bitmap operations can handle cl_idx > sizeof(long) * 8, so @@ -599,7 +599,7 @@ int tgt_client_add(const struct lu_env *env, struct obd_export *exp, int idx) LASSERTF(idx >= 0, "%d\n", idx); if (!strcmp(ted->ted_lcd->lcd_uuid, tgt->lut_obd->obd_uuid.uuid) || - (exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0) + exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) RETURN(0); if (test_and_set_bit(idx, tgt->lut_client_bitmap)) { @@ -636,7 +636,7 @@ int tgt_client_del(const struct lu_env *env, struct obd_export *exp) /* XXX if lcd_uuid were a real obd_uuid, I could use obd_uuid_equals */ if (!strcmp((char *)ted->ted_lcd->lcd_uuid, (char *)tgt->lut_obd->obd_uuid.uuid) || - (exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0) + exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) RETURN(0); CDEBUG(D_INFO, "%s: del client at idx %u, off %lld, UUID '%s'\n",