Skip to contentSkip to conversation

dlm: handle invalid lockspace member remove

PATCH New Alexander Aring 1 participant 4 messages Aug 14, 2025 Distributed lock manager (DLM)

lore
Share & tools
lore

Alexander Aring

author maintainer
#0 lore raw

PATCH 1/4 dlm: handle invalid lockspace member remove

Since commit de7b4869b4ecf ("dlm: add new configfs entry release_recover for lockspace members") we are moving lockspace members into a gone list before removing them to get additional removing attributes from configfs. There is still a very unlikely possibility when find_config_node() returns NULL, then for some reason the node wasn't marked as gone but it was removed. We will just handle this case and drop an error to observe if this case can ever happen.

---
 fs/dlm/member.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/dlm/member.c +7 -1
index 356337102015e..c0f557a80a754 100644
@@ -571,7 +571,13 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
 
 	list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) {
 		node = find_config_node(rv, memb->nodeid);
-		if (node && !node->new && !node->gone)
+		if (!node) {
+			log_error(ls, "remove member %d invalid",
+				  memb->nodeid);
+			return -EFAULT;
+		}
+
+		if (!node->new && !node->gone)
 			continue;
 
 		release_recover = 0;
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH 2/4 dlm: move to rinfo for all middle conversion cases

Since commit f74dacb4c8116 ("dlm: fix recovery of middle conversions") we introduced additional debugging information if we hit the middle conversion by using log_limit(). The DLM log_limit() functionality requires a DLM debug option being enabled. As this case is so rarely and excempt any potential introduced new issue with recovery we switching it to log_rinfo() ad this is ratelimited under normal DLM loglevel.

---
 fs/dlm/lock.c    | 2 +-
 fs/dlm/recover.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/dlm/lock.c +1 -1
index 6dd3a524cd352..be938fdf17d96 100644
@@ -5576,7 +5576,7 @@ static int receive_rcom_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
 
 	if (rl->rl_status == DLM_LKSTS_CONVERT && middle_conversion(lkb)) {
 		/* We may need to adjust grmode depending on other granted locks. */
-		log_limit(ls, "%s %x middle convert gr %d rq %d remote %d %x",
+		log_rinfo(ls, "%s %x middle convert gr %d rq %d remote %d %x",
 			  __func__, lkb->lkb_id, lkb->lkb_grmode,
 			  lkb->lkb_rqmode, lkb->lkb_nodeid, lkb->lkb_remid);
 		rsb_set_flag(r, RSB_RECOVER_CONVERT);
fs/dlm/recover.c +1 -1
index be4240f09abd4..3ac020fb8139e 100644
@@ -842,7 +842,7 @@ static void recover_conversion(struct dlm_rsb *r)
 		 */
 		if (((lkb->lkb_grmode == DLM_LOCK_PR) && (other_grmode == DLM_LOCK_CW)) ||
 		    ((lkb->lkb_grmode == DLM_LOCK_CW) && (other_grmode == DLM_LOCK_PR))) {
-			log_limit(ls, "%s %x gr %d rq %d, remote %d %x, other_lkid %u, other gr %d, set gr=NL",
+			log_rinfo(ls, "%s %x gr %d rq %d, remote %d %x, other_lkid %u, other gr %d, set gr=NL",
 				  __func__, lkb->lkb_id, lkb->lkb_grmode,
 				  lkb->lkb_rqmode, lkb->lkb_nodeid,
 				  lkb->lkb_remid, other_lkid, other_grmode);
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH 3/4 dlm: handle release_option as unsigned

In reply to Alexander Aring

Future patches will introduce a invalid argument check for undefined values. All values for release_option are positive integer values to not check on negative values as well we just change the parameter to unsigned int.

---
 fs/dlm/lockspace.c  | 8 ++++----
 include/linux/dlm.h | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)
fs/dlm/lockspace.c +4 -4
index d986b7ef153dc..8eadbf0fdf179 100644
@@ -676,7 +676,7 @@ int dlm_new_user_lockspace(const char *name, const char *cluster,
    This is because there may be LKBs queued as ASTs that have been unlinked
    from their RSBs and are pending deletion once the AST has been delivered */
 
-static int lockspace_busy(struct dlm_ls *ls, int release_option)
+static int lockspace_busy(struct dlm_ls *ls, unsigned int release_option)
 {
 	struct dlm_lkb *lkb;
 	unsigned long id;
@@ -704,7 +704,7 @@ static int lockspace_busy(struct dlm_ls *ls, int release_option)
 	return rv;
 }
 
-static int release_lockspace(struct dlm_ls *ls, int release_option)
+static int release_lockspace(struct dlm_ls *ls, unsigned int release_option)
 {
 	int busy, rv;
 
@@ -792,7 +792,7 @@ static int release_lockspace(struct dlm_ls *ls, int release_option)
  * See DLM_RELEASE defines for release_option values and their meaning.
  */
 
-int dlm_release_lockspace(void *lockspace, int force)
+int dlm_release_lockspace(void *lockspace, unsigned int release_option)
 {
 	struct dlm_ls *ls;
 	int error;
@@ -803,7 +803,7 @@ int dlm_release_lockspace(void *lockspace, int force)
 	dlm_put_lockspace(ls);
 
 	mutex_lock(&ls_lock);
-	error = release_lockspace(ls, force);
+	error = release_lockspace(ls, release_option);
 	if (!error)
 		ls_count--;
 	if (!ls_count)
include/linux/dlm.h +2 -1
index 108eb953eb181..34015a008b801 100644
@@ -122,7 +122,8 @@ int dlm_new_lockspace(const char *name, const char *cluster,
  * release_option: see DLM_RELEASE values above.
  */
 
-int dlm_release_lockspace(dlm_lockspace_t *lockspace, int release_option);
+int dlm_release_lockspace(dlm_lockspace_t *lockspace,
+			  unsigned int release_option);
 
 /*
  * dlm_lock
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH 4/4 dlm: check for undefined release_option values

In reply to Alexander Aring

Checking on all undefined release_option values to return -EINVAL in case a user is providing them to dlm_release_lockspace().

---
 fs/dlm/lockspace.c  | 3 +++
 include/linux/dlm.h | 1 +
 2 files changed, 4 insertions(+)
fs/dlm/lockspace.c +3 -0
index 8eadbf0fdf179..ddaa765587068 100644
@@ -797,6 +797,9 @@ int dlm_release_lockspace(void *lockspace, unsigned int release_option)
 	struct dlm_ls *ls;
 	int error;
 
+	if (release_option > __DLM_RELEASE_MAX)
+		return -EINVAL;
+
 	ls = dlm_find_lockspace_local(lockspace);
 	if (!ls)
 		return -EINVAL;
include/linux/dlm.h +1 -0
index 34015a008b801..7e7b45b0d0970 100644
@@ -113,6 +113,7 @@ int dlm_new_lockspace(const char *name, const char *cluster,
 #define DLM_RELEASE_NORMAL		2
 #define DLM_RELEASE_NO_EVENT		3
 #define DLM_RELEASE_RECOVER		4
+#define __DLM_RELEASE_MAX		DLM_RELEASE_RECOVER
 
 /*
  * dlm_release_lockspace
Signature · 1 line
2.43.0