Whamcloud - gitweb
LU-8957 obdclass: fix exp_nid_hash race 34/24434/5
authorYang Sheng <yang.sheng@intel.com>
Mon, 19 Dec 2016 19:07:30 +0000 (03:07 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 9 Jan 2017 05:52:41 +0000 (05:52 +0000)
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 <yang.sheng@intel.com>
Reviewed-on: https://review.whamcloud.com/24434
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/genops.c

index 560ab8a..9c05633 100644 (file)
@@ -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: