Skip to contentSkip to conversation

Fix oddity where mdadm did not recognise a relative path

PATCH Applied Wols Lists 2 participants 5 messages Jan 17, 2017 – Mar 3, 2017 MD RAID

lore
Share & tools
lore

Wols Lists

author
#0 lore raw

PATCH 1/1 Fix oddity where mdadm did not recognise a relative path

From 4ce784307a9004124392ce48432960d7ca94d0bf Mon Sep 17 00:00:00 2001
From: Wol <[email protected]>
Date: Tue, 17 Jan 2017 17:47:05 +0000
Subject: [PATCH] Fix oddity where mdadm did not recognise a relative path

mdadm assumed that a pathname started with a "/", while an array name didn't. This alters the logic so that if the first character is not a "/" it tries to open an array, and if that fails it drops through to the pathname code rather than terminating immediately with an error.

---
 mdadm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
mdadm.c +6 -6
index c3a265b..b5d89e4 100644
@@ -1899,12 +1899,12 @@ static int misc_list(struct mddev_dev *devlist,
 			rv |= SetAction(dv->devname, c->action);
 			continue;
 		}
-		if (dv->devname[0] == '/')
-			mdfd = open_mddev(dv->devname, 1);
-		else {
-			mdfd = open_dev(dv->devname);
-			if (mdfd < 0)
-				pr_err("Cannot open %s\n", dv->devname);
+		switch(dv->devname[0] == '/') {
+			case 0:
+				mdfd = open_dev(dv->devname);
+				if (mdfd >= 0) break;
+			case 1:
+				mdfd = open_mddev(dv->devname, 1);  
 		}
 		if (mdfd>=0) {
 			switch(dv->disposition) {
Signature · 1 line
2.7.3
#1 lore raw
Quoted 11 lines · Wols Lists

From 4ce784307a9004124392ce48432960d7ca94d0bf Mon Sep 17 00:00:00 2001
From: Wol <[email protected]>
Date: Tue, 17 Jan 2017 17:47:05 +0000
Subject: [PATCH] Fix oddity where mdadm did not recognise a relative path

mdadm assumed that a pathname started with a "/", while an array name didn't. This alters the logic so that if the first character is not a "/" it tries to open an array, and if that fails it drops through to the pathname code rather than terminating immediately with an error.

Quoted 4 lines
---
 mdadm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Applied, thanks!

Sorry I have been swamped the last couple of weeks finishing up my old job and starting the new one. Will be bogged down a lot the next couple of weeks, so please be patient.

Cheers,
Jes

author
#2 lore raw
Quoted 17 lines · On 29/01/17 17:48, [email protected] wrote:
Quoted 11 lines · Wols Lists

From 4ce784307a9004124392ce48432960d7ca94d0bf Mon Sep 17 00:00:00 2001
From: Wol <[email protected]>
Date: Tue, 17 Jan 2017 17:47:05 +0000
Subject: [PATCH] Fix oddity where mdadm did not recognise a relative path

mdadm assumed that a pathname started with a "/", while an array name didn't. This alters the logic so that if the first character is not a "/" it tries to open an array, and if that fails it drops through to the pathname code rather than terminating immediately with an error.

Quoted 4 lines
---
 mdadm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Quoted 6 lines

Applied, thanks!

Sorry I have been swamped the last couple of weeks finishing up my old job and starting the new one. Will be bogged down a lot the next couple of weeks, so please be patient.

Neil said you were changing jobs - that's fine. I just didn't want it to get missed, and as there was no initial response I was trying to do as gentle a "what's up" as I could.

That's fine. If it's in, then great :-) and I can wait for it to be released whenever.

Cheers,
Wol

#3 lore raw
In reply to Wols Lists
Quoted 26 lines · Wols Lists

From 4ce784307a9004124392ce48432960d7ca94d0bf Mon Sep 17 00:00:00 2001
From: Wol <[email protected]>
Date: Tue, 17 Jan 2017 17:47:05 +0000
Subject: [PATCH] Fix oddity where mdadm did not recognise a relative path

mdadm assumed that a pathname started with a "/", while an array name didn't. This alters the logic so that if the first character is not a "/" it tries to open an array, and if that fails it drops through to the pathname code rather than terminating immediately with an error.

---
 mdadm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
mdadm.c +0 -2
index c3a265b..b5d89e4 100644
@@ -1899,12 +1899,12 @@ static int misc_list(struct mddev_dev *devlist,
 			rv |= SetAction(dv->devname, c->action);
 			continue;
 		}
-		if (dv->devname[0] == '/')
-			mdfd = open_mddev(dv->devname, 1);

mdadm.c static int misc_list(struct mddev_dev *devlist, · line 1907

Quoted 10 lines
mdadm.c +6 -4
-		else {
-			mdfd = open_dev(dv->devname);
-			if (mdfd < 0)
-				pr_err("Cannot open %s\n", dv->devname);
+		switch(dv->devname[0] == '/') {
+			case 0:
+				mdfd = open_dev(dv->devname);
+				if (mdfd >= 0) break;
+			case 1:
+				mdfd = open_mddev(dv->devname, 1);  

I thought this was still pending but going back, it looks like I did apply it. The problem is I noticed a major issue in the patch, which doesn't belong in code, it is doing 'if () break' on the same line.

Mind sending me a patch to fix that.

Thanks,
Jes

author
#4 lore raw
Quoted 4 lines

I thought this was still pending but going back, it looks like I did apply it. The problem is I noticed a major issue in the patch, which doesn't belong in code, it is doing 'if () break' on the same line.

Sorry about that - corporate style and all that :-) but it is important to not break the standard style.

Quoted 6 lines

Mind sending me a patch to fix that.

Thanks,
Jes

Cheers,
Wol

From 945b835cc89fd16279e01f743f8507b80219c8a1 Mon Sep 17 00:00:00 2001
From: Wol <[email protected]>
Date: Fri, 3 Mar 2017 18:31:52 +0000
Subject: [PATCH] Fix formatting error

---
 mdadm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mdadm.c +2 -1
index b5d89e4..d973ae4 100644
@@ -1902,7 +1902,8 @@ static int misc_list(struct mddev_dev *devlist,
 		switch(dv->devname[0] == '/') {
 			case 0:
 				mdfd = open_dev(dv->devname);
-				if (mdfd >= 0) break;
+				if (mdfd >= 0)
+					break;
 			case 1:
 				mdfd = open_mddev(dv->devname, 1);  
 		}
Signature · 1 line
2.7.3