linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naohiro Aota <naohiro.aota@wdc.com>
To: linux-btrfs@vger.kernel.org
Cc: Naohiro Aota <naohiro.aota@wdc.com>
Subject: [PATCH 11/13] btrfs: zoned: activate necessary block group
Date: Mon,  4 Jul 2022 13:58:15 +0900	[thread overview]
Message-ID: <bbdd836915d620e57416174ece589c6c33da4511.1656909695.git.naohiro.aota@wdc.com> (raw)
In-Reply-To: <cover.1656909695.git.naohiro.aota@wdc.com>

There are two places where allocating a chunk is not enough. These two
places are trying to ensure the space by allocating a chunk. To meet the
condition for active_total_bytes, we also need to activate a block group
there.

CC: stable@vger.kernel.org # 5.16+
Fixes: afba2bc036b0 ("btrfs: zoned: implement active zone tracking")
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/block-group.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 51e7c1f1d93f..1c22cfe91a65 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -2664,6 +2664,11 @@ int btrfs_inc_block_group_ro(struct btrfs_block_group *cache,
 	ret = btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE);
 	if (ret < 0)
 		goto out;
+	/*
+	 * We have allocated a new chunk. We also need to activate that chunk to
+	 * grant metadata tickets for zoned btrfs.
+	 */
+	btrfs_zoned_activate_one_bg(fs_info, cache->space_info, true);
 	ret = inc_block_group_ro(cache, 0);
 	if (ret == -ETXTBSY)
 		goto unlock_out;
@@ -3889,6 +3894,12 @@ static void reserve_chunk_space(struct btrfs_trans_handle *trans,
 		if (IS_ERR(bg)) {
 			ret = PTR_ERR(bg);
 		} else {
+			/*
+			 * We have a new chunk. We also need to activate it for
+			 * zoned btrfs.
+			 */
+			btrfs_zoned_activate_one_bg(fs_info, info, true);
+
 			/*
 			 * If we fail to add the chunk item here, we end up
 			 * trying again at phase 2 of chunk allocation, at
-- 
2.35.1


  parent reply	other threads:[~2022-07-04  4:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04  4:58 [PATCH 00/13] btrfs: zoned: fix active zone tracking issues Naohiro Aota
2022-07-04  4:58 ` [PATCH 01/13] block: add bdev_max_segments() helper Naohiro Aota
2022-07-04  6:57   ` Johannes Thumshirn
2022-07-04  8:23   ` Christoph Hellwig
2022-07-04 13:27     ` Naohiro Aota
2022-07-04  4:58 ` [PATCH 02/13] btrfs: zoned: revive max_zone_append_bytes Naohiro Aota
2022-07-04  7:57   ` Johannes Thumshirn
2022-07-04  8:24   ` Christoph Hellwig
2022-07-04  9:33   ` Johannes Thumshirn
2022-07-04 11:54     ` Christoph Hellwig
2022-07-04 13:24       ` Naohiro Aota
2022-07-04  4:58 ` [PATCH 03/13] btrfs: replace BTRFS_MAX_EXTENT_SIZE with fs_info->max_extent_size Naohiro Aota
2022-07-04  7:02   ` Johannes Thumshirn
2022-07-04  7:46     ` Naohiro Aota
2022-07-04  4:58 ` [PATCH 04/13] btrfs: convert count_max_extents() to use fs_info->max_extent_size Naohiro Aota
2022-07-04  7:56   ` Johannes Thumshirn
2022-07-04  4:58 ` [PATCH 05/13] btrfs: use fs_info->max_extent_size in get_extent_max_capacity() Naohiro Aota
2022-07-04  7:12   ` Johannes Thumshirn
2022-07-04  4:58 ` [PATCH 06/13] btrfs: let can_allocate_chunk return int Naohiro Aota
2022-07-04  7:11   ` Johannes Thumshirn
2022-07-04  4:58 ` [PATCH 07/13] btrfs: zoned: finish least available block group on data BG allocation Naohiro Aota
2022-07-04  7:25   ` Johannes Thumshirn
2022-07-04 13:25     ` Naohiro Aota
2022-07-04  4:58 ` [PATCH 08/13] btrfs: zoned: introduce space_info->active_total_bytes Naohiro Aota
2022-07-04  4:58 ` [PATCH 09/13] btrfs: zoned: disable metadata overcommit for zoned Naohiro Aota
2022-07-04  7:52   ` Johannes Thumshirn
2022-07-04  4:58 ` [PATCH 10/13] btrfs: zoned: activate metadata BG on flush_space Naohiro Aota
2022-07-07 14:51   ` Johannes Thumshirn
2022-07-04  4:58 ` Naohiro Aota [this message]
2022-07-04  4:58 ` [PATCH 12/13] btrfs: zoned: write out partially allocated region Naohiro Aota
2022-07-04  4:58 ` [PATCH 13/13] btrfs: zoned: wait until zone is finished when allocation didn't progress Naohiro Aota
2022-07-08 18:01 ` [PATCH 00/13] btrfs: zoned: fix active zone tracking issues David Sterba
2022-07-08 23:06   ` Naohiro Aota
2022-07-08 23:18 Naohiro Aota
2022-07-08 23:18 ` [PATCH 11/13] btrfs: zoned: activate necessary block group Naohiro Aota

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bbdd836915d620e57416174ece589c6c33da4511.1656909695.git.naohiro.aota@wdc.com \
    --to=naohiro.aota@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).