From: Wang Shilong Date: Sat, 16 Jan 2021 12:46:13 +0000 (+0800) Subject: LU-14283 obdclass: connect vs disconnect race X-Git-Tag: 2.14.0-RC1~17 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F56%2F41256%2F3;p=fs%2Flustre-release.git 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 --- 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. */