[PATCH RFC 2/2] xfs: avoid potenial alloc inode failed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux