linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Howto start reshape from 100% when change readonly raid to readwrite
@ 2014-09-11  3:06 Apple Yin
  2014-09-12  4:05 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Apple Yin @ 2014-09-11  3:06 UTC (permalink / raw)
  To: linux-raid

I met a prolem which confused me long time.
Background:
I have two machines which connected to the same HDDs, both of them are
linux software raid. Machine 1 called Master, Machine 2 called Slave.
Master can readwrite the HDD, Slave can read the HDD only.

/dev/md1 was  created on Master, and level is raid5 with 3 active
disks + 1 spare disk. On slave I assemble the md1 as readonly with the
same disks.Here is my steps:
Create md1(raid5) on Master:
#mdadm --create /dev/md1 -l 5 -n 3 -x 1 /dev/sd[bcde]
Assemble md1(raid5) as readonly on Slave:
#mdadm -A /dev/md1 /dev/sd[bcde] -o


When Master doing the reshape(#mdadm --grow --raid-devices 4 /dev/md1
), Slave need to do the same reshape( #mdadm --grow --raid-devices 4
/dev/md1).But md on Slave is readonly, so md_do_sync() not start.
After Master finish the reshape, all data has moved from 3disks to
4disks. How can I ask Slave's md1 to start the reshape from 100% after
set it to readwrite ? Here is my steps:

1.On Slave, I modify the reshape_position_store() of md.c in kernel,
to let user space to set reshape_position to “none” (100%):
static ssize_t
reshape_position_store(struct mddev *mddev, const char *buf, size_t len)
{
…
if (cmd_match(buf, “none”))
;
else if (buf == e || (*e && *e != ‘\n’))
return -EINVAL;

if (cmd_match(buf, “none”))
mddev->reshape_position = MaxSector;
else
mddev->reshape_position = new;
…
}
#echo none > /sys/block/md1/md/reshape_position

2. change readonly raid to readwrite on Slave
#mdadm –readwrite /dev/md1


Result: the reshape didn’t start . Slave's md1 size still the old size
( with 3 disk size)



BRs,
AppleYin
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Howto start reshape from 100% when change readonly raid to readwrite
  2014-09-11  3:06 Howto start reshape from 100% when change readonly raid to readwrite Apple Yin
@ 2014-09-12  4:05 ` NeilBrown
  0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2014-09-12  4:05 UTC (permalink / raw)
  To: Apple Yin; +Cc: linux-raid

[-- Attachment #1: Type: text/plain, Size: 2759 bytes --]

On Thu, 11 Sep 2014 11:06:59 +0800 Apple Yin <bravery.apple@gmail.com> wrote:

> I met a prolem which confused me long time.
> Background:
> I have two machines which connected to the same HDDs, both of them are
> linux software raid. Machine 1 called Master, Machine 2 called Slave.
> Master can readwrite the HDD, Slave can read the HDD only.
> 
> /dev/md1 was  created on Master, and level is raid5 with 3 active
> disks + 1 spare disk. On slave I assemble the md1 as readonly with the
> same disks.Here is my steps:
> Create md1(raid5) on Master:
> #mdadm --create /dev/md1 -l 5 -n 3 -x 1 /dev/sd[bcde]
> Assemble md1(raid5) as readonly on Slave:
> #mdadm -A /dev/md1 /dev/sd[bcde] -o
> 
> 
> When Master doing the reshape(#mdadm --grow --raid-devices 4 /dev/md1
> ), Slave need to do the same reshape( #mdadm --grow --raid-devices 4
> /dev/md1).But md on Slave is readonly, so md_do_sync() not start.
> After Master finish the reshape, all data has moved from 3disks to
> 4disks. How can I ask Slave's md1 to start the reshape from 100% after
> set it to readwrite ? Here is my steps:

There is no way that you can make this reliable.
Even without a --grow happening, the read-only mount of changeable data could
end up very confused.  You definitely cannot get md/raid5 to track the
changes made by another instance of md when reshaping.

If you unmount and --stop the array before starting the reshape, then
re-assemble and re-mount it, the more obvious probably should go away.
But it is likely there will still be less-obvious problems.

md might support clusters one day (though raid1 is much more likely than
raid5) but it certainly doesn't today.
I suggest you try to find a different solution to your underlying problem.

NeilBrown


> 
> 1.On Slave, I modify the reshape_position_store() of md.c in kernel,
> to let user space to set reshape_position to “none” (100%):
> static ssize_t
> reshape_position_store(struct mddev *mddev, const char *buf, size_t len)
> {
> …
> if (cmd_match(buf, “none”))
> ;
> else if (buf == e || (*e && *e != ‘\n’))
> return -EINVAL;
> 
> if (cmd_match(buf, “none”))
> mddev->reshape_position = MaxSector;
> else
> mddev->reshape_position = new;
> …
> }
> #echo none > /sys/block/md1/md/reshape_position
> 
> 2. change readonly raid to readwrite on Slave
> #mdadm –readwrite /dev/md1
> 
> 
> Result: the reshape didn’t start . Slave's md1 size still the old size
> ( with 3 disk size)
> 
> 
> 
> BRs,
> AppleYin
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-12  4:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-11  3:06 Howto start reshape from 100% when change readonly raid to readwrite Apple Yin
2014-09-12  4:05 ` NeilBrown

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).