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/inode.c | |
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/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5f9194438f7c..956f1eb913b1 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3671,8 +3671,12 @@ static int btrfs_setattr_size(struct inode *inode, struct iattr *attr) | |||
3671 | static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) | 3671 | static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) |
3672 | { | 3672 | { |
3673 | struct inode *inode = dentry->d_inode; | 3673 | struct inode *inode = dentry->d_inode; |
3674 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
3674 | int err; | 3675 | int err; |
3675 | 3676 | ||
3677 | if (btrfs_root_readonly(root)) | ||
3678 | return -EROFS; | ||
3679 | |||
3676 | err = inode_change_ok(inode, attr); | 3680 | err = inode_change_ok(inode, attr); |
3677 | if (err) | 3681 | if (err) |
3678 | return err; | 3682 | return err; |
@@ -7206,6 +7210,10 @@ static int btrfs_set_page_dirty(struct page *page) | |||
7206 | 7210 | ||
7207 | static int btrfs_permission(struct inode *inode, int mask) | 7211 | static int btrfs_permission(struct inode *inode, int mask) |
7208 | { | 7212 | { |
7213 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
7214 | |||
7215 | if (btrfs_root_readonly(root) && (mask & MAY_WRITE)) | ||
7216 | return -EROFS; | ||
7209 | if ((BTRFS_I(inode)->flags & BTRFS_INODE_READONLY) && (mask & MAY_WRITE)) | 7217 | if ((BTRFS_I(inode)->flags & BTRFS_INODE_READONLY) && (mask & MAY_WRITE)) |
7210 | return -EACCES; | 7218 | return -EACCES; |
7211 | return generic_permission(inode, mask, btrfs_check_acl); | 7219 | return generic_permission(inode, mask, btrfs_check_acl); |