linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Warkentin <andreiw@vmware.com>
To: linux-raid@vger.kernel.org
Cc: Andrei Warkentin <andreiw@vmware.com>, Neil Brown <neilb@suse.de>
Subject: [RFC] MD: Allow restarting an interrupted incremental recovery.
Date: Wed, 12 Oct 2011 19:05:33 -0400	[thread overview]
Message-ID: <1318460733-886-1-git-send-email-andreiw@vmware.com> (raw)
In-Reply-To: <CANz0V+7ZGKvyznbU_5d2cQm2XL=Wf9B8+HwZZ9KeZSfuawtyOg@mail.gmail.com>

If an incremental recovery was interrupted, a subsequent
re-add will result in a full recovery, even though an
incremental should be possible (seen with raid1).

Solve this problem by not updating the superblock on the
recovering device until array is not degraded any longer.

Cc: Neil Brown <neilb@suse.de>
Signed-off-by: Andrei Warkentin <andreiw@vmware.com>
---
 drivers/md/md.c |   19 +++++++++++++------
 drivers/md/md.h |    6 ++++++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5404b22..153b3c6 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2444,9 +2444,12 @@ repeat:
 			continue; /* no noise on spare devices */
 		if (test_bit(Faulty, &rdev->flags))
 			dprintk("(skipping faulty ");
+		else if (test_bit(InIncremental, &rdev->flags))
+			dprintk("(skipping incremental s/r ");
 
 		dprintk("%s ", bdevname(rdev->bdev,b));
-		if (!test_bit(Faulty, &rdev->flags)) {
+		if (!test_bit(Faulty, &rdev->flags) &&
+		    !test_bit(InIncremental, &rdev->flags)) {
 			md_super_write(mddev,rdev,
 				       rdev->sb_start, rdev->sb_size,
 				       rdev->sb_page);
@@ -5490,9 +5493,10 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
 			return -EINVAL;
 		}
 
-		if (test_bit(In_sync, &rdev->flags))
+		if (test_bit(In_sync, &rdev->flags)) {
 			rdev->saved_raid_disk = rdev->raid_disk;
-		else
+			set_bit(InIncremental, &rdev->flags);
+		} else
 			rdev->saved_raid_disk = -1;
 
 		clear_bit(In_sync, &rdev->flags); /* just to be sure */
@@ -7353,15 +7357,18 @@ static void reap_sync_thread(mddev_t *mddev)
 	if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
 	    mddev->pers->finish_reshape)
 		mddev->pers->finish_reshape(mddev);
-	md_update_sb(mddev, 1);
 
 	/* if array is no-longer degraded, then any saved_raid_disk
-	 * information must be scrapped
+	 * information must be scrapped, and superblock for
+	 * incrementally recovered device written out.
 	 */
 	if (!mddev->degraded)
-		list_for_each_entry(rdev, &mddev->disks, same_set)
+		list_for_each_entry(rdev, &mddev->disks, same_set) {
 			rdev->saved_raid_disk = -1;
+			clear_bit(InIncremental, &rdev->flags);
+		}
 
+	md_update_sb(mddev, 1);
 	clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
 	clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
 	clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 1e586bb..5e5399a 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -104,6 +104,12 @@ struct mdk_rdev_s
 					 * accurately as possible is good, but
 					 * not absolutely critical.
 					 */
+#define InIncremental	12		/* Device is undergoing incremental
+					 * recovery, hence its superblock
+					 * is not written out until the recovery
+					 * ends, allowing the later to be
+					 * restared if interrupted.
+					 */
 	wait_queue_head_t blocked_wait;
 
 	int desc_nr;			/* descriptor index in the superblock */
-- 
1.7.4.1


  reply	other threads:[~2011-10-12 23:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-12 19:41 [RFC] MD: Restart an interrupted incremental recovery Andrei Warkentin
2011-10-12 23:04 ` Andrei E. Warkentin
2011-10-12 23:05   ` Andrei Warkentin [this message]
2011-10-14  1:18     ` [RFC] MD: Allow restarting " Andrei E. Warkentin
2011-10-17  3:20       ` NeilBrown
2011-10-17 17:26         ` Andrei Warkentin
2011-10-17 20:58           ` NeilBrown
2011-10-14  1:07 ` [RFC] MD: Restart " Andrei E. Warkentin

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=1318460733-886-1-git-send-email-andreiw@vmware.com \
    --to=andreiw@vmware.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    /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).