Re: [PATCH resend] btrfs: mount: call btrfs_check_rw_degradable only if there is a missing device
From: Josef Bacik <josef@toxicpanda.com>
Date: 2021-10-19 14:06:37
From: Josef Bacik <josef@toxicpanda.com>
Date: 2021-10-19 14:06:37
On Tue, Oct 19, 2021 at 06:43:38PM +0800, Anand Jain wrote:
In open_ctree() in btrfs_check_rw_degradable() [1], we check each block
group individually if at least the minimum number of devices is available
for that profile. If all the devices are available, then we don't have to
check degradable.
[1]
open_ctree()
::
3559 if (!sb_rdonly(sb) && !btrfs_check_rw_degradable(fs_info, NULL)) {
Also before calling btrfs_check_rw_degradable() in open_ctee() at the
line number shown below [2] we call btrfs_read_chunk_tree() and down to
add_missing_dev() to record number of missing devices.
[2]
open_ctree()
::
3454 ret = btrfs_read_chunk_tree(fs_info);
btrfs_read_chunk_tree()
read_one_chunk() / read_one_dev()
add_missing_dev()
So, check if there is any missing device before btrfs_check_rw_degradable()
in open_ctree().
With this, in an example, the mount command could save ~16ms.[3] in the
most common case, that is no device is missing.
[3]
1) * 16934.96 us | btrfs_check_rw_degradable [btrfs]();
Signed-off-by: Anand Jain <redacted>Reviewed-by: Josef Bacik <josef@toxicpanda.com> Thanks, Josef