linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiao Ni <xni@redhat.com>
To: mariusz.tkaczyk@linux.intel.com
Cc: linux-raid@vger.kernel.org, ncroxon@redhat.com
Subject: [PATCH V2 1/2] mdadm/Manage: Clear superblock if adding new device fails
Date: Fri, 18 Oct 2024 16:48:16 +0800	[thread overview]
Message-ID: <20241018084817.60233-2-xni@redhat.com> (raw)
In-Reply-To: <20241018084817.60233-1-xni@redhat.com>

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

Signed-off-by: Xiao Ni <xni@redhat.com>
---
v2: change type of add_new_super to bool
 Manage.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Manage.c b/Manage.c
index 246ef3194aaa..8c58683b83c1 100644
--- a/Manage.c
+++ b/Manage.c
@@ -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;
 }
-- 
2.32.0 (Apple Git-132)


  reply	other threads:[~2024-10-18  8:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18  8:48 [PATCH 0/2] mdadm: minor fixes Xiao Ni
2024-10-18  8:48 ` Xiao Ni [this message]
2024-10-18  8:48 ` [PATCH 2/2] mdadm/Grow: Check new_level interface rather than kernel version Xiao Ni
2024-10-18 12:51 ` [PATCH 0/2] mdadm: minor fixes Mariusz Tkaczyk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241018084817.60233-2-xni@redhat.com \
    --to=xni@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mariusz.tkaczyk@linux.intel.com \
    --cc=ncroxon@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).