All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: open_ctree: call btrfs_check_rw_degradable only if there is a missing device
@ 2021-08-30 13:11 Anand Jain
  2021-09-20 10:38 ` Anand Jain
  0 siblings, 1 reply; 2+ messages in thread
From: Anand Jain @ 2021-08-30 13:11 UTC (permalink / raw)
  To: linux-btrfs

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. However, 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 missing device.

[3]
 1) * 16934.96 us | btrfs_check_rw_degradable [btrfs]();

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/disk-io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4f38a657a30e..0ef3a8660ebd 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3556,7 +3556,8 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 		goto fail_sysfs;
 	}
 
-	if (!sb_rdonly(sb) && !btrfs_check_rw_degradable(fs_info, NULL)) {
+	if (!sb_rdonly(sb) && fs_info->fs_devices->missing_devices &&
+	    !btrfs_check_rw_degradable(fs_info, NULL)) {
 		btrfs_warn(fs_info,
 		"writable mount is not allowed due to too many missing devices");
 		goto fail_sysfs;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: open_ctree: call btrfs_check_rw_degradable only if there is a missing device
  2021-08-30 13:11 [PATCH] btrfs: open_ctree: call btrfs_check_rw_degradable only if there is a missing device Anand Jain
@ 2021-09-20 10:38 ` Anand Jain
  0 siblings, 0 replies; 2+ messages in thread
From: Anand Jain @ 2021-09-20 10:38 UTC (permalink / raw)
  To: linux-btrfs


Ping?

Thanks, Anand

On 30/08/2021 21:11, 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. However, 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 missing device.
> 
> [3]
>   1) * 16934.96 us | btrfs_check_rw_degradable [btrfs]();
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>   fs/btrfs/disk-io.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 4f38a657a30e..0ef3a8660ebd 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -3556,7 +3556,8 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
>   		goto fail_sysfs;
>   	}
>   
> -	if (!sb_rdonly(sb) && !btrfs_check_rw_degradable(fs_info, NULL)) {
> +	if (!sb_rdonly(sb) && fs_info->fs_devices->missing_devices &&
> +	    !btrfs_check_rw_degradable(fs_info, NULL)) {
>   		btrfs_warn(fs_info,
>   		"writable mount is not allowed due to too many missing devices");
>   		goto fail_sysfs;
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-20 10:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 13:11 [PATCH] btrfs: open_ctree: call btrfs_check_rw_degradable only if there is a missing device Anand Jain
2021-09-20 10:38 ` Anand Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.