public inbox for gfs2@lists.linux.dev
 help / color / mirror / Atom feed
From: Alexander Aring <aahringo@redhat.com>
To: teigland@redhat.com
Cc: gfs2@lists.linux.dev, aahringo@redhat.com
Subject: [RFC dlm/next 03/11] dlm: use hold_lkb() instead kref_get()
Date: Thu,  7 Nov 2024 15:46:09 -0500	[thread overview]
Message-ID: <20241107204617.147842-4-aahringo@redhat.com> (raw)
In-Reply-To: <20241107204617.147842-1-aahringo@redhat.com>

Using internal dlm helper to call kref_get() for a lkb.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 fs/dlm/lock.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 32fdee78e7f5..42cef3d2af47 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -1523,6 +1523,15 @@ static int create_lkb(struct dlm_ls *ls, struct dlm_lkb **lkb_ret)
 	return _create_lkb(ls, lkb_ret, 1, ULONG_MAX);
 }
 
+/* This is only called to add a reference when the code already holds
+ * a valid reference to the lkb, so there's no need for locking.
+ */
+
+static inline void hold_lkb(struct dlm_lkb *lkb)
+{
+	kref_get(&lkb->lkb_ref);
+}
+
 static int find_lkb(struct dlm_ls *ls, uint32_t lkid, struct dlm_lkb **lkb_ret)
 {
 	struct dlm_lkb *lkb;
@@ -1536,7 +1545,7 @@ static int find_lkb(struct dlm_ls *ls, uint32_t lkid, struct dlm_lkb **lkb_ret)
 		 */
 		read_lock_bh(&ls->ls_lkbxa_lock);
 		if (kref_read(&lkb->lkb_ref))
-			kref_get(&lkb->lkb_ref);
+			hold_lkb(lkb);
 		else
 			lkb = NULL;
 		read_unlock_bh(&ls->ls_lkbxa_lock);
@@ -1593,14 +1602,6 @@ int dlm_put_lkb(struct dlm_lkb *lkb)
 	return __put_lkb(ls, lkb);
 }
 
-/* This is only called to add a reference when the code already holds
-   a valid reference to the lkb, so there's no need for locking. */
-
-static inline void hold_lkb(struct dlm_lkb *lkb)
-{
-	kref_get(&lkb->lkb_ref);
-}
-
 static void unhold_lkb_assert(struct kref *kref)
 {
 	struct dlm_lkb *lkb = container_of(kref, struct dlm_lkb, lkb_ref);
@@ -1638,7 +1639,7 @@ static void lkb_add_ordered(struct list_head *new, struct list_head *head,
 
 static void add_lkb(struct dlm_rsb *r, struct dlm_lkb *lkb, int status)
 {
-	kref_get(&lkb->lkb_ref);
+	hold_lkb(lkb);
 
 	DLM_ASSERT(!lkb->lkb_status, dlm_print_lkb(lkb););
 
-- 
2.43.0


  parent reply	other threads:[~2024-11-07 20:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 20:46 [RFC dlm/next 00/11] dlm: approach for new lkb reference counting Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 01/11] dlm: remove set_master() negative return check Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 02/11] dlm: use move_lkb() instead del/add lkb Alexander Aring
2024-11-07 20:46 ` Alexander Aring [this message]
2024-11-07 20:46 ` [RFC dlm/next 04/11] dlm: don't track references on move_lkb() Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 05/11] dlm: drop lkb hold for waiter conversion handling Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 06/11] dlm: track reference for lkb_rsb_lookup Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 07/11] dlm: call queue_cast() on master copy as well Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 08/11] dlm: make send dlm message as non-failure Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 09/11] dlm: introduce new lkb refcount model Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 10/11] dlm: void convert, cancel and unlock requests Alexander Aring
2024-11-07 20:46 ` [RFC dlm/next 11/11] dlm: return void for _request_lock function 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=20241107204617.147842-4-aahringo@redhat.com \
    --to=aahringo@redhat.com \
    --cc=gfs2@lists.linux.dev \
    --cc=teigland@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