Re: [RFC] wrong behavior of re-adding a device

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

 



On Tue, Sep 25, 2018 at 3:47 AM Guoqing Jiang <gqjiang@xxxxxxxx> wrote:
>
>
>
> On 9/21/18 6:39 PM, Gi-Oh Kim wrote:
> > On Fri, Sep 21, 2018 at 5:58 AM Guoqing Jiang <gqjiang@xxxxxxxx> wrote:
> >>
> >>
> >> On 9/20/18 9:36 PM, Gi-Oh Kim wrote:
> >>> On Wed, Sep 19, 2018 at 5:09 PM Gi-Oh Kim <gi-oh.kim@xxxxxxxxxxxxxxxx> wrote:
> >>>> Hi,
> >>>>
> >>>> I found a weird behavior of re-adding a device.
> >>>> I think it is a kernel bug.
> >>>> I would appreciate it if somebody can confirm if it is a bug or feature.
> >>>>
> >>>> I tested re-adding a device as following.
> >>>> 1. create md with ram0 and ram1
> >>>> 2. add ram2
> >>>> 3. grow raid-device number to 3
> >>>> 4. remove ram2
> >>>> 5. grow raid-device number to 2
> >>>> 6. add ram2
> >>>> 7. ram0 become faulty and ram2 become active
> >>>> 8. stop md
> >>>> 9. assemble md with ram0 and ram1 => fail because ram0 is faulty
> >>> Hi,
> >>>
> >>> I checked the kernel function raid1_spare_active() in raid1.c and
> >>> found out ram0 is set as faulty on purpose.
> >>> If ram0 is set as fauly to replace it with ram2, i think it should be
> >>> successful to assemble ram1 and ram2.
> >>> But "mdadm -A /dev/md111 /dev/ram1 /dev/ram2" creates md111 with only ram2.
> >>> I do not understand why it is necessary to set ram0 faulty.
> >> When ram2 is add back to array, seems array prefers to use the previous
> >> role
> >> which is recorded by saved_raid_disk.
> >>
> >>> How can I re-add ram2 device as the spare device without setting ram0 faulty?
> >> I guess you can achieve the goal by remove the superblock of ram2
> >> (before step 6).
> > Yes, right. ram2 was re-added because it is just removed.
> > I tried removing the superblock of ram2 and touch md111 and both worked well
> > because mdadm did adding, not re-adding.
> >
> >> BTW, could you try the below change? I think it can fix the issue.
> > Yes, it fixed the issue.
> > Thank you very much.
> > Could you please send the patch to maintainers?
>
> Sure, and I will add your Reported-by and Tested-by tags.

I thank you.

>
> Thanks,
> Guoqing
>
>
> >> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> >> index 4e990246225e..1d54109071cc 100644
> >> --- a/drivers/md/raid1.c
> >> +++ b/drivers/md/raid1.c
> >> @@ -1734,6 +1734,7 @@ static int raid1_add_disk(struct mddev *mddev,
> >> struct md_rdev *rdev)
> >>            */
> >>           if (rdev->saved_raid_disk >= 0 &&
> >>               rdev->saved_raid_disk >= first &&
> >> +           rdev->saved_raid_disk < conf->raid_disks &&
> >>               conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
> >>                   first = last = rdev->saved_raid_disk;
> >>
> >>
> >>
> >> Thanks,
> >> Guoqing
> >
> >
>


-- 
GIOH KIM
Linux Kernel Entwickler

ProfitBricks GmbH
Greifswalder Str. 207
D - 10405 Berlin

Tel:       +49 176 2697 8962
Fax:      +49 30 577 008 299
Email:    gi-oh.kim@xxxxxxxxxxxxxxxx
URL:      https://www.profitbricks.de

Sitz der Gesellschaft: Berlin
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B
Geschäftsführer: Achim Weiss, Matthias Steinberg, Christoph Steffens




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux