From: Mikhail Pershin Date: Mon, 6 Jun 2011 19:12:25 +0000 (+0400) Subject: LU-395 Fix obd_zombie_barrier() X-Git-Tag: 2.0.63.0~11 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c4e3a69dd9a335d54f747d2e969edefe7bcce4cd LU-395 Fix obd_zombie_barrier() The obd_zombie_barrier() is waiting for obd_zombie_export list is empty and exit, but export may be not yet destroyed. This produces race between export destroying and other cleanups like lut_fini() The patch introduces zombies_in_destroy variable which is counter, and obd_zombie_barrier is checking it. Change-Id: I0fd4a1023efade1cb40d4c36e59169a25a525ed1 Signed-off-by: Mikhail Pershin Reviewed-on: http://review.whamcloud.com/899 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 9a9adfa..e0a9416 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1464,6 +1464,9 @@ void obd_exports_barrier(struct obd_device *obd) } EXPORT_SYMBOL(obd_exports_barrier); +/* Total amount of zombies to be destroyed */ +static int zombies_count = 0; + /** * kill zombie imports and exports */ @@ -1494,11 +1497,19 @@ void obd_zombie_impexp_cull(void) cfs_spin_unlock(&obd_zombie_impexp_lock); - if (import != NULL) + if (import != NULL) { class_import_destroy(import); + cfs_spin_lock(&obd_zombie_impexp_lock); + zombies_count--; + cfs_spin_unlock(&obd_zombie_impexp_lock); + } - if (export != NULL) + if (export != NULL) { class_export_destroy(export); + cfs_spin_lock(&obd_zombie_impexp_lock); + zombies_count--; + cfs_spin_unlock(&obd_zombie_impexp_lock); + } cfs_cond_resched(); } while (import != NULL || export != NULL); @@ -1523,10 +1534,8 @@ static int obd_zombie_impexp_check(void *arg) int rc; cfs_spin_lock(&obd_zombie_impexp_lock); - rc = cfs_list_empty(&obd_zombie_imports) && - cfs_list_empty(&obd_zombie_exports) && + rc = (zombies_count == 0) && !cfs_test_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags); - cfs_spin_unlock(&obd_zombie_impexp_lock); RETURN(rc); @@ -1541,6 +1550,7 @@ static void obd_zombie_export_add(struct obd_export *exp) { cfs_list_del_init(&exp->exp_obd_chain); cfs_spin_unlock(&exp->exp_obd->obd_dev_lock); cfs_spin_lock(&obd_zombie_impexp_lock); + zombies_count++; cfs_list_add(&exp->exp_obd_chain, &obd_zombie_exports); cfs_spin_unlock(&obd_zombie_impexp_lock); @@ -1555,6 +1565,7 @@ static void obd_zombie_import_add(struct obd_import *imp) { LASSERT(imp->imp_sec == NULL); cfs_spin_lock(&obd_zombie_impexp_lock); LASSERT(cfs_list_empty(&imp->imp_zombie_chain)); + zombies_count++; cfs_list_add(&imp->imp_zombie_chain, &obd_zombie_imports); cfs_spin_unlock(&obd_zombie_impexp_lock); @@ -1579,8 +1590,7 @@ static int obd_zombie_is_idle(void) LASSERT(!cfs_test_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags)); cfs_spin_lock(&obd_zombie_impexp_lock); - rc = cfs_list_empty(&obd_zombie_imports) && - cfs_list_empty(&obd_zombie_exports); + rc = (zombies_count == 0); cfs_spin_unlock(&obd_zombie_impexp_lock); return rc; }