Skip to content

Commit 6baf4cc

Browse files
johnpgarryDarrick J. Wong
authored andcommitted
xfs: allow block allocator to take an alignment hint
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Signed-off-by: John Garry <[email protected]>
1 parent 85bf2df commit 6baf4cc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,6 +3312,11 @@ xfs_bmap_compute_alignments(
33123312
align = xfs_get_cowextsz_hint(ap->ip);
33133313
else if (ap->datatype & XFS_ALLOC_USERDATA)
33143314
align = xfs_get_extsz_hint(ap->ip);
3315+
3316+
/* Try to align start block to any minimum allocation alignment */
3317+
if (align > 1 && (ap->flags & XFS_BMAPI_EXTSZALIGN))
3318+
args->alignment = align;
3319+
33153320
if (align) {
33163321
if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0,
33173322
ap->eof, 0, ap->conv, &ap->offset,

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ struct xfs_bmalloca {
8787
/* Do not update the rmap btree. Used for reconstructing bmbt from rmapbt. */
8888
#define XFS_BMAPI_NORMAP (1u << 10)
8989

90+
/* Try to align allocations to the extent size hint */
91+
#define XFS_BMAPI_EXTSZALIGN (1u << 11)
92+
9093
#define XFS_BMAPI_FLAGS \
9194
{ XFS_BMAPI_ENTIRE, "ENTIRE" }, \
9295
{ XFS_BMAPI_METADATA, "METADATA" }, \
@@ -98,7 +101,8 @@ struct xfs_bmalloca {
98101
{ XFS_BMAPI_REMAP, "REMAP" }, \
99102
{ XFS_BMAPI_COWFORK, "COWFORK" }, \
100103
{ XFS_BMAPI_NODISCARD, "NODISCARD" }, \
101-
{ XFS_BMAPI_NORMAP, "NORMAP" }
104+
{ XFS_BMAPI_NORMAP, "NORMAP" },\
105+
{ XFS_BMAPI_EXTSZALIGN, "EXTSZALIGN" }
102106

103107

104108
static inline int xfs_bmapi_aflag(int w)

0 commit comments

Comments
 (0)