From fab404836d9eff7cfe61dc280a7854608894f645 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 6 Jun 2022 10:48:24 -0400 Subject: [PATCH] LU-12514 target: move server mount code to target layer Currently the server mount code for lustre_tgt is all in obdclass. If we change the stack to initialize the LNet / ptlrpc layer after mounting then we will end up with modular circular dependencies. To avoid this move all the lustre_tgt mounting code to the target layer. This way the mounting code can use both ptlrpc and obdclass module routiens. Also include MODULE_ALAIS("lustre_tgt") so mount -t lustre_tgt will load ptlrpc which contains the target layer. Change-Id: I392602e8fd18d001cb97b05b909c366ba5b8fa82 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/47160 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/include/obd_class.h | 2 -- lustre/obdclass/Makefile.in | 2 -- lustre/obdclass/class_obd.c | 13 ------------ lustre/obdclass/genops.c | 2 ++ lustre/obdclass/llog_swab.c | 2 ++ lustre/obdclass/obd_config.c | 3 +++ lustre/obdclass/obd_mount.c | 1 + lustre/ptlrpc/Makefile.in | 2 +- lustre/ptlrpc/ptlrpc_internal.h | 22 +-------------------- lustre/ptlrpc/ptlrpc_module.c | 23 +++++++++++++--------- lustre/target/Makefile.am | 3 ++- lustre/target/tgt_internal.h | 2 ++ lustre/target/tgt_main.c | 8 ++++++++ .../obd_mount_server.c => target/tgt_mount.c} | 0 14 files changed, 36 insertions(+), 49 deletions(-) rename lustre/{obdclass/obd_mount_server.c => target/tgt_mount.c} (100%) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 30782c4..4ca1dc6 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1832,8 +1832,6 @@ void lustre_deregister_lwp_item(struct obd_export **exp); struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx); void lustre_notify_lwp_list(struct obd_export *exp); int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx); -int lustre_tgt_register_fs(void); -void lustre_tgt_unregister_fs(void); #endif /* HAVE_SERVER_SUPPORT */ int lustre_check_exclusion(struct super_block *sb, char *svname); diff --git a/lustre/obdclass/Makefile.in b/lustre/obdclass/Makefile.in index afb99fc..d51e089 100644 --- a/lustre/obdclass/Makefile.in +++ b/lustre/obdclass/Makefile.in @@ -21,7 +21,6 @@ obdclass-all-objs += range_lock.o interval_tree.o @SERVER_TRUE@obdclass-all-objs += lprocfs_status_server.o @SERVER_TRUE@obdclass-all-objs += lu_ucred.o @SERVER_TRUE@obdclass-all-objs += md_attrs.o -@SERVER_TRUE@obdclass-all-objs += obd_mount_server.o @SERVER_TRUE@obdclass-all-objs += obdo_server.o @SERVER_TRUE@obdclass-all-objs += scrub.o @@ -39,7 +38,6 @@ EXTRA_DIST += range_lock.c interval_tree.c @SERVER_FALSE@EXTRA_DIST += lprocfs_status_server.c @SERVER_FALSE@EXTRA_DIST += lu_ucred.c @SERVER_FALSE@EXTRA_DIST += md_attrs.c -@SERVER_FALSE@EXTRA_DIST += obd_mount_server.c @SERVER_FALSE@EXTRA_DIST += obdo_server.c @SERVER_FALSE@EXTRA_DIST += scrub.c diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index f0c6118..135d188 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -747,14 +747,6 @@ static int __init obdclass_init(void) err = lu_ucred_global_init(); if (err != 0) goto cleanup_dt_global; - - err = lustre_tgt_register_fs(); - if (err && err != -EBUSY) { - /* Don't fail if server code also registers "lustre_tgt" */ - CERROR("obdclass: register fstype 'lustre_tgt' failed: rc = %d\n", - err); - goto cleanup_lu_ucred_global; - } #endif /* HAVE_SERVER_SUPPORT */ /* simulate a late OOM situation now to require all @@ -769,10 +761,6 @@ static int __init obdclass_init(void) cleanup_all: #ifdef HAVE_SERVER_SUPPORT - /* fake error but filesystem has been registered */ - lustre_tgt_unregister_fs(); - -cleanup_lu_ucred_global: lu_ucred_global_fini(); cleanup_dt_global: @@ -849,7 +837,6 @@ static void __exit obdclass_exit(void) misc_deregister(&obd_psdev); #ifdef HAVE_SERVER_SUPPORT - lustre_tgt_unregister_fs(); lu_ucred_global_fini(); dt_global_fini(); #endif /* HAVE_SERVER_SUPPORT */ diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 5f3edde..8cc3a7c 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -146,6 +146,7 @@ struct obd_type *class_get_type(const char *name) } return type; } +EXPORT_SYMBOL(class_get_type); void class_put_type(struct obd_type *type) { @@ -153,6 +154,7 @@ void class_put_type(struct obd_type *type) module_put(type->typ_dt_ops->o_owner); atomic_dec(&type->typ_refcnt); } +EXPORT_SYMBOL(class_put_type); static void class_sysfs_release(struct kobject *kobj) { diff --git a/lustre/obdclass/llog_swab.c b/lustre/obdclass/llog_swab.c index 67c0ce6..79aa160 100644 --- a/lustre/obdclass/llog_swab.c +++ b/lustre/obdclass/llog_swab.c @@ -421,6 +421,7 @@ void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) print_lustre_cfg(lcfg); EXIT; } +EXPORT_SYMBOL(lustre_swab_lustre_cfg); /* used only for compatibility with old on-disk cfg_marker data */ struct cfg_marker32 { @@ -486,3 +487,4 @@ void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size) EXIT; } +EXPORT_SYMBOL(lustre_swab_cfg_marker); diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 6f49fc9..92fe5d8 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -520,6 +520,7 @@ int class_match_nid(char *buf, char *key, lnet_nid_t nid) } return rc; } +EXPORT_SYMBOL(class_match_nid); int class_match_net(char *buf, char *key, __u32 net) { @@ -539,6 +540,7 @@ int class_match_net(char *buf, char *key, __u32 net) } return rc; } +EXPORT_SYMBOL(class_match_net); char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index) { @@ -988,6 +990,7 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg) RETURN(rc); } +EXPORT_SYMBOL(class_add_conn); /** Remove a failover NID location. */ static int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg) diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index bbd5343..cfa40d3 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -202,6 +202,7 @@ int lustre_start_simple(char *obdname, char *type, char *uuid, } return rc; } +EXPORT_SYMBOL(lustre_start_simple); static DEFINE_MUTEX(mgc_start_lock); diff --git a/lustre/ptlrpc/Makefile.in b/lustre/ptlrpc/Makefile.in index 9f53bd8..82f2e10 100644 --- a/lustre/ptlrpc/Makefile.in +++ b/lustre/ptlrpc/Makefile.in @@ -14,7 +14,7 @@ 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 +target_objs += $(TARGET)tgt_mount.o $(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 diff --git a/lustre/ptlrpc/ptlrpc_internal.h b/lustre/ptlrpc/ptlrpc_internal.h index 399ff28..d85a79b 100644 --- a/lustre/ptlrpc/ptlrpc_internal.h +++ b/lustre/ptlrpc/ptlrpc_internal.h @@ -331,27 +331,7 @@ int tgt_mod_init(void); void tgt_mod_exit(void); int nodemap_mod_init(void); void nodemap_mod_exit(void); -#else /* HAVE_SERVER_SUPPORT */ -static inline int tgt_mod_init(void) -{ - return 0; -} - -static inline void tgt_mod_exit(void) -{ - return; -} - -static inline int nodemap_mod_init(void) -{ - return 0; -} - -static inline void nodemap_mod_exit(void) -{ - return; -} -#endif /* !HAVE_SERVER_SUPPORT */ +#endif /* HAVE_SERVER_SUPPORT */ static inline void ptlrpc_reqset_put(struct ptlrpc_request_set *set) { diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c index abde1f2..c21fa62 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -59,13 +59,9 @@ static __init int ptlrpc_init(void) if (rc) RETURN(rc); - rc = tgt_mod_init(); - if (rc) - GOTO(err_layout, rc); - rc = ptlrpc_hr_init(); if (rc) - GOTO(err_tgt, rc); + GOTO(err_layout, rc); rc = ptlrpc_request_cache_init(); if (rc) @@ -95,13 +91,22 @@ static __init int ptlrpc_init(void) if (rc) GOTO(err_sptlrpc, rc); - rc = nodemap_mod_init(); +#ifdef HAVE_SERVER_SUPPORT + rc = tgt_mod_init(); if (rc) GOTO(err_nrs, rc); + rc = nodemap_mod_init(); + if (rc) + GOTO(err_tgt, rc); +#endif RETURN(0); +#ifdef HAVE_SERVER_SUPPORT +err_tgt: + tgt_mod_exit(); err_nrs: ptlrpc_nrs_fini(); +#endif err_sptlrpc: sptlrpc_fini(); err_ldlm: @@ -116,8 +121,6 @@ err_cache: ptlrpc_request_cache_fini(); err_hr: ptlrpc_hr_fini(); -err_tgt: - tgt_mod_exit(); err_layout: req_layout_fini(); return rc; @@ -125,7 +128,10 @@ err_layout: static void __exit ptlrpc_exit(void) { +#ifdef HAVE_SERVER_SUPPORT nodemap_mod_exit(); + tgt_mod_exit(); +#endif ptlrpc_nrs_fini(); sptlrpc_fini(); ldlm_exit(); @@ -134,7 +140,6 @@ static void __exit ptlrpc_exit(void) ptlrpc_request_cache_fini(); ptlrpc_hr_fini(); ptlrpc_connection_fini(); - tgt_mod_exit(); req_layout_fini(); } diff --git a/lustre/target/Makefile.am b/lustre/target/Makefile.am index a8165a9..2dedb56 100644 --- a/lustre/target/Makefile.am +++ b/lustre/target/Makefile.am @@ -32,7 +32,8 @@ MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ EXTRA_DIST = tgt_main.c tgt_lastrcvd.c tgt_handler.c tgt_internal.h \ - tgt_grant.c out_handler.c out_lib.c barrier.c tgt_fmd.c + tgt_grant.c out_handler.c out_lib.c barrier.c tgt_fmd.c \ + tgt_mount.c EXTRA_DIST += update_trans.c EXTRA_DIST += update_records.c EXTRA_DIST += update_recovery.c diff --git a/lustre/target/tgt_internal.h b/lustre/target/tgt_internal.h index 39fb410..b5ab975 100644 --- a/lustre/target/tgt_internal.h +++ b/lustre/target/tgt_internal.h @@ -282,6 +282,8 @@ int top_trans_create_tmt(const struct lu_env *env, struct top_thandle *top_th); void tgt_cancel_slc_locks(struct lu_target *tgt, __u64 transno); +int lustre_tgt_register_fs(void); +void lustre_tgt_unregister_fs(void); void barrier_init(void); void barrier_fini(void); diff --git a/lustre/target/tgt_main.c b/lustre/target/tgt_main.c index 76ccece..b40d466 100644 --- a/lustre/target/tgt_main.c +++ b/lustre/target/tgt_main.c @@ -824,6 +824,12 @@ int tgt_mod_init(void) if (result != 0) RETURN(result); + result = lustre_tgt_register_fs(); + if (result != 0) { + lu_kmem_fini(tgt_caches); + RETURN(result); + } + tgt_page_to_corrupt = alloc_page(GFP_KERNEL); tgt_key_init_generic(&tgt_thread_key, NULL); @@ -848,6 +854,8 @@ void tgt_mod_exit(void) lu_context_key_degister(&tgt_session_key); update_info_fini(); + lustre_tgt_unregister_fs(); + lu_kmem_fini(tgt_caches); } diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/target/tgt_mount.c similarity index 100% rename from lustre/obdclass/obd_mount_server.c rename to lustre/target/tgt_mount.c -- 1.8.3.1