From: Hongchao Zhang Date: Sat, 24 May 2014 08:46:07 +0000 (+0800) Subject: LU-5128 obdclass: fix a race in recovery X-Git-Tag: 2.6.51~101 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5a7e4480fc519c8df4ca0b11e6d5239956316bd3;hp=9feb80c65b077204f7091e90f314098266fb7e82 LU-5128 obdclass: fix a race in recovery in "class_export_recovery_cleanup", the check of the flag "exp->exp_req_replay_needed" should be protected by "exp_lock". Change-Id: I9a1b0583cb15df896e4a608ee0e396bb90486888 Signed-off-by: Hongchao Zhang Reviewed-on: http://review.whamcloud.com/10849 Tested-by: Jenkins Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index ad5473b..109394c 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1203,22 +1203,24 @@ void class_export_recovery_cleanup(struct obd_export *exp) exp->exp_obd->obd_stale_clients++; } spin_unlock(&obd->obd_recovery_task_lock); + + spin_lock(&exp->exp_lock); /** Cleanup req replay fields */ if (exp->exp_req_replay_needed) { - spin_lock(&exp->exp_lock); exp->exp_req_replay_needed = 0; - spin_unlock(&exp->exp_lock); + LASSERT(atomic_read(&obd->obd_req_replay_clients)); atomic_dec(&obd->obd_req_replay_clients); } + /** Cleanup lock replay data */ if (exp->exp_lock_replay_needed) { - spin_lock(&exp->exp_lock); exp->exp_lock_replay_needed = 0; - spin_unlock(&exp->exp_lock); + LASSERT(atomic_read(&obd->obd_lock_replay_clients)); atomic_dec(&obd->obd_lock_replay_clients); } + spin_unlock(&exp->exp_lock); } /* This function removes 1-3 references from the export: