From e34950d29f1168a8a85f26e862eaec888b94350e Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Sun, 8 May 2022 18:09:31 -0400 Subject: [PATCH] LU-8837 lustre: make uapi...lustre_disk.h unnecessary on client uapi/linux/lustre/lustre_disk.h doesn't contain anything that is needed for client-only code, but that code doesn't compile with the file excluded, largely due to dependency on IS_SERVER() and related macros. So for client-only code provide stubs for IS_SERVER() and related macros, and don't include the uapi...lustre_disk.h file. This will cause some code to now be compiled-out on client-only, and allows some #ifdefs to be removed. A few function need to be protected with #ifdef HAVE_SERVER_SUPPORT, and llog_server.o needs to be disabled for client-only compiles. Signed-off-by: Mr NeilBrown Change-Id: I19c5b1612108e448f8b6a1fe3d3a448aa4abdd2a Reviewed-on: https://review.whamcloud.com/41994 Reviewed-by: James Simmons Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/lustre_disk.h | 21 ++++- lustre/mgc/mgc_internal.h | 8 ++ lustre/mgc/mgc_request.c | 220 ++++++++++++++++++++++++------------------- lustre/obdclass/obd_mount.c | 2 + lustre/ptlrpc/Makefile.in | 9 +- 5 files changed, 156 insertions(+), 104 deletions(-) diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 7e7de02..cad22a3 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -47,18 +47,31 @@ #include #include #include -#include -#include #if !defined(CONFIG_LL_ENCRYPTION) && defined(HAVE_LUSTRE_CRYPTO) #include #endif - +#include +#ifdef HAVE_SERVER_SUPPORT +#include #define IS_MDT(data) ((data)->lsi_flags & LDD_F_SV_TYPE_MDT) #define IS_OST(data) ((data)->lsi_flags & LDD_F_SV_TYPE_OST) #define IS_MGS(data) ((data)->lsi_flags & LDD_F_SV_TYPE_MGS) -#define IS_SERVER(data) ((data)->lsi_flags & (LDD_F_SV_TYPE_MGS | \ +#define IS_SERVER(data) ((data) && \ + (data)->lsi_flags & (LDD_F_SV_TYPE_MGS | \ LDD_F_SV_TYPE_MDT | \ LDD_F_SV_TYPE_OST)) +#else +#define LDD_F_SV_TYPE_MDT 0x0001 +#define LDD_F_SV_TYPE_OST 0x0002 +#define LDD_F_SV_TYPE_MGS 0x0004 +#define LDD_F_SV_ALL 0x0008 + +#define IS_MDT(data) (0) +#define IS_OST(data) (0) +#define IS_MGS(data) (0) +#define IS_SERVER(data) (0) +#endif + #define MT_STR(data) mt_str((data)->ldd_mount_type) /****************** mount command *********************/ diff --git a/lustre/mgc/mgc_internal.h b/lustre/mgc/mgc_internal.h index 2289972..8429a32 100644 --- a/lustre/mgc/mgc_internal.h +++ b/lustre/mgc/mgc_internal.h @@ -63,12 +63,20 @@ static inline bool cld_is_recover(struct config_llog_data *cld) static inline bool cld_is_nodemap(struct config_llog_data *cld) { +#ifdef HAVE_SERVER_SUPPORT return cld->cld_type == MGS_CFG_T_NODEMAP; +#else + return false; +#endif } static inline bool cld_is_barrier(struct config_llog_data *cld) { +#ifdef HAVE_SERVER_SUPPORT return cld->cld_type == MGS_CFG_T_BARRIER; +#else + return false; +#endif } #endif /* _MGC_INTERNAL_H */ diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index e396ad5..4a98226 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -262,15 +262,14 @@ static struct config_llog_data *config_recover_log_add(struct obd_device *obd, struct super_block *sb) { struct config_llog_instance lcfg = *cfg; - struct lustre_sb_info *lsi = s2lsi(sb); struct config_llog_data *cld; char logname[32]; - if (IS_OST(lsi)) + if (IS_OST(s2lsi(sb))) return NULL; /* for osp-on-ost, see lustre_start_osp() */ - if (IS_MDT(lsi) && lcfg.cfg_instance) + if (IS_MDT(s2lsi(sb)) && lcfg.cfg_instance) return NULL; /* We have to use different llog for clients and MDTs for DNE, @@ -278,7 +277,7 @@ static struct config_llog_data *config_recover_log_add(struct obd_device *obd, */ LASSERT(strlen(fsname) < sizeof(logname) / 2); strncpy(logname, fsname, sizeof(logname)); - if (IS_SERVER(lsi)) { /* mdt */ + if (IS_SERVER(s2lsi(sb))) { /* mdt */ LASSERT(lcfg.cfg_instance == 0); lcfg.cfg_instance = ll_get_cfg_instance(sb); strncat(logname, "-mdtir", sizeof(logname)); @@ -738,6 +737,7 @@ static void mgc_requeue_add(struct config_llog_data *cld) } /********************** class fns **********************/ +#ifdef HAVE_SERVER_SUPPORT static int mgc_local_llog_init(const struct lu_env *env, struct obd_device *obd, struct obd_device *disk) @@ -863,6 +863,7 @@ static int mgc_fs_cleanup(const struct lu_env *env, struct obd_device *obd) RETURN(0); } +#endif /* HAVE_SERVER_SUPPORT */ static int mgc_llog_init(const struct lu_env *env, struct obd_device *obd) { @@ -1112,12 +1113,11 @@ static int mgc_enqueue(struct obd_export *exp, enum ldlm_type type, req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, 0); ptlrpc_request_set_replen(req); - /* check if this is server or client */ - if (cld->cld_cfg.cfg_sb) { - struct lustre_sb_info *lsi = s2lsi(cld->cld_cfg.cfg_sb); - if (lsi && IS_SERVER(lsi)) - short_limit = 1; - } + /* check if this is server or client */ + if (cld->cld_cfg.cfg_sb && + IS_SERVER(s2lsi(cld->cld_cfg.cfg_sb))) + short_limit = 1; + /* Limit how long we will wait for the enqueue to complete */ req->rq_delay_limit = short_limit ? 5 : MGC_ENQUEUE_LIMIT; rc = ldlm_cli_enqueue(exp, &req, &einfo, &cld->cld_resid, NULL, flags, @@ -1149,26 +1149,27 @@ static void mgc_notify_active(struct obd_device *unused) /* TODO: Help the MGS rebuild nidtbl. -jay */ } +#ifdef HAVE_SERVER_SUPPORT /* Send target_reg message to MGS */ static int mgc_target_register(struct obd_export *exp, - struct mgs_target_info *mti) + struct mgs_target_info *mti) { - struct ptlrpc_request *req; - struct mgs_target_info *req_mti, *rep_mti; - int rc; - ENTRY; + struct ptlrpc_request *req; + struct mgs_target_info *req_mti, *rep_mti; + int rc; + ENTRY; - req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), - &RQF_MGS_TARGET_REG, LUSTRE_MGS_VERSION, - MGS_TARGET_REG); - if (req == NULL) - RETURN(-ENOMEM); + req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), + &RQF_MGS_TARGET_REG, LUSTRE_MGS_VERSION, + MGS_TARGET_REG); + if (req == NULL) + RETURN(-ENOMEM); - req_mti = req_capsule_client_get(&req->rq_pill, &RMF_MGS_TARGET_INFO); - if (!req_mti) { - ptlrpc_req_finished(req); - RETURN(-ENOMEM); - } + req_mti = req_capsule_client_get(&req->rq_pill, &RMF_MGS_TARGET_INFO); + if (!req_mti) { + ptlrpc_req_finished(req); + RETURN(-ENOMEM); + } memcpy(req_mti, mti, sizeof(*req_mti)); ptlrpc_request_set_replen(req); @@ -1198,6 +1199,7 @@ static int mgc_target_register(struct obd_export *exp, RETURN(rc); } +#endif /* HAVE_SERVER_SUPPORT */ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, u32 keylen, void *key, @@ -1229,17 +1231,19 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, RETURN(0); } - /* FIXME move this to mgc_process_config */ - if (KEY_IS(KEY_REGISTER_TARGET)) { - struct mgs_target_info *mti; - if (vallen != sizeof(struct mgs_target_info)) - RETURN(-EINVAL); - mti = (struct mgs_target_info *)val; - CDEBUG(D_MGC, "register_target %s %#x\n", - mti->mti_svname, mti->mti_flags); - rc = mgc_target_register(exp, mti); - RETURN(rc); - } +#ifdef HAVE_SERVER_SUPPORT + /* FIXME move this to mgc_process_config */ + if (KEY_IS(KEY_REGISTER_TARGET)) { + struct mgs_target_info *mti; + + if (vallen != sizeof(struct mgs_target_info)) + RETURN(-EINVAL); + mti = (struct mgs_target_info *)val; + CDEBUG(D_MGC, "register_target %s %#x\n", + mti->mti_svname, mti->mti_flags); + rc = mgc_target_register(exp, mti); + RETURN(rc); + } if (KEY_IS(KEY_SET_FS)) { struct super_block *sb = (struct super_block *)val; @@ -1255,6 +1259,7 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = mgc_fs_cleanup(env, exp->exp_obd); RETURN(rc); } +#endif if (KEY_IS(KEY_MGSSEC)) { struct client_obd *cli = &exp->exp_obd->u.cli; struct sptlrpc_flavor flvr; @@ -1373,7 +1378,6 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, void *data, int datalen, bool mne_swab) { struct config_llog_instance *cfg = &cld->cld_cfg; - struct lustre_sb_info *lsi = s2lsi(cfg->cfg_sb); struct mgs_nidtbl_entry *entry; struct lustre_cfg *lcfg; struct lustre_cfg_bufs bufs; @@ -1393,12 +1397,14 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, /* get dynamic nids setting */ dynamic_nids = mgc->obd_dynamic_nids; - if (!IS_SERVER(lsi)) { + if (!IS_SERVER(s2lsi(cfg->cfg_sb))) { pos = snprintf(inst, sizeof(inst), "%016lx", cfg->cfg_instance); if (pos >= PAGE_SIZE) return -E2BIG; #ifdef HAVE_SERVER_SUPPORT } else { + struct lustre_sb_info *lsi = s2lsi(cfg->cfg_sb); + LASSERT(IS_MDT(lsi)); rc = server_name2svname(lsi->lsi_svname, inst, NULL, sizeof(inst)); @@ -1822,6 +1828,7 @@ out: return rc; } +#ifdef HAVE_SERVER_SUPPORT static int mgc_barrier_glimpse_ast(struct ldlm_lock *lock, void *data) { struct config_llog_data *cld = lock->l_ast_data; @@ -1880,36 +1887,14 @@ out: return rc; } -/* local_only means it cannot get remote llogs */ -static int mgc_process_cfg_log(struct obd_device *mgc, - struct config_llog_data *cld, int local_only) +static int +mgc_process_server_cfg_log(struct lu_env *env, struct llog_ctxt **ctxt, + struct lustre_sb_info *lsi, struct obd_device *mgc, + struct config_llog_data *cld, int local_only) { - struct llog_ctxt *ctxt, *lctxt = NULL; - struct client_obd *cli = &mgc->u.cli; - struct lustre_sb_info *lsi = NULL; - int rc = 0; - struct lu_env *env; - - ENTRY; - - LASSERT(cld); - LASSERT(mutex_is_locked(&cld->cld_lock)); - - if (cld->cld_cfg.cfg_sb) - lsi = s2lsi(cld->cld_cfg.cfg_sb); - - OBD_ALLOC_PTR(env); - if (env == NULL) - RETURN(-ENOMEM); - - rc = lu_env_init(env, LCT_MG_THREAD); - if (rc) - GOTO(out_free, rc); - - ctxt = llog_get_context(mgc, LLOG_CONFIG_REPL_CTXT); - LASSERT(ctxt); - - lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT); + struct llog_ctxt *lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT); + struct client_obd *cli = &mgc->u.cli; + int rc = 0; /* Copy the setup log locally if we can. Don't mess around if we're * running an MGS though (logs are already local). */ @@ -1922,14 +1907,14 @@ static int mgc_process_cfg_log(struct obd_device *mgc, CDEBUG(D_INFO, "%s: copy local log %s\n", mgc->obd_name, cld->cld_logname); - rc = mgc_llog_local_copy(env, mgc, ctxt, lctxt, + rc = mgc_llog_local_copy(env, mgc, *ctxt, lctxt, cld->cld_logname); if (!rc) lsi->lsi_flags &= ~LDD_F_NO_LOCAL_LOGS; } if (local_only || rc) { - if (unlikely(lsi->lsi_flags & LDD_F_NO_LOCAL_LOGS) - || rc) { + if (unlikely(lsi->lsi_flags & LDD_F_NO_LOCAL_LOGS) || + rc) { CWARN("%s: local log %s are not valid and/or remote logs are not accessbile rc = %d\n", mgc->obd_name, cld->cld_logname, rc); GOTO(out_pop, rc = -EIO); @@ -1948,12 +1933,11 @@ static int mgc_process_cfg_log(struct obd_device *mgc, /* Now, whether we copied or not, start using the local llog. * If we failed to copy, we'll start using whatever the old * log has. */ - llog_ctxt_put(ctxt); - ctxt = lctxt; + llog_ctxt_put(*ctxt); + *ctxt = lctxt; lctxt = NULL; - } else { - if (local_only) /* no local log at client side */ - GOTO(out_pop, rc = -EIO); + } else if (local_only) { /* no local log at client side */ + GOTO(out_pop, rc = -EIO); } rc = -EAGAIN; @@ -1970,8 +1954,51 @@ static int mgc_process_cfg_log(struct obd_device *mgc, &cld->cld_cfg); llog_ctxt_put(rctxt); } +out_pop: + if (lctxt) + __llog_ctxt_put(env, lctxt); + return rc; +} +#else /* !HAVE_SERVER_SUPPORT */ +#define mgc_barrier_glimpse_ast NULL +#endif /* HAVE_SERVER_SUPPORT */ + +/* local_only means it cannot get remote llogs */ +static int mgc_process_cfg_log(struct obd_device *mgc, + struct config_llog_data *cld, int local_only) +{ + struct llog_ctxt *ctxt; + struct lustre_sb_info *lsi = NULL; + int rc = 0; + struct lu_env *env; + ENTRY; + LASSERT(cld); + LASSERT(mutex_is_locked(&cld->cld_lock)); + + if (cld->cld_cfg.cfg_sb) + lsi = s2lsi(cld->cld_cfg.cfg_sb); + + OBD_ALLOC_PTR(env); + if (!env) + RETURN(-ENOMEM); + + rc = lu_env_init(env, LCT_MG_THREAD); + if (rc) + GOTO(out_free, rc); + + ctxt = llog_get_context(mgc, LLOG_CONFIG_REPL_CTXT); + LASSERT(ctxt); +#ifdef HAVE_SERVER_SUPPORT + rc = mgc_process_server_cfg_log(env, &ctxt, lsi, mgc, cld, + local_only); + if (rc == -EIO && local_only) + GOTO(out_pop, rc); if (rc && rc != -ENOENT) +#else + if (local_only) + GOTO(out_pop, rc); +#endif rc = class_config_parse_llog(env, ctxt, cld->cld_logname, &cld->cld_cfg); @@ -1987,9 +2014,6 @@ static int mgc_process_cfg_log(struct obd_device *mgc, out_pop: __llog_ctxt_put(env, ctxt); - if (lctxt) - __llog_ctxt_put(env, lctxt); - lu_env_fini(env); out_free: OBD_FREE_PTR(env); @@ -2170,25 +2194,27 @@ static int mgc_process_config(struct obd_device *obd, size_t len, void *buf) ENTRY; switch(lcfg->lcfg_command) { - case LCFG_LOV_ADD_OBD: { - /* Overloading this cfg command: register a new target */ - struct mgs_target_info *mti; - - if (LUSTRE_CFG_BUFLEN(lcfg, 1) != - sizeof(struct mgs_target_info)) - GOTO(out, rc = -EINVAL); - - mti = (struct mgs_target_info *)lustre_cfg_buf(lcfg, 1); - CDEBUG(D_MGC, "add_target %s %#x\n", - mti->mti_svname, mti->mti_flags); - rc = mgc_target_register(obd->u.cli.cl_mgc_mgsexp, mti); - break; - } - case LCFG_LOV_DEL_OBD: - /* Unregister has no meaning at the moment. */ - CERROR("lov_del_obd unimplemented\n"); - rc = -ENOSYS; - break; +#ifdef HAVE_SERVER_SUPPORT + case LCFG_LOV_ADD_OBD: { + /* Overloading this cfg command: register a new target */ + struct mgs_target_info *mti; + + if (LUSTRE_CFG_BUFLEN(lcfg, 1) != + sizeof(struct mgs_target_info)) + GOTO(out, rc = -EINVAL); + + mti = lustre_cfg_buf(lcfg, 1); + CDEBUG(D_MGC, "add_target %s %#x\n", + mti->mti_svname, mti->mti_flags); + rc = mgc_target_register(obd->u.cli.cl_mgc_mgsexp, mti); + break; + } + case LCFG_LOV_DEL_OBD: + /* Unregister has no meaning at the moment. */ + CERROR("lov_del_obd unimplemented\n"); + rc = -EINVAL; + break; +#endif case LCFG_SPTLRPC_CONF: { rc = sptlrpc_process_config(lcfg); break; diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index bb4dd25..bbd5343 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -801,6 +801,7 @@ int server_name2fsname(const char *svname, char *fsname, const char **endptr) } EXPORT_SYMBOL(server_name2fsname); +#ifdef HAVE_SERVER_SUPPORT /** * Get service name (svname) from string * rc < 0 on error @@ -826,6 +827,7 @@ int server_name2svname(const char *label, char *svname, const char **endptr, return 0; } EXPORT_SYMBOL(server_name2svname); +#endif /* HAVE_SERVER_SUPPORT */ /** * check server name is OST. diff --git a/lustre/ptlrpc/Makefile.in b/lustre/ptlrpc/Makefile.in index 2688d8c..9f53bd8 100644 --- a/lustre/ptlrpc/Makefile.in +++ b/lustre/ptlrpc/Makefile.in @@ -14,10 +14,11 @@ target_objs += $(TARGET)tgt_handler.o $(TARGET)out_handler.o target_objs += $(TARGET)out_lib.o $(TARGET)update_trans.o target_objs += $(TARGET)update_records.o $(TARGET)update_recovery.o target_objs += $(TARGET)tgt_grant.o $(TARGET)tgt_fmd.o +target_objs += $(TARGET)barrier.o ptlrpc_objs := client.o recover.o connection.o niobuf.o pack_generic.o ptlrpc_objs += events.o ptlrpc_module.o service.o pinger.o -ptlrpc_objs += llog_net.o llog_client.o llog_server.o import.o ptlrpcd.o +ptlrpc_objs += llog_net.o llog_client.o import.o ptlrpcd.o ptlrpc_objs += pers.o lproc_ptlrpc.o wiretest.o layout.o ptlrpc_objs += sec.o sec_ctx.o sec_bulk.o sec_gc.o sec_config.o sec_lproc.o ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o nrs_delay.o heap.o @@ -29,8 +30,9 @@ nodemap_objs := nodemap_handler.o nodemap_lproc.o nodemap_range.o nodemap_objs += nodemap_idmap.o nodemap_rbtree.o nodemap_member.o nodemap_objs += nodemap_storage.o -ptlrpc-objs := $(ldlm_objs) $(ptlrpc_objs) $(TARGET)barrier.o -@SERVER_TRUE@ptlrpc-objs += $(target_objs) $(nodemap_objs) $(nrs_server_objs) pack_server.o +ptlrpc-objs := $(ldlm_objs) $(ptlrpc_objs) +@SERVER_TRUE@ptlrpc-objs += $(target_objs) $(nodemap_objs) $(nrs_server_objs) +@SERVER_TRUE@ptlrpc-objs += pack_server.o llog_server.o @GSS_TRUE@obj-m += gss/ @@ -55,6 +57,7 @@ EXTRA_DIST := $(ptlrpc_objs:.o=.c) ptlrpc_internal.h EXTRA_DIST += $(nodemap_objs:.o=.c) nodemap_internal.h heap.h EXTRA_DIST += $(nrs_server_objs:.o=.c) EXTRA_DIST += pack_server.c +EXTRA_DIST += llog_server.c EXTRA_PRE_CFLAGS := -I@LUSTRE@/ldlm -I@LUSTRE@/target -- 1.8.3.1