* [PATCH] btrfs: zoned: wait extent buffer IOs before finishing a zone
@ 2022-09-07 14:43 Naohiro Aota
2022-09-08 0:13 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: Naohiro Aota @ 2022-09-07 14:43 UTC (permalink / raw)
To: linux-btrfs; +Cc: Naohiro Aota
Before sending REQ_OP_ZONE_FINISH to a zone, we need to ensure that ongoing
IOs already finished. Or, we will see a "Zone Is Full" error for the IOs,
as the ZONE_FINISH command makes the zone full.
We ensure that with btrfs_wait_block_group_reservations() and
btrfs_wait_ordered_roots() for a data block group. And, for a metadata
block group, the comparison of alloc_offset vs meta_write_pointer mostly
ensures IOs for the allocated region already sent. However, there still can
be a little time-frame where the IOs are sent but not yet completed.
Introduce wait_eb_writebacks() to ensure such IOs are completed for a
metadata block group. It walks the buffer_radix to find extent buffers in
the block group and wait_on_extent_buffer_writeback() on them.
Fixes: afba2bc036b0 ("btrfs: zoned: implement active zone tracking")
CC: stable@vger.kernel.org # 5.19+
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
fs/btrfs/zoned.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index e12c0ca509fb..c8315fe16214 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1921,10 +1921,44 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
return ret;
}
+static void wait_eb_writebacks(struct btrfs_block_group *block_group)
+{
+ struct btrfs_fs_info *fs_info = block_group->fs_info;
+ const u64 end = block_group->start + block_group->length;
+ struct radix_tree_iter iter;
+ struct extent_buffer *eb;
+ void **slot;
+
+ rcu_read_lock();
+ radix_tree_for_each_slot(slot, &fs_info->buffer_radix, &iter,
+ block_group->start >> fs_info->sectorsize_bits) {
+ eb = radix_tree_deref_slot(slot);
+ if (!eb)
+ continue;
+ if (radix_tree_deref_retry(eb)) {
+ slot = radix_tree_iter_retry(&iter);
+ continue;
+ }
+
+ if (eb->start < block_group->start)
+ continue;
+ if (eb->start >= end)
+ break;
+
+ slot = radix_tree_iter_resume(slot, &iter);
+ rcu_read_unlock();
+ wait_on_extent_buffer_writeback(eb);
+ rcu_read_lock();
+ }
+ rcu_read_unlock();
+}
+
static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_written)
{
struct btrfs_fs_info *fs_info = block_group->fs_info;
struct map_lookup *map;
+ const bool is_metadata = block_group->flags &
+ (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_SYSTEM);
int ret = 0;
int i;
@@ -1935,8 +1969,7 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
}
/* Check if we have unwritten allocated space */
- if ((block_group->flags &
- (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_SYSTEM)) &&
+ if (is_metadata &&
block_group->start + block_group->alloc_offset > block_group->meta_write_pointer) {
spin_unlock(&block_group->lock);
return -EAGAIN;
@@ -1961,6 +1994,9 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
/* No need to wait for NOCOW writers. Zoned mode does not allow that */
btrfs_wait_ordered_roots(fs_info, U64_MAX, block_group->start,
block_group->length);
+ /* Wait for extent buffers to be written. */
+ if (is_metadata)
+ wait_eb_writebacks(block_group);
spin_lock(&block_group->lock);
--
2.37.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: zoned: wait extent buffer IOs before finishing a zone
2022-09-07 14:43 [PATCH] btrfs: zoned: wait extent buffer IOs before finishing a zone Naohiro Aota
@ 2022-09-08 0:13 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-09-08 0:13 UTC (permalink / raw)
To: Naohiro Aota, linux-btrfs; +Cc: kbuild-all, Naohiro Aota
Hi Naohiro,
I love your patch! Perhaps something to improve:
[auto build test WARNING on kdave/for-next]
[also build test WARNING on linus/master v6.0-rc4 next-20220907]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Naohiro-Aota/btrfs-zoned-wait-extent-buffer-IOs-before-finishing-a-zone/20220907-224702
base: https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
config: s390-randconfig-s041-20220907 (https://download.01.org/0day-ci/archive/20220908/202209080826.AuNlP9ys-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/f858e96a8ad7eb5499e18501bfbcaad594eace1f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Naohiro-Aota/btrfs-zoned-wait-extent-buffer-IOs-before-finishing-a-zone/20220907-224702
git checkout f858e96a8ad7eb5499e18501bfbcaad594eace1f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=s390 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
fs/btrfs/zoned.c:137:29: sparse: sparse: restricted __le64 degrades to integer
fs/btrfs/zoned.c:137:52: sparse: sparse: restricted __le64 degrades to integer
>> fs/btrfs/zoned.c:1932:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void **slot @@ got void [noderef] __rcu ** @@
fs/btrfs/zoned.c:1932:9: sparse: expected void **slot
fs/btrfs/zoned.c:1932:9: sparse: got void [noderef] __rcu **
>> fs/btrfs/zoned.c:1932:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void **slot @@ got void [noderef] __rcu ** @@
fs/btrfs/zoned.c:1932:9: sparse: expected void **slot
fs/btrfs/zoned.c:1932:9: sparse: got void [noderef] __rcu **
>> fs/btrfs/zoned.c:1934:44: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __rcu **slot @@ got void **slot @@
fs/btrfs/zoned.c:1934:44: sparse: expected void [noderef] __rcu **slot
fs/btrfs/zoned.c:1934:44: sparse: got void **slot
fs/btrfs/zoned.c:1938:30: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void **slot @@ got void [noderef] __rcu ** @@
fs/btrfs/zoned.c:1938:30: sparse: expected void **slot
fs/btrfs/zoned.c:1938:30: sparse: got void [noderef] __rcu **
fs/btrfs/zoned.c:1947:47: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __rcu **slot @@ got void **slot @@
fs/btrfs/zoned.c:1947:47: sparse: expected void [noderef] __rcu **slot
fs/btrfs/zoned.c:1947:47: sparse: got void **slot
fs/btrfs/zoned.c:1947:22: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void **slot @@ got void [noderef] __rcu ** @@
fs/btrfs/zoned.c:1947:22: sparse: expected void **slot
fs/btrfs/zoned.c:1947:22: sparse: got void [noderef] __rcu **
fs/btrfs/zoned.c:1932:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __rcu **slot @@ got void **slot @@
fs/btrfs/zoned.c:1932:9: sparse: expected void [noderef] __rcu **slot
fs/btrfs/zoned.c:1932:9: sparse: got void **slot
>> fs/btrfs/zoned.c:1932:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void **slot @@ got void [noderef] __rcu ** @@
fs/btrfs/zoned.c:1932:9: sparse: expected void **slot
fs/btrfs/zoned.c:1932:9: sparse: got void [noderef] __rcu **
fs/btrfs/zoned.c:2303:25: sparse: sparse: context imbalance in 'btrfs_zoned_activate_one_bg' - different lock contexts for basic block
vim +1932 fs/btrfs/zoned.c
1922
1923 static void wait_eb_writebacks(struct btrfs_block_group *block_group)
1924 {
1925 struct btrfs_fs_info *fs_info = block_group->fs_info;
1926 const u64 end = block_group->start + block_group->length;
1927 struct radix_tree_iter iter;
1928 struct extent_buffer *eb;
1929 void **slot;
1930
1931 rcu_read_lock();
> 1932 radix_tree_for_each_slot(slot, &fs_info->buffer_radix, &iter,
1933 block_group->start >> fs_info->sectorsize_bits) {
> 1934 eb = radix_tree_deref_slot(slot);
1935 if (!eb)
1936 continue;
1937 if (radix_tree_deref_retry(eb)) {
1938 slot = radix_tree_iter_retry(&iter);
1939 continue;
1940 }
1941
1942 if (eb->start < block_group->start)
1943 continue;
1944 if (eb->start >= end)
1945 break;
1946
1947 slot = radix_tree_iter_resume(slot, &iter);
1948 rcu_read_unlock();
1949 wait_on_extent_buffer_writeback(eb);
1950 rcu_read_lock();
1951 }
1952 rcu_read_unlock();
1953 }
1954
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-08 0:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-07 14:43 [PATCH] btrfs: zoned: wait extent buffer IOs before finishing a zone Naohiro Aota
2022-09-08 0:13 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox