diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2020-02-19 17:02:52 -0800 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2020-06-01 21:16:45 -0700 |
commit | f5ca42903458e0315f6d18d7adf610c4ef719dfa (patch) | |
tree | 4817b77a4bb3333c6bf4bce57f3316a62a6077aa /fs | |
parent | 1dd10f46e2b541e91c36471adacd7469a240262f (diff) |
xfs: add realtime reverse map inode to superblock
Add a metadir path to select the realtime rmap btree inode and load
it at mount time. The rtrmapbt inode will have a unique extent format
code, which means that we also have to update the inode validation and
flush routines to look for it.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 9 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_imeta.c | 2 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_imeta.h | 1 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_inode_buf.c | 6 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_inode_fork.c | 9 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_rtrmap_btree.c | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_inode.c | 9 | ||||
-rw-r--r-- | fs/xfs/xfs_inode_item.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_inode_item_recover.c | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.h | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 45 |
11 files changed, 80 insertions, 11 deletions
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 0aaf96e26155..9a0943a3874c 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -608,6 +608,12 @@ static inline bool xfs_sb_version_hasmetadir(struct xfs_sb *sbp) (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR); } +static inline bool xfs_sb_version_hasrtrmapbt(struct xfs_sb *sbp) +{ + return xfs_sb_version_hasmetadir(sbp) && sbp->sb_rblocks > 0 && + xfs_sb_version_hasrmapbt(sbp); +} + /* * end of superblock version macros */ @@ -1028,7 +1034,8 @@ enum xfs_dinode_fmt { XFS_DINODE_FMT_LOCAL, /* bulk data */ XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */ XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */ - XFS_DINODE_FMT_UUID /* added long ago, but never used */ + XFS_DINODE_FMT_UUID, /* added long ago, but never used */ + XFS_DINODE_FMT_RMAP, /* reverse mapping btree */ }; #define XFS_INODE_FORMAT_STR \ diff --git a/fs/xfs/libxfs/xfs_imeta.c b/fs/xfs/libxfs/xfs_imeta.c index 91870c6611ba..d3dac49467d9 100644 --- a/fs/xfs/libxfs/xfs_imeta.c +++ b/fs/xfs/libxfs/xfs_imeta.c @@ -57,12 +57,14 @@ /* Static metadata inode paths */ static const char *rtbitmap_path[] = {"realtime", "0.bitmap"}; static const char *rtsummary_path[] = {"realtime", "0.summary"}; +static const char *rtrmapbt_path[] = {"realtime", "0.rmap"}; static const char *usrquota_path[] = {"quota", "user"}; static const char *grpquota_path[] = {"quota", "group"}; static const char *prjquota_path[] = {"quota", "project"}; XFS_IMETA_DEFINE_PATH(XFS_IMETA_RTBITMAP, rtbitmap_path); XFS_IMETA_DEFINE_PATH(XFS_IMETA_RTSUMMARY, rtsummary_path); +XFS_IMETA_DEFINE_PATH(XFS_IMETA_RTRMAPBT, rtrmapbt_path); XFS_IMETA_DEFINE_PATH(XFS_IMETA_USRQUOTA, usrquota_path); XFS_IMETA_DEFINE_PATH(XFS_IMETA_GRPQUOTA, grpquota_path); XFS_IMETA_DEFINE_PATH(XFS_IMETA_PRJQUOTA, prjquota_path); diff --git a/fs/xfs/libxfs/xfs_imeta.h b/fs/xfs/libxfs/xfs_imeta.h index 8d3d1aa2b1ab..b37e265629c4 100644 --- a/fs/xfs/libxfs/xfs_imeta.h +++ b/fs/xfs/libxfs/xfs_imeta.h @@ -33,6 +33,7 @@ struct xfs_imeta_end { /* Lookup keys for static metadata inodes. */ extern const struct xfs_imeta_path XFS_IMETA_RTBITMAP; extern const struct xfs_imeta_path XFS_IMETA_RTSUMMARY; +extern const struct xfs_imeta_path XFS_IMETA_RTRMAPBT; extern const struct xfs_imeta_path XFS_IMETA_USRQUOTA; extern const struct xfs_imeta_path XFS_IMETA_GRPQUOTA; extern const struct xfs_imeta_path XFS_IMETA_PRJQUOTA; diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index 077d039dfa88..6719dd8ba1ab 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -388,6 +388,12 @@ xfs_dinode_verify_fork( return __this_address; } break; + case XFS_DINODE_FMT_RMAP: + if (!xfs_sb_version_hasrtrmapbt(&mp->m_sb)) + return __this_address; + if (!(dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_METADATA))) + return __this_address; + break; default: return __this_address; } diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index 8672aa729e16..0f8d45b2197f 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -75,6 +75,11 @@ xfs_iformat_fork( case XFS_DINODE_FMT_BTREE: error = xfs_iformat_btree(ip, dip, XFS_DATA_FORK); break; + case XFS_DINODE_FMT_RMAP: + if (!xfs_sb_version_hasrtrmapbt(&ip->i_mount->m_sb)) + return -EFSCORRUPTED; + /* to be implemented later */ + break; default: xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, dip, sizeof(*dip), __this_address); @@ -546,6 +551,10 @@ xfs_iflush_fork( } break; + case XFS_DINODE_FMT_RMAP: + /* to be implemented later */ + break; + default: ASSERT(0); break; diff --git a/fs/xfs/libxfs/xfs_rtrmap_btree.c b/fs/xfs/libxfs/xfs_rtrmap_btree.c index 84b1d234a2f6..5c13248d7970 100644 --- a/fs/xfs/libxfs/xfs_rtrmap_btree.c +++ b/fs/xfs/libxfs/xfs_rtrmap_btree.c @@ -318,6 +318,7 @@ xfs_rtrmapbt_verify( struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); xfs_failaddr_t fa; + xfs_ino_t ino = XFS_RMAP_OWN_UNKNOWN; int level; if (block->bb_magic != cpu_to_be32(XFS_RTRMAP_CRC_MAGIC)) @@ -325,7 +326,9 @@ xfs_rtrmapbt_verify( if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) return __this_address; - fa = xfs_btree_lblock_v5hdr_verify(bp, XFS_RMAP_OWN_UNKNOWN); + if (mp->m_rrmapip) + ino = mp->m_rrmapip->i_ino; + fa = xfs_btree_lblock_v5hdr_verify(bp, ino); if (fa) return fa; level = be16_to_cpu(block->bb_level); @@ -507,6 +510,7 @@ xfs_rtrmapbt_commit_staged_btree( int flags = XFS_ILOG_CORE | XFS_ILOG_DBROOT; ASSERT(cur->bc_flags & XFS_BTREE_STAGING); + ASSERT(ifake->if_format == XFS_DINODE_FMT_RMAP); ifp = XFS_IFORK_PTR(cur->bc_ino.ip, XFS_DATA_FORK); xfs_ifork_reset(ifp); diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index ee56847ebb28..edc579029dc2 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2892,7 +2892,14 @@ xfs_iflush_int( __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip); goto corrupt_out; } - if (S_ISREG(VFS_I(ip)->i_mode)) { + if (ip->i_d.di_format == XFS_DINODE_FMT_RMAP) { + if (mp->m_rrmapip && mp->m_rrmapip->i_ino != ip->i_ino) { + xfs_alert_tag(mp, XFS_PTAG_IFLUSH, + "%s: Bad rt rmapbt inode %Lu, ptr "PTR_FMT, + __func__, ip->i_ino, ip); + goto corrupt_out; + } + } else if (S_ISREG(VFS_I(ip)->i_mode)) { if (XFS_TEST_ERROR( (ip->i_d.di_format != XFS_DINODE_FMT_EXTENTS) && (ip->i_d.di_format != XFS_DINODE_FMT_BTREE), diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index a5ed38c43012..3eed7cb24598 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -47,6 +47,7 @@ xfs_inode_item_data_fork_size( } break; case XFS_DINODE_FMT_BTREE: + case XFS_DINODE_FMT_RMAP: if ((iip->ili_fields & XFS_ILOG_DBROOT) && ip->i_df.if_broot_bytes > 0) { *nbytes += ip->i_df.if_broot_bytes; @@ -167,6 +168,7 @@ xfs_inode_item_format_data_fork( } break; case XFS_DINODE_FMT_BTREE: + case XFS_DINODE_FMT_RMAP: iip->ili_fields &= ~(XFS_ILOG_DDATA | XFS_ILOG_DEXT | XFS_ILOG_DEV); diff --git a/fs/xfs/xfs_inode_item_recover.c b/fs/xfs/xfs_inode_item_recover.c index 2bdba612aa71..033956bfe607 100644 --- a/fs/xfs/xfs_inode_item_recover.c +++ b/fs/xfs/xfs_inode_item_recover.c @@ -236,6 +236,7 @@ xlog_recover_inode_commit_pass2( if (unlikely(S_ISREG(ldip->di_mode))) { if ((ldip->di_format != XFS_DINODE_FMT_EXTENTS) && + (ldip->di_format != XFS_DINODE_FMT_RMAP) && (ldip->di_format != XFS_DINODE_FMT_BTREE)) { XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)", XFS_ERRLEVEL_LOW, mp, ldip, diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 988a8f903c46..ea356c08505a 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -119,6 +119,7 @@ typedef struct xfs_mount { uint8_t *m_rsum_cache; struct xfs_inode *m_rbmip; /* pointer to bitmap inode */ struct xfs_inode *m_rsumip; /* pointer to summary inode */ + struct xfs_inode *m_rrmapip; /* pointer to rmap inode */ struct xfs_inode *m_rootip; /* pointer to root directory */ struct xfs_inode *m_metadirip; /* metadata inode directory */ struct xfs_quotainfo *m_quotainfo; /* disk quota information */ diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 846e3c2d56b3..976a7b017c82 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -21,6 +21,7 @@ #include "xfs_health.h" #include "xfs_da_format.h" #include "xfs_imeta.h" +#include "xfs_error.h" /* * Read and return the summary information for a given extent size, @@ -1226,12 +1227,13 @@ xfs_rtmount_init( * Get the bitmap and summary inodes and the summary cache into the mount * structure at mount time. */ -int /* error */ +int xfs_rtmount_inodes( - xfs_mount_t *mp) /* file system mount structure */ + struct xfs_mount *mp) { - int error; /* error return value */ - xfs_sb_t *sbp; + struct xfs_sb *sbp; + xfs_ino_t ino; + int error; sbp = &mp->m_sb; error = xfs_imeta_iget(mp, mp->m_sb.sb_rbmino, XFS_DIR3_FT_REG_FILE, @@ -1246,13 +1248,38 @@ xfs_rtmount_inodes( &mp->m_rsumip); if (xfs_metadata_is_sick(error)) xfs_rt_mark_sick(mp, XFS_SICK_RT_SUMMARY); - if (error) { - xfs_imeta_irele(mp->m_rbmip); - return error; - } + if (error) + goto out_rbm; ASSERT(mp->m_rsumip != NULL); + + /* If we have rmap and a realtime device, look for the rtrmapbt. */ + if (xfs_sb_version_hasrtrmapbt(&mp->m_sb)) { + error = xfs_imeta_lookup(mp, &XFS_IMETA_RTRMAPBT, &ino); + if (error) + goto out_rsum; + + error = xfs_imeta_iget(mp, ino, XFS_DIR3_FT_REG_FILE, + &mp->m_rrmapip); + if (error) + goto out_rsum; + + if (XFS_IS_CORRUPT(mp, + mp->m_rrmapip->i_d.di_format != + XFS_DINODE_FMT_RMAP)) { + error = -EFSCORRUPTED; + goto out_rrmap; + } + } + xfs_alloc_rsum_cache(mp, sbp->sb_rbmblocks); return 0; +out_rrmap: + xfs_imeta_irele(mp->m_rrmapip); +out_rsum: + xfs_imeta_irele(mp->m_rsumip); +out_rbm: + xfs_imeta_irele(mp->m_rbmip); + return error; } void @@ -1260,6 +1287,8 @@ xfs_rtunmount_inodes( struct xfs_mount *mp) { kmem_free(mp->m_rsum_cache); + if (mp->m_rrmapip) + xfs_imeta_irele(mp->m_rrmapip); if (mp->m_rbmip) xfs_imeta_irele(mp->m_rbmip); if (mp->m_rsumip) |