[lustre-devel] [PATCH 3/9] lustre: obdclass: connect vs disconnect race

James Simmons jsimmons at infradead.org
Mon Feb 8 16:54:21 PST 2021

From: Wang Shilong <wshilong at ddn.com>

There might be a possible race if setup (connect)
and cleanup (disconnect) are tangled together(similar
comments in osc_disconnect()):

  Thread1:                              Thread2:
    connecting                            class_cleanup
                                            obd->obd_setup = 0
        if (obd->obd_set_up)
            osc_init_grant() /*skipped*/

And If RPC was waked up and send out before
class_disconnect_exports(), It might hit divide zero crash
in osc_announce_cached() because @cl_max_extent_pages is zero.

The problem is we clear @obd_setup too early, It should be cleared
when OBD is really shutdown.

Fixes: cfd750 ("lustre: obdclass: obd_device improvement")
WC-bug-id: https://jira.whamcloud.com/browse/LU-14283
Lustre-commit: 4f689a30fb5d870 ("LU-14283 obdclass: connect vs disconnect race")
Signed-off-by: Wang Shilong <wshilong at ddn.com>
Reviewed-on: https://review.whamcloud.com/41256
Reviewed-by: Sebastien Buisson <sbuisson at ddn.com>
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: John L. Hammond <jhammond at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
 fs/lustre/obdclass/obd_config.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/fs/lustre/obdclass/obd_config.c b/fs/lustre/obdclass/obd_config.c
index 09dee7b..8f062bb 100644
--- a/fs/lustre/obdclass/obd_config.c
+++ b/fs/lustre/obdclass/obd_config.c
@@ -467,10 +467,6 @@ static int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
 	/* Leave this on forever */
 	obd->obd_stopping = 1;
-	/* function can't return error after that point, so clear setup flag
-	 * as early as possible to avoid finding via obd_devs / hash
-	 */
-	obd->obd_set_up = 0;
 	while (obd->obd_conn_inprogress > 0)

More information about the lustre-devel mailing list