From: Alex Zhuravlev Date: Mon, 27 Feb 2023 18:40:34 +0000 (+0300) Subject: LU-9806 obdclass: wait for all exports to go X-Git-Tag: 2.15.57~52 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=08f9ebe93b300c39d2af1fb8e82a22e9c84f401b;p=fs%2Flustre-release.git LU-9806 obdclass: wait for all exports to go obd_zombie_export_add() removes an export from the stale list and then schedules a job to destroy that export. in this short window ofd_fini()/mdt_fini() can find obd_linked_exports list empty and no work in zombie work queue. then the obd is being removed and concurrent export destroy may find the obd in a unexpected state: LustreError: 11166:0:(tgt_lastrcvd.c:469:tgt_client_free()) ASSERTION( lut && lut->lut_client_bitmap ) failed use obd_stale_export_num counter to block in obd_zombie_barrier. move atomic_inc() from class_unlink_export to obd_export_zombie_add() as self-exports are not added to the stale list. I Signed-off-by: Alex Zhuravlev Change-Id: I62ed019f86becd3c66f5fcdf991f13cd47466e5e Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50147 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Alexey Lyashkov Reviewed-by: Mikhail Pershin Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index c300236..3ebb015 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1014,6 +1014,9 @@ static void obd_zombie_exp_cull(struct work_struct *ws) export = container_of(ws, struct obd_export, exp_zombie_work); class_export_destroy(export); + LASSERT(atomic_read(&obd_stale_export_num) > 0); + if (atomic_dec_and_test(&obd_stale_export_num)) + wake_up_var(&obd_stale_export_num); } /* Creates a new export, adds it to the hash table, and returns a @@ -1153,7 +1156,6 @@ void class_unlink_export(struct obd_export *exp) list_del_init(&exp->exp_obd_chain_timed); exp->exp_obd->obd_num_exports--; spin_unlock(&exp->exp_obd->obd_dev_lock); - atomic_inc(&obd_stale_export_num); /* A reference is kept by obd_stale_exports list */ obd_stale_export_put(exp); @@ -1807,12 +1809,11 @@ EXPORT_SYMBOL(obd_exports_barrier); * Add export to the obd_zombe thread and notify it. */ static void obd_zombie_export_add(struct obd_export *exp) { - atomic_dec(&obd_stale_export_num); + atomic_inc(&obd_stale_export_num); spin_lock(&exp->exp_obd->obd_dev_lock); LASSERT(!list_empty(&exp->exp_obd_chain)); list_del_init(&exp->exp_obd_chain); spin_unlock(&exp->exp_obd->obd_dev_lock); - queue_work(zombie_wq, &exp->exp_zombie_work); } @@ -1830,6 +1831,8 @@ static void obd_zombie_import_add(struct obd_import *imp) { */ void obd_zombie_barrier(void) { + wait_var_event(&obd_stale_export_num, + atomic_read(&obd_stale_export_num) == 0); flush_workqueue(zombie_wq); } EXPORT_SYMBOL(obd_zombie_barrier);