diff mbox series

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

Message ID 1612832067-1449-4-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series Sync to OpenSFS as of Feb 8, 2021 | expand

Commit Message

James Simmons Feb. 9, 2021, 12:54 a.m. UTC
From: Wang Shilong <wshilong@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
      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: 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@ddn.com>
Reviewed-on: https://review.whamcloud.com/41256
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/obdclass/obd_config.c | 4 ----
 1 file changed, 4 deletions(-)
diff mbox series

Patch

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;
 	spin_unlock(&obd->obd_dev_lock);
 
 	while (obd->obd_conn_inprogress > 0)