WSL2-Linux-Kernel/fs/xfs/libxfs
Dave Chinner 9419092fb2 xfs: fix livelock in delayed allocation at ENOSPC
On a filesystem with a non-zero stripe unit and a large sequential
write, delayed allocation will set a minimum allocation length of
the stripe unit. If allocation fails because there are no extents
long enough for an aligned minlen allocation, it is supposed to
fall back to unaligned allocation which allows single block extents
to be allocated.

When the allocator code was rewritting in the 6.3 cycle, this
fallback was broken - the old code used args->fsbno as the both the
allocation target and the allocation result, the new code passes the
target as a separate parameter. The conversion didn't handle the
aligned->unaligned fallback path correctly - it reset args->fsbno to
the target fsbno on failure which broke allocation failure detection
in the high level code and so it never fell back to unaligned
allocations.

This resulted in a loop in writeback trying to allocate an aligned
block, getting a false positive success, trying to insert the result
in the BMBT. This did nothing because the extent already was in the
BMBT (merge results in an unchanged extent) and so it returned the
prior extent to the conversion code as the current iomap.

Because the iomap returned didn't cover the offset we tried to map,
xfs_convert_blocks() then retries the allocation, which fails in the
same way and now we have a livelock.

Reported-and-tested-by: Brian Foster <bfoster@redhat.com>
Fixes: 8584332709 ("xfs: factor xfs_bmap_btalloc()")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
2023-04-27 09:02:11 +10:00
..
xfs_ag.c xfs: allow queued AG intents to drain before scrubbing 2023-04-11 18:59:58 -07:00
xfs_ag.h xfs: allow queued AG intents to drain before scrubbing 2023-04-11 18:59:58 -07:00
xfs_ag_resv.c xfs: inobt can use perags in many more places than it does 2023-02-13 09:14:52 +11:00
xfs_ag_resv.h
xfs_alloc.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_alloc.h xfs: replace xfs_btree_has_record with a general keyspace scanner 2023-04-11 19:00:10 -07:00
xfs_alloc_btree.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_alloc_btree.h
xfs_attr.c
xfs_attr.h
xfs_attr_leaf.c
xfs_attr_leaf.h
xfs_attr_remote.c
xfs_attr_remote.h
xfs_attr_sf.h
xfs_bit.c
xfs_bit.h
xfs_bmap.c xfs: fix livelock in delayed allocation at ENOSPC 2023-04-27 09:02:11 +10:00
xfs_bmap.h xfs: accumulate iextent records when checking bmap 2023-04-11 19:00:24 -07:00
xfs_bmap_btree.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_bmap_btree.h
xfs_btree.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_btree.h xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_btree_staging.c
xfs_btree_staging.h
xfs_cksum.h
xfs_da_btree.c
xfs_da_btree.h
xfs_da_format.h
xfs_defer.c xfs: allow queued AG intents to drain before scrubbing 2023-04-11 18:59:58 -07:00
xfs_defer.h
xfs_dir2.c xfs: stabilize the dirent name transformation function used for ascii-ci dir hash computation 2023-04-11 19:05:04 -07:00
xfs_dir2.h xfs: stabilize the dirent name transformation function used for ascii-ci dir hash computation 2023-04-11 19:05:04 -07:00
xfs_dir2_block.c
xfs_dir2_data.c
xfs_dir2_leaf.c
xfs_dir2_node.c
xfs_dir2_priv.h
xfs_dir2_sf.c
xfs_dquot_buf.c
xfs_errortag.h
xfs_format.h
xfs_fs.h
xfs_health.h
xfs_ialloc.c xfs: convert xfs_ialloc_has_inodes_at_extent to return keyfill scan results 2023-04-11 19:00:15 -07:00
xfs_ialloc.h xfs: convert xfs_ialloc_has_inodes_at_extent to return keyfill scan results 2023-04-11 19:00:15 -07:00
xfs_ialloc_btree.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_ialloc_btree.h xfs: standardize ondisk to incore conversion for inode btrees 2023-04-11 19:00:01 -07:00
xfs_iext_tree.c
xfs_inode_buf.c
xfs_inode_buf.h
xfs_inode_fork.c xfs: standardize btree record checking code [v24.5] 2023-04-14 07:09:18 +10:00
xfs_inode_fork.h xfs: _{attr,data}_map_shared should take ILOCK_EXCL until iread_extents is completely done 2023-04-12 15:49:10 +10:00
xfs_log_format.h
xfs_log_recover.h
xfs_log_rlimit.c
xfs_quota_defs.h
xfs_refcount.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_refcount.h xfs: replace xfs_btree_has_record with a general keyspace scanner 2023-04-11 19:00:10 -07:00
xfs_refcount_btree.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_refcount_btree.h
xfs_rmap.c xfs: teach scrub to check for sole ownership of metadata objects 2023-04-11 19:00:15 -07:00
xfs_rmap.h xfs: teach scrub to check for sole ownership of metadata objects 2023-04-11 19:00:15 -07:00
xfs_rmap_btree.c xfs: implement masked btree key comparisons for _has_records scans 2023-04-11 19:00:11 -07:00
xfs_rmap_btree.h
xfs_rtbitmap.c
xfs_sb.c xfs: don't consider future format versions valid 2023-04-12 15:48:50 +10:00
xfs_sb.h
xfs_shared.h
xfs_symlink_remote.c
xfs_trans_inode.c
xfs_trans_resv.c
xfs_trans_resv.h
xfs_trans_space.h
xfs_types.c
xfs_types.h xfs: replace xfs_btree_has_record with a general keyspace scanner 2023-04-11 19:00:10 -07:00