mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
xfs: correct the parent pointer space reservation comment
The comment on xfs_parent_calc_space_res() claims parent pointers are "always the first attr in an attr tree". They are not: a parent pointer is recorded per dirent, so by the Nth hardlink the attr fork is already in leaf or node format. The reservation is still correct, because XFS_DAENTER_SPACE_RES() covers a split at every level of a maximum-depth attr dabtree whatever format the fork is in, but anyone auditing a shortfall here is led by the comment to look for a bug that is not there. Rewrite the comment to state what actually bounds the result, and record why the double split allowance and the extent-add term differ from xfs_attr_calc_size(). Signed-off-by: Javier Tia <floss@jetm.me> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
d058f24b16
commit
6c0fc3cb4e
|
|
@ -22,8 +22,23 @@ xfs_parent_calc_space_res(
|
|||
unsigned int namelen)
|
||||
{
|
||||
/*
|
||||
* Parent pointers are always the first attr in an attr tree, and never
|
||||
* larger than a block
|
||||
* A parent pointer is recorded per dirent, so an inode with N links
|
||||
* carries N of them and the attr fork can already be in leaf or node
|
||||
* format when one is added. That does not affect the reservation:
|
||||
* XFS_DAENTER_SPACE_RES covers a split at every level of a
|
||||
* maximum-depth attr dabtree, whatever format the fork is in now.
|
||||
*
|
||||
* The name is a dirent name and the value is a struct xfs_parent_rec,
|
||||
* so the leaf entry is always local and never exceeds 272 bytes.
|
||||
* Parent pointers require V5, hence a 1k minimum block size, so the
|
||||
* entry always stays under half a block and this needs none of the
|
||||
* double split allowance that xfs_attr_calc_size() makes.
|
||||
*
|
||||
* The second term hands a byte count to a macro whose parameter counts
|
||||
* mappings, so it asks for more extent-add allowance than the single
|
||||
* mapping a parent pointer adds - how much more depends on the block
|
||||
* size. It over-reserves either way, which is why it is left alone:
|
||||
* correcting the unit would shrink a reservation that is only generous.
|
||||
*/
|
||||
return XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) +
|
||||
XFS_NEXTENTADD_SPACE_RES(mp, namelen, XFS_ATTR_FORK);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user