diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2020-10-25 17:15:42 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2020-10-26 18:32:22 -0700 |
commit | b5784c56dcbbebf9de7a058a052d6de1f316d0d5 (patch) | |
tree | 02efc9899a08ff76cda7c071ec80489195ba8062 | |
parent | a46b8f83632df9026f1545f0cadafddbfe813da6 (diff) |
xfs: create a log incompat flag for atomic extent swapping
Create a log incompat flag so that we only attempt to process swap
extent log items if the filesystem supports it.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 8 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_fs.h | 1 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_sb.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_super.c | 12 |
4 files changed, 23 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 1953a3ca3a0a..7ad26df6e304 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -483,6 +483,7 @@ xfs_sb_has_incompat_feature( return (sbp->sb_features_incompat & feature) != 0; } +#define XFS_SB_FEAT_INCOMPAT_LOG_ATOMIC_SWAP (1 << 0) #define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL static inline bool @@ -584,6 +585,13 @@ static inline bool xfs_sb_version_hasinobtcounts(struct xfs_sb *sbp) (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT); } +static inline bool xfs_sb_version_hasatomicswap(struct xfs_sb *sbp) +{ + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && + (sbp->sb_features_log_incompat & + XFS_SB_FEAT_INCOMPAT_LOG_ATOMIC_SWAP); +} + /* * end of superblock version macros */ diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 0b50fde148b2..d403c3476789 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -250,6 +250,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_RMAPBT (1 << 19) /* reverse mapping btree */ #define XFS_FSOP_GEOM_FLAGS_REFLINK (1 << 20) /* files can share blocks */ #define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21) /* 64-bit nsec timestamps */ +#define XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP (1 << 22) /* atomic swapext */ /* * Minimum and maximum sizes need for growth checks. diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 938a0978f0ad..b9473717d9a0 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -1168,6 +1168,8 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_REFLINK; if (xfs_sb_version_hasbigtime(sbp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_BIGTIME; + if (xfs_sb_version_hasatomicswap(sbp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP; if (xfs_sb_version_hassector(sbp)) geo->logsectsize = sbp->sb_logsectsize; else diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index e5d8f9bc2d87..df862854beb8 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1708,6 +1708,18 @@ xfs_fc_fill_super( xfs_warn(mp, "EXPERIMENTAL inode btree counters feature in use. Use at your own risk!"); + if (xfs_sb_version_hasatomicswap(&mp->m_sb)) { + if (xfs_sb_version_hasrealtime(&mp->m_sb)) { + xfs_alert(mp, + "Atomic file range swap cannot realtime files!"); + error = -EINVAL; + goto out_filestream_unmount; + } + + xfs_warn(mp, + "EXPERIMENTAL atomic file range swap feature in use. Use at your own risk!"); + } + error = xfs_mountfs(mp); if (error) goto out_filestream_unmount; |