[PATCH 1/5] mkfs: hoist the internal log size clamp code

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

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Move the code that clamps the computation of the internal log size so
that we can begin to enhnace mkfs without turning calculate_log_size
into more spaghetti.

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 mkfs/xfs_mkfs.c |   49 +++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 20 deletions(-)


diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 96682f9a..b97bd360 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3259,6 +3259,34 @@ validate_log_size(uint64_t logblocks, int blocklog, int min_logblocks)
 	}
 }
 
+static void
+clamp_internal_log_size(
+	struct mkfs_params	*cfg,
+	struct xfs_mount	*mp,
+	int			min_logblocks)
+{
+	/* Ensure the chosen size meets minimum log size requirements */
+	cfg->logblocks = max(min_logblocks, cfg->logblocks);
+
+	/*
+	 * Make sure the log fits wholly within an AG
+	 *
+	 * XXX: If agf->freeblks ends up as 0 because the log uses all
+	 * the free space, it causes the kernel all sorts of problems
+	 * with per-ag reservations. Right now just back it off one
+	 * block, but there's a whole can of worms here that needs to be
+	 * opened to decide what is the valid maximum size of a log in
+	 * an AG.
+	 */
+	cfg->logblocks = min(cfg->logblocks,
+			     libxfs_alloc_ag_max_usable(mp) - 1);
+
+	/* and now clamp the size to the maximum supported size */
+	cfg->logblocks = min(cfg->logblocks, XFS_MAX_LOG_BLOCKS);
+	if ((cfg->logblocks << cfg->blocklog) > XFS_MAX_LOG_BYTES)
+		cfg->logblocks = XFS_MAX_LOG_BYTES >> cfg->blocklog;
+}
+
 static void
 calculate_log_size(
 	struct mkfs_params	*cfg,
@@ -3331,26 +3359,7 @@ _("external log device size %lld blocks too small, must be at least %lld blocks\
 			cfg->logblocks = cfg->logblocks >> cfg->blocklog;
 		}
 
-		/* Ensure the chosen size meets minimum log size requirements */
-		cfg->logblocks = max(min_logblocks, cfg->logblocks);
-
-		/*
-		 * Make sure the log fits wholly within an AG
-		 *
-		 * XXX: If agf->freeblks ends up as 0 because the log uses all
-		 * the free space, it causes the kernel all sorts of problems
-		 * with per-ag reservations. Right now just back it off one
-		 * block, but there's a whole can of worms here that needs to be
-		 * opened to decide what is the valid maximum size of a log in
-		 * an AG.
-		 */
-		cfg->logblocks = min(cfg->logblocks,
-				     libxfs_alloc_ag_max_usable(mp) - 1);
-
-		/* and now clamp the size to the maximum supported size */
-		cfg->logblocks = min(cfg->logblocks, XFS_MAX_LOG_BLOCKS);
-		if ((cfg->logblocks << cfg->blocklog) > XFS_MAX_LOG_BYTES)
-			cfg->logblocks = XFS_MAX_LOG_BYTES >> cfg->blocklog;
+		clamp_internal_log_size(cfg, mp, min_logblocks);
 
 		validate_log_size(cfg->logblocks, cfg->blocklog, min_logblocks);
 	}




[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