Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4330e183 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba
Browse files

btrfs: Do chunk level check for degraded rw mount



Now use the btrfs_check_rw_degradable() to check if we can mount in the
degraded mode.

With this patch, we can mount in the following case:
 # mkfs.btrfs -f -m raid1 -d single /dev/sdb /dev/sdc
 # wipefs -a /dev/sdc
 # mount /dev/sdb /mnt/btrfs -o degraded
 As the single data chunk is only on sdb, so it's OK to mount as
 degraded, as missing one device is OK for RAID1.

But still fail in the following case as expected:
 # mkfs.btrfs -f -m raid1 -d single /dev/sdb /dev/sdc
 # wipefs -a /dev/sdb
 # mount /dev/sdc /mnt/btrfs -o degraded
 As the data chunk is only in sdb, so it's not OK to mount it as
 degraded.

Reported-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Reported-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarQu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 21634a19
Loading
Loading
Loading
Loading
+3 −8
Original line number Original line Diff line number Diff line
@@ -3035,15 +3035,10 @@ int open_ctree(struct super_block *sb,
		btrfs_err(fs_info, "failed to read block groups: %d", ret);
		btrfs_err(fs_info, "failed to read block groups: %d", ret);
		goto fail_sysfs;
		goto fail_sysfs;
	}
	}
	fs_info->num_tolerated_disk_barrier_failures =

		btrfs_calc_num_tolerated_disk_barrier_failures(fs_info);
	if (!(sb->s_flags & MS_RDONLY) && !btrfs_check_rw_degradable(fs_info)) {
	if (fs_info->fs_devices->missing_devices >
	     fs_info->num_tolerated_disk_barrier_failures &&
	    !(sb->s_flags & MS_RDONLY)) {
		btrfs_warn(fs_info,
		btrfs_warn(fs_info,
"missing devices (%llu) exceeds the limit (%d), writeable mount is not allowed",
		"writeable mount is not allowed due to too many missing devices");
			fs_info->fs_devices->missing_devices,
			fs_info->num_tolerated_disk_barrier_failures);
		goto fail_sysfs;
		goto fail_sysfs;
	}
	}