From 4f689a30fb5d8707270dfc9df9329b32fec8440f Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Sat, 16 Jan 2021 20:46:13 +0800 Subject: [PATCH] LU-14283 obdclass: connect vs disconnect race 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 ptlrpc_connect_interpret obd->obd_setup = 0 obd_import_event if (obd->obd_set_up) osc_init_grant() /*skipped*/ ptlrpc_activate_import.. 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: 45900a ("LU-4134 obdclass: obd_device improvement") Signed-off-by: Wang Shilong Change-Id: I898b6f53602c05221a3154a61615a0e270167ac6 Reviewed-on: https://review.whamcloud.com/41256 Tested-by: jenkins Reviewed-by: Sebastien Buisson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/obdclass/obd_config.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index bf86016..69ca1b4 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -837,11 +837,6 @@ 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; spin_unlock(&obd->obd_dev_lock); /* wait for already-arrived-connections to finish. */ -- 1.8.3.1