[PATCH 3/9] xfs: select the AG with the largest contiguous space

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

 



From: Dave Chinner <dchinner@xxxxxxxxxx>

If we don't find an AG with sufficient contiguous free space for a
maxlen allocation, make sure we select the AG with the largest
contiguous free space to allocate from.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 fs/xfs/libxfs/xfs_bmap.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index e64ba7e2d13d..ee1c1415c67a 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3233,6 +3233,8 @@ xfs_bmap_btalloc_select_lengths(
 	struct xfs_mount	*mp = args->mp;
 	struct xfs_perag	*pag;
 	xfs_agnumber_t		agno, startag;
+	xfs_agnumber_t		max_blen_agno;
+	xfs_extlen_t		max_blen = 0;
 	int			error = 0;
 
 	if (ap->tp->t_flags & XFS_TRANS_LOWMODE) {
@@ -3264,10 +3266,22 @@ xfs_bmap_btalloc_select_lengths(
 			}
 			break;
 		}
+		if (*blen > max_blen) {
+			max_blen = *blen;
+			max_blen_agno = agno;
+		}
 	}
 	if (pag)
 		xfs_perag_rele(pag);
 
+	if (max_blen > *blen) {
+		if (max_blen_agno != startag) {
+			ap->blkno = XFS_AGB_TO_FSB(mp, max_blen_agno, 0);
+			ap->aeof = false;
+		}
+		*blen = max_blen;
+	}
+
 	args->minlen = xfs_bmap_select_minlen(ap, args, *blen);
 	return error;
 }
-- 
2.40.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