Re: FAILED: patch "[PATCH] md: fix problem when adding device to read-only array with" failed to apply to 3.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 22 Jan 2014 13:16:12 -0800 <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:

> 
> The patch below does not apply to the 3.4-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@xxxxxxxxxxxxxxx>.

This doesn't apply and isn't needed.
Though the patch in 3.2 which I identified isn't ideal, it didn't really
become a problem until

commit 7ceb17e87bde79d285a8b988cfed9eaeebe60b86
Author: NeilBrown <neilb@xxxxxxx>
Date:   Wed Apr 24 11:42:42 2013 +1000

    md: Allow devices to be re-added to a read-only array.

which was in 3.10.
So this patch is only needed in 3.10 and later, and I think it applies
cleanly to all those.

Sorry for the noise.

NeilBrown


> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> >From 8313b8e57f55b15e5b7f7fc5d1630bbf686a9a97 Mon Sep 17 00:00:00 2001
> From: NeilBrown <neilb@xxxxxxx>
> Date: Thu, 12 Dec 2013 10:13:33 +1100
> Subject: [PATCH] md: fix problem when adding device to read-only array with
>  bitmap.
> 
> If an array is started degraded, and then the missing device
> is found it can be re-added and a minimal bitmap-based recovery
> will bring it fully up-to-date.
> 
> If the array is read-only a recovery would not be allowed.
> But also if the array is read-only and the missing device was
> present very recently, then there could be no need for any
> recovery at all, so we simply include the device in the read-only
> array without any recovery.
> 
> However... if the missing device was removed a little longer ago
> it could be missing some updates, but if a bitmap is present it will
> be conditionally accepted pending a bitmap-based update.  We don't
> currently detect this case properly and will include that old
> device into the read-only array with no recovery even though it really
> needs a recovery.
> 
> This patch keeps track of whether a bitmap-based-recovery is really
> needed or not in the new Bitmap_sync rdev flag.  If that is set,
> then the device will not be added to a read-only array.
> 
> Cc: Andrei Warkentin <andreiw@xxxxxxxxxx>
> Fixes: d70ed2e4fafdbef0800e73942482bb075c21578b
> Cc: stable@xxxxxxxxxxxxxxx (3.2+)
> Signed-off-by: NeilBrown <neilb@xxxxxxx>
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index e60cebf3f519..2a456a5d59a8 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -1087,6 +1087,7 @@ static int super_90_validate(struct mddev *mddev, struct md_rdev *rdev)
>  	rdev->raid_disk = -1;
>  	clear_bit(Faulty, &rdev->flags);
>  	clear_bit(In_sync, &rdev->flags);
> +	clear_bit(Bitmap_sync, &rdev->flags);
>  	clear_bit(WriteMostly, &rdev->flags);
>  
>  	if (mddev->raid_disks == 0) {
> @@ -1165,6 +1166,8 @@ static int super_90_validate(struct mddev *mddev, struct md_rdev *rdev)
>  		 */
>  		if (ev1 < mddev->bitmap->events_cleared)
>  			return 0;
> +		if (ev1 < mddev->events)
> +			set_bit(Bitmap_sync, &rdev->flags);
>  	} else {
>  		if (ev1 < mddev->events)
>  			/* just a hot-add of a new device, leave raid_disk at -1 */
> @@ -1573,6 +1576,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
>  	rdev->raid_disk = -1;
>  	clear_bit(Faulty, &rdev->flags);
>  	clear_bit(In_sync, &rdev->flags);
> +	clear_bit(Bitmap_sync, &rdev->flags);
>  	clear_bit(WriteMostly, &rdev->flags);
>  
>  	if (mddev->raid_disks == 0) {
> @@ -1655,6 +1659,8 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
>  		 */
>  		if (ev1 < mddev->bitmap->events_cleared)
>  			return 0;
> +		if (ev1 < mddev->events)
> +			set_bit(Bitmap_sync, &rdev->flags);
>  	} else {
>  		if (ev1 < mddev->events)
>  			/* just a hot-add of a new device, leave raid_disk at -1 */
> @@ -2798,6 +2804,7 @@ slot_store(struct md_rdev *rdev, const char *buf, size_t len)
>  		else
>  			rdev->saved_raid_disk = -1;
>  		clear_bit(In_sync, &rdev->flags);
> +		clear_bit(Bitmap_sync, &rdev->flags);
>  		err = rdev->mddev->pers->
>  			hot_add_disk(rdev->mddev, rdev);
>  		if (err) {
> @@ -5770,6 +5777,7 @@ static int add_new_disk(struct mddev * mddev, mdu_disk_info_t *info)
>  			    info->raid_disk < mddev->raid_disks) {
>  				rdev->raid_disk = info->raid_disk;
>  				set_bit(In_sync, &rdev->flags);
> +				clear_bit(Bitmap_sync, &rdev->flags);
>  			} else
>  				rdev->raid_disk = -1;
>  		} else
> @@ -7716,7 +7724,8 @@ static int remove_and_add_spares(struct mddev *mddev,
>  		if (test_bit(Faulty, &rdev->flags))
>  			continue;
>  		if (mddev->ro &&
> -		    rdev->saved_raid_disk < 0)
> +		    ! (rdev->saved_raid_disk >= 0 &&
> +		       !test_bit(Bitmap_sync, &rdev->flags)))
>  			continue;
>  
>  		rdev->recovery_offset = 0;
> @@ -7797,9 +7806,12 @@ void md_check_recovery(struct mddev *mddev)
>  			 * As we only add devices that are already in-sync,
>  			 * we can activate the spares immediately.
>  			 */
> -			clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
>  			remove_and_add_spares(mddev, NULL);
> -			mddev->pers->spare_active(mddev);
> +			/* There is no thread, but we need to call
> +			 * ->spare_active and clear saved_raid_disk
> +			 */
> +			md_reap_sync_thread(mddev);
> +			clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
>  			goto unlock;
>  		}
>  
> diff --git a/drivers/md/md.h b/drivers/md/md.h
> index 2f5cc8a7ef3e..0095ec84ffc7 100644
> --- a/drivers/md/md.h
> +++ b/drivers/md/md.h
> @@ -129,6 +129,9 @@ struct md_rdev {
>  enum flag_bits {
>  	Faulty,			/* device is known to have a fault */
>  	In_sync,		/* device is in_sync with rest of array */
> +	Bitmap_sync,		/* ..actually, not quite In_sync.  Need a
> +				 * bitmap-based recovery to get fully in sync
> +				 */
>  	Unmerged,		/* device is being added to array and should
>  				 * be considerred for bvec_merge_fn but not
>  				 * yet for actual IO

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]