* [PATCH] mkfs: don't use xfs_verify_fsbno() before m_sb is fully set up
@ 2019-07-09 20:09 Eric Sandeen
2019-07-09 20:33 ` Eric Sandeen
2019-07-10 6:09 ` Darrick J. Wong
0 siblings, 2 replies; 3+ messages in thread
From: Eric Sandeen @ 2019-07-09 20:09 UTC (permalink / raw)
To: linux-xfs, Dave Chinner, Darrick J. Wong
Commit 8da5298 mkfs: validate start and end of aligned logs stopped
open-coding log end block checks, and used xfs_verify_fsbno() instead.
It also used xfs_verify_fsbno() to validate the log start. This
seemed to make sense, but then xfs/306 started failing on 4k sector
filesystems, which leads to a log striep unite being set on a single
AG filesystem.
As it turns out, if xfs_verify_fsbno() is testing a block in the
last AG, it needs to have mp->m_sb.sb_dblocks set, which isn't done
until later. With sb_dblocks unset we can't know how many blocks
are in the last AG, and hence can't validate it.
To fix all this, go back to open-coding the checks; note that this
/does/ rely on m_sb.sb_agblklog being set, but that /is/ already
done in the early call to start_superblock_setup().
Fixes: 8da5298 ("mkfs: validate start and end of aligned logs")
Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
Sorry for missing this one in regression testing :/
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 468b8fde..4e576a5c 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3040,7 +3040,7 @@ align_internal_log(
cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit;
/* If our log start overlaps the next AG's metadata, fail. */
- if (!xfs_verify_fsbno(mp, cfg->logstart)) {
+ if (XFS_FSB_TO_AGBNO(mp, cfg->logstart) <= XFS_AGFL_BLOCK(mp)) {
fprintf(stderr,
_("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
"within an allocation group.\n"),
@@ -3051,10 +3051,9 @@ _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
/* round up/down the log size now */
align_log_size(cfg, sunit);
- /* check the aligned log still fits in an AG. */
+ /* check the aligned log still starts and ends in the same AG. */
logend = cfg->logstart + cfg->logblocks - 1;
- if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend) ||
- !xfs_verify_fsbno(mp, logend)) {
+ if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend)) {
fprintf(stderr,
_("Due to stripe alignment, the internal log size (%lld) is too large.\n"
"Must fit within an allocation group.\n"),
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mkfs: don't use xfs_verify_fsbno() before m_sb is fully set up
2019-07-09 20:09 [PATCH] mkfs: don't use xfs_verify_fsbno() before m_sb is fully set up Eric Sandeen
@ 2019-07-09 20:33 ` Eric Sandeen
2019-07-10 6:09 ` Darrick J. Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2019-07-09 20:33 UTC (permalink / raw)
To: Eric Sandeen, linux-xfs, Dave Chinner, Darrick J. Wong
On 7/9/19 3:09 PM, Eric Sandeen wrote:
> Commit 8da5298 mkfs: validate start and end of aligned logs stopped
> open-coding log end block checks, and used xfs_verify_fsbno() instead.
> It also used xfs_verify_fsbno() to validate the log start. This
> seemed to make sense, but then xfs/306 started failing on 4k sector
> filesystems, which leads to a log striep unite being set on a single
> AG filesystem.
Uh, "... which leads to a log stripe unit being set on a single AG
filesystem, with subsequent failures in align_internal_log()."
-Eric
> As it turns out, if xfs_verify_fsbno() is testing a block in the
> last AG, it needs to have mp->m_sb.sb_dblocks set, which isn't done
> until later. With sb_dblocks unset we can't know how many blocks
> are in the last AG, and hence can't validate it.
>
> To fix all this, go back to open-coding the checks; note that this
> /does/ rely on m_sb.sb_agblklog being set, but that /is/ already
> done in the early call to start_superblock_setup().
>
> Fixes: 8da5298 ("mkfs: validate start and end of aligned logs")
> Reported-by: Dave Chinner <david@fromorbit.com>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> Sorry for missing this one in regression testing :/
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 468b8fde..4e576a5c 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -3040,7 +3040,7 @@ align_internal_log(
> cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit;
>
> /* If our log start overlaps the next AG's metadata, fail. */
> - if (!xfs_verify_fsbno(mp, cfg->logstart)) {
> + if (XFS_FSB_TO_AGBNO(mp, cfg->logstart) <= XFS_AGFL_BLOCK(mp)) {
> fprintf(stderr,
> _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
> "within an allocation group.\n"),
> @@ -3051,10 +3051,9 @@ _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
> /* round up/down the log size now */
> align_log_size(cfg, sunit);
>
> - /* check the aligned log still fits in an AG. */
> + /* check the aligned log still starts and ends in the same AG. */
> logend = cfg->logstart + cfg->logblocks - 1;
> - if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend) ||
> - !xfs_verify_fsbno(mp, logend)) {
> + if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend)) {
> fprintf(stderr,
> _("Due to stripe alignment, the internal log size (%lld) is too large.\n"
> "Must fit within an allocation group.\n"),
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mkfs: don't use xfs_verify_fsbno() before m_sb is fully set up
2019-07-09 20:09 [PATCH] mkfs: don't use xfs_verify_fsbno() before m_sb is fully set up Eric Sandeen
2019-07-09 20:33 ` Eric Sandeen
@ 2019-07-10 6:09 ` Darrick J. Wong
1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2019-07-10 6:09 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs, Dave Chinner
On Tue, Jul 09, 2019 at 03:09:00PM -0500, Eric Sandeen wrote:
> Commit 8da5298 mkfs: validate start and end of aligned logs stopped
> open-coding log end block checks, and used xfs_verify_fsbno() instead.
> It also used xfs_verify_fsbno() to validate the log start. This
> seemed to make sense, but then xfs/306 started failing on 4k sector
> filesystems, which leads to a log striep unite being set on a single
> AG filesystem.
>
> As it turns out, if xfs_verify_fsbno() is testing a block in the
> last AG, it needs to have mp->m_sb.sb_dblocks set, which isn't done
> until later. With sb_dblocks unset we can't know how many blocks
> are in the last AG, and hence can't validate it.
>
> To fix all this, go back to open-coding the checks; note that this
> /does/ rely on m_sb.sb_agblklog being set, but that /is/ already
> done in the early call to start_superblock_setup().
>
> Fixes: 8da5298 ("mkfs: validate start and end of aligned logs")
> Reported-by: Dave Chinner <david@fromorbit.com>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> Sorry for missing this one in regression testing :/
Sorry for totally not noticing that we're validating using an incomplete
xfs_mount... <grumble>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 468b8fde..4e576a5c 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -3040,7 +3040,7 @@ align_internal_log(
> cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit;
>
> /* If our log start overlaps the next AG's metadata, fail. */
> - if (!xfs_verify_fsbno(mp, cfg->logstart)) {
> + if (XFS_FSB_TO_AGBNO(mp, cfg->logstart) <= XFS_AGFL_BLOCK(mp)) {
> fprintf(stderr,
> _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
> "within an allocation group.\n"),
> @@ -3051,10 +3051,9 @@ _("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n"
> /* round up/down the log size now */
> align_log_size(cfg, sunit);
>
> - /* check the aligned log still fits in an AG. */
> + /* check the aligned log still starts and ends in the same AG. */
> logend = cfg->logstart + cfg->logblocks - 1;
> - if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend) ||
> - !xfs_verify_fsbno(mp, logend)) {
> + if (XFS_FSB_TO_AGNO(mp, cfg->logstart) != XFS_FSB_TO_AGNO(mp, logend)) {
> fprintf(stderr,
> _("Due to stripe alignment, the internal log size (%lld) is too large.\n"
> "Must fit within an allocation group.\n"),
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-10 6:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-09 20:09 [PATCH] mkfs: don't use xfs_verify_fsbno() before m_sb is fully set up Eric Sandeen
2019-07-09 20:33 ` Eric Sandeen
2019-07-10 6:09 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox