Bug#628668: mdadm: Impossible to clear the write-mostly flag in metadata

NeilBrown neilb at suse.de
Tue Aug 2 03:45:24 UTC 2011


On Tue, 31 May 2011 10:37:53 +0200 (CEST) Anders Boström
<anders at netinsight.net> wrote:

> Package: mdadm
> Version: 3.1.4-1+8efb9d1
> Severity: normal
> 
> When turning off write-mostly on a device in an active raid1 array,
> using something like this:
> 
> echo -writemostly >/sys/block/md127/md/dev-md2/state
> 
> write-mostly is turned off:
> 
> flash:~ >mdadm -D /dev/md127 
> /dev/md127:
>         Version : 1.2
>   Creation Time : Thu Oct 15 13:32:06 2009
>      Raid Level : raid1
>      Array Size : 312581688 (298.10 GiB 320.08 GB)
>   Used Dev Size : 312581688 (298.10 GiB 320.08 GB)
>    Raid Devices : 2
>   Total Devices : 2
>     Persistence : Superblock is persistent
> 
>     Update Time : Tue May 31 10:35:15 2011
>           State : clean
>  Active Devices : 2
> Working Devices : 2
>  Failed Devices : 0
>   Spare Devices : 0
> 
>            Name : flash:mirror1  (local to host flash)
>            UUID : 066d46b2:5ca5113d:261cfcc0:626c2d62
>          Events : 842
> 
>     Number   Major   Minor   RaidDevice State
>        3       9        2        0      active sync   /dev/md/2
>        2       8        3        1      active sync writemostly   /dev/sda3
> flash:~ >
> 
> But the metadata isn't updated:
> 
> flash:~ >mdadm -E /dev/md/2
> /dev/md/2:
>           Magic : a92b4efc
>         Version : 1.2
>     Feature Map : 0x0
>      Array UUID : 066d46b2:5ca5113d:261cfcc0:626c2d62
>            Name : flash:mirror1  (local to host flash)
>   Creation Time : Thu Oct 15 13:32:06 2009
>      Raid Level : raid1
>    Raid Devices : 2
> 
>  Avail Dev Size : 625163376 (298.10 GiB 320.08 GB)
>      Array Size : 625163376 (298.10 GiB 320.08 GB)
>     Data Offset : 144 sectors
>    Super Offset : 8 sectors
>           State : clean
>     Device UUID : c995047e:7f56e673:9fc386be:dac782e1
> 
>       Flags : write-mostly
>     Update Time : Tue May 31 10:29:08 2011
>        Checksum : 8020a873 - correct
>          Events : 842
> 
> 
>    Device Role : Active device 0
>    Array State : AA ('A' == active, '.' == missing)
> flash:~ >
> 
> And after a reboot, md2 is flagged as writemostly again.
> 
> / Anders
> 

This needs to be fixed in the kernel.
I have added a patch to me 'for-next' branch and it should appear in 3.1-rc
at some stage.

Thanks for the report.

NeilBrown



http://neil.brown.name/git?p=md;a=commitdiff;h=f5d912d100ea7078bd28668aa3265ebd2bb53a84

From: NeilBrown <neilb at suse.de>
Date: Tue, 2 Aug 2011 03:38:35 +0000 (+1000)
Subject: md: ensure changes to 'write-mostly' are reflected in metadata.
X-Git-Url: http://neil.brown.name/git?p=md;a=commitdiff_plain;h=f5d912d100ea7078bd28668aa3265ebd2bb53a84

md: ensure changes to 'write-mostly' are reflected in metadata.

The 'write-mostly' flag can be changed through sysfs.
With 0.90 metadata, those changes are reflected in the metadata.
For 1.x metadata, they aren't.

So fix super_1_sync to record 'write-mostly' status.

Signed-off-by: NeilBrown <neilb at suse.de>
---

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1cd9bfb..9a88023 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1738,6 +1738,11 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
 	sb->level = cpu_to_le32(mddev->level);
 	sb->layout = cpu_to_le32(mddev->layout);
 
+	if (test_bit(WriteMostly, &rdev->flags))
+		sb->devflags |= WriteMostly1;
+	else
+		sb->devflags &= ~WriteMostly1;
+
 	if (mddev->bitmap && mddev->bitmap_info.file == NULL) {
 		sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_info.offset);
 		sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);






More information about the pkg-mdadm-devel mailing list