Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 533b81c8 authored by Eric Sandeen's avatar Eric Sandeen Committed by Dave Chinner
Browse files

xfs: Use defines for CRC offsets in all cases



Some calls to crc functions used useful #defines,
others used awkward offsetof() constructs.

Switch them all to #define to make things a bit cleaner.

Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent e0d2c23a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ typedef struct xfs_agf {
	/* structure must be padded to 64 bit alignment */
} xfs_agf_t;

#define XFS_AGF_CRC_OFF		offsetof(struct xfs_agf, agf_crc)

#define	XFS_AGF_MAGICNUM	0x00000001
#define	XFS_AGF_VERSIONNUM	0x00000002
#define	XFS_AGF_SEQNO		0x00000004
@@ -167,6 +169,8 @@ typedef struct xfs_agi {
	/* structure must be padded to 64 bit alignment */
} xfs_agi_t;

#define XFS_AGI_CRC_OFF		offsetof(struct xfs_agi, agi_crc)

#define	XFS_AGI_MAGICNUM	0x00000001
#define	XFS_AGI_VERSIONNUM	0x00000002
#define	XFS_AGI_SEQNO		0x00000004
@@ -222,6 +226,8 @@ typedef struct xfs_agfl {
	__be32		agfl_bno[];	/* actually XFS_AGFL_SIZE(mp) */
} xfs_agfl_t;

#define XFS_AGFL_CRC_OFF	offsetof(struct xfs_agfl, agfl_crc)

/*
 * tags for inode radix tree
 */
+4 −6
Original line number Diff line number Diff line
@@ -486,7 +486,7 @@ xfs_agfl_read_verify(
		return;

	agfl_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length),
				   offsetof(struct xfs_agfl, agfl_crc));
				   XFS_AGFL_CRC_OFF);

	agfl_ok = agfl_ok && xfs_agfl_verify(bp);

@@ -516,8 +516,7 @@ xfs_agfl_write_verify(
	if (bip)
		XFS_BUF_TO_AGFL(bp)->agfl_lsn = cpu_to_be64(bip->bli_item.li_lsn);

	xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length),
			 offsetof(struct xfs_agfl, agfl_crc));
	xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), XFS_AGFL_CRC_OFF);
}

const struct xfs_buf_ops xfs_agfl_buf_ops = {
@@ -2242,7 +2241,7 @@ xfs_agf_read_verify(

	if (xfs_sb_version_hascrc(&mp->m_sb))
		agf_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length),
					  offsetof(struct xfs_agf, agf_crc));
					  XFS_AGF_CRC_OFF);

	agf_ok = agf_ok && xfs_agf_verify(mp, bp);

@@ -2272,8 +2271,7 @@ xfs_agf_write_verify(
	if (bip)
		XFS_BUF_TO_AGF(bp)->agf_lsn = cpu_to_be64(bip->bli_item.li_lsn);

	xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length),
			 offsetof(struct xfs_agf, agf_crc));
	xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), XFS_AGF_CRC_OFF);
}

const struct xfs_buf_ops xfs_agf_buf_ops = {
+2 −0
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ typedef struct xfs_dinode {
	/* structure must be padded to 64 bit alignment */
} xfs_dinode_t;

#define XFS_DINODE_CRC_OFF	offsetof(struct xfs_dinode, di_crc)

#define DI_MAX_FLUSH 0xffff

/*
+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,8 @@ struct xfs_dsymlink_hdr {
	__be64	sl_lsn;
};

#define XFS_SYMLINK_CRC_OFF	offsetof(struct xfs_dsymlink_hdr, sl_crc)

/*
 * The maximum pathlen is 1024 bytes. Since the minimum file system
 * blocksize is 512 bytes, we can get a max of 3 extents back from
+2 −3
Original line number Diff line number Diff line
@@ -1572,7 +1572,7 @@ xfs_agi_read_verify(

	if (xfs_sb_version_hascrc(&mp->m_sb))
		agi_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length),
					  offsetof(struct xfs_agi, agi_crc));
					  XFS_AGI_CRC_OFF);
	agi_ok = agi_ok && xfs_agi_verify(bp);

	if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI,
@@ -1600,8 +1600,7 @@ xfs_agi_write_verify(

	if (bip)
		XFS_BUF_TO_AGI(bp)->agi_lsn = cpu_to_be64(bip->bli_item.li_lsn);
	xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length),
			 offsetof(struct xfs_agi, agi_crc));
	xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), XFS_AGI_CRC_OFF);
}

const struct xfs_buf_ops xfs_agi_buf_ops = {
Loading