aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2012-08-01 12:56:49 -0400
committerChris Mason <chris.mason@fusionio.com>2012-10-09 09:20:19 -0400
commit5af3e8cce8b7ba0a2819e18c9146c8c0b452d479 (patch)
tree15c2b4859ea041c09f027ac44de506ac0ffcafa4 /fs/btrfs/ioctl.c
parent62856a9b73860cffe2a3d91b069393b88c219aa6 (diff)
Btrfs: make filesystem read-only when submitting barrier fails
So far the return code of barrier_all_devices() is ignored, which means that errors are ignored. The result can be a corrupt filesystem which is not consistent. This commit adds code to evaluate the return code of barrier_all_devices(). The normal btrfs_error() mechanism is used to switch the filesystem into read-only mode when errors are detected. In order to decide whether barrier_all_devices() should return error or success, the number of disks that are allowed to fail the barrier submission is calculated. This calculation accounts for the worst RAID level of metadata, system and data. If single, dup or RAID0 is in use, a single disk error is already considered to be fatal. Otherwise a single disk error is tolerated. The calculation of the number of disks that are tolerated to fail the barrier operation is performed when the filesystem gets mounted, when a balance operation is started and finished, and when devices are added or removed. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index d6836af6d60f..f5a2e6c4320a 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2875,8 +2875,8 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
2875 return 0; 2875 return 0;
2876} 2876}
2877 2877
2878static void get_block_group_info(struct list_head *groups_list, 2878void btrfs_get_block_group_info(struct list_head *groups_list,
2879 struct btrfs_ioctl_space_info *space) 2879 struct btrfs_ioctl_space_info *space)
2880{ 2880{
2881 struct btrfs_block_group_cache *block_group; 2881 struct btrfs_block_group_cache *block_group;
2882 2882
@@ -2984,8 +2984,8 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
2984 down_read(&info->groups_sem); 2984 down_read(&info->groups_sem);
2985 for (c = 0; c < BTRFS_NR_RAID_TYPES; c++) { 2985 for (c = 0; c < BTRFS_NR_RAID_TYPES; c++) {
2986 if (!list_empty(&info->block_groups[c])) { 2986 if (!list_empty(&info->block_groups[c])) {
2987 get_block_group_info(&info->block_groups[c], 2987 btrfs_get_block_group_info(
2988 &space); 2988 &info->block_groups[c], &space);
2989 memcpy(dest, &space, sizeof(space)); 2989 memcpy(dest, &space, sizeof(space));
2990 dest++; 2990 dest++;
2991 space_args.total_spaces++; 2991 space_args.total_spaces++;