* [PATCH] xfs: only validate summary counts on primary superblock
@ 2018-08-01 23:18 Darrick J. Wong
2018-08-02 1:05 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2018-08-01 23:18 UTC (permalink / raw)
To: xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
Skip the summary counter checks for secondary superblocks because
userspace has always written the secondary supers with zeroed counters.
mkfs.xfs fails immediately without this patch.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/libxfs/xfs_sb.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index ca1b3a7a9171..47e1dd4a5009 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -148,6 +148,7 @@ xfs_validate_sb_read(
STATIC int
xfs_validate_sb_write(
struct xfs_mount *mp,
+ struct xfs_buf *bp,
struct xfs_sb *sbp)
{
/*
@@ -155,10 +156,13 @@ xfs_validate_sb_write(
* the superblock. We skip this in the read validator because there
* could be newer superblocks in the log and if the values are garbage
* even after replay we'll recalculate them at the end of log mount.
+ * We only check the primary superblock to allow userspace tools to
+ * write secondary superblocks with zeroed counters.
*/
- if (sbp->sb_fdblocks > sbp->sb_dblocks ||
- !xfs_verify_icount(mp, sbp->sb_icount) ||
- sbp->sb_ifree > sbp->sb_icount) {
+ if (XFS_BUF_ADDR(bp) == XFS_SB_DADDR &&
+ (sbp->sb_fdblocks > sbp->sb_dblocks ||
+ !xfs_verify_icount(mp, sbp->sb_icount) ||
+ sbp->sb_ifree > sbp->sb_icount)) {
xfs_warn(mp, "SB summary counter sanity check failed");
return -EFSCORRUPTED;
}
@@ -756,7 +760,7 @@ xfs_sb_write_verify(
error = xfs_validate_sb_common(mp, bp, &sb);
if (error)
goto out_error;
- error = xfs_validate_sb_write(mp, &sb);
+ error = xfs_validate_sb_write(mp, bp, &sb);
if (error)
goto out_error;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs: only validate summary counts on primary superblock
2018-08-01 23:18 [PATCH] xfs: only validate summary counts on primary superblock Darrick J. Wong
@ 2018-08-02 1:05 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2018-08-02 1:05 UTC (permalink / raw)
To: xfs
On Wed, Aug 01, 2018 at 04:18:55PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Skip the summary counter checks for secondary superblocks because
> userspace has always written the secondary supers with zeroed counters.
> mkfs.xfs fails immediately without this patch.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Bleh, self-NAK on this, never mind.
--D
> ---
> fs/xfs/libxfs/xfs_sb.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index ca1b3a7a9171..47e1dd4a5009 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -148,6 +148,7 @@ xfs_validate_sb_read(
> STATIC int
> xfs_validate_sb_write(
> struct xfs_mount *mp,
> + struct xfs_buf *bp,
> struct xfs_sb *sbp)
> {
> /*
> @@ -155,10 +156,13 @@ xfs_validate_sb_write(
> * the superblock. We skip this in the read validator because there
> * could be newer superblocks in the log and if the values are garbage
> * even after replay we'll recalculate them at the end of log mount.
> + * We only check the primary superblock to allow userspace tools to
> + * write secondary superblocks with zeroed counters.
> */
> - if (sbp->sb_fdblocks > sbp->sb_dblocks ||
> - !xfs_verify_icount(mp, sbp->sb_icount) ||
> - sbp->sb_ifree > sbp->sb_icount) {
> + if (XFS_BUF_ADDR(bp) == XFS_SB_DADDR &&
> + (sbp->sb_fdblocks > sbp->sb_dblocks ||
> + !xfs_verify_icount(mp, sbp->sb_icount) ||
> + sbp->sb_ifree > sbp->sb_icount)) {
> xfs_warn(mp, "SB summary counter sanity check failed");
> return -EFSCORRUPTED;
> }
> @@ -756,7 +760,7 @@ xfs_sb_write_verify(
> error = xfs_validate_sb_common(mp, bp, &sb);
> if (error)
> goto out_error;
> - error = xfs_validate_sb_write(mp, &sb);
> + error = xfs_validate_sb_write(mp, bp, &sb);
> if (error)
> goto out_error;
>
> --
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-02 2:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 23:18 [PATCH] xfs: only validate summary counts on primary superblock Darrick J. Wong
2018-08-02 1:05 ` Darrick J. Wong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.