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 10/11] dlm: void convert, cancel and unlock requests
Date: Thu,  7 Nov 2024 15:46:16 -0500	[thread overview]
Message-ID: <20241107204617.147842-11-aahringo@redhat.com> (raw)
In-Reply-To: <20241107204617.147842-1-aahringo@redhat.com>

Ad the new lkb refcount model does not require to evaluate the return
value of request functions we can change those function to return no
value. Before the return value was just always zeroed out if any of the
non-zero return value was returned. This is not necessary anymore.

The _request_lock() function need an additional handling as the user
request functionality still needs to evaluate the return value.

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

diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 1de8598d7451..28c312410527 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -84,7 +84,7 @@ 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 int _cancel_lock(struct dlm_rsb *r, struct dlm_lkb *lkb);
+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);
 static int receive_extralen(const struct dlm_message *ms);
@@ -3268,9 +3268,9 @@ static int _request_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 
 /* change some property of an existing lkb, e.g. mode */
 
-static int _convert_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
+static void _convert_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 {
-	int error = 0;
+	int error;
 
 	WARN_ON(lkb->lkb_rq_state != DLM_LKB_RQ_STATE_CONVERT);
 
@@ -3283,15 +3283,13 @@ static int _convert_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 		   between do_convert and do_convert_effects */
 		do_convert_effects(r, lkb, error);
 	}
-
-	return error;
 }
 
 /* remove an existing lkb from the granted queue */
 
-static int _unlock_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
+static void _unlock_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 {
-	int error = 0;
+	int error;
 
 	WARN_ON(lkb->lkb_rq_state != DLM_LKB_RQ_STATE_REQUEST &&
 		lkb->lkb_rq_state != DLM_LKB_RQ_STATE_CONVERT);
@@ -3305,15 +3303,13 @@ static int _unlock_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 		   between do_unlock and do_unlock_effects */
 		do_unlock_effects(r, lkb, error);
 	}
-
-	return error;
 }
 
 /* remove an existing lkb from the convert or wait queue */
 
-static int _cancel_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
+static void _cancel_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 {
-	int error = 0;
+	int error;
 
 	WARN_ON(lkb->lkb_rq_state != DLM_LKB_RQ_STATE_REQUEST &&
 		lkb->lkb_rq_state != DLM_LKB_RQ_STATE_CONVERT);
@@ -3327,8 +3323,6 @@ static int _cancel_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
 		   between do_cancel and do_cancel_effects */
 		do_cancel_effects(r, lkb, error);
 	}
-
-	return error;
 }
 
 /*
@@ -3385,7 +3379,7 @@ static int convert_lock(struct dlm_ls *ls, struct dlm_lkb *lkb,
 	if (error)
 		goto out;
 
-	error = _convert_lock(r, lkb);
+	_convert_lock(r, lkb);
  out:
 	unlock_rsb(r);
 	put_rsb(r);
@@ -3407,7 +3401,7 @@ static int unlock_lock(struct dlm_ls *ls, struct dlm_lkb *lkb,
 	if (error)
 		goto out;
 
-	error = _unlock_lock(r, lkb);
+	_unlock_lock(r, lkb);
  out:
 	unlock_rsb(r);
 	put_rsb(r);
@@ -3429,7 +3423,7 @@ static int cancel_lock(struct dlm_ls *ls, struct dlm_lkb *lkb,
 	if (error)
 		goto out;
 
-	error = _cancel_lock(r, lkb);
+	_cancel_lock(r, lkb);
  out:
 	unlock_rsb(r);
 	put_rsb(r);
@@ -3482,13 +3476,11 @@ int dlm_lock(dlm_lockspace_t *lockspace,
 	else
 		error = request_lock(ls, lkb, name, namelen, &args);
 
-	if (error == -EINPROGRESS)
-		error = 0;
  out_put:
 	trace_dlm_lock_end(ls, lkb, name, namelen, mode, flags, error, true);
 
 	__put_lkb(ls, lkb);
-	if (error == -EAGAIN || error == -EDEADLK)
+	if (error == -EAGAIN || error == -EINPROGRESS)
 		error = 0;
  out:
 	dlm_unlock_recovery(ls);
@@ -3528,8 +3520,6 @@ int dlm_unlock(dlm_lockspace_t *lockspace,
 	else
 		error = unlock_lock(ls, lkb, &args);
 
-	if (error == -DLM_EUNLOCK || error == -DLM_ECANCEL)
-		error = 0;
 	if (error == -EBUSY && (flags & (DLM_LKF_CANCEL | DLM_LKF_FORCEUNLOCK)))
 		error = 0;
  out_put:
@@ -4497,7 +4487,6 @@ static int receive_request_reply(struct dlm_ls *ls,
 			confirm_master(r, result);
 		} else {
 			_request_lock(r, lkb);
-
 			if (r->res_master_nodeid == dlm_our_nodeid())
 				confirm_master(r, 0);
 		}
@@ -5884,8 +5873,6 @@ int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
 
 	error = convert_lock(ls, lkb, &args);
 
-	if (error == -EINPROGRESS || error == -EAGAIN || error == -EDEADLK)
-		error = 0;
  out_put:
 	trace_dlm_lock_end(ls, lkb, NULL, 0, mode, flags, error, false);
 	dlm_put_lkb(lkb);
@@ -6092,7 +6079,7 @@ int dlm_user_deadlock(struct dlm_ls *ls, uint32_t flags, uint32_t lkid)
 		goto out_r;
 	set_bit(DLM_IFL_DEADLOCK_CANCEL_BIT, &lkb->lkb_iflags);
 
-	error = _cancel_lock(r, lkb);
+	_cancel_lock(r, lkb);
  out_r:
 	unlock_rsb(r);
 	put_rsb(r);
-- 
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 ` [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 ` Alexander Aring [this message]
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-11-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