diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2010-12-20 03:04:08 -0500 |
---|---|---|
committer | Li Zefan <lizf@cn.fujitsu.com> | 2010-12-22 19:49:17 -0500 |
commit | b83cc9693f39689490970c19f6c5b866f6719a70 (patch) | |
tree | b86d09884015fce195a4ac5ff1e8ec5f6ec00677 /fs/btrfs/ctree.h | |
parent | fa0d2b9bd717340e0bc4850a80ac0eb344e9a7fb (diff) |
Btrfs: Add readonly snapshots support
Usage:
Set BTRFS_SUBVOL_RDONLY of btrfs_ioctl_vol_arg_v2->flags, and call
ioctl(BTRFS_I0CTL_SNAP_CREATE_V2).
Implementation:
- Set readonly bit of btrfs_root_item->flags.
- Add readonly checks in btrfs_permission (inode_permission),
btrfs_setattr, btrfs_set/remove_xattr and some ioctls.
Changelog for v3:
- Eliminate btrfs_root->readonly, but check btrfs_root->root_item.flags.
- Rename BTRFS_ROOT_SNAP_RDONLY to BTRFS_ROOT_SUBVOL_RDONLY.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index af52f6d7a4d8..4403e5643d43 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -597,6 +597,8 @@ struct btrfs_dir_item { | |||
597 | u8 type; | 597 | u8 type; |
598 | } __attribute__ ((__packed__)); | 598 | } __attribute__ ((__packed__)); |
599 | 599 | ||
600 | #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0) | ||
601 | |||
600 | struct btrfs_root_item { | 602 | struct btrfs_root_item { |
601 | struct btrfs_inode_item inode; | 603 | struct btrfs_inode_item inode; |
602 | __le64 generation; | 604 | __le64 generation; |
@@ -1893,6 +1895,11 @@ BTRFS_SETGET_STACK_FUNCS(root_limit, struct btrfs_root_item, byte_limit, 64); | |||
1893 | BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item, | 1895 | BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item, |
1894 | last_snapshot, 64); | 1896 | last_snapshot, 64); |
1895 | 1897 | ||
1898 | static inline bool btrfs_root_readonly(struct btrfs_root *root) | ||
1899 | { | ||
1900 | return root->root_item.flags & BTRFS_ROOT_SUBVOL_RDONLY; | ||
1901 | } | ||
1902 | |||
1896 | /* struct btrfs_super_block */ | 1903 | /* struct btrfs_super_block */ |
1897 | 1904 | ||
1898 | BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64); | 1905 | BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, 64); |