Whamcloud - gitweb
LU-9806 obdclass: wait for all exports to go 47/50147/11
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 27 Feb 2023 18:40:34 +0000 (21:40 +0300)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 Jul 2023 16:41:40 +0000 (16:41 +0000)
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 <bzzz@whamcloud.com>
Change-Id: I62ed019f86becd3c66f5fcdf991f13cd47466e5e
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50147
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Reviewed-by: Mikhail Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/genops.c

index c300236..3ebb015 100644 (file)
@@ -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);