diff mbox series

btrfs: zoned: enable metadata over-commit for non-ZNS setup

Message ID e0290c4d7af96991ddee4442a1c602cfb3a79ba3.1673330455.git.naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: zoned: enable metadata over-commit for non-ZNS setup | expand

Commit Message

Naohiro Aota Jan. 10, 2023, 6:04 a.m. UTC
The commit 79417d040f4f ("btrfs: zoned: disable metadata overcommit for
zoned") disabled the metadata over-commit to track active zones properly.

However, it also introduced a heavy overhead by allocating new metadata
block groups and/or flushing dirty buffers to release the space
reservations. Specifically, a workload (write only without any sync
operations) worsen its performance from 343.77 MB/sec (v5.19) to 182.89
MB/sec (v6.0).

The performance is still bad on current misc-next which is 187.95 MB/sec.
And, with this patch applied, it improves back to 326.70 MB/sec (+73.82%).

This patch introduces a new fs_info->flag BTRFS_FS_NO_OVERCOMMIT to
indicate it needs to disable the metadata over-commit. The flag is enabled
when a device with max active zones limit is loaded into a file-system.

Fixes: 79417d040f4f ("btrfs: zoned: disable metadata overcommit for zoned")
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/fs.h         | 6 ++++++
 fs/btrfs/space-info.c | 3 ++-
 fs/btrfs/zoned.c      | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)

Comments

Johannes Thumshirn Jan. 10, 2023, 8:10 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
David Sterba Jan. 11, 2023, 6:31 p.m. UTC | #2
On Tue, Jan 10, 2023 at 03:04:32PM +0900, Naohiro Aota wrote:
> The commit 79417d040f4f ("btrfs: zoned: disable metadata overcommit for
> zoned") disabled the metadata over-commit to track active zones properly.
> 
> However, it also introduced a heavy overhead by allocating new metadata
> block groups and/or flushing dirty buffers to release the space
> reservations. Specifically, a workload (write only without any sync
> operations) worsen its performance from 343.77 MB/sec (v5.19) to 182.89
> MB/sec (v6.0).
> 
> The performance is still bad on current misc-next which is 187.95 MB/sec.
> And, with this patch applied, it improves back to 326.70 MB/sec (+73.82%).
> 
> This patch introduces a new fs_info->flag BTRFS_FS_NO_OVERCOMMIT to
> indicate it needs to disable the metadata over-commit. The flag is enabled
> when a device with max active zones limit is loaded into a file-system.
> 
> Fixes: 79417d040f4f ("btrfs: zoned: disable metadata overcommit for zoned")
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Added to misc-next, thanks.

> ---
>  fs/btrfs/fs.h         | 6 ++++++
>  fs/btrfs/space-info.c | 3 ++-
>  fs/btrfs/zoned.c      | 1 +
>  3 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
> index a749367e5ae2..37b86acfcbcf 100644
> --- a/fs/btrfs/fs.h
> +++ b/fs/btrfs/fs.h
> @@ -119,6 +119,12 @@ enum {
>  	/* Indicate that we want to commit the transaction. */
>  	BTRFS_FS_NEED_TRANS_COMMIT,
>  
> +	/*
> +	 * Indicate metadata over-commit is disabled. This is set when active
> +	 * zone tracking is needed.
> +	 */
> +	BTRFS_FS_NO_OVERCOMMIT,
> +
>  #if BITS_PER_LONG == 32
>  	/* Indicate if we have error/warn message printed on 32bit systems */
>  	BTRFS_FS_32BIT_ERROR,
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index d28ee4e36f3d..69c09508afb5 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -407,7 +407,8 @@ int btrfs_can_overcommit(struct btrfs_fs_info *fs_info,
>  		return 0;
>  
>  	used = btrfs_space_info_used(space_info, true);
> -	if (btrfs_is_zoned(fs_info) && (space_info->flags & BTRFS_BLOCK_GROUP_METADATA))
> +	if (test_bit(BTRFS_FS_NO_OVERCOMMIT, &fs_info->flags) &&
> +	    (space_info->flags & BTRFS_BLOCK_GROUP_METADATA))
>  		avail = 0;
>  	else
>  		avail = calc_available_free_space(fs_info, space_info, flush);
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index bca9feb34c0c..f93215b377b3 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -542,6 +542,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
>  		}
>  		atomic_set(&zone_info->active_zones_left,
>  			   max_active_zones - nactive);
> +		set_bit(BTRFS_FS_NO_OVERCOMMIT, &fs_info->flags);

I've added the commit why it's here as well.
diff mbox series

Patch

diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
index a749367e5ae2..37b86acfcbcf 100644
--- a/fs/btrfs/fs.h
+++ b/fs/btrfs/fs.h
@@ -119,6 +119,12 @@  enum {
 	/* Indicate that we want to commit the transaction. */
 	BTRFS_FS_NEED_TRANS_COMMIT,
 
+	/*
+	 * Indicate metadata over-commit is disabled. This is set when active
+	 * zone tracking is needed.
+	 */
+	BTRFS_FS_NO_OVERCOMMIT,
+
 #if BITS_PER_LONG == 32
 	/* Indicate if we have error/warn message printed on 32bit systems */
 	BTRFS_FS_32BIT_ERROR,
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index d28ee4e36f3d..69c09508afb5 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -407,7 +407,8 @@  int btrfs_can_overcommit(struct btrfs_fs_info *fs_info,
 		return 0;
 
 	used = btrfs_space_info_used(space_info, true);
-	if (btrfs_is_zoned(fs_info) && (space_info->flags & BTRFS_BLOCK_GROUP_METADATA))
+	if (test_bit(BTRFS_FS_NO_OVERCOMMIT, &fs_info->flags) &&
+	    (space_info->flags & BTRFS_BLOCK_GROUP_METADATA))
 		avail = 0;
 	else
 		avail = calc_available_free_space(fs_info, space_info, flush);
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index bca9feb34c0c..f93215b377b3 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -542,6 +542,7 @@  int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
 		}
 		atomic_set(&zone_info->active_zones_left,
 			   max_active_zones - nactive);
+		set_bit(BTRFS_FS_NO_OVERCOMMIT, &fs_info->flags);
 	}
 
 	/* Validate superblock log */