fs: dlm: use spin lock instead of mutex
authorAlexander Aring <aahringo@redhat.com>
Thu, 27 Oct 2022 20:45:19 +0000 (16:45 -0400)
committerDavid Teigland <teigland@redhat.com>
Tue, 8 Nov 2022 18:59:41 +0000 (12:59 -0600)
There is no need to use a mutex in those hot path sections. We change it
to spin lock to serve callbacks more faster by not allowing schedule.
The locked sections will not be locked for a long time.

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

index daaa0dff6ef4e812d49d0518d28614b0e03fd694..3e76ec75bc5559490ade171b082cbb95296750a5 100644 (file)
@@ -190,7 +190,7 @@ void dlm_add_cb(struct dlm_lkb *lkb, uint32_t flags, int mode, int status,
                return;
        }
 
-       mutex_lock(&lkb->lkb_cb_mutex);
+       spin_lock(&lkb->lkb_cb_lock);
        prev_seq = lkb->lkb_callbacks[0].seq;
 
        rv = dlm_add_lkb_callback(lkb, flags, mode, status, sbflags, new_seq);
@@ -209,7 +209,7 @@ void dlm_add_cb(struct dlm_lkb *lkb, uint32_t flags, int mode, int status,
                spin_unlock(&ls->ls_cb_lock);
        }
  out:
-       mutex_unlock(&lkb->lkb_cb_mutex);
+       spin_unlock(&lkb->lkb_cb_lock);
 }
 
 void dlm_callback_work(struct work_struct *work)
@@ -223,7 +223,7 @@ void dlm_callback_work(struct work_struct *work)
 
        memset(&callbacks, 0, sizeof(callbacks));
 
-       mutex_lock(&lkb->lkb_cb_mutex);
+       spin_lock(&lkb->lkb_cb_lock);
        if (!lkb->lkb_callbacks[0].seq) {
                /* no callback work exists, shouldn't happen */
                log_error(ls, "dlm_callback_work %x no work", lkb->lkb_id);
@@ -244,7 +244,7 @@ void dlm_callback_work(struct work_struct *work)
                dlm_print_lkb(lkb);
                dlm_dump_lkb_callbacks(lkb);
        }
-       mutex_unlock(&lkb->lkb_cb_mutex);
+       spin_unlock(&lkb->lkb_cb_lock);
 
        castfn = lkb->lkb_astfn;
        bastfn = lkb->lkb_bastfn;
index fc4be8c357036c5cf3f290e85400278f3193af59..730808289a424c4aca191256aeda1319de879376 100644 (file)
@@ -268,7 +268,7 @@ struct dlm_lkb {
        unsigned long           lkb_timeout_cs;
 #endif
 
-       struct mutex            lkb_cb_mutex;
+       spinlock_t              lkb_cb_lock;
        struct work_struct      lkb_cb_work;
        struct list_head        lkb_cb_list; /* for ls_cb_delay or proc->asts */
        struct dlm_callback     lkb_callbacks[DLM_CALLBACKS_SIZE];
index 0b1bc24536cebe7026053f03ca27a5c34c77bbea..40e4e4a1c582341d1218f0eb8325ad41e8e5833c 100644 (file)
@@ -1218,7 +1218,7 @@ static int _create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret,
        INIT_LIST_HEAD(&lkb->lkb_time_list);
 #endif
        INIT_LIST_HEAD(&lkb->lkb_cb_list);
-       mutex_init(&lkb->lkb_cb_mutex);
+       spin_lock_init(&lkb->lkb_cb_lock);
        INIT_WORK(&lkb->lkb_cb_work, dlm_callback_work);
 
        idr_preload(GFP_NOFS);