diff mbox

xfs: fix superblock inprogress check

Message ID 1471844367-9679-1-git-send-email-david@fromorbit.com (mailing list archive)
State Accepted
Headers show

Commit Message

Dave Chinner Aug. 22, 2016, 5:39 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

From inspection, the superblock sb_inprogress check is done in the
verifier and triggered only for the primary superblock via a
"bp->b_bn == XFS_SB_DADDR" check.

Unfortunately, the primary superblock is an uncached buffer, and
hence it is configured by xfs_buf_read_uncached() with:

	bp->b_bn = XFS_BUF_DADDR_NULL;  /* always null for uncached buffers */

And so this check never triggers. Fix it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/libxfs/xfs_sb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Brian Foster Aug. 24, 2016, 6:07 p.m. UTC | #1
On Mon, Aug 22, 2016 at 03:39:27PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> From inspection, the superblock sb_inprogress check is done in the
> verifier and triggered only for the primary superblock via a
> "bp->b_bn == XFS_SB_DADDR" check.
> 
> Unfortunately, the primary superblock is an uncached buffer, and
> hence it is configured by xfs_buf_read_uncached() with:
> 
> 	bp->b_bn = XFS_BUF_DADDR_NULL;  /* always null for uncached buffers */
> 
> And so this check never triggers. Fix it.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---

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

>  fs/xfs/libxfs/xfs_sb.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index 0e3d4f5..4aecc5f 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -583,7 +583,8 @@ xfs_sb_verify(
>  	 * Only check the in progress field for the primary superblock as
>  	 * mkfs.xfs doesn't clear it from secondary superblocks.
>  	 */
> -	return xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR,
> +	return xfs_mount_validate_sb(mp, &sb,
> +				     bp->b_maps[0].bm_bn == XFS_SB_DADDR,
>  				     check_version);
>  }
>  
> -- 
> 2.8.0.rc3
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
Christoph Hellwig Aug. 25, 2016, 8:08 a.m. UTC | #2
On Mon, Aug 22, 2016 at 03:39:27PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> >From inspection, the superblock sb_inprogress check is done in the
> verifier and triggered only for the primary superblock via a
> "bp->b_bn == XFS_SB_DADDR" check.
> 
> Unfortunately, the primary superblock is an uncached buffer, and
> hence it is configured by xfs_buf_read_uncached() with:
> 
> 	bp->b_bn = XFS_BUF_DADDR_NULL;  /* always null for uncached buffers */

Hmm, I wonder why we did that, it seems a bit counter intuitive.

But the patch itself looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox

Patch

diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 0e3d4f5..4aecc5f 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -583,7 +583,8 @@  xfs_sb_verify(
 	 * Only check the in progress field for the primary superblock as
 	 * mkfs.xfs doesn't clear it from secondary superblocks.
 	 */
-	return xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR,
+	return xfs_mount_validate_sb(mp, &sb,
+				     bp->b_maps[0].bm_bn == XFS_SB_DADDR,
 				     check_version);
 }