diff options
author | Darrick J. Wong <djwong@kernel.org> | 2022-07-14 11:06:43 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2022-10-14 14:16:50 -0700 |
commit | bd644ca83b4f070b5d3837fbdbb9eea850e52917 (patch) | |
tree | 540455bb5d3aff2c789bcab614e0db0dc6a419cb | |
parent | 53e4f929abcec6f199aa67539c4aa1799320b657 (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, and a geometry flag to
advertise support if it's present.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 1 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_fs.h | 1 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_sb.c | 3 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_swapext.h | 24 |
4 files changed, 29 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index dd3f7a0f6999..d902cd3451bc 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -391,6 +391,7 @@ xfs_sb_has_incompat_feature( } #define XFS_SB_FEAT_INCOMPAT_LOG_XATTRS (1 << 0) /* Delayed Attributes */ +#define XFS_SB_FEAT_INCOMPAT_LOG_SWAPEXT (1 << 31) /* file extent swap */ #define XFS_SB_FEAT_INCOMPAT_LOG_ALL \ (XFS_SB_FEAT_INCOMPAT_LOG_XATTRS) #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h index 210c17f5a16c..8418068c6e38 100644 --- a/fs/xfs/libxfs/xfs_fs.h +++ b/fs/xfs/libxfs/xfs_fs.h @@ -239,6 +239,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21) /* 64-bit nsec timestamps */ #define XFS_FSOP_GEOM_FLAGS_INOBTCNT (1 << 22) /* inobt btree counter */ #define XFS_FSOP_GEOM_FLAGS_NREXT64 (1 << 23) /* large extent counters */ +#define XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP (1 << 31) /* atomic file extent swap */ /* * 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 5e80a6aff19c..c86999debe58 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -25,6 +25,7 @@ #include "xfs_da_format.h" #include "xfs_health.h" #include "xfs_ag.h" +#include "xfs_swapext.h" /* * Physical superblock buffer manipulations. Shared with libxfs in userspace. @@ -1195,6 +1196,8 @@ xfs_fs_geometry( } if (xfs_has_large_extent_counts(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_NREXT64; + if (xfs_swapext_supported(mp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP; geo->rtsectsize = sbp->sb_blocksize; geo->dirblocksize = xfs_dir2_dirblock_bytes(sbp); diff --git a/fs/xfs/libxfs/xfs_swapext.h b/fs/xfs/libxfs/xfs_swapext.h new file mode 100644 index 000000000000..316323339d76 --- /dev/null +++ b/fs/xfs/libxfs/xfs_swapext.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022 Oracle. All Rights Reserved. + * Author: Darrick J. Wong <djwong@kernel.org> + */ +#ifndef __XFS_SWAPEXT_H_ +#define __XFS_SWAPEXT_H_ 1 + +/* + * Decide if this filesystem supports using log items to swap file extents and + * restart the operation if the system fails before the operation completes. + * + * This can be done to individual file extents by using the block mapping log + * intent items introduced with reflink and rmap; or to entire file ranges + * using swapext log intent items to track the overall progress across multiple + * extent mappings. Realtime is not supported yet. + */ +static inline bool xfs_swapext_supported(struct xfs_mount *mp) +{ + return (xfs_has_reflink(mp) || xfs_has_rmapbt(mp)) && + !xfs_has_realtime(mp); +} + +#endif /* __XFS_SWAPEXT_H_ */ |