aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2012-10-30 13:16:16 -0400
committerJosef Bacik <jbacik@fusionio.com>2012-12-12 17:15:18 -0500
commit292fd7fc39aa06668f3a8db546714e727120cb3e (patch)
tree5a1e20ab34f9b5114734ac107c2b4baa1fdba196 /fs
parentd1423248734df6d9aff769abffd675dc034e0601 (diff)
Btrfs: don't allow degraded mount if too many devices are missing
The current behavior is to allow mounting or remounting a filesystem writeable in degraded mode if at least one writeable device is present. The next failed write access to a missing device which is above the tolerance of the configured level of redundancy results in an read-only enforcement. Even without this, the next time barrier_all_devices() is called and more devices are missing than tolerable, the switch to read-only mode takes place. In order to behave predictably and to provide proper feedback to the user at mount time, this patch compares the number of missing devices with the number of devices that are tolerated to be missing according to the configured RAID level. If more devices are missing than tolerated, e.g. if two devices are missing in case of RAID1, only a read-only mount and remount is allowed. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/disk-io.c7
-rw-r--r--fs/btrfs/super.c9
2 files changed, 16 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index bd70c2852ba0..064315990f8a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2508,6 +2508,13 @@ retry_root_backup:
2508 } 2508 }
2509 fs_info->num_tolerated_disk_barrier_failures = 2509 fs_info->num_tolerated_disk_barrier_failures =
2510 btrfs_calc_num_tolerated_disk_barrier_failures(fs_info); 2510 btrfs_calc_num_tolerated_disk_barrier_failures(fs_info);
2511 if (fs_info->fs_devices->missing_devices >
2512 fs_info->num_tolerated_disk_barrier_failures &&
2513 !(sb->s_flags & MS_RDONLY)) {
2514 printk(KERN_WARNING
2515 "Btrfs: too many missing devices, writeable mount is not allowed\n");
2516 goto fail_block_groups;
2517 }
2511 2518
2512 fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root, 2519 fs_info->cleaner_kthread = kthread_run(cleaner_kthread, tree_root,
2513 "btrfs-cleaner"); 2520 "btrfs-cleaner");
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 915ac14c2064..acd2df85bed5 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1226,6 +1226,15 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
1226 goto restore; 1226 goto restore;
1227 } 1227 }
1228 1228
1229 if (fs_info->fs_devices->missing_devices >
1230 fs_info->num_tolerated_disk_barrier_failures &&
1231 !(*flags & MS_RDONLY)) {
1232 printk(KERN_WARNING
1233 "Btrfs: too many missing devices, writeable remount is not allowed\n");
1234 ret = -EACCES;
1235 goto restore;
1236 }
1237
1229 if (btrfs_super_log_root(fs_info->super_copy) != 0) { 1238 if (btrfs_super_log_root(fs_info->super_copy) != 0) {
1230 ret = -EINVAL; 1239 ret = -EINVAL;
1231 goto restore; 1240 goto restore;