Blame SOURCES/xfsprogs-5.1.0-mkfs-don-t-use-xfs_verify_fsbno-before-m_sb-is-fully.patch

82babb
From 9c726ef0d2d829ae83756d3817f271e9c2c8777a Mon Sep 17 00:00:00 2001
82babb
From: Eric Sandeen <sandeen@redhat.com>
82babb
Date: Wed, 10 Jul 2019 11:35:07 -0400
82babb
Subject: [PATCH] mkfs: don't use xfs_verify_fsbno() before m_sb is fully set
82babb
 up
82babb
82babb
Commit 8da5298 mkfs: validate start and end of aligned logs stopped
82babb
open-coding log end block checks, and used xfs_verify_fsbno() instead.
82babb
It also used xfs_verify_fsbno() to validate the log start.  This
82babb
seemed to make sense, but then xfs/306 started failing on 4k sector
82babb
filesystems, which leads to a log striep unite being set on a single
82babb
AG filesystem.
82babb
82babb
As it turns out, if xfs_verify_fsbno() is testing a block in the
82babb
last AG, it needs to have mp->m_sb.sb_dblocks set, which isn't done
82babb
until later.  With sb_dblocks unset we can't know how many blocks
82babb
are in the last AG, and hence can't validate it.
82babb
82babb
To fix all this, go back to open-coding the checks; note that this
82babb
/does/ rely on m_sb.sb_agblklog being set, but that /is/ already
82babb
done in the early call to start_superblock_setup().
82babb
82babb
Fixes: 8da5298 ("mkfs: validate start and end of aligned logs")
82babb
Reported-by: Dave Chinner <david@fromorbit.com>
82babb
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
82babb
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
82babb
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
82babb
---
82babb
 mkfs/xfs_mkfs.c | 7 +++----
82babb
 1 file changed, 3 insertions(+), 4 deletions(-)
82babb
82babb
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
82babb
index 468b8fde..4e576a5c 100644
82babb
--- a/mkfs/xfs_mkfs.c
82babb
+++ b/mkfs/xfs_mkfs.c
82babb
@@ -3040,7 +3040,7 @@ align_internal_log(
82babb
 		cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit;
82babb
 
82babb
 	/* If our log start overlaps the next AG's metadata, fail. */
82babb
-	if (!xfs_verify_fsbno(mp, cfg->logstart)) {
82babb
+	if (XFS_FSB_TO_AGBNO(mp, cfg->logstart) <= XFS_AGFL_BLOCK(mp)) {
82babb
 			fprintf(stderr,
82babb
 _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
82babb
   "within an allocation group.\n"),
82babb
@@ -3051,10 +3051,9 @@ _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
82babb
 	/* round up/down the log size now */
82babb
 	align_log_size(cfg, sunit);
82babb
 
82babb
-	/* check the aligned log still fits in an AG. */
82babb
+	/* check the aligned log still starts and ends in the same AG. */
82babb
 	logend = cfg->logstart + cfg->logblocks - 1;
82babb
-	if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend) ||
82babb
-	    !xfs_verify_fsbno(mp, logend)) {
82babb
+	if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend)) {
82babb
 		fprintf(stderr,
82babb
 _("Due to stripe alignment, the internal log size (%lld) is too large.\n"
82babb
   "Must fit within an allocation group.\n"),
82babb
-- 
82babb
2.17.0
82babb