Re: [PATCH v3 07/21] fs: xfs: align args->minlen for forced allocation alignment

From: John Garry
Date: Fri Jun 07 2024 - 02:05:37 EST


On 06/06/2024 17:22, John Garry wrote:

i.e. why didn't it round the start offset down to 48?
Answering that question will tell you where the bug is.

After xfs_bmap_compute_alignments() -> xfs_bmap_extsize_align(), ap->offset=48 - that seems ok.

Maybe the problem is in xfs_bmap_process_allocated_extent(). For the problematic case when calling that function:

args->fsbno=7840 args->len=16 ap->offset=48 orig_offset=56 orig_length=24

So, as the comment reads there, we could not satisfy the original length request, so we move up the position of the extent.

I assume that we just don't want to do that for forcealign, correct?


JFYI, after making this following change, my stress test ran overnight:

@@ -3506,13 +3513,15 @@ xfs_bmap_process_allocated_extent(
* very fragmented so we're unlikely to be able to satisfy the
* hints anyway.
*/
+ if (!xfs_inode_has_forcealign(ap->ip)) {
if (ap->length <= orig_length)
ap->offset = orig_offset;
else if (ap->offset + ap->length < orig_offset + orig_length)
ap->offset = orig_offset + orig_length - ap->length;
-
+ }
+



Of course, if the allocation start is rounded down to 48, then
the length should be rounded up to 32 to cover the entire range we
are writing new data to.