Skip to contentSkip to conversation

mdadm: Expose Kill() return codes to user

PATCH Applied John Pittman 2 participants 4 messages Feb 2, 2018 – Feb 7, 2018 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mdadm: Expose Kill() return codes to user

In misc_list(), case KillOpt, the return values from the Kill() function are saved, but soon after cleared with a bitwise OR assignment. Expose these return values to the user, indicating success of the zeroing operation or an error value to accompany the error message printed to the console.

Before:

   # mdadm -C /dev/md0 -l 1 -n 2 -e 1.2 /dev/sda /dev/sdb
   mdadm: array /dev/md0 started.
   # mdadm --zero-superblock /dev/sdb
   mdadm: Couldn't open /dev/sdb for write - not zeroing
   # echo $?
   0

After:

   # mdadm -C /dev/md0 -l 1 -n 2 -e 1.2 /dev/sda /dev/sdb
   mdadm: array /dev/md0 started.
   # mdadm --zero-superblock /dev/sdb
   mdadm: Couldn't open /dev/sdb for write - not zeroing
   # echo $?
   2
---
 mdadm.c | 1 -
 1 file changed, 1 deletion(-)
mdadm.c +0 -1
index afc3015..77b80fa 100644
@@ -1937,7 +1937,6 @@ static int misc_list(struct mddev_dev *devlist,
 					rv |= Kill(dv->devname, NULL, c->force, v, 0);
 					v = -1;
 				} while (rv == 0);
-				rv &= ~2;
 			}
 			continue;
 		case 'Q':
Signature · 1 line
2.7.5
Applied
#1 lore raw
Quoted 17 lines · John Pittman

In misc_list(), case KillOpt, the return values from the Kill() function are saved, but soon after cleared with a bitwise OR assignment. Expose these return values to the user, indicating success of the zeroing operation or an error value to accompany the error message printed to the console.

Before:

   # mdadm -C /dev/md0 -l 1 -n 2 -e 1.2 /dev/sda /dev/sdb
   mdadm: array /dev/md0 started.
   # mdadm --zero-superblock /dev/sdb
   mdadm: Couldn't open /dev/sdb for write - not zeroing
   # echo $?
   0

After:

Quoted 8 lines
   # mdadm -C /dev/md0 -l 1 -n 2 -e 1.2 /dev/sda /dev/sdb
   mdadm: array /dev/md0 started.
   # mdadm --zero-superblock /dev/sdb
   mdadm: Couldn't open /dev/sdb for write - not zeroing
   # echo $?
   2

Seems reasonable to me!

Applied!

Thanks,
Jes

#2 lore raw

Terribly sorry Jes, got pulled away and did not get back. Unfortunately this patch is incorrect. Please revert. It causes the return value of even a successful wipe to be 2. If I can figure out why, I will re-submit. Apologies again.

Quoted 34 lines · Jes Sorensen
Quoted 17 lines · John Pittman

In misc_list(), case KillOpt, the return values from the Kill() function are saved, but soon after cleared with a bitwise OR assignment. Expose these return values to the user, indicating success of the zeroing operation or an error value to accompany the error message printed to the console.

Before:

   # mdadm -C /dev/md0 -l 1 -n 2 -e 1.2 /dev/sda /dev/sdb
   mdadm: array /dev/md0 started.
   # mdadm --zero-superblock /dev/sdb
   mdadm: Couldn't open /dev/sdb for write - not zeroing
   # echo $?
   0

After:

Quoted 8 lines
   # mdadm -C /dev/md0 -l 1 -n 2 -e 1.2 /dev/sda /dev/sdb
   mdadm: array /dev/md0 started.
   # mdadm --zero-superblock /dev/sdb
   mdadm: Couldn't open /dev/sdb for write - not zeroing
   # echo $?
   2

Seems reasonable to me!

Applied!

Thanks,
Jes

#3 lore raw
Quoted 4 lines · John Pittman

Terribly sorry Jes, got pulled away and did not get back. Unfortunately this patch is incorrect. Please revert. It causes the return value of even a successful wipe to be 2. If I can figure out why, I will re-submit. Apologies again.

Good thing I hadn't pushed it - gone!

Jes

Quoted 35 lines · Jes Sorensen
Quoted 34 lines · John Pittman
Quoted 17 lines

In misc_list(), case KillOpt, the return values from the Kill() function are saved, but soon after cleared with a bitwise OR assignment. Expose these return values to the user, indicating success of the zeroing operation or an error value to accompany the error message printed to the console.

Before:

   # mdadm -C /dev/md0 -l 1 -n 2 -e 1.2 /dev/sda /dev/sdb
   mdadm: array /dev/md0 started.
   # mdadm --zero-superblock /dev/sdb
   mdadm: Couldn't open /dev/sdb for write - not zeroing
   # echo $?
   0

After:

Quoted 8 lines
   # mdadm -C /dev/md0 -l 1 -n 2 -e 1.2 /dev/sda /dev/sdb
   mdadm: array /dev/md0 started.
   # mdadm --zero-superblock /dev/sdb
   mdadm: Couldn't open /dev/sdb for write - not zeroing
   # echo $?
   2

Seems reasonable to me!

Applied!

Thanks,
Jes