[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240419061848.1032366-3-yebin10@huawei.com>
Date: Fri, 19 Apr 2024 14:18:48 +0800
From: Ye Bin <yebin10@...wei.com>
To: <djwong@...nel.org>, <linux-xfs@...r.kernel.org>,
<chandan.babu@...cle.com>, <dchinner@...hat.com>
CC: <linux-kernel@...r.kernel.org>, <yebin10@...wei.com>
Subject: [PATCH RFC 2/2] xfs: avoid potenial alloc inode failed
As 'pag->pagf_longest' may be temporarily set to 0. When the AGF buffer
lock is not held, using 'pag->pagf_longest' to determine whether the space
is available will cause misjudgment.
When the fragmentation is not serious and the reserved space exists, using
'pag->pagf_longest' to determine whether the space is available cannot filter
out the space that really cannot be allocated.
So remove judgement about 'pag->pagf_longest' in xfs_dialloc_good_ag().
Signed-off-by: Ye Bin <yebin10@...wei.com>
---
fs/xfs/libxfs/xfs_ialloc.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index e5ac3e5430c4..bb0ce2248386 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -1689,7 +1689,6 @@ xfs_dialloc_good_ag(
{
struct xfs_mount *mp = tp->t_mountp;
xfs_extlen_t ineed;
- xfs_extlen_t longest = 0;
int needspace;
int error;
@@ -1717,12 +1716,7 @@ xfs_dialloc_good_ag(
/*
* Check that there is enough free space for the file plus a chunk of
- * inodes if we need to allocate some. If this is the first pass across
- * the AGs, take into account the potential space needed for alignment
- * of inode chunks when checking the longest contiguous free space in
- * the AG - this prevents us from getting ENOSPC because we have free
- * space larger than ialloc_blks but alignment constraints prevent us
- * from using it.
+ * inodes if we need to allocate some.
*
* If we can't find an AG with space for full alignment slack to be
* taken into account, we must be near ENOSPC in all AGs. Hence we
@@ -1742,12 +1736,9 @@ xfs_dialloc_good_ag(
ineed = M_IGEO(mp)->ialloc_min_blks;
if (flags && ineed > 1)
ineed += M_IGEO(mp)->cluster_align;
- longest = pag->pagf_longest;
- if (!longest)
- longest = pag->pagf_flcount > 0;
needspace = S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode);
- if (pag->pagf_freeblks < needspace + ineed || longest < ineed)
+ if (pag->pagf_freeblks < needspace + ineed)
return false;
return true;
}
--
2.34.1
Powered by blists - more mailing lists