Whamcloud - gitweb
LU-13494 osp: wait for import invalidation 99/45499/31
authorAlex Zhuravlev <bzzz@whamcloud.com>
Tue, 9 Nov 2021 08:03:32 +0000 (11:03 +0300)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 Mar 2023 23:13:20 +0000 (23:13 +0000)
osp_update_fini() should wait till racing ptlrpc_import_invalidate()
(running in a dedicated invalidation thread) is complete as the both
threads access ou_update and osp_update_fini() release the structure.

the change also fixes kernel's warning on scheduling while atomic:
old osp_update_fini() took the spinlock to protect ou_list, but
given new wait_event() we don't need to protect the list anymore.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Iea40d3be8b1b3079b9fe8bdd015cc3392027b64d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/45499
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/osp/osp_dev.c

index 5497028..d1232e9 100644 (file)
@@ -570,6 +570,7 @@ static int osp_update_init(struct osp_device *osp)
  */
 static void osp_update_fini(const struct lu_env *env, struct osp_device *osp)
 {
+       struct obd_import *imp = osp->opd_obd->u.cli.cl_import;
        struct osp_update_request *our;
        struct osp_update_request *tmp;
        struct osp_updates *ou = osp->opd_update;
@@ -580,17 +581,22 @@ static void osp_update_fini(const struct lu_env *env, struct osp_device *osp)
        kthread_stop(ou->ou_update_task);
        lu_env_fini(&ou->ou_env);
 
+       /*
+        * import invalidation can be running in a dedicated thread.
+        * we have to wait for the thread's completion as the thread
+        * invalidates this list as well.
+        */
+       wait_event_idle(imp->imp_recovery_waitq,
+                       (atomic_read(&imp->imp_inval_count) == 0));
+
        /* Remove the left osp thandle from the list */
-       spin_lock(&ou->ou_lock);
-       list_for_each_entry_safe(our, tmp, &ou->ou_list,
-                                our_list) {
+       list_for_each_entry_safe(our, tmp, &ou->ou_list, our_list) {
                list_del_init(&our->our_list);
                LASSERT(our->our_th != NULL);
                osp_trans_callback(env, our->our_th, -EIO);
                /* our will be destroyed in osp_thandle_put() */
                osp_thandle_put(env, our->our_th);
        }
-       spin_unlock(&ou->ou_lock);
 
        OBD_FREE_PTR(ou);
        osp->opd_update = NULL;