public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: sandeen@sandeen.net
Cc: linux-xfs@vger.kernel.org, Brian Foster <bfoster@redhat.com>,
	Eric Sandeen <sandeen@redhat.com>,
	"Darrick J . Wong" <darrick.wong@oracle.com>
Subject: [PATCH 31/58] xfs: remove XFS_BUF_TO_SBP
Date: Thu,  7 May 2020 14:18:24 +0200	[thread overview]
Message-ID: <20200507121851.304002-32-hch@lst.de> (raw)
In-Reply-To: <20200507121851.304002-1-hch@lst.de>

Source kernel commit: 3e6e8afd3abb745871ee215738a899a495c54a66

Just dereference bp->b_addr directly and make the code a little
simpler and more clear.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 copy/xfs_copy.c     |  2 +-
 db/init.c           |  2 +-
 libxfs/xfs_ag.c     |  2 +-
 libxfs/xfs_format.h |  1 -
 libxfs/xfs_sb.c     | 17 +++++++++--------
 mkfs/xfs_mkfs.c     |  8 +++++---
 repair/agheader.c   |  2 +-
 repair/phase5.c     |  2 +-
 repair/scan.c       |  4 ++--
 repair/xfs_repair.c |  4 ++--
 10 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index 72ce3fe7..2d087f71 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -720,7 +720,7 @@ main(int argc, char **argv)
 	}
 
 	sb = &mbuf.m_sb;
-	libxfs_sb_from_disk(sb, XFS_BUF_TO_SBP(sbp));
+	libxfs_sb_from_disk(sb, sbp->b_addr);
 
 	/* Do it again, now with proper length and verifier */
 	libxfs_buf_relse(sbp);
diff --git a/db/init.c b/db/init.c
index ac649fbd..19f0900a 100644
--- a/db/init.c
+++ b/db/init.c
@@ -119,7 +119,7 @@ init(
 	}
 
 	/* copy SB from buffer to in-core, converting architecture as we go */
-	libxfs_sb_from_disk(&xmount.m_sb, XFS_BUF_TO_SBP(bp));
+	libxfs_sb_from_disk(&xmount.m_sb, bp->b_addr);
 	libxfs_buf_relse(bp);
 
 	sbp = &xmount.m_sb;
diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c
index c6160df7..9ce7abd7 100644
--- a/libxfs/xfs_ag.c
+++ b/libxfs/xfs_ag.c
@@ -231,7 +231,7 @@ xfs_sbblock_init(
 	struct xfs_buf		*bp,
 	struct aghdr_init_data	*id)
 {
-	struct xfs_dsb		*dsb = XFS_BUF_TO_SBP(bp);
+	struct xfs_dsb		*dsb = bp->b_addr;
 
 	xfs_sb_to_disk(dsb, &mp->m_sb);
 	dsb->sb_inprogress = 1;
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index 1fec1302..09fd5d23 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h
@@ -560,7 +560,6 @@ xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino)
 
 #define XFS_SB_DADDR		((xfs_daddr_t)0) /* daddr in filesystem/ag */
 #define	XFS_SB_BLOCK(mp)	XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
-#define XFS_BUF_TO_SBP(bp)	((xfs_dsb_t *)((bp)->b_addr))
 
 #define	XFS_HDR_BLOCK(mp,d)	((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
 #define	XFS_DADDR_TO_FSB(mp,d)	XFS_AGB_TO_FSB(mp, \
diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
index 687e33d8..e26b9016 100644
--- a/libxfs/xfs_sb.c
+++ b/libxfs/xfs_sb.c
@@ -217,7 +217,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;
 
@@ -658,7 +658,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;
 
 	/*
@@ -684,7 +684,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, dsb, false);
 	error = xfs_validate_sb_common(mp, bp, &sb);
 	if (error)
 		goto out_error;
@@ -707,7 +707,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! */
@@ -725,13 +725,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);
 	error = xfs_validate_sb_common(mp, bp, &sb);
 	if (error)
 		goto out_error;
@@ -743,7 +744,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;
@@ -904,7 +905,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);
 	xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);
 	xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb) - 1);
 }
@@ -984,7 +985,7 @@ xfs_update_secondary_sbs(
 		bp->b_ops = &xfs_sb_buf_ops;
 		xfs_buf_oneshot(bp);
 		xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
-		xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb);
+		xfs_sb_to_disk(bp->b_addr, &mp->m_sb);
 		xfs_buf_delwri_queue(bp, &buffer_list);
 		xfs_buf_relse(bp);
 
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 039b1dcc..e76d2a7a 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3490,6 +3490,7 @@ rewrite_secondary_superblocks(
 	struct xfs_mount	*mp)
 {
 	struct xfs_buf		*buf;
+	struct xfs_dsb		*sb;
 	int			error;
 
 	/* rewrite the last superblock */
@@ -3502,7 +3503,8 @@ rewrite_secondary_superblocks(
 				progname, mp->m_sb.sb_agcount - 1);
 		exit(1);
 	}
-	XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
+	sb = buf->b_addr;
+	sb->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
 	libxfs_buf_mark_dirty(buf);
 	libxfs_buf_relse(buf);
 
@@ -3519,7 +3521,7 @@ rewrite_secondary_superblocks(
 				progname, (mp->m_sb.sb_agcount - 1) / 2);
 		exit(1);
 	}
-	XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
+	sb->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
 	libxfs_buf_mark_dirty(buf);
 	libxfs_buf_relse(buf);
 }
@@ -3867,7 +3869,7 @@ main(
 	buf = libxfs_getsb(mp);
 	if (!buf || buf->b_error)
 		exit(1);
-	(XFS_BUF_TO_SBP(buf))->sb_inprogress = 0;
+	((struct xfs_dsb *)buf->b_addr)->sb_inprogress = 0;
 	libxfs_buf_mark_dirty(buf);
 	libxfs_buf_relse(buf);
 
diff --git a/repair/agheader.c b/repair/agheader.c
index 218ee256..f28d8a7b 100644
--- a/repair/agheader.c
+++ b/repair/agheader.c
@@ -241,7 +241,7 @@ secondary_sb_whack(
 	struct xfs_sb	*sb,
 	xfs_agnumber_t	i)
 {
-	struct xfs_dsb	*dsb = XFS_BUF_TO_SBP(sbuf);
+	struct xfs_dsb	*dsb = sbuf->b_addr;
 	int		do_bzero = 0;
 	int		size;
 	char		*ip;
diff --git a/repair/phase5.c b/repair/phase5.c
index fd7659dc..677297fe 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -2263,7 +2263,7 @@ sync_sb(xfs_mount_t *mp)
 
 	update_sb_version(mp);
 
-	libxfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb);
+	libxfs_sb_to_disk(bp->b_addr, &mp->m_sb);
 	libxfs_buf_mark_dirty(bp);
 	libxfs_buf_relse(bp);
 }
diff --git a/repair/scan.c b/repair/scan.c
index e40ce194..5c8d8b23 100644
--- a/repair/scan.c
+++ b/repair/scan.c
@@ -2375,7 +2375,7 @@ scan_ag(
 		objname = _("root superblock");
 		goto out_free_sb;
 	}
-	libxfs_sb_from_disk(sb, XFS_BUF_TO_SBP(sbbuf));
+	libxfs_sb_from_disk(sb, sbbuf->b_addr);
 
 	error = salvage_buffer(mp->m_dev,
 			XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
@@ -2480,7 +2480,7 @@ scan_ag(
 	if (sb_dirty && !no_modify) {
 		if (agno == 0)
 			memcpy(&mp->m_sb, sb, sizeof(xfs_sb_t));
-		libxfs_sb_to_disk(XFS_BUF_TO_SBP(sbbuf), sb);
+		libxfs_sb_to_disk(sbbuf->b_addr, sb);
 		libxfs_buf_mark_dirty(sbbuf);
 		libxfs_buf_relse(sbbuf);
 	} else
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index e509fdeb..9d72fa8e 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -478,7 +478,7 @@ guess_correct_sunit(
 		error = -libxfs_sb_read_secondary(mp, NULL, agno, &bp);
 		if (error)
 			continue;
-		libxfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp));
+		libxfs_sb_from_disk(&sb, bp->b_addr);
 		libxfs_buf_relse(bp);
 
 		calc_rootino = libxfs_ialloc_calc_rootino(mp, sb.sb_unit);
@@ -1081,7 +1081,7 @@ _("Warning:  project quota information would be cleared.\n"
 	if (!sbp)
 		do_error(_("couldn't get superblock\n"));
 
-	dsb = XFS_BUF_TO_SBP(sbp);
+	dsb = sbp->b_addr;
 
 	if (be16_to_cpu(dsb->sb_qflags) & XFS_ALL_QUOTA_CHKD) {
 		do_warn(_("Note - quota info will be regenerated on next "
-- 
2.26.2


  parent reply	other threads:[~2020-05-07 12:20 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 12:17 libxfs 5.7 resync Christoph Hellwig
2020-05-07 12:17 ` [PATCH 01/58] xfs: add agf freeblocks verify in xfs_agf_verify Christoph Hellwig
2020-05-07 12:17 ` [PATCH 02/58] xfs: ensure that the inode uid/gid match values match the icdinode ones Christoph Hellwig
2020-05-07 12:17 ` [PATCH 03/58] xfs: remove the icdinode di_uid/di_gid members Christoph Hellwig
2020-05-07 12:17 ` [PATCH 04/58] xfs: remove the kuid/kgid conversion wrappers Christoph Hellwig
2020-05-07 12:17 ` [PATCH 05/58] xfs: fix an undefined behaviour in _da3_path_shift Christoph Hellwig
2020-05-07 12:17 ` [PATCH 06/58] xfs: open code insert range extent split helper Christoph Hellwig
2020-05-07 12:18 ` [PATCH 07/58] xfs: remove the ATTR_INCOMPLETE flag Christoph Hellwig
2020-05-07 12:18 ` [PATCH 08/58] xfs: merge xfs_attr_remove into xfs_attr_set Christoph Hellwig
2020-05-07 12:18 ` [PATCH 09/58] xfs: remove the name == NULL check from xfs_attr_args_init Christoph Hellwig
2020-05-07 12:18 ` [PATCH 10/58] xfs: remove the MAXNAMELEN " Christoph Hellwig
2020-05-07 12:18 ` [PATCH 11/58] xfs: turn xfs_da_args.value into a void pointer Christoph Hellwig
2020-05-07 12:18 ` [PATCH 12/58] xfs: pass an initialized xfs_da_args structure to xfs_attr_set Christoph Hellwig
2020-05-07 12:18 ` [PATCH 13/58] xfs: pass an initialized xfs_da_args to xfs_attr_get Christoph Hellwig
2020-05-07 12:18 ` [PATCH 14/58] xfs: remove the xfs_inode argument to xfs_attr_get_ilocked Christoph Hellwig
2020-05-07 12:18 ` [PATCH 15/58] xfs: remove ATTR_KERNOVAL Christoph Hellwig
2020-05-07 12:18 ` [PATCH 16/58] xfs: remove ATTR_ALLOC and XFS_DA_OP_ALLOCVAL Christoph Hellwig
2020-05-07 12:18 ` [PATCH 17/58] xfs: replace ATTR_KERNOTIME with XFS_DA_OP_NOTIME Christoph Hellwig
2020-05-07 12:18 ` [PATCH 18/58] xfs: factor out a xfs_attr_match helper Christoph Hellwig
2020-05-07 12:18 ` [PATCH 19/58] xfs: cleanup struct xfs_attr_list_context Christoph Hellwig
2020-05-07 12:18 ` [PATCH 20/58] xfs: remove the unused ATTR_ENTRY macro Christoph Hellwig
2020-05-07 12:18 ` [PATCH 21/58] xfs: move the legacy xfs_attr_list to xfs_ioctl.c Christoph Hellwig
2020-05-07 12:18 ` [PATCH 22/58] xfs: rename xfs_attr_list_int to xfs_attr_list Christoph Hellwig
2020-05-07 12:18 ` [PATCH 23/58] xfs: clean up the ATTR_REPLACE checks Christoph Hellwig
2020-05-07 12:18 ` [PATCH 24/58] xfs: clean up the attr flag confusion Christoph Hellwig
2020-05-07 12:18 ` [PATCH 25/58] xfs: remove XFS_DA_OP_INCOMPLETE Christoph Hellwig
2020-05-07 12:18 ` [PATCH 26/58] xfs: embedded the attrlist cursor into struct xfs_attr_list_context Christoph Hellwig
2020-05-07 12:18 ` [PATCH 27/58] xfs: remove the agfl_bno member from struct xfs_agfl Christoph Hellwig
2020-05-07 12:18 ` [PATCH 28/58] xfs: remove the xfs_agfl_t typedef Christoph Hellwig
2020-05-07 12:18 ` [PATCH 29/58] xfs: remove XFS_BUF_TO_AGI Christoph Hellwig
2020-05-07 12:18 ` [PATCH 30/58] xfs: remove XFS_BUF_TO_AGF Christoph Hellwig
2020-05-07 12:18 ` Christoph Hellwig [this message]
2020-05-07 12:18 ` [PATCH 32/58] xfs: fix xfs_rmap_has_other_keys usage of ECANCELED Christoph Hellwig
2020-05-07 12:18 ` [PATCH 33/58] xfs: add a function to deal with corrupt buffers post-verifiers Christoph Hellwig
2020-05-07 12:18 ` [PATCH 34/58] xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails Christoph Hellwig
2020-05-07 12:18 ` [PATCH 35/58] xfs: don't ever return a stale pointer from __xfs_dir3_free_read Christoph Hellwig
2020-05-07 12:18 ` [PATCH 36/58] xfs: check owner of dir3 free blocks Christoph Hellwig
2020-05-07 12:18 ` [PATCH 37/58] xfs: check owner of dir3 data blocks Christoph Hellwig
2020-05-07 12:18 ` [PATCH 38/58] xfs: check owner of dir3 blocks Christoph Hellwig
2020-05-07 12:18 ` [PATCH 39/58] xfs: introduce new private btree cursor names Christoph Hellwig
2020-05-07 12:18 ` [PATCH 40/58] xfs: convert btree cursor ag-private member name Christoph Hellwig
2020-05-07 12:18 ` [PATCH 41/58] xfs: convert btree cursor inode-private member names Christoph Hellwig
2020-05-07 12:18 ` [PATCH 42/58] xfs: rename btree cursor private btree member flags Christoph Hellwig
2020-05-07 12:18 ` [PATCH 43/58] xfs: make btree cursor private union anonymous Christoph Hellwig
2020-05-07 12:18 ` [PATCH 44/58] xfs: make the btree cursor union members named structure Christoph Hellwig
2020-05-07 12:18 ` [PATCH 45/58] xfs: make the btree ag cursor private union anonymous Christoph Hellwig
2020-05-07 12:18 ` [PATCH 46/58] xfs: xfs_dabuf_map should return ENOMEM when map allocation fails Christoph Hellwig
2020-05-07 12:18 ` [PATCH 47/58] xfs: fix incorrect test in xfs_alloc_ag_vextent_lastblock Christoph Hellwig
2020-05-07 12:18 ` [PATCH 48/58] xfs: introduce fake roots for ag-rooted btrees Christoph Hellwig
2020-05-07 12:18 ` [PATCH 49/58] xfs: introduce fake roots for inode-rooted btrees Christoph Hellwig
2020-05-07 12:18 ` [PATCH 50/58] xfs: support bulk loading of staged btrees Christoph Hellwig
2020-05-07 12:18 ` [PATCH 51/58] xfs: add support for free space btree staging cursors Christoph Hellwig
2020-05-07 12:18 ` [PATCH 52/58] xfs: add support for inode " Christoph Hellwig
2020-05-07 12:18 ` [PATCH 53/58] xfs: add support for refcount " Christoph Hellwig
2020-05-07 12:18 ` [PATCH 54/58] xfs: add support for rmap " Christoph Hellwig
2020-05-07 12:18 ` [PATCH 55/58] xfs: add a new xfs_sb_version_has_v3inode helper Christoph Hellwig
2020-05-07 12:18 ` [PATCH 56/58] xfs: only check the superblock version for dinode size calculation Christoph Hellwig
2020-05-07 12:18 ` [PATCH 57/58] xfs: remove the di_version field from struct icdinode Christoph Hellwig
2020-05-07 12:18 ` [PATCH 58/58] xfs: validate the realtime geometry in xfs_validate_sb_common Christoph Hellwig
2020-05-07 12:47 ` libxfs 5.7 resync Eric Sandeen
2020-05-07 15:48 ` Darrick J. Wong
2020-05-07 15:54   ` Darrick J. Wong
2020-05-07 15:54   ` Christoph Hellwig
2020-05-07 16:07     ` Darrick J. Wong
2020-05-07 16:11     ` Christoph Hellwig
2020-05-07 16:12       ` Eric Sandeen
2020-05-07 16:14         ` Christoph Hellwig
2020-05-07 16:22     ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200507121851.304002-32-hch@lst.de \
    --to=hch@lst.de \
    --cc=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox