]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix writing data into the seed filesystem
authorMiao Xie <miaox@cn.fujitsu.com>
Thu, 3 Jul 2014 10:22:13 +0000 (18:22 +0800)
committerChris Mason <clm@fb.com>
Wed, 17 Sep 2014 20:37:27 +0000 (13:37 -0700)
commitfd261139d9bb09597de78ca2391429215272d475
treebfcd3d752e12bb727701250fdf58cb5f3f0abebc
parenteb88dd64510e29af1f2a8381c827ba9e7d3653f2
Btrfs: fix writing data into the seed filesystem

If we mounted a seed filesystem with degraded option, and then added a new
device into the seed filesystem, then we found adding device failed because
of the IO failure.

Steps to reproduce:
 # mkfs.btrfs -d raid1 -m raid1 <dev0> <dev1>
 # btrfstune -S 1 <dev0>
 # mount <dev0> -o degraded <mnt>
 # btrfs device add -f <dev2> <mnt>

It is because the original didn't set the chunk on the seed device to be
read-only if the degraded flag was set. It was introduced by patch c93cd51c8,
which fixed the problem the raid1 filesystem became read-only after one device
of it was missing. But this fix method was not right, we should set the read-only
flag according to the number of the missing devices, not the degraded mount
option, if the number of the missing devices is less than the max error number
that the profile of the chunk tolerates, we don't set it to be read-only.

Cc: Josef Bacik <jbacik@fb.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/volumes.c