cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [RESEND dlm/next 11/16] fs: dlm: change ls_clear_proc_locks to spinlock
Date: Mon, 15 Aug 2022 15:43:23 -0400	[thread overview]
Message-ID: <20220815194328.2208580-12-aahringo@redhat.com> (raw)
In-Reply-To: <20220815194328.2208580-1-aahringo@redhat.com>

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>
---
 fs/dlm/dlm_internal.h | 2 +-
 fs/dlm/lock.c         | 8 ++++----
 fs/dlm/lockspace.c    | 2 +-
 fs/dlm/user.c         | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index 8aca8085d24e..e34c3d2639a5 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -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 */
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index c41aa8ab3230..65a7a0631ec8 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -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);
 }
 
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 56c79926e7be..41a6504cfab5 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -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
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 99e8f0744513..df6215c73239 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -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,
-- 
2.31.1


  parent reply	other threads:[~2022-08-15 19:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 19:43 [Cluster-devel] [RESEND dlm/next 00/16] fs: dlm: fixes, cleanups and locktorture Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 01/16] fs: dlm: fix race in lowcomms Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 02/16] fs: dlm: fix race between test_bit() and queue_work() Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 03/16] fs: dlm: handle -EBUSY as first for lock validation Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 04/16] fs: dlm: handle -EBUSY as first for unlock validation Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 05/16] fs: dlm: use __func__ for function name Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 06/16] fs: dlm: handle -EINVAL as log_error() Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 07/16] fs: dlm: fix invalid derefence of sb_lvbptr Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 08/16] fs: dlm: allow lockspaces have zero lvblen Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 09/16] fs: dlm: handle rcom in else if branch Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 10/16] fs: dlm: remove dlm_del_ast prototype Alexander Aring
2022-08-15 19:43 ` Alexander Aring [this message]
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 12/16] fs: dlm: trace user space callbacks Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 13/16] fs: dlm: move DLM_LSFL_FS out of uapi Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 14/16] fs: dlm: LSFL_CB_DELAY only for kernel lockspaces Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 15/16] fs: dlm: const void resource name parameter Alexander Aring
2022-08-15 19:43 ` [Cluster-devel] [RESEND dlm/next 16/16] fs: dlm: initial commit of locktorture Alexander Aring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220815194328.2208580-12-aahringo@redhat.com \
    --to=aahringo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).