summaryrefslogtreecommitdiff
path: root/super0.c
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2011-09-19 13:06:38 +1000
committerNeilBrown <neilb@suse.de>2011-09-19 13:06:38 +1000
commit16715c01f7ea4410d3b0eb3fe8bd66ab9241f036 (patch)
tree577cb4f71bc616f53ccd04b3e004bd152d06bae8 /super0.c
parent3f555346fb26b7ee7447b004ecb2c2d57f243867 (diff)
Fix readding of a readwrite drive into a writemostly array
If you create a two drive raid1 array with one device writemostly, then fail the readwrite drive, when you add a new device, it will get the writemostly bit copied out of the remaining device's superblock into it's own. You can then remove the new drive and readd it as readwrite, which will work for the readd, but it leaves the stale WriteMostly1 bit in devflags resulting in the device going back to writemostly on the next assembly. The fix is to make sure that A) when we readd a device and we might have filled the st->sb info from a running device instead of the device being readded, then clear/set the WriteMostly1 bit in the super1 struct in addition to setting the disk state (ditto for super0, but slightly different mechanism) and B) when adding a clean device to an array (when we most certainly did copy the superblock info from an existing device), then clear any writemostly bits. Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super0.c')
-rw-r--r--super0.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/super0.c b/super0.c
index 62c4ff0c..f791e9d7 100644
--- a/super0.c
+++ b/super0.c
@@ -570,6 +570,10 @@ static int update_super0(struct supertype *st, struct mdinfo *info,
sb->state &= ~(1<<MD_SB_BITMAP_PRESENT);
} else if (strcmp(update, "_reshape_progress")==0)
sb->reshape_position = info->reshape_progress;
+ else if (strcmp(update, "writemostly")==0)
+ sb->state |= (1<<MD_DISK_WRITEMOSTLY);
+ else if (strcmp(update, "readwrite")==0)
+ sb->state &= ~(1<<MD_DISK_WRITEMOSTLY);
else
rv = -1;
@@ -688,6 +692,8 @@ static int add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo,
dk->minor = dinfo->minor;
dk->raid_disk = dinfo->raid_disk;
dk->state = dinfo->state;
+ /* In case our source disk was writemostly, don't copy that bit */
+ dk->state &= ~(1<<MD_DISK_WRITEMOSTLY);
sb->this_disk = sb->disks[dinfo->number];
sb->sb_csum = calc_sb0_csum(sb);