From 7a48c2efa0ee9d0b09a4d850a7acfb87adb642fa Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Tue, 20 Dec 2016 03:07:30 +0800 Subject: [PATCH] LU-8957 obdclass: fix exp_nid_hash race Move exp_nid_hash unhash operation under exp_lock. To avoid parallel export disconnect may race in there. Change-Id: I02a9cf550b4edee7c42ba90d3f3926cd2584c24b Signed-off-by: Yang Sheng Reviewed-on: https://review.whamcloud.com/24434 Tested-by: Jenkins Reviewed-by: John L. Hammond Reviewed-by: Niu Yawei Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/obdclass/genops.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 560ab8a..9c05633 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1235,6 +1235,13 @@ int class_disconnect(struct obd_export *export) spin_lock(&export->exp_lock); already_disconnected = export->exp_disconnected; export->exp_disconnected = 1; + /* We hold references of export for uuid hash + * and nid_hash and export link at least. So + * it is safe to call cfs_hash_del in there. */ + if (!hlist_unhashed(&export->exp_nid_hash)) + cfs_hash_del(export->exp_obd->obd_nid_hash, + &export->exp_connection->c_peer.nid, + &export->exp_nid_hash); spin_unlock(&export->exp_lock); /* class_cleanup(), abort_recovery(), and class_fail_export() @@ -1248,11 +1255,6 @@ int class_disconnect(struct obd_export *export) CDEBUG(D_IOCTL, "disconnect: cookie %#llx\n", export->exp_handle.h_cookie); - if (!hlist_unhashed(&export->exp_nid_hash)) - cfs_hash_del(export->exp_obd->obd_nid_hash, - &export->exp_connection->c_peer.nid, - &export->exp_nid_hash); - class_export_recovery_cleanup(export); class_unlink_export(export); no_disconn: -- 1.8.3.1