From 198d29c2ae9f3b56f6ac0223686cb47578ac5d69 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Fri, 12 Apr 2024 08:28:28 +0300 Subject: [PATCH] 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 Lustre-change: https://review.whamcloud.com/50147 Lustre-commit: 08f9ebe93b300c39d2af1fb8e82a22e9c84f401b Signed-off-by: Alex Zhuravlev Change-Id: I62ed019f86becd3c66f5fcdf991f13cd47466e5e Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54753 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/obdclass/genops.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 7c245c2..e157e9a 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1011,6 +1011,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 @@ -1150,7 +1153,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); @@ -1803,12 +1805,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); } @@ -1826,6 +1827,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); -- 1.8.3.1