]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: allow block allocator to take an alignment hint
authorJohn Garry <john.g.garry@oracle.com>
Tue, 1 Jul 2025 17:45:12 +0000 (10:45 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 15 Jul 2025 05:12:03 +0000 (22:12 -0700)
Source kernel commit: 6baf4cc47a741024d37e6149d5d035d3fc9ed1fe

Add a BMAPI flag to provide a hint to the block allocator to align extents
according to the extszhint.

This will be useful for atomic writes to ensure that we are not being
allocated extents which are not suitable (for atomic writes).

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: John Garry <john.g.garry@oracle.com>
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h

index 3cb47c3c8707dbe12391bf1765043348808fffef..99f5e6f9d545a4595d7804398f7859fbc0e1c150 100644 (file)
@@ -3306,6 +3306,11 @@ xfs_bmap_compute_alignments(
                align = xfs_get_cowextsz_hint(ap->ip);
        else if (ap->datatype & XFS_ALLOC_USERDATA)
                align = xfs_get_extsz_hint(ap->ip);
+
+       /* Try to align start block to any minimum allocation alignment */
+       if (align > 1 && (ap->flags & XFS_BMAPI_EXTSZALIGN))
+               args->alignment = align;
+
        if (align) {
                if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0,
                                        ap->eof, 0, ap->conv, &ap->offset,
index b4d9c6e0f3f9b6dc23172901201e951ef905ee73..d5f2729305fada794f94c2c86766572f167e0dd4 100644 (file)
@@ -87,6 +87,9 @@ struct xfs_bmalloca {
 /* Do not update the rmap btree.  Used for reconstructing bmbt from rmapbt. */
 #define XFS_BMAPI_NORMAP       (1u << 10)
 
+/* Try to align allocations to the extent size hint */
+#define XFS_BMAPI_EXTSZALIGN   (1u << 11)
+
 #define XFS_BMAPI_FLAGS \
        { XFS_BMAPI_ENTIRE,     "ENTIRE" }, \
        { XFS_BMAPI_METADATA,   "METADATA" }, \
@@ -98,7 +101,8 @@ struct xfs_bmalloca {
        { XFS_BMAPI_REMAP,      "REMAP" }, \
        { XFS_BMAPI_COWFORK,    "COWFORK" }, \
        { XFS_BMAPI_NODISCARD,  "NODISCARD" }, \
-       { XFS_BMAPI_NORMAP,     "NORMAP" }
+       { XFS_BMAPI_NORMAP,     "NORMAP" },\
+       { XFS_BMAPI_EXTSZALIGN, "EXTSZALIGN" }
 
 
 static inline int xfs_bmapi_aflag(int w)