From: Alexander Aring <aahringo@redhat.com>
To: teigland@redhat.com
Cc: gfs2@lists.linux.dev, aahringo@redhat.com
Subject: [RFC dlm/next 11/11] dlm: return void for _request_lock function
Date: Thu, 7 Nov 2024 15:46:17 -0500 [thread overview]
Message-ID: <20241107204617.147842-12-aahringo@redhat.com> (raw)
In-Reply-To: <20241107204617.147842-1-aahringo@redhat.com>
Change the _request_lock() function that it cannot fail as the recent
changes to the lkb refcounting model does not require to evaluate the
return value to may call a put.
For the dlm_user_request() function we still need to know if the result
-EAGAIN was happening as the lkb lifetime ends to not add the lkb to the
ownqueue. This is the only user, we use a call-by-reference result
parameter to allow the user to know if the lkb lifetime ended
immediately on the lock request as dlm_user_request() requires.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/lock.c | 49 ++++++++++++++++++++++---------------------------
1 file changed, 22 insertions(+), 27 deletions(-)
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 28c312410527..10058c89c811 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -83,7 +83,7 @@ static void send_grant(struct dlm_rsb *r, struct dlm_lkb *lkb);
static void send_bast(struct dlm_rsb *r, struct dlm_lkb *lkb, int mode);
static void send_lookup(struct dlm_rsb *r, struct dlm_lkb *lkb);
static void send_remove(struct dlm_rsb *r);
-static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb);
+static void _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, int *result);
static void _cancel_lock(struct dlm_rsb *r, struct dlm_lkb *lkb);
static void __receive_convert_reply(struct dlm_rsb *r, struct dlm_lkb *lkb,
const struct dlm_message *ms, bool local);
@@ -2761,7 +2761,7 @@ static void process_lookup_list(struct dlm_rsb *r)
list_for_each_entry_safe(lkb, safe, &r->res_lookup, lkb_rsb_lookup) {
list_del_init(&lkb->lkb_rsb_lookup);
- _request_lock(r, lkb);
+ _request_lock(r, lkb, NULL);
dlm_put_lkb(lkb);
}
}
@@ -2796,7 +2796,7 @@ static void confirm_master(struct dlm_rsb *r, int error)
lkb_rsb_lookup);
list_del_init(&lkb->lkb_rsb_lookup);
r->res_first_lkid = lkb->lkb_id;
- _request_lock(r, lkb);
+ _request_lock(r, lkb, NULL);
dlm_put_lkb(lkb);
}
break;
@@ -3241,7 +3241,7 @@ static void do_cancel_effects(struct dlm_rsb *r, struct dlm_lkb *lkb,
/* add a new lkb to a possibly new rsb, called by requesting process */
-static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
+static void _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb, int *result)
{
int error;
@@ -3263,7 +3263,8 @@ static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
do_request_effects(r, lkb, error);
}
out:
- return error;
+ if (result)
+ *result = error;
}
/* change some property of an existing lkb, e.g. mode */
@@ -3332,7 +3333,7 @@ static void _cancel_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
static int request_lock(struct dlm_ls *ls, struct dlm_lkb *lkb,
const void *name, int len,
- struct dlm_args *args)
+ struct dlm_args *args, int *result)
{
struct dlm_rsb *r;
int error;
@@ -3357,11 +3358,11 @@ static int request_lock(struct dlm_ls *ls, struct dlm_lkb *lkb,
attach_lkb(r, lkb);
lkb->lkb_lksb->sb_lkid = lkb->lkb_id;
- error = _request_lock(r, lkb);
+ _request_lock(r, lkb, result);
unlock_rsb(r);
put_rsb(r);
- return error;
+ return 0;
}
static int convert_lock(struct dlm_ls *ls, struct dlm_lkb *lkb,
@@ -3474,14 +3475,12 @@ int dlm_lock(dlm_lockspace_t *lockspace,
if (convert)
error = convert_lock(ls, lkb, &args);
else
- error = request_lock(ls, lkb, name, namelen, &args);
+ error = request_lock(ls, lkb, name, namelen, &args, NULL);
out_put:
trace_dlm_lock_end(ls, lkb, name, namelen, mode, flags, error, true);
__put_lkb(ls, lkb);
- if (error == -EAGAIN || error == -EINPROGRESS)
- error = 0;
out:
dlm_unlock_recovery(ls);
dlm_put_lockspace(ls);
@@ -4486,7 +4485,7 @@ static int receive_request_reply(struct dlm_ls *ls,
queue_cast_overlap(r, lkb);
confirm_master(r, result);
} else {
- _request_lock(r, lkb);
+ _request_lock(r, lkb, NULL);
if (r->res_master_nodeid == dlm_our_nodeid())
confirm_master(r, 0);
}
@@ -4772,7 +4771,7 @@ static void receive_lookup_reply(struct dlm_ls *ls,
goto out_list;
}
- _request_lock(r, lkb);
+ _request_lock(r, lkb, NULL);
out_list:
if (do_lookup_list)
@@ -5328,7 +5327,7 @@ int dlm_recover_waiters_post(struct dlm_ls *ls)
switch (mstype) {
case DLM_MSG_LOOKUP:
case DLM_MSG_REQUEST:
- _request_lock(r, lkb);
+ _request_lock(r, lkb, NULL);
if (r->res_nodeid != -1 && is_master(r))
confirm_master(r, 0);
break;
@@ -5767,7 +5766,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
{
struct dlm_lkb *lkb;
struct dlm_args args;
- int error;
+ int error, result;
dlm_lock_recovery(ls);
@@ -5800,20 +5799,16 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
When DLM_DFL_USER_BIT is set, the dlm knows that this is a userspace
lock and that lkb_astparam is the dlm_user_args structure. */
set_bit(DLM_DFL_USER_BIT, &lkb->lkb_dflags);
- error = request_lock(ls, lkb, name, namelen, &args);
+ error = request_lock(ls, lkb, name, namelen, &args, &result);
+ if (error)
+ goto out_put;
- switch (error) {
- case 0:
- break;
- case -EINPROGRESS:
- error = 0;
- break;
- case -EAGAIN:
- error = 0;
- fallthrough;
- default:
+ /* the lkb lifetime ended because request_lock() handled
+ * internally an -EAGAIN, so we don't add it to the
+ * ownqueue.
+ */
+ if (result == -EAGAIN)
goto out_put;
- }
/* add this new lkb to the per-process list of locks */
spin_lock_bh(&ua->proc->locks_spin);
--
2.43.0
prev 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 ` [RFC dlm/next 03/11] dlm: use hold_lkb() instead kref_get() Alexander Aring
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 ` Alexander Aring [this message]
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-12-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