Skip to contentSkip to conversation

md-cluster: fix error return code in join()

PATCH Applied Wei Yongjun 2 participants 2 messages Aug 21, 2016 – Aug 24, 2016 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md-cluster: fix error return code in join()

From: Wei Yongjun <[email protected]>

Fix to return error code -ENOMEM from the lockres_init() error handling case instead of 0, as done elsewhere in this function.

---
 drivers/md/md-cluster.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/md/md-cluster.c +9 -3
index 333f0cf..2b13117 100644
@@ -874,8 +874,10 @@ static int join(struct mddev *mddev, int nodes)
 		goto err;
 	}
 	cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0);
-	if (!cinfo->ack_lockres)
+	if (!cinfo->ack_lockres) {
+		ret = -ENOMEM;
 		goto err;
+	}
 	/* get sync CR lock on ACK. */
 	if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR))
 		pr_err("md-cluster: failed to get a sync CR lock on ACK!(%d)\n",
@@ -889,8 +891,10 @@ static int join(struct mddev *mddev, int nodes)
 	pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number);
 	snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1);
 	cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1);
-	if (!cinfo->bitmap_lockres)
+	if (!cinfo->bitmap_lockres) {
+		ret = -ENOMEM;
 		goto err;
+	}
 	if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) {
 		pr_err("Failed to get bitmap lock\n");
 		ret = -EINVAL;
@@ -898,8 +902,10 @@ static int join(struct mddev *mddev, int nodes)
 	}
 
 	cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0);
-	if (!cinfo->resync_lockres)
+	if (!cinfo->resync_lockres) {
+		ret = -ENOMEM;
 		goto err;
+	}
 
 	return 0;
 err:
Applied
#1 lore raw
Quoted 40 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

Fix to return error code -ENOMEM from the lockres_init() error handling case instead of 0, as done elsewhere in this function.

---
 drivers/md/md-cluster.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/md/md-cluster.c +6 -2
index 333f0cf..2b13117 100644
@@ -874,8 +874,10 @@ static int join(struct mddev *mddev, int nodes)
 		goto err;
 	}
 	cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0);
-	if (!cinfo->ack_lockres)
+	if (!cinfo->ack_lockres) {
+		ret = -ENOMEM;
 		goto err;
+	}
 	/* get sync CR lock on ACK. */
 	if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR))
 		pr_err("md-cluster: failed to get a sync CR lock on ACK!(%d)\n",
@@ -889,8 +891,10 @@ static int join(struct mddev *mddev, int nodes)
 	pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number);
 	snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1);
 	cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1);
-	if (!cinfo->bitmap_lockres)
+	if (!cinfo->bitmap_lockres) {
+		ret = -ENOMEM;
 		goto err;
+	}
 	if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) {
 		pr_err("Failed to get bitmap lock\n");
 		ret = -EINVAL;
@@ -898,8 +902,10 @@ static int join(struct mddev *mddev, int nodes)
 	}

drivers/md/md-cluster.c static int join(struct mddev *mddev, int nodes) · line 911

Quoted 10 lines
drivers/md/md-cluster.c +3 -1
 
 	cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0);
-	if (!cinfo->resync_lockres)
+	if (!cinfo->resync_lockres) {
+		ret = -ENOMEM;
 		goto err;
+	}
 
 	return 0;
 err:

applied, thanks!