Skip to contentSkip to conversation

mdadm: minor fixes

PATCH Applied Xiao Ni 2 participants 4 messages Oct 18, 2024 MD RAID

lore
Share & tools
lore

Xiao Ni

author
#0 lore raw

cover mdadm: minor fixes

Xiao Ni (2):
mdadm/Manage: Clear superblock if adding new device fails mdadm/Grow: Check new_level interface rather than kernel version

 Grow.c   | 2 +-
 Manage.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.32.0 (Apple Git-132)
author
#1 lore raw

PATCH v2 1/2 mdadm/Manage: Clear superblock if adding new device fails

The superblock is kept if adding new device fails. It should clear the superblock if it fails to add a new disk.

---
v2: change type of add_new_super to bool

 Manage.c | 4 ++++
 1 file changed, 4 insertions(+)
Manage.c +4 -0
index 246ef3194aaa..8c58683b83c1 100644
@@ -793,6 +793,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
 	int j;
 	mdu_disk_info_t disc;
 	struct map_ent *map = NULL;
+	bool add_new_super = false;
 
 	if (!get_dev_size(tfd, dv->devname, &ldsize)) {
 		if (dv->disposition == 'M')
@@ -1011,6 +1012,7 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
 			goto unlock;
 		if (tst->ss->write_init_super(tst))
 			goto unlock;
+		add_new_super = true;
 	} else if (dv->disposition == 'A') {
 		/*  this had better be raid1.
 		 * As we are "--re-add"ing we must find a spare slot
@@ -1078,6 +1080,8 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
 	map_unlock(&map);
 	return 1;
 unlock:
+	if (add_new_super)
+		Kill(dv->devname, tst, 0, -1, 0);
 	map_unlock(&map);
 	return -1;
 }
Signature · 1 line
2.32.0 (Apple Git-132)
author
#2 lore raw

PATCH 2/2 mdadm/Grow: Check new_level interface rather than kernel version

In reply to Xiao Ni

Different os distributions have different kernel version themselves. Check new_level sysfs interface rather than kernel version.

---
 Grow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Grow.c +1 -1
index ef1285ecebcf..9032c3e9c09f 100644
@@ -2952,7 +2952,7 @@ static int impose_reshape(struct mdinfo *sra,
 			err = errno;
 
 		/* new_level is introduced in kernel 6.12 */
-		if (!err && get_linux_version() >= 6012000 &&
+		if (!err && sysfs_attribute_available(sra, NULL, "new_level") &&
 				sysfs_set_num(sra, NULL, "new_level", info->new_level) < 0)
 			err = errno;
 
Signature · 1 line
2.32.0 (Apple Git-132)
#3 lore raw
In reply to Xiao Ni
Quoted 8 lines · On Fri, 18 Oct 2024 16:48:15 +0800 Xiao Ni <[email protected]> wrote:

Xiao Ni (2):
mdadm/Manage: Clear superblock if adding new device fails mdadm/Grow: Check new_level interface rather than kernel version

 Grow.c   | 2 +-
 Manage.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

Applied!

Thanks,
Mariusz