On Thu, 7 Nov 2024 15:03:00 +0800, alexjlzheng@xxxxxxxxx wrote: > After xfs_alloc_compute_diff(), the length of the candidate extent > may change, so make necessary corrections to args->len. > > Signed-off-by: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx> > --- > fs/xfs/libxfs/xfs_alloc.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c > index 22bdbb3e9980..6a5e6cc7a259 100644 > --- a/fs/xfs/libxfs/xfs_alloc.c > +++ b/fs/xfs/libxfs/xfs_alloc.c > @@ -1069,6 +1069,10 @@ xfs_alloc_cur_check( > if (bnew == NULLAGBLOCK) > goto out; > > + args->len = XFS_EXTLEN_MIN(bnoa + lena - bnew, args->maxlen); > + if (args->len < acur->len) > + goto out; > + > /* > * Deactivate a bnobt cursor with worse locality than the current best. > */ > -- > 2.41.1 Sorry, I must have misunderstood the intent of the code when sending this patch. In fact, args->len should not be changed. But my starting point is I was wondering what will happen if xfs_alloc_compute_diff()'s changes to bnew cause the extent's remaining length to be less than args->len? So I have send a new patch: https://lore.kernel.org/linux-xfs/20241107084044.182463-1-alexjlzheng@xxxxxxxxxxx/T/#u Also, am I missing some key code to ensure that the above situation does not occur? Jinliang Zheng :)