From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [RFC PATCH dlm/next 1/2] fs: dlm: provide some lockless functionality
Date: Mon, 4 Oct 2021 16:58:04 -0400 [thread overview]
Message-ID: <20211004205805.3938460-2-aahringo@redhat.com> (raw)
In-Reply-To: <20211004205805.3938460-1-aahringo@redhat.com>
This patch provides some lockless functionality for the central dlm
locking logic. It can be used internally to call central dlm locking
logic functionality if the necessary resource lock is already held.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/lock.c | 72 ++++++++++++++++++++++++++++++++++-----------------
1 file changed, 48 insertions(+), 24 deletions(-)
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 3d4eeab213da..c419a5b5b7c0 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -4641,25 +4641,33 @@ static void __receive_convert_reply(struct dlm_rsb *r, struct dlm_lkb *lkb,
}
}
-static void _receive_convert_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
+static void _receive_convert_reply_lockless(struct dlm_lkb *lkb,
+ struct dlm_message *ms,
+ struct dlm_rsb *r)
{
- struct dlm_rsb *r = lkb->lkb_resource;
int error;
- hold_rsb(r);
- lock_rsb(r);
-
error = validate_message(lkb, ms);
if (error)
- goto out;
+ return;
/* stub reply can happen with waiters_mutex held */
error = remove_from_waiters_ms(lkb, ms);
if (error)
- goto out;
+ return;
__receive_convert_reply(r, lkb, ms);
- out:
+}
+
+static void _receive_convert_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
+{
+ struct dlm_rsb *r = lkb->lkb_resource;
+
+ hold_rsb(r);
+ lock_rsb(r);
+
+ _receive_convert_reply_lockless(lkb, ms, r);
+
unlock_rsb(r);
put_rsb(r);
}
@@ -4678,22 +4686,20 @@ static int receive_convert_reply(struct dlm_ls *ls, struct dlm_message *ms)
return 0;
}
-static void _receive_unlock_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
+static void _receive_unlock_reply_lockless(struct dlm_lkb *lkb,
+ struct dlm_message *ms,
+ struct dlm_rsb *r)
{
- struct dlm_rsb *r = lkb->lkb_resource;
int error;
- hold_rsb(r);
- lock_rsb(r);
-
error = validate_message(lkb, ms);
if (error)
- goto out;
+ return;
/* stub reply can happen with waiters_mutex held */
error = remove_from_waiters_ms(lkb, ms);
if (error)
- goto out;
+ return;
/* this is the value returned from do_unlock() on the master */
@@ -4709,7 +4715,17 @@ static void _receive_unlock_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
log_error(r->res_ls, "receive_unlock_reply %x error %d",
lkb->lkb_id, ms->m_result);
}
- out:
+}
+
+static void _receive_unlock_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
+{
+ struct dlm_rsb *r = lkb->lkb_resource;
+
+ hold_rsb(r);
+ lock_rsb(r);
+
+ _receive_unlock_reply_lockless(lkb, ms, r);
+
unlock_rsb(r);
put_rsb(r);
}
@@ -4728,22 +4744,20 @@ static int receive_unlock_reply(struct dlm_ls *ls, struct dlm_message *ms)
return 0;
}
-static void _receive_cancel_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
+static void _receive_cancel_reply_lockless(struct dlm_lkb *lkb,
+ struct dlm_message *ms,
+ struct dlm_rsb *r)
{
- struct dlm_rsb *r = lkb->lkb_resource;
int error;
- hold_rsb(r);
- lock_rsb(r);
-
error = validate_message(lkb, ms);
if (error)
- goto out;
+ return;
/* stub reply can happen with waiters_mutex held */
error = remove_from_waiters_ms(lkb, ms);
if (error)
- goto out;
+ return;
/* this is the value returned from do_cancel() on the master */
@@ -4759,7 +4773,17 @@ static void _receive_cancel_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
log_error(r->res_ls, "receive_cancel_reply %x error %d",
lkb->lkb_id, ms->m_result);
}
- out:
+}
+
+static void _receive_cancel_reply(struct dlm_lkb *lkb, struct dlm_message *ms)
+{
+ struct dlm_rsb *r = lkb->lkb_resource;
+
+ hold_rsb(r);
+ lock_rsb(r);
+
+ _receive_cancel_reply_lockless(lkb, ms, r);
+
unlock_rsb(r);
put_rsb(r);
}
--
2.27.0
next prev parent reply other threads:[~2021-10-04 20:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-04 20:58 [Cluster-devel] [RFC PATCH dlm/next 0/2] fs: dlm: remove reverse locking order Alexander Aring
2021-10-04 20:58 ` Alexander Aring [this message]
2021-10-04 20:58 ` [Cluster-devel] [RFC PATCH dlm/next 2/2] fs: dlm: change dlm logic locking behaviour 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=20211004205805.3938460-2-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).