From: Christoph Hellwig Date: Mon, 29 Jul 2024 23:22:56 +0000 (-0700) Subject: xfs: do not allocate the entire delalloc extent in xfs_bmapi_write X-Git-Tag: v6.10.0~24^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=884c8799665bf48bc89c2b1bda7449d01aae6a9d;p=thirdparty%2Fxfsprogs-dev.git xfs: do not allocate the entire delalloc extent in xfs_bmapi_write Source kernel commit: 21255afdd7296f57dd65f815301426bcf911c82d While trying to convert the entire delalloc extent is a good decision for regular writeback as it leads to larger contigous on-disk extents, but for other callers of xfs_bmapi_write is is rather questionable as it forced them to loop creating new transactions just in case there is no large enough contiguous extent to cover the whole delalloc reservation. Change xfs_bmapi_write to only allocate the passed in range instead, whіle the writeback path through xfs_bmapi_convert_delalloc and xfs_bmapi_allocate still always converts the full extents. Signed-off-by: Christoph Hellwig Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R --- diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 9af65a18..e6d70013 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -4518,8 +4518,9 @@ xfs_bmapi_write( bma.length = XFS_FILBLKS_MIN(len, XFS_MAX_BMBT_EXTLEN); if (wasdelay) { - bma.offset = bma.got.br_startoff; - bma.length = bma.got.br_blockcount; + bma.length = XFS_FILBLKS_MIN(bma.length, + bma.got.br_blockcount - + (bno - bma.got.br_startoff)); } else { if (!eof) bma.length = XFS_FILBLKS_MIN(bma.length,