summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorYan Zheng2008-11-18 03:11:30 +0100
committerChris Mason2008-11-18 03:11:30 +0100
commit2b82032c34ec40515d3c45c36cd1961f37977de8 (patch)
treefbdfe7b13dd51983dfca4aeb75983b37ee186ff9 /fs/btrfs/super.c
parentBtrfs: mount ro and remount support (diff)
downloadkernel-qcow2-linux-2b82032c34ec40515d3c45c36cd1961f37977de8.tar.gz
kernel-qcow2-linux-2b82032c34ec40515d3c45c36cd1961f37977de8.tar.xz
kernel-qcow2-linux-2b82032c34ec40515d3c45c36cd1961f37977de8.zip
Btrfs: Seed device support
Seed device is a special btrfs with SEEDING super flag set and can only be mounted in read-only mode. Seed devices allow people to create new btrfs on top of it. The new FS contains the same contents as the seed device, but it can be mounted in read-write mode. This patch does the following: 1) split code in btrfs_alloc_chunk into two parts. The first part does makes the newly allocated chunk usable, but does not do any operation that modifies the chunk tree. The second part does the the chunk tree modifications. This division is for the bootstrap step of adding storage to the seed device. 2) Update device management code to handle seed device. The basic idea is: For an FS grown from seed devices, its seed devices are put into a list. Seed devices are opened on demand at mounting time. If any seed device is missing or has been changed, btrfs kernel module will refuse to mount the FS. 3) make btrfs_find_block_group not return NULL when all block groups are read-only. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 04a3bf816509..92393cc60d08 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -431,6 +431,11 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
if (error)
goto error_free_subvol_name;
+ if (!(flags & MS_RDONLY) && fs_devices->rw_devices == 0) {
+ error = -EACCES;
+ goto error_close_devices;
+ }
+
bdev = fs_devices->latest_bdev;
s = sget(fs_type, btrfs_test_super, set_anon_super, fs_devices);
if (IS_ERR(s))
@@ -444,6 +449,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
goto error_close_devices;
}
+ btrfs_close_devices(fs_devices);
} else {
char b[BDEVNAME_SIZE];
@@ -512,6 +518,9 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
ret = btrfs_commit_super(root);
WARN_ON(ret);
} else {
+ if (root->fs_info->fs_devices->rw_devices == 0)
+ return -EACCES;
+
if (btrfs_super_log_root(&root->fs_info->super_copy) != 0)
return -EINVAL;