linux-stable/fs/btrfs
Naohiro Aota 0b214ccbc7 btrfs: zoned: wait for data BG to be finished on direct IO allocation
commit 776a838f1f upstream.

Running the fio command below on a ZNS device results in "Resource
temporarily unavailable" error.

  $ sudo fio --name=w --directory=/mnt --filesize=1GB --bs=16MB --numjobs=16 \
        --rw=write --ioengine=libaio --iodepth=128 --direct=1

  fio: io_u error on file /mnt/w.2.0: Resource temporarily unavailable: write offset=117440512, buflen=16777216
  fio: io_u error on file /mnt/w.2.0: Resource temporarily unavailable: write offset=134217728, buflen=16777216
  ...

This happens because -EAGAIN error returned from btrfs_reserve_extent()
called from btrfs_new_extent_direct() is spilling over to the userland.

btrfs_reserve_extent() returns -EAGAIN when there is no active zone
available. Then, the caller should wait for some other on-going IO to
finish a zone and retry the allocation.

This logic is already implemented for buffered write in cow_file_range(),
but it is missing for the direct IO counterpart. Implement the same logic
for it.

Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fixes: 2ce543f478 ("btrfs: zoned: wait until zone is finished when allocation didn't progress")
CC: stable@vger.kernel.org # 6.1+
Tested-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 17:15:11 +00:00
..
tests btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
Kconfig
Makefile
accessors.c
accessors.h
acl.c
acl.h
async-thread.c btrfs: use alloc_ordered_workqueue() to create ordered workqueues 2023-06-19 13:59:30 +02:00
async-thread.h btrfs: use alloc_ordered_workqueue() to create ordered workqueues 2023-06-19 13:59:30 +02:00
backref.c btrfs: fix unwritten extent buffer after snapshotting a new subvolume 2023-11-02 09:36:50 +01:00
backref.h btrfs: fix unwritten extent buffer after snapshotting a new subvolume 2023-11-02 09:36:50 +01:00
bio.c btrfs: add an ordered_extent pointer to struct btrfs_bio 2023-06-19 13:59:36 +02:00
bio.h btrfs: add an ordered_extent pointer to struct btrfs_bio 2023-06-19 13:59:36 +02:00
block-group.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
block-group.h btrfs: wait for actual caching progress during allocation 2023-08-10 16:44:14 +02:00
block-rsv.c btrfs: account block group tree when calculating global reserve size 2023-07-20 19:22:54 +02:00
block-rsv.h btrfs: move btrfs_check_trunc_cache_free_space into block-rsv.c 2023-06-19 13:59:24 +02:00
btrfs_inode.h btrfs: remove btrfs_writepage_endio_finish_ordered 2023-10-10 22:02:54 +02:00
check-integrity.c btrfs: rename __btrfs_map_block to btrfs_map_block 2023-06-19 13:59:34 +02:00
check-integrity.h
compression.c btrfs: make btrfs_compressed_bioset static 2023-06-19 17:01:44 +02:00
compression.h btrfs: pass an ordered_extent to btrfs_submit_compressed_write 2023-06-19 13:59:36 +02:00
ctree.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
ctree.h btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
defrag.c btrfs: drop gfp from parameter extent state helpers 2023-06-19 13:59:30 +02:00
defrag.h
delalloc-space.c btrfs: don't arbitrarily slow down delalloc if we're committing 2023-11-28 17:15:05 +00:00
delalloc-space.h
delayed-inode.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
delayed-inode.h btrfs: fix infinite directory reads 2023-08-14 16:17:37 +02:00
delayed-ref.c btrfs: prevent transaction block reserve underflow when starting transaction 2023-10-25 12:16:16 +02:00
delayed-ref.h btrfs: prevent transaction block reserve underflow when starting transaction 2023-10-25 12:16:16 +02:00
dev-replace.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
dev-replace.h
dir-item.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
dir-item.h
discard.c btrfs: unexport btrfs_run_discard_work and make it static 2023-06-19 13:59:25 +02:00
discard.h btrfs: unexport btrfs_run_discard_work and make it static 2023-06-19 13:59:25 +02:00
disk-io.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
disk-io.h btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
export.c
export.h
extent-io-tree.c btrfs: drop gfp from parameter extent state helpers 2023-06-19 13:59:30 +02:00
extent-io-tree.h btrfs: drop gfp from parameter extent state helpers 2023-06-19 13:59:30 +02:00
extent-tree.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
extent-tree.h btrfs: remove level argument from btrfs_set_block_flags 2023-06-19 13:59:24 +02:00
extent_io.c btrfs: don't clear uptodate on write errors 2023-10-10 22:02:55 +02:00
extent_io.h btrfs: remove end_extent_writepage 2023-10-10 22:02:54 +02:00
extent_map.c btrfs: fix incorrect splitting in btrfs_drop_extent_map_range 2023-08-18 14:38:10 +02:00
extent_map.h btrfs: pass the new logical address to split_extent_map 2023-06-19 13:59:33 +02:00
file-item.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
file-item.h btrfs: scrub: avoid unnecessary csum tree search preparing stripes 2023-09-19 12:30:24 +02:00
file.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
file.h
free-space-cache.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
free-space-cache.h btrfs: move btrfs_check_trunc_cache_free_space into block-rsv.c 2023-06-19 13:59:24 +02:00
free-space-tree.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
free-space-tree.h
fs.c
fs.h btrfs: zoned: activate metadata block group on write time 2023-09-23 11:14:31 +02:00
inode-item.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
inode-item.h btrfs: move split_flags/combine_flags helpers to inode-item.h 2023-06-19 13:59:25 +02:00
inode.c btrfs: zoned: wait for data BG to be finished on direct IO allocation 2023-11-28 17:15:11 +00:00
ioctl.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
ioctl.h
locking.c btrfs: add block-group tree to lockdep classes 2023-06-19 13:59:35 +02:00
locking.h
lru_cache.c
lru_cache.h
lzo.c btrfs: disable allocation warnings for compression workspaces 2023-06-19 13:59:34 +02:00
messages.c btrfs: remove v0 extent handling 2023-11-02 09:36:50 +01:00
messages.h btrfs: remove v0 extent handling 2023-11-02 09:36:50 +01:00
misc.h btrfs: export bitmap_test_range_all_{set,zero} 2023-06-19 13:59:22 +02:00
ordered-data.c btrfs: remove btrfs_writepage_endio_finish_ordered 2023-10-10 22:02:54 +02:00
ordered-data.h btrfs: add a btrfs_finish_ordered_extent helper 2023-06-19 13:59:37 +02:00
orphan.c
orphan.h
print-tree.c btrfs: remove v0 extent handling 2023-11-02 09:36:50 +01:00
print-tree.h btrfs: print-tree: pass const extent buffer pointer 2023-06-19 13:59:22 +02:00
props.c
props.h
qgroup.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
qgroup.h
raid56.c btrfs: scrub: avoid unnecessary csum tree search preparing stripes 2023-09-19 12:30:24 +02:00
raid56.h btrfs: scrub: use recovered data stripes as cache to avoid unnecessary read 2023-06-19 13:59:24 +02:00
rcu-string.h
ref-verify.c
ref-verify.h
reflink.c
reflink.h
relocation.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
relocation.h btrfs: pass an ordered_extent to btrfs_reloc_clone_csums 2023-06-19 13:59:36 +02:00
root-tree.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
root-tree.h
scrub.c btrfs: make found_logical_ret parameter mandatory for function queue_scrub_stripe() 2023-11-20 11:57:26 +01:00
scrub.h
send.c btrfs: send: do not BUG_ON() on unexpected symlink data extent 2023-06-19 13:59:39 +02:00
send.h
space-info.c btrfs: zoned: re-enable metadata over-commit for zoned mode 2023-09-19 12:30:24 +02:00
space-info.h
subpage.c btrfs: stop setting PageError in the data I/O path 2023-06-19 13:59:35 +02:00
subpage.h btrfs: stop setting PageError in the data I/O path 2023-06-19 13:59:35 +02:00
super.c btrfs: properly report 0 avail for very full file systems 2023-10-06 13:16:26 +02:00
super.h
sysfs.c
sysfs.h
transaction.c btrfs: prevent transaction block reserve underflow when starting transaction 2023-10-25 12:16:16 +02:00
transaction.h btrfs: always print transaction aborted messages with an error level 2023-10-10 22:02:57 +02:00
tree-checker.c for-6.5-rc5-tag 2023-08-12 13:28:55 -07:00
tree-checker.h btrfs: move btrfs_verify_level_key into tree-checker.c 2023-06-19 13:59:25 +02:00
tree-log.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
tree-log.h btrfs: change for_rename argument of btrfs_record_unlink_dir() to bool 2023-06-19 13:59:26 +02:00
tree-mod-log.c btrfs: avoid tree mod log ENOMEM failures when we don't need to log 2023-06-19 13:59:38 +02:00
tree-mod-log.h
ulist.c
ulist.h
uuid-tree.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
uuid-tree.h
verity.c
verity.h
volumes.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
volumes.h btrfs: add a helper to read the superblock metadata_uuid 2023-09-23 11:14:31 +02:00
xattr.c btrfs: abort transaction on generation mismatch when marking eb as dirty 2023-11-28 17:14:40 +00:00
xattr.h
zlib.c btrfs: disable allocation warnings for compression workspaces 2023-06-19 13:59:34 +02:00
zoned.c btrfs: zoned: activate metadata block group on write time 2023-09-23 11:14:31 +02:00
zoned.h btrfs: zoned: defer advancing meta write pointer 2023-09-23 11:14:30 +02:00
zstd.c btrfs: disable allocation warnings for compression workspaces 2023-06-19 13:59:34 +02:00