Whamcloud - gitweb
LU-18162 obdclass: init LU device after alloc 84/58784/5
authorTimothy Day <timday@amazon.com>
Mon, 14 Apr 2025 19:03:18 +0000 (19:03 +0000)
committerOleg Drokin <green@whamcloud.com>
Fri, 2 May 2025 02:20:39 +0000 (02:20 +0000)
During obd_setup, ldto_device_alloc will be called if it
is defined. Initialize each lu device after it is allocated.
This isn't currently used by any existing LU device. This is
intended for future LU device conversions.

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I859e467971db4335ae98fbc57643be8e1a261694
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58784
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/obd_class.h

index e08b39c..c4d3418 100644 (file)
@@ -575,6 +575,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
        ldt = type->typ_lu;
        if (ldt != NULL) {
                struct lu_context session_ctx;
+               struct lu_device *dev;
                struct lu_env env;
 
                lu_context_init(&session_ctx, LCT_SESSION | LCT_SERVER_SESSION);
@@ -583,21 +584,22 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
 
                rc = lu_env_init(&env, ldt->ldt_ctx_tags);
                if (rc == 0) {
-                       struct lu_device *dev;
                        env.le_ses = &session_ctx;
                        dev = ldto_device_alloc(&env, ldt, cfg);
-                       lu_env_fini(&env);
                        if (!IS_ERR(dev)) {
                                obd->obd_lu_dev = dev;
                                dev->ld_obd = obd;
+                               dev->ld_type = ldt;
 #ifdef HAVE_SERVER_SUPPORT
                                if (lu_device_is_dt(dev) &&
                                    lu2dt_dev(dev)->dd_rdonly)
                                        obd->obd_read_only = 1;
 #endif
-                               rc = 0;
-                       } else
+                               rc = ldto_device_init(&env, dev, ldt->ldt_name, NULL);
+                       } else {
                                rc = PTR_ERR(dev);
+                       }
+                       lu_env_fini(&env);
                }
                lu_context_exit(&session_ctx);
                lu_context_fini(&session_ctx);