Commit b81b79f4 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarChandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 8a627143
...@@ -497,6 +497,23 @@ static inline bool xfs_sb_version_hascrc(struct xfs_sb *sbp) ...@@ -497,6 +497,23 @@ static inline bool xfs_sb_version_hascrc(struct xfs_sb *sbp)
return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
} }
/*
* v5 file systems support V3 inodes only, earlier file systems support
* v2 and v1 inodes.
*/
static inline bool xfs_sb_version_has_v3inode(struct xfs_sb *sbp)
{
return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
}
static inline bool xfs_dinode_good_version(struct xfs_sb *sbp,
uint8_t version)
{
if (xfs_sb_version_has_v3inode(sbp))
return version == 3;
return version == 1 || version == 2;
}
static inline bool xfs_sb_version_has_pquotino(struct xfs_sb *sbp) static inline bool xfs_sb_version_has_pquotino(struct xfs_sb *sbp)
{ {
return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
......
...@@ -304,7 +304,7 @@ xfs_ialloc_inode_init( ...@@ -304,7 +304,7 @@ xfs_ialloc_inode_init(
* That means for v3 inode we log the entire buffer rather than just the * That means for v3 inode we log the entire buffer rather than just the
* inode cores. * inode cores.
*/ */
if (xfs_sb_version_hascrc(&mp->m_sb)) { if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
version = 3; version = 3;
ino = XFS_AGINO_TO_INO(mp, agno, XFS_AGB_TO_AGINO(mp, agbno)); ino = XFS_AGINO_TO_INO(mp, agno, XFS_AGB_TO_AGINO(mp, agbno));
...@@ -2872,7 +2872,7 @@ xfs_ialloc_setup_geometry( ...@@ -2872,7 +2872,7 @@ xfs_ialloc_setup_geometry(
* cannot change the behavior. * cannot change the behavior.
*/ */
igeo->inode_cluster_size_raw = XFS_INODE_BIG_CLUSTER_SIZE; igeo->inode_cluster_size_raw = XFS_INODE_BIG_CLUSTER_SIZE;
if (xfs_sb_version_hascrc(&mp->m_sb)) { if (xfs_sb_version_has_v3inode(&mp->m_sb)) {
int new_size = igeo->inode_cluster_size_raw; int new_size = igeo->inode_cluster_size_raw;
new_size *= mp->m_sb.sb_inodesize / XFS_DINODE_MIN_SIZE; new_size *= mp->m_sb.sb_inodesize / XFS_DINODE_MIN_SIZE;
......
...@@ -44,17 +44,6 @@ xfs_inobp_check( ...@@ -44,17 +44,6 @@ xfs_inobp_check(
} }
#endif #endif
bool
xfs_dinode_good_version(
struct xfs_mount *mp,
__u8 version)
{
if (xfs_sb_version_hascrc(&mp->m_sb))
return version == 3;
return version == 1 || version == 2;
}
/* /*
* If we are doing readahead on an inode buffer, we might be in log recovery * If we are doing readahead on an inode buffer, we might be in log recovery
* reading an inode allocation buffer that hasn't yet been replayed, and hence * reading an inode allocation buffer that hasn't yet been replayed, and hence
...@@ -93,7 +82,7 @@ xfs_inode_buf_verify( ...@@ -93,7 +82,7 @@ xfs_inode_buf_verify(
dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog)); dip = xfs_buf_offset(bp, (i << mp->m_sb.sb_inodelog));
unlinked_ino = be32_to_cpu(dip->di_next_unlinked); unlinked_ino = be32_to_cpu(dip->di_next_unlinked);
di_ok = xfs_verify_magic16(bp, dip->di_magic) && di_ok = xfs_verify_magic16(bp, dip->di_magic) &&
xfs_dinode_good_version(mp, dip->di_version) && xfs_dinode_good_version(&mp->m_sb, dip->di_version) &&
xfs_verify_agino_or_null(mp, agno, unlinked_ino); xfs_verify_agino_or_null(mp, agno, unlinked_ino);
if (unlikely(XFS_TEST_ERROR(!di_ok, mp, if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
XFS_ERRTAG_ITOBP_INOTOBP))) { XFS_ERRTAG_ITOBP_INOTOBP))) {
...@@ -454,7 +443,7 @@ xfs_dinode_verify( ...@@ -454,7 +443,7 @@ xfs_dinode_verify(
/* Verify v3 integrity information first */ /* Verify v3 integrity information first */
if (dip->di_version >= 3) { if (dip->di_version >= 3) {
if (!xfs_sb_version_hascrc(&mp->m_sb)) if (!xfs_sb_version_has_v3inode(&mp->m_sb))
return __this_address; return __this_address;
if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize, if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
XFS_DINODE_CRC_OFF)) XFS_DINODE_CRC_OFF))
...@@ -629,7 +618,7 @@ xfs_iread( ...@@ -629,7 +618,7 @@ xfs_iread(
/* shortcut IO on inode allocation if possible */ /* shortcut IO on inode allocation if possible */
if ((iget_flags & XFS_IGET_CREATE) && if ((iget_flags & XFS_IGET_CREATE) &&
xfs_sb_version_hascrc(&mp->m_sb) && xfs_sb_version_has_v3inode(&mp->m_sb) &&
!(mp->m_flags & XFS_MOUNT_IKEEP)) { !(mp->m_flags & XFS_MOUNT_IKEEP)) {
VFS_I(ip)->i_generation = prandom_u32(); VFS_I(ip)->i_generation = prandom_u32();
ip->i_d.di_version = 3; ip->i_d.di_version = 3;
......
...@@ -59,8 +59,6 @@ void xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from); ...@@ -59,8 +59,6 @@ void xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
void xfs_log_dinode_to_disk(struct xfs_log_dinode *from, void xfs_log_dinode_to_disk(struct xfs_log_dinode *from,
struct xfs_dinode *to); struct xfs_dinode *to);
bool xfs_dinode_good_version(struct xfs_mount *mp, __u8 version);
#if defined(DEBUG) #if defined(DEBUG)
void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *); void xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
#else #else
......
...@@ -187,7 +187,7 @@ xfs_calc_inode_chunk_res( ...@@ -187,7 +187,7 @@ xfs_calc_inode_chunk_res(
XFS_FSB_TO_B(mp, 1)); XFS_FSB_TO_B(mp, 1));
if (alloc) { if (alloc) {
/* icreate tx uses ordered buffers */ /* icreate tx uses ordered buffers */
if (xfs_sb_version_hascrc(&mp->m_sb)) if (xfs_sb_version_has_v3inode(&mp->m_sb))
return res; return res;
size = XFS_FSB_TO_B(mp, 1); size = XFS_FSB_TO_B(mp, 1);
} }
......
...@@ -345,7 +345,7 @@ xfs_buf_item_format( ...@@ -345,7 +345,7 @@ xfs_buf_item_format(
* occurs during recovery. * occurs during recovery.
*/ */
if (bip->bli_flags & XFS_BLI_INODE_BUF) { if (bip->bli_flags & XFS_BLI_INODE_BUF) {
if (xfs_sb_version_hascrc(&lip->li_mountp->m_sb) || if (xfs_sb_version_has_v3inode(&lip->li_mountp->m_sb) ||
!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && !((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
xfs_log_item_in_current_chkpt(lip))) xfs_log_item_in_current_chkpt(lip)))
bip->__bli_format.blf_flags |= XFS_BLF_INODE_BUF; bip->__bli_format.blf_flags |= XFS_BLF_INODE_BUF;
......
...@@ -2997,7 +2997,7 @@ xlog_recover_inode_pass2( ...@@ -2997,7 +2997,7 @@ xlog_recover_inode_pass2(
* superblock flag to determine whether we need to look at di_flushiter * superblock flag to determine whether we need to look at di_flushiter
* to skip replay when the on disk inode is newer than the log one * to skip replay when the on disk inode is newer than the log one
*/ */
if (!xfs_sb_version_hascrc(&mp->m_sb) && if (!xfs_sb_version_has_v3inode(&mp->m_sb) &&
ldip->di_flushiter < be16_to_cpu(dip->di_flushiter)) { ldip->di_flushiter < be16_to_cpu(dip->di_flushiter)) {
/* /*
* Deal with the wrap case, DI_MAX_FLUSH is less * Deal with the wrap case, DI_MAX_FLUSH is less
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment