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 <wshilong@ddn.com>
Change-Id: I898b6f53602c05221a3154a61615a0e270167ac6
Reviewed-on: https://review.whamcloud.com/41256
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
}
/* 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. */