aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-05-13 13:46:40 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:03 -0400
commitdfe25020689bb2d318782d2c9c7141203583fc70 (patch)
treee106059546d7755af0d3b86bf47c113ca8927d7d /fs/btrfs/super.c
parent1259ab75c62462b8ffad90067b5e1f6312786a18 (diff)
Btrfs: Add mount -o degraded to allow mounts to continue with missing devices
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 020e5a83e31f..273a5b511f50 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -65,11 +65,13 @@ static void btrfs_put_super (struct super_block * sb)
65} 65}
66 66
67enum { 67enum {
68 Opt_subvol, Opt_nodatasum, Opt_nodatacow, Opt_max_extent, 68 Opt_degraded, Opt_subvol, Opt_nodatasum, Opt_nodatacow,
69 Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd, Opt_err, 69 Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier,
70 Opt_ssd, Opt_err,
70}; 71};
71 72
72static match_table_t tokens = { 73static match_table_t tokens = {
74 {Opt_degraded, "degraded"},
73 {Opt_subvol, "subvol=%s"}, 75 {Opt_subvol, "subvol=%s"},
74 {Opt_nodatasum, "nodatasum"}, 76 {Opt_nodatasum, "nodatasum"},
75 {Opt_nodatacow, "nodatacow"}, 77 {Opt_nodatacow, "nodatacow"},
@@ -106,9 +108,8 @@ u64 btrfs_parse_size(char *str)
106 return res; 108 return res;
107} 109}
108 110
109static int parse_options (char * options, 111int btrfs_parse_options(char *options, struct btrfs_root *root,
110 struct btrfs_root *root, 112 char **subvol_name)
111 char **subvol_name)
112{ 113{
113 char * p; 114 char * p;
114 struct btrfs_fs_info *info = NULL; 115 struct btrfs_fs_info *info = NULL;
@@ -135,6 +136,12 @@ static int parse_options (char * options,
135 136
136 token = match_token(p, tokens, args); 137 token = match_token(p, tokens, args);
137 switch (token) { 138 switch (token) {
139 case Opt_degraded:
140 if (info) {
141 printk("btrfs: allowing degraded mounts\n");
142 btrfs_set_opt(info->mount_opt, DEGRADED);
143 }
144 break;
138 case Opt_subvol: 145 case Opt_subvol:
139 if (subvol_name) { 146 if (subvol_name) {
140 *subvol_name = match_strdup(&args[0]); 147 *subvol_name = match_strdup(&args[0]);
@@ -234,7 +241,7 @@ static int btrfs_fill_super(struct super_block * sb,
234 sb->s_xattr = btrfs_xattr_handlers; 241 sb->s_xattr = btrfs_xattr_handlers;
235 sb->s_time_gran = 1; 242 sb->s_time_gran = 1;
236 243
237 tree_root = open_ctree(sb, fs_devices); 244 tree_root = open_ctree(sb, fs_devices, (char *)data);
238 245
239 if (IS_ERR(tree_root)) { 246 if (IS_ERR(tree_root)) {
240 printk("btrfs: open_ctree failed\n"); 247 printk("btrfs: open_ctree failed\n");
@@ -267,8 +274,6 @@ static int btrfs_fill_super(struct super_block * sb,
267 goto fail_close; 274 goto fail_close;
268 } 275 }
269 276
270 parse_options((char *)data, tree_root, NULL);
271
272 /* this does the super kobj at the same time */ 277 /* this does the super kobj at the same time */
273 err = btrfs_sysfs_add_super(tree_root->fs_info); 278 err = btrfs_sysfs_add_super(tree_root->fs_info);
274 if (err) 279 if (err)
@@ -341,7 +346,7 @@ int btrfs_get_sb_bdev(struct file_system_type *fs_type,
341 if (error) 346 if (error)
342 return error; 347 return error;
343 348
344 bdev = fs_devices->lowest_bdev; 349 bdev = fs_devices->latest_bdev;
345 btrfs_lock_volumes(); 350 btrfs_lock_volumes();
346 s = sget(fs_type, btrfs_test_super, set_anon_super, fs_devices); 351 s = sget(fs_type, btrfs_test_super, set_anon_super, fs_devices);
347 btrfs_unlock_volumes(); 352 btrfs_unlock_volumes();
@@ -411,7 +416,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type,
411 int ret; 416 int ret;
412 char *subvol_name = NULL; 417 char *subvol_name = NULL;
413 418
414 parse_options((char *)data, NULL, &subvol_name); 419 btrfs_parse_options((char *)data, NULL, &subvol_name);
415 ret = btrfs_get_sb_bdev(fs_type, flags, dev_name, data, mnt, 420 ret = btrfs_get_sb_bdev(fs_type, flags, dev_name, data, mnt,
416 subvol_name ? subvol_name : "default"); 421 subvol_name ? subvol_name : "default");
417 if (subvol_name) 422 if (subvol_name)