Whamcloud - gitweb
LU-18162 mdc: convert Metadata Client to LU device
authorTimothy Day <timday@amazon.com>
Tue, 15 Apr 2025 17:38:09 +0000 (17:38 +0000)
committerOleg Drokin <green@linuxhacker.ru>
Fri, 13 Jun 2025 01:36:16 +0000 (21:36 -0400)
Convert MDC to use LU device init/fini rather
than the legacy OBD API.

Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: Ic48accf1104d2845707b44519c32c5ced56ae8ef

lustre/include/lustre_osc.h
lustre/mdc/mdc_dev.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_request.c
lustre/obdclass/lu_object.c
lustre/osc/osc_dev.c

index 44b763b..55027da 100644 (file)
@@ -595,14 +595,6 @@ bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
 bool osc_discard_cb(const struct lu_env *env, struct cl_io *io,
                    void **pvec, int count, void *cbdata);
 
-/* osc_dev.c */
-int osc_device_init(const struct lu_env *env, struct lu_device *d,
-                   const char *name, struct lu_device *next);
-struct lu_device *osc_device_fini(const struct lu_env *env,
-                                 struct lu_device *d);
-struct lu_device *osc_device_free(const struct lu_env *env,
-                                 struct lu_device *d);
-
 /* osc_object.c */
 int osc_object_init(const struct lu_env *env, struct lu_object *obj,
                    const struct lu_object_conf *conf);
index ba5719e..67a7451 100644 (file)
@@ -1676,21 +1676,36 @@ static const struct lu_device_operations mdc_lu_ops = {
        .ldo_recovery_complete = NULL,
 };
 
+static struct lu_device *mdc_device_free(const struct lu_env *env,
+                                        struct lu_device *lu)
+{
+       struct obd_device *obd = lu->ld_obd;
+       struct client_obd *cli = &obd->u.cli;
+       struct osc_device *osc = lu2osc_dev(lu);
+
+       LASSERT(cli->cl_mod_rpcs_in_flight == 0);
+       cl_device_fini(lu2cl_dev(lu));
+       osc_cleanup_common(obd);
+       OBD_FREE_PTR(osc);
+
+       return NULL;
+}
+
 static struct lu_device *mdc_device_alloc(const struct lu_env *env,
                                          struct lu_device_type *t,
                                          struct lustre_cfg *cfg)
 {
        struct lu_device *d;
-       struct osc_device *oc;
+       struct osc_device *osc;
        struct obd_device *obd;
        int rc;
 
-       OBD_ALLOC_PTR(oc);
-       if (oc == NULL)
+       OBD_ALLOC_PTR(osc);
+       if (osc == NULL)
                RETURN(ERR_PTR(-ENOMEM));
 
-       cl_device_init(&oc->osc_cl, t);
-       d = osc2lu_dev(oc);
+       cl_device_init(&osc->osc_cl, t);
+       d = osc2lu_dev(osc);
        d->ld_ops = &mdc_lu_ops;
 
        /* Setup MDC OBD */
@@ -1700,19 +1715,41 @@ static struct lu_device *mdc_device_alloc(const struct lu_env *env,
 
        rc = mdc_setup(obd, cfg);
        if (rc < 0) {
-               osc_device_free(env, d);
+               mdc_device_free(env, d);
                RETURN(ERR_PTR(rc));
        }
-       oc->osc_exp = obd->obd_self_export;
-       oc->osc_stats.os_init = ktime_get_real();
+       osc->osc_exp = obd->obd_self_export;
+       osc->osc_stats.os_init = ktime_get_real();
        RETURN(d);
 }
 
+static int mdc_device_init(const struct lu_env *env, struct lu_device *d,
+                          const char *name, struct lu_device *next)
+{
+       RETURN(0);
+}
+
+static struct lu_device *mdc_device_fini(const struct lu_env *env,
+                                        struct lu_device *lu)
+{
+       struct obd_device *obd = lu->ld_obd;
+
+       ENTRY;
+
+       osc_precleanup_common(obd);
+       mdc_changelog_cdev_finish(obd);
+       mdc_llog_finish(obd);
+       lprocfs_free_md_stats(obd);
+       ptlrpc_lprocfs_unregister_obd(obd);
+
+       RETURN(NULL);
+}
+
 static const struct lu_device_type_operations mdc_device_type_ops = {
        .ldto_device_alloc = mdc_device_alloc,
-       .ldto_device_free = osc_device_free,
-       .ldto_device_init = osc_device_init,
-       .ldto_device_fini = osc_device_fini
+       .ldto_device_free = mdc_device_free,
+       .ldto_device_init = mdc_device_init,
+       .ldto_device_fini = mdc_device_fini
 };
 
 struct lu_device_type mdc_device_type = {
index f412576..cfe1f00 100644 (file)
@@ -89,6 +89,7 @@ int mdc_resource_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
 int mdc_fid_alloc(const struct lu_env *env, struct obd_export *exp,
                  struct lu_fid *fid, struct md_op_data *op_data);
 int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg);
+void mdc_llog_finish(struct obd_device *obd);
 
 struct obd_client_handle;
 
index c131b53..6f98346 100644 (file)
@@ -46,8 +46,6 @@
 
 #define REQUEST_MINOR 244
 
-static int mdc_cleanup(struct obd_device *obd);
-
 static inline int mdc_queue_wait(struct ptlrpc_request *req)
 {
        struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
@@ -2989,7 +2987,7 @@ static int mdc_llog_init(struct obd_device *obd)
        RETURN(0);
 }
 
-static void mdc_llog_finish(struct obd_device *obd)
+void mdc_llog_finish(struct obd_device *obd)
 {
        struct llog_ctxt *ctxt;
 
@@ -3071,32 +3069,8 @@ static int mdc_init_ea_size(struct obd_export *exp, __u32 easize,
        RETURN(0);
 }
 
-static int mdc_precleanup(struct obd_device *obd)
-{
-       ENTRY;
-       osc_precleanup_common(obd);
-
-       mdc_changelog_cdev_finish(obd);
-       mdc_llog_finish(obd);
-       lprocfs_free_md_stats(obd);
-       ptlrpc_lprocfs_unregister_obd(obd);
-
-       RETURN(0);
-}
-
-static int mdc_cleanup(struct obd_device *obd)
-{
-       struct client_obd *cli = &obd->u.cli;
-
-       LASSERT(cli->cl_mod_rpcs_in_flight == 0);
-       return osc_cleanup_common(obd);
-}
-
 static const struct obd_ops mdc_obd_ops = {
        .o_owner            = THIS_MODULE,
-       .o_setup            = mdc_setup,
-       .o_precleanup       = mdc_precleanup,
-       .o_cleanup          = mdc_cleanup,
        .o_add_conn         = client_import_add_conn,
        .o_del_conn         = client_import_del_conn,
        .o_connect          = client_connect_import,
index 61b6a01..604dc94 100644 (file)
@@ -1335,15 +1335,23 @@ void lu_stack_fini(const struct lu_env *env, struct lu_device *top)
 
        lu_site_purge(env, site, ~0);
        for (scan = top; scan != NULL; scan = next) {
-               next = ldto_device_fini(env, scan);
+               if (strcmp(scan->ld_type->ldt_name, LUSTRE_MDC_NAME) == 0)
+                       next = NULL;
+               else
+                       next = ldto_device_fini(env, scan);
+
                lu_device_put(scan);
        }
 
        /* purge again. */
        lu_site_purge(env, site, ~0);
 
-       for (scan = top; scan != NULL; scan = next)
+       for (scan = top; scan != NULL; scan = next) {
+               if (strcmp(scan->ld_type->ldt_name, LUSTRE_MDC_NAME) == 0)
+                       break;
+
                next = ldto_device_free(env, scan);
+       }
 }
 EXPORT_SYMBOL(lu_stack_fini);
 
index c329fbe..1e8cf74 100644 (file)
@@ -149,22 +149,20 @@ static const struct lu_device_operations osc_lu_ops = {
         .ldo_recovery_complete = NULL
 };
 
-int osc_device_init(const struct lu_env *env, struct lu_device *d,
-                   const char *name, struct lu_device *next)
+static int osc_device_init(const struct lu_env *env, struct lu_device *d,
+                          const char *name, struct lu_device *next)
 {
         RETURN(0);
 }
-EXPORT_SYMBOL(osc_device_init);
 
-struct lu_device *osc_device_fini(const struct lu_env *env,
-                                 struct lu_device *d)
+static struct lu_device *osc_device_fini(const struct lu_env *env,
+                                        struct lu_device *d)
 {
        return NULL;
 }
-EXPORT_SYMBOL(osc_device_fini);
 
-struct lu_device *osc_device_free(const struct lu_env *env,
-                                 struct lu_device *d)
+static struct lu_device *osc_device_free(const struct lu_env *env,
+                                        struct lu_device *d)
 {
        struct osc_device *oc = lu2osc_dev(d);
 
@@ -172,7 +170,6 @@ struct lu_device *osc_device_free(const struct lu_env *env,
        OBD_FREE_PTR(oc);
        return NULL;
 }
-EXPORT_SYMBOL(osc_device_free);
 
 static struct lu_device *osc_device_alloc(const struct lu_env *env,
                                          struct lu_device_type *t,