]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit - libxfs/xfs_bmap.c
xfs: block reservation too large for minleft allocation
authorDave Chinner <dchinner@redhat.com>
Tue, 9 May 2023 09:29:36 +0000 (11:29 +0200)
committerCarlos Maiolino <cem@kernel.org>
Tue, 9 May 2023 17:53:30 +0000 (19:53 +0200)
commit4442ae9597d36096e40d32cfbb0b6ed1e40097e4
tree0a8a7f032a06fcd7ef6bd69762f3f2b66fbbc7e2
parent33f3aac8b28d7d41bd24bf808f7217d21d22d51c
xfs: block reservation too large for minleft allocation

Source kernel commit: d5753847b216db0e553e8065aa825cfe497ad143

When we enter xfs_bmbt_alloc_block() without having first allocated
a data extent (i.e. tp->t_firstblock == NULLFSBLOCK) because we
are doing something like unwritten extent conversion, the transaction
block reservation is used as the minleft value.

This works for operations like unwritten extent conversion, but it
assumes that the block reservation is only for a BMBT split. THis is
not always true, and sometimes results in larger than necessary
minleft values being set. We only actually need enough space for a
btree split, something we already handle correctly in
xfs_bmapi_write() via the xfs_bmapi_minleft() calculation.

We should use xfs_bmapi_minleft() in xfs_bmbt_alloc_block() to
calculate the number of blocks a BMBT split on this inode is going to
require, not use the transaction block reservation that contains the
maximum number of blocks this transaction may consume in it...

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h
libxfs/xfs_bmap_btree.c