On 1/30/20 7:33 AM, Christoph Hellwig wrote: > Just dereference bp->b_addr directly and make the code a little > simpler and more clear. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> ... > diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c > index 2f60fc3c99a0..772649f4eed6 100644 > --- a/fs/xfs/libxfs/xfs_sb.c > +++ b/fs/xfs/libxfs/xfs_sb.c > @@ -220,7 +220,7 @@ xfs_validate_sb_common( > struct xfs_buf *bp, > struct xfs_sb *sbp) > { > - struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp); > + struct xfs_dsb *dsb = bp->b_addr; > uint32_t agcount = 0; > uint32_t rem; > > @@ -681,7 +681,7 @@ xfs_sb_read_verify( > { > struct xfs_sb sb; > struct xfs_mount *mp = bp->b_mount; > - struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp); > + struct xfs_dsb *dsb = bp->b_addr; > int error; > > /* > @@ -707,7 +707,7 @@ xfs_sb_read_verify( > * Check all the superblock fields. Don't byteswap the xquota flags > * because _verify_common checks the on-disk values. > */ > - __xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp), false); > + __xfs_sb_from_disk(&sb, bp->b_addr, false); why not dsb here > error = xfs_validate_sb_common(mp, bp, &sb); > if (error) > goto out_error; > @@ -730,7 +730,7 @@ static void > xfs_sb_quiet_read_verify( > struct xfs_buf *bp) > { > - struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp); > + struct xfs_dsb *dsb = bp->b_addr; > > if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC)) { > /* XFS filesystem, verify noisily! */ > @@ -748,13 +748,14 @@ xfs_sb_write_verify( > struct xfs_sb sb; > struct xfs_mount *mp = bp->b_mount; > struct xfs_buf_log_item *bip = bp->b_log_item; > + struct xfs_dsb *dsb = bp->b_addr; > int error; > > /* > * Check all the superblock fields. Don't byteswap the xquota flags > * because _verify_common checks the on-disk values. > */ > - __xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp), false); > + __xfs_sb_from_disk(&sb, dsb, false); (as you did here) > error = xfs_validate_sb_common(mp, bp, &sb); > if (error) > goto out_error; > @@ -766,7 +767,7 @@ xfs_sb_write_verify( > return; > > if (bip) > - XFS_BUF_TO_SBP(bp)->sb_lsn = cpu_to_be64(bip->bli_item.li_lsn); > + dsb->sb_lsn = cpu_to_be64(bip->bli_item.li_lsn); > > xfs_buf_update_cksum(bp, XFS_SB_CRC_OFF); > return; > @@ -927,7 +928,7 @@ xfs_log_sb( > mp->m_sb.sb_ifree = percpu_counter_sum(&mp->m_ifree); > mp->m_sb.sb_fdblocks = percpu_counter_sum(&mp->m_fdblocks); > > - xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb); > + xfs_sb_to_disk(bp->b_addr, &mp->m_sb); hm no "dsb" in this case ... In any case seems like if you already have a local xfs_dsb, use that vs. bp->b_addr? -Eric