Skip to content

Commit b81b79f

Browse files
Christoph Hellwigdjwong
authored andcommitted
xfs: add a new xfs_sb_version_has_v3inode helper
Add a new wrapper to check if a file system supports the v3 inode format with a larger dinode core. Previously we used xfs_sb_version_hascrc for that, which is technically correct but a little confusing to read. Also move xfs_dinode_good_version next to xfs_sb_version_has_v3inode so that we have one place that documents the superblock version to inode version relationship. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
1 parent 8a62714 commit b81b79f

7 files changed

Lines changed: 25 additions & 21 deletions

File tree

‎fs/xfs/libxfs/xfs_format.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,23 @@ static inline bool xfs_sb_version_hascrc(struct xfs_sb *sbp)
497497
return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
498498
}
499499

500+
/*
501+
* v5 file systems support V3 inodes only, earlier file systems support
502+
* v2 and v1 inodes.
503+
*/
504+
static inline bool xfs_sb_version_has_v3inode(struct xfs_sb *sbp)
505+
{
506+
return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
507+
}
508+
509+
static inline bool xfs_dinode_good_version(struct xfs_sb *sbp,
510+
uint8_t version)
511+
{
512+
if (xfs_sb_version_has_v3inode(sbp))
513+
return version == 3;
514+
return version == 1 || version == 2;
515+
}
516+
500517
static inline bool xfs_sb_version_has_pquotino(struct xfs_sb *sbp)
501518
{
502519
return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;

‎fs/xfs/libxfs/xfs_ialloc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ xfs_ialloc_inode_init(
304304
* That means for v3 inode we log the entire buffer rather than just the
305305
* inode cores.
306306
*/
307-
if (xfs_sb_version_hascrc(&mp->m_sb)) {
307+
if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
308308
version = 3;
309309
ino = XFS_AGINO_TO_INO(mp, agno, XFS_AGB_TO_AGINO(mp, agbno));
310310

@@ -2872,7 +2872,7 @@ xfs_ialloc_setup_geometry(
28722872
* cannot change the behavior.
28732873
*/
28742874
igeo->inode_cluster_size_raw = XFS_INODE_BIG_CLUSTER_SIZE;
2875-
if (xfs_sb_version_hascrc(&mp->m_sb)) {
2875+
if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
28762876
int new_size = igeo->inode_cluster_size_raw;
28772877

28782878
new_size *= mp->m_sb.sb_inodesize / XFS_DINODE_MIN_SIZE;

‎fs/xfs/libxfs/xfs_inode_buf.c‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@ xfs_inobp_check(
4444
}
4545
#endif
4646

47-
bool
48-
xfs_dinode_good_version(
49-
struct xfs_mount *mp,
50-
__u8 version)
51-
{
52-
if (xfs_sb_version_hascrc(&mp->m_sb))
53-
return version == 3;
54-
55-
return version == 1 || version == 2;
56-
}
57-
5847
/*
5948
* If we are doing readahead on an inode buffer, we might be in log recovery
6049
* reading an inode allocation buffer that hasn't yet been replayed, and hence
@@ -93,7 +82,7 @@ xfs_inode_buf_verify(
9382
dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog));
9483
unlinked_ino = be32_to_cpu(dip->di_next_unlinked);
9584
di_ok = xfs_verify_magic16(bp, dip->di_magic) &&
96-
xfs_dinode_good_version(mp, dip->di_version) &&
85+
xfs_dinode_good_version(&mp->m_sb, dip->di_version) &&
9786
xfs_verify_agino_or_null(mp, agno, unlinked_ino);
9887
if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
9988
XFS_ERRTAG_ITOBP_INOTOBP))) {
@@ -454,7 +443,7 @@ xfs_dinode_verify(
454443

455444
/* Verify v3 integrity information first */
456445
if (dip->di_version >= 3) {
457-
if (!xfs_sb_version_hascrc(&mp->m_sb))
446+
if (!xfs_sb_version_has_v3inode(&mp->m_sb))
458447
return __this_address;
459448
if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
460449
XFS_DINODE_CRC_OFF))
@@ -629,7 +618,7 @@ xfs_iread(
629618

630619
/* shortcut IO on inode allocation if possible */
631620
if ((iget_flags & XFS_IGET_CREATE) &&
632-
xfs_sb_version_hascrc(&mp->m_sb) &&
621+
xfs_sb_version_has_v3inode(&mp->m_sb) &&
633622
!(mp->m_flags & XFS_MOUNT_IKEEP)) {
634623
VFS_I(ip)->i_generation = prandom_u32();
635624
ip->i_d.di_version = 3;

‎fs/xfs/libxfs/xfs_inode_buf.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ void xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
5959
void xfs_log_dinode_to_disk(struct xfs_log_dinode *from,
6060
struct xfs_dinode *to);
6161

62-
bool xfs_dinode_good_version(struct xfs_mount *mp, __u8 version);
63-
6462
#if defined(DEBUG)
6563
void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
6664
#else

‎fs/xfs/libxfs/xfs_trans_resv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ xfs_calc_inode_chunk_res(
187187
XFS_FSB_TO_B(mp, 1));
188188
if (alloc) {
189189
/* icreate tx uses ordered buffers */
190-
if (xfs_sb_version_hascrc(&mp->m_sb))
190+
if (xfs_sb_version_has_v3inode(&mp->m_sb))
191191
return res;
192192
size = XFS_FSB_TO_B(mp, 1);
193193
}

‎fs/xfs/xfs_buf_item.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ xfs_buf_item_format(
345345
* occurs during recovery.
346346
*/
347347
if (bip->bli_flags & XFS_BLI_INODE_BUF) {
348-
if (xfs_sb_version_hascrc(&lip->li_mountp->m_sb) ||
348+
if (xfs_sb_version_has_v3inode(&lip->li_mountp->m_sb) ||
349349
!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
350350
xfs_log_item_in_current_chkpt(lip)))
351351
bip->__bli_format.blf_flags |= XFS_BLF_INODE_BUF;

‎fs/xfs/xfs_log_recover.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2997,7 +2997,7 @@ xlog_recover_inode_pass2(
29972997
* superblock flag to determine whether we need to look at di_flushiter
29982998
* to skip replay when the on disk inode is newer than the log one
29992999
*/
3000-
if (!xfs_sb_version_hascrc(&mp->m_sb) &&
3000+
if (!xfs_sb_version_has_v3inode(&mp->m_sb) &&
30013001
ldip->di_flushiter < be16_to_cpu(dip->di_flushiter)) {
30023002
/*
30033003
* Deal with the wrap case, DI_MAX_FLUSH is less

0 commit comments

Comments
 (0)