From: Timothy Day Date: Mon, 14 Apr 2025 19:03:18 +0000 (+0000) Subject: LU-18162 obdclass: init LU device after alloc X-Git-Tag: 2.16.55~61 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=973b5f1fed3d69b29ef5dcaa4fc283b07e85d13d;p=fs%2Flustre-release.git LU-18162 obdclass: init LU device after alloc 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 Change-Id: I859e467971db4335ae98fbc57643be8e1a261694 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58784 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger --- diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index e08b39c..c4d3418 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -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);