Btrfs: don't allow the replace procedure on read only filesystems
authorStefan Behrens <sbehrens@giantdisaster.de>
Mon, 19 Aug 2013 16:51:13 +0000 (18:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Sep 2013 00:18:27 +0000 (17:18 -0700)
commit42cc8e56740efe9acc271f4780b81ac5ecef188c
tree74398f595fec34e75698e536b25fd4c75b40a78d
parentd2310f7119ba394d3256c221886c048189dcfb91
Btrfs: don't allow the replace procedure on read only filesystems

commit bbb651e469d99f0088e286fdeb54acca7bb4ad4e upstream.

If you start the replace procedure on a read only filesystem, at
the end the procedure fails to write the updated dev_items to the
chunk tree. The problem is that this error is not indicated except
for a WARN_ON(). If the user now thinks that everything was done
as expected and destroys the source device (with mkfs or with a
hammer). The next mount fails with "failed to read chunk root" and
the filesystem is gone.

This commit adds code to fail the attempt to start the replace
procedure if the filesystem is mounted read-only.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/ioctl.c