fs: dlm: change ls_clear_proc_locks to spinlock
authorAlexander Aring <aahringo@redhat.com>
Mon, 15 Aug 2022 19:43:23 +0000 (15:43 -0400)
committerDavid Teigland <teigland@redhat.com>
Tue, 23 Aug 2022 19:54:02 +0000 (14:54 -0500)
This patch changes the ls_clear_proc_locks to a spinlock because there
is no need to handle it as a mutex as there is no sleepable context when
ls_clear_proc_locks is held. This allows us to call those functionality
in non-sleepable contexts.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/dlm_internal.h
fs/dlm/lock.c
fs/dlm/lockspace.c
fs/dlm/user.c

index 8aca808..e34c3d2 100644 (file)
@@ -661,7 +661,7 @@ struct dlm_ls {
        spinlock_t              ls_recover_idr_lock;
        wait_queue_head_t       ls_wait_general;
        wait_queue_head_t       ls_recover_lock_wait;
-       struct mutex            ls_clear_proc_locks;
+       spinlock_t              ls_clear_proc_locks;
 
        struct list_head        ls_root_list;   /* root resources */
        struct rw_semaphore     ls_root_sem;    /* protect root_list */
index c41aa8a..65a7a06 100644 (file)
@@ -6215,7 +6215,7 @@ static struct dlm_lkb *del_proc_lock(struct dlm_ls *ls,
 {
        struct dlm_lkb *lkb = NULL;
 
-       mutex_lock(&ls->ls_clear_proc_locks);
+       spin_lock(&ls->ls_clear_proc_locks);
        if (list_empty(&proc->locks))
                goto out;
 
@@ -6227,7 +6227,7 @@ static struct dlm_lkb *del_proc_lock(struct dlm_ls *ls,
        else
                lkb->lkb_flags |= DLM_IFL_DEAD;
  out:
-       mutex_unlock(&ls->ls_clear_proc_locks);
+       spin_unlock(&ls->ls_clear_proc_locks);
        return lkb;
 }
 
@@ -6264,7 +6264,7 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc)
                dlm_put_lkb(lkb);
        }
 
-       mutex_lock(&ls->ls_clear_proc_locks);
+       spin_lock(&ls->ls_clear_proc_locks);
 
        /* in-progress unlocks */
        list_for_each_entry_safe(lkb, safe, &proc->unlocking, lkb_ownqueue) {
@@ -6280,7 +6280,7 @@ void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc)
                dlm_put_lkb(lkb);
        }
 
-       mutex_unlock(&ls->ls_clear_proc_locks);
+       spin_unlock(&ls->ls_clear_proc_locks);
        dlm_unlock_recovery(ls);
 }
 
index 56c7992..41a6504 100644 (file)
@@ -584,7 +584,7 @@ static int new_lockspace(const char *name, const char *cluster,
        atomic_set(&ls->ls_requestqueue_cnt, 0);
        init_waitqueue_head(&ls->ls_requestqueue_wait);
        mutex_init(&ls->ls_requestqueue_mutex);
-       mutex_init(&ls->ls_clear_proc_locks);
+       spin_lock_init(&ls->ls_clear_proc_locks);
 
        /* Due backwards compatibility with 3.1 we need to use maximum
         * possible dlm message size to be sure the message will fit and
index 99e8f07..df6215c 100644 (file)
@@ -184,7 +184,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
                return;
 
        ls = lkb->lkb_resource->res_ls;
-       mutex_lock(&ls->ls_clear_proc_locks);
+       spin_lock(&ls->ls_clear_proc_locks);
 
        /* If ORPHAN/DEAD flag is set, it means the process is dead so an ast
           can't be delivered.  For ORPHAN's, dlm_clear_proc_locks() freed
@@ -230,7 +230,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
                spin_unlock(&proc->locks_spin);
        }
  out:
-       mutex_unlock(&ls->ls_clear_proc_locks);
+       spin_unlock(&ls->ls_clear_proc_locks);
 }
 
 static int device_user_lock(struct dlm_user_proc *proc,