diff mbox

mkfs: set agblklog when we're verifying minimum log size

Message ID 20170707033138.GC4103@magnolia (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Darrick J. Wong July 7, 2017, 3:31 a.m. UTC
In e5cc9d560a ("mkfs: set agsize prior to calculating minimum log
size"), we set the ag size in the superblock structure so that we can
calculate the maximum btree height correctly.  The btree heights are
used to calculate transaction reservation sizes; these sizes are used to
compute the minimum log length; and the minimum log length is checked by
the kernel.

Unfortunately, I didn't realize that some of the btree sizing functions
also depend on the agblklog (log2 of the ag size), so we've been
underestimating the minimum log length allowable, which results in mkfs
formatting filesystems that the kernel refuses to mount.

This can be trivially reproduced by formatting a small (~800M) volume
with rmap and reflink turned on.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 mkfs/maxtrres.c |    1 +
 1 file changed, 1 insertion(+)

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Brian Foster July 7, 2017, 12:01 p.m. UTC | #1
On Thu, Jul 06, 2017 at 08:31:38PM -0700, Darrick J. Wong wrote:
> In e5cc9d560a ("mkfs: set agsize prior to calculating minimum log
> size"), we set the ag size in the superblock structure so that we can
> calculate the maximum btree height correctly.  The btree heights are
> used to calculate transaction reservation sizes; these sizes are used to
> compute the minimum log length; and the minimum log length is checked by
> the kernel.
> 
> Unfortunately, I didn't realize that some of the btree sizing functions
> also depend on the agblklog (log2 of the ag size), so we've been
> underestimating the minimum log length allowable, which results in mkfs
> formatting filesystems that the kernel refuses to mount.
> 
> This can be trivially reproduced by formatting a small (~800M) volume
> with rmap and reflink turned on.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  mkfs/maxtrres.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mkfs/maxtrres.c b/mkfs/maxtrres.c
> index fba7818..69ec67a 100644
> --- a/mkfs/maxtrres.c
> +++ b/mkfs/maxtrres.c
> @@ -54,6 +54,7 @@ max_trans_res(
>  	sbp->sb_blocklog = blocklog;
>  	sbp->sb_blocksize = 1 << blocklog;
>  	sbp->sb_agblocks = agsize;
> +	sbp->sb_agblklog = (uint8_t)libxfs_log2_roundup((unsigned int)agsize);
>  	sbp->sb_inodelog = inodelog;
>  	sbp->sb_inopblog = blocklog - inodelog;
>  	sbp->sb_inodesize = 1 << inodelog;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/mkfs/maxtrres.c b/mkfs/maxtrres.c
index fba7818..69ec67a 100644
--- a/mkfs/maxtrres.c
+++ b/mkfs/maxtrres.c
@@ -54,6 +54,7 @@  max_trans_res(
 	sbp->sb_blocklog = blocklog;
 	sbp->sb_blocksize = 1 << blocklog;
 	sbp->sb_agblocks = agsize;
+	sbp->sb_agblklog = (uint8_t)libxfs_log2_roundup((unsigned int)agsize);
 	sbp->sb_inodelog = inodelog;
 	sbp->sb_inopblog = blocklog - inodelog;
 	sbp->sb_inodesize = 1 << inodelog;