Whamcloud - gitweb
LU-12514 target: move server mount code to target layer 60/47160/6
authorJames Simmons <jsimmons@infradead.org>
Mon, 6 Jun 2022 14:48:24 +0000 (10:48 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 1 Sep 2022 05:53:08 +0000 (05:53 +0000)
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 <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/47160
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
14 files changed:
lustre/include/obd_class.h
lustre/obdclass/Makefile.in
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdclass/llog_swab.c
lustre/obdclass/obd_config.c
lustre/obdclass/obd_mount.c
lustre/ptlrpc/Makefile.in
lustre/ptlrpc/ptlrpc_internal.h
lustre/ptlrpc/ptlrpc_module.c
lustre/target/Makefile.am
lustre/target/tgt_internal.h
lustre/target/tgt_main.c
lustre/target/tgt_mount.c [moved from lustre/obdclass/obd_mount_server.c with 100% similarity]

index 30782c4..4ca1dc6 100644 (file)
@@ -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);
 
index afb99fc..d51e089 100644 (file)
@@ -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
 
index f0c6118..135d188 100644 (file)
@@ -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 */
index 5f3edde..8cc3a7c 100644 (file)
@@ -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)
 {
index 67c0ce6..79aa160 100644 (file)
@@ -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);
index 6f49fc9..92fe5d8 100644 (file)
@@ -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)
index bbd5343..cfa40d3 100644 (file)
@@ -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);
 
index 9f53bd8..82f2e10 100644 (file)
@@ -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
index 399ff28..d85a79b 100644 (file)
@@ -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)
 {
index abde1f2..c21fa62 100644 (file)
@@ -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();
 }
 
index a8165a9..2dedb56 100644 (file)
@@ -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
index 39fb410..b5ab975 100644 (file)
@@ -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);
 
index 76ccece..b40d466 100644 (file)
@@ -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);
 }