diff options
author | David Sterba <dsterba@suse.cz> | 2013-12-16 11:34:17 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-01-28 16:20:01 -0500 |
commit | 2c68653787f91c62f8891209dc1f617088c822e4 (patch) | |
tree | 4f17ea8a804b6174de028c85aa3037c6ec6d28de /fs/btrfs/ctree.h | |
parent | a8d89f5ba0e17622cde8f5ac48ef745a9fb1e13b (diff) |
btrfs: Check read-only status of roots during send
All the subvolues that are involved in send must be read-only during the
whole operation. The ioctl SUBVOL_SETFLAGS could be used to change the
status to read-write and the result of send stream is undefined if the
data change unexpectedly.
Fix that by adding a refcount for all involved roots and verify that
there's no send in progress during SUBVOL_SETFLAGS ioctl call that does
read-only -> read-write transition.
We need refcounts because there are no restrictions on number of send
parallel operations currently run on a single subvolume, be it source,
parent or one of the multiple clone sources.
Kernel is silent when the RO checks fail and returns EPERM. The same set
of checks is done already in userspace before send starts.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 3c9053a153b1..9318c7520f50 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1814,6 +1814,12 @@ struct btrfs_root { | |||
1814 | struct list_head ordered_extents; | 1814 | struct list_head ordered_extents; |
1815 | struct list_head ordered_root; | 1815 | struct list_head ordered_root; |
1816 | u64 nr_ordered_extents; | 1816 | u64 nr_ordered_extents; |
1817 | |||
1818 | /* | ||
1819 | * Number of currently running SEND ioctls to prevent | ||
1820 | * manipulation with the read-only status via SUBVOL_SETFLAGS | ||
1821 | */ | ||
1822 | int send_in_progress; | ||
1817 | }; | 1823 | }; |
1818 | 1824 | ||
1819 | struct btrfs_ioctl_defrag_range_args { | 1825 | struct btrfs_ioctl_defrag_range_args { |