Skip to content

Commit ac3a027

Browse files
author
Darrick J. Wong
committed
xfs: don't use the incore struct xfs_sb for offsets into struct xfs_dsb
Currently, the XFS_SB_CRC_OFF macro uses the incore superblock struct (xfs_sb) to compute the address of sb_crc within the ondisk superblock struct (xfs_dsb). This is a landmine if we ever change the layout of the incore superblock (as we're about to do), so redefine the macro to use xfs_dsb to compute the layout of xfs_dsb. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 47d4d59 commit ac3a027

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

fs/xfs/libxfs/xfs_format.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ struct xfs_ifork;
9090
#define XFSLABEL_MAX 12
9191

9292
/*
93-
* Superblock - in core version. Must match the ondisk version below.
94-
* Must be padded to 64 bit alignment.
93+
* Superblock - in core version. Must be padded to 64 bit alignment.
9594
*/
9695
typedef struct xfs_sb {
9796
uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
@@ -178,10 +177,8 @@ typedef struct xfs_sb {
178177
/* must be padded to 64 bit alignment */
179178
} xfs_sb_t;
180179

181-
#define XFS_SB_CRC_OFF offsetof(struct xfs_sb, sb_crc)
182-
183180
/*
184-
* Superblock - on disk version. Must match the in core version above.
181+
* Superblock - on disk version.
185182
* Must be padded to 64 bit alignment.
186183
*/
187184
struct xfs_dsb {
@@ -265,6 +262,8 @@ struct xfs_dsb {
265262
/* must be padded to 64 bit alignment */
266263
};
267264

265+
#define XFS_SB_CRC_OFF offsetof(struct xfs_dsb, sb_crc)
266+
268267
/*
269268
* Misc. Flags - warning - these will be cleared by xfs_repair unless
270269
* a feature bit is set when the flag is used.

fs/xfs/libxfs/xfs_ondisk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ xfs_check_ondisk_structs(void)
8585
XFS_CHECK_STRUCT_SIZE(xfs_attr_leaf_name_remote_t, 12);
8686
*/
8787

88+
XFS_CHECK_OFFSET(struct xfs_dsb, sb_crc, 224);
8889
XFS_CHECK_OFFSET(xfs_attr_leaf_name_local_t, valuelen, 0);
8990
XFS_CHECK_OFFSET(xfs_attr_leaf_name_local_t, namelen, 2);
9091
XFS_CHECK_OFFSET(xfs_attr_leaf_name_local_t, nameval, 3);

0 commit comments

Comments
 (0)