From: Darrick J. Wong Date: Mon, 29 Jul 2024 23:23:01 +0000 (-0700) Subject: xfs_repair: add exchange-range to file systems X-Git-Tag: v6.10.0~23^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7fea27240484ad839f542e20a819ea5a28bdc112;p=thirdparty%2Fxfsprogs-dev.git xfs_repair: add exchange-range to file systems Enable upgrading existing filesystems to support the file exchange range feature. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8 index 4794d677..63f8ee90 100644 --- a/man/man8/xfs_admin.8 +++ b/man/man8/xfs_admin.8 @@ -156,6 +156,13 @@ data fork extent count will be 2^48 - 1, while the maximum attribute fork extent count will be 2^32 - 1. The filesystem cannot be downgraded after this feature is enabled. Once enabled, the filesystem will not be mountable by older kernels. This feature was added to Linux 5.19. +.TP 0.4i +.B exchange +Upgrade a filesystem to support atomic file content exchanges through the +XFS_IOC_EXCHANGE_RANGE ioctl, and to support online repairs of directories, +extended attributes, symbolic links, and realtime free space metadata. +The filesystem cannot be downgraded after this feature is enabled. +Once enabled, the filesystem will not be mountable by older kernels. .RE .TP .BI \-U " uuid" diff --git a/repair/globals.c b/repair/globals.c index 24f720c4..c0c45df5 100644 --- a/repair/globals.c +++ b/repair/globals.c @@ -52,6 +52,7 @@ bool features_changed; /* did we change superblock feature bits? */ bool add_inobtcount; /* add inode btree counts to AGI */ bool add_bigtime; /* add support for timestamps up to 2486 */ bool add_nrext64; +bool add_exchrange; /* add file content exchange support */ /* misc status variables */ diff --git a/repair/globals.h b/repair/globals.h index b83a8ae6..1eadfdbf 100644 --- a/repair/globals.h +++ b/repair/globals.h @@ -93,6 +93,7 @@ extern bool features_changed; /* did we change superblock feature bits? */ extern bool add_inobtcount; /* add inode btree counts to AGI */ extern bool add_bigtime; /* add support for timestamps up to 2486 */ extern bool add_nrext64; +extern bool add_exchrange; /* add file content exchange support */ /* misc status variables */ diff --git a/repair/phase2.c b/repair/phase2.c index 06374817..83f0c539 100644 --- a/repair/phase2.c +++ b/repair/phase2.c @@ -182,6 +182,34 @@ set_nrext64( return true; } +static bool +set_exchrange( + struct xfs_mount *mp, + struct xfs_sb *new_sb) +{ + if (xfs_has_exchange_range(mp)) { + printf(_("Filesystem already supports exchange-range.\n")); + exit(0); + } + + if (!xfs_has_crc(mp)) { + printf( + _("File exchange-range feature only supported on V5 filesystems.\n")); + exit(0); + } + + if (!xfs_has_reflink(mp)) { + printf( + _("File exchange-range feature cannot be added without reflink.\n")); + exit(0); + } + + printf(_("Adding file exchange-range support to filesystem.\n")); + new_sb->sb_features_ro_compat |= XFS_SB_FEAT_INCOMPAT_EXCHRANGE; + new_sb->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR; + return true; +} + struct check_state { struct xfs_sb sb; uint64_t features; @@ -290,6 +318,8 @@ upgrade_filesystem( dirty |= set_bigtime(mp, &new_sb); if (add_nrext64) dirty |= set_nrext64(mp, &new_sb); + if (add_exchrange) + dirty |= set_exchrange(mp, &new_sb); if (!dirty) return; diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 88aa7554..e325d61f 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -69,6 +69,7 @@ enum c_opt_nums { CONVERT_INOBTCOUNT, CONVERT_BIGTIME, CONVERT_NREXT64, + CONVERT_EXCHRANGE, C_MAX_OPTS, }; @@ -77,6 +78,7 @@ static char *c_opts[] = { [CONVERT_INOBTCOUNT] = "inobtcount", [CONVERT_BIGTIME] = "bigtime", [CONVERT_NREXT64] = "nrext64", + [CONVERT_EXCHRANGE] = "exchange", [C_MAX_OPTS] = NULL, }; @@ -360,6 +362,15 @@ process_args(int argc, char **argv) _("-c nrext64 only supports upgrades\n")); add_nrext64 = true; break; + case CONVERT_EXCHRANGE: + if (!val) + do_abort( + _("-c exchange requires a parameter\n")); + if (strtol(val, NULL, 0) != 1) + do_abort( + _("-c exchange only supports upgrades\n")); + add_exchrange = true; + break; default: unknown('c', val); break;