]> git.hungrycats.org Git - linux/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)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Wed, 3 Dec 2014 15:16:11 +0000 (10:16 -0500)
commit07624efa75581cf94eefd236852e34c33eb8125d
treeed32863b2d01903b86f6723380acd41c9a4d1b84
parent0f605ff6e3795815110764c8baa40ad453abef2b
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 f48b90756,
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>
(cherry picked from commit d20983b40e828fdca920b3d678544c6a0967a446)
fs/btrfs/volumes.c