@@ -176,6 +176,14 @@ .SH OPTIONS
This upgrade can fail if any AG has less than 2% free space remaining.
The filesystem cannot be downgraded after this feature is enabled.
This feature was added to Linux 4.9.
+.TP 0.4i
+.B rmapbt
+Store an index of the owners of on-disk blocks.
+This enables much stronger cross-referencing of various metadata structures
+and online repairs to space usage metadata.
+The filesystem cannot be downgraded after this feature is enabled.
+This upgrade can fail if any AG has less than 5% free space remaining.
+This feature was added to Linux 4.8.
.RE
.TP
.BI \-U " uuid"
@@ -55,6 +55,7 @@ bool add_nrext64;
bool add_exchrange; /* add file content exchange support */
bool add_finobt; /* add free inode btrees */
bool add_reflink; /* add reference count btrees */
+bool add_rmapbt; /* add reverse mapping btrees */
/* misc status variables */
@@ -96,6 +96,7 @@ extern bool add_nrext64;
extern bool add_exchrange; /* add file content exchange support */
extern bool add_finobt; /* add free inode btrees */
extern bool add_reflink; /* add reference count btrees */
+extern bool add_rmapbt; /* add reverse mapping btrees */
/* misc status variables */
@@ -261,6 +261,40 @@ set_reflink(
return true;
}
+static bool
+set_rmapbt(
+ struct xfs_mount *mp,
+ struct xfs_sb *new_sb)
+{
+ if (xfs_has_rmapbt(mp)) {
+ printf(_("Filesystem already supports reverse mapping btrees.\n"));
+ exit(0);
+ }
+
+ if (!xfs_has_crc(mp)) {
+ printf(
+ _("Reverse mapping btree feature only supported on V5 filesystems.\n"));
+ exit(0);
+ }
+
+ if (xfs_has_realtime(mp)) {
+ printf(
+ _("Reverse mapping btree feature not supported with realtime.\n"));
+ exit(0);
+ }
+
+ if (xfs_has_reflink(mp) && !add_reflink) {
+ printf(
+ _("Reverse mapping btrees cannot be added when reflink is enabled.\n"));
+ exit(0);
+ }
+
+ printf(_("Adding reverse mapping btrees to filesystem.\n"));
+ new_sb->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_RMAPBT;
+ new_sb->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR;
+ return true;
+}
+
struct check_state {
struct xfs_sb sb;
uint64_t features;
@@ -431,6 +465,8 @@ need_check_fs_free_space(
return true;
if (xfs_has_reflink(mp) && !(old->features & XFS_FEAT_REFLINK))
return true;
+ if (xfs_has_rmapbt(mp) && !(old->features & XFS_FEAT_RMAPBT))
+ return true;
return false;
}
@@ -512,6 +548,8 @@ upgrade_filesystem(
dirty |= set_finobt(mp, &new_sb);
if (add_reflink)
dirty |= set_reflink(mp, &new_sb);
+ if (add_rmapbt)
+ dirty |= set_rmapbt(mp, &new_sb);
if (!dirty)
return;
@@ -69,7 +69,7 @@ rmap_needs_work(
struct xfs_mount *mp)
{
return xfs_has_reflink(mp) || add_reflink ||
- xfs_has_rmapbt(mp);
+ xfs_has_rmapbt(mp) || add_rmapbt;
}
static inline bool rmaps_has_observations(const struct xfs_ag_rmap *ag_rmap)
@@ -1339,7 +1339,7 @@ rmaps_verify_btree(
struct xfs_perag *pag = NULL;
int error;
- if (!xfs_has_rmapbt(mp))
+ if (!xfs_has_rmapbt(mp) || add_rmapbt)
return;
if (rmapbt_suspect) {
if (no_modify && agno == 0)
@@ -1398,7 +1398,7 @@ rtrmaps_verify_btree(
struct xfs_inode *ip = NULL;
int error;
- if (!xfs_has_rmapbt(mp))
+ if (!xfs_has_rmapbt(mp) || add_rmapbt)
return;
if (rmapbt_suspect) {
if (no_modify && rgno == 0)
@@ -73,6 +73,7 @@ enum c_opt_nums {
CONVERT_EXCHRANGE,
CONVERT_FINOBT,
CONVERT_REFLINK,
+ CONVERT_RMAPBT,
C_MAX_OPTS,
};
@@ -84,6 +85,7 @@ static char *c_opts[] = {
[CONVERT_EXCHRANGE] = "exchange",
[CONVERT_FINOBT] = "finobt",
[CONVERT_REFLINK] = "reflink",
+ [CONVERT_RMAPBT] = "rmapbt",
[C_MAX_OPTS] = NULL,
};
@@ -394,6 +396,15 @@ process_args(int argc, char **argv)
_("-c reflink only supports upgrades\n"));
add_reflink = true;
break;
+ case CONVERT_RMAPBT:
+ if (!val)
+ do_abort(
+ _("-c rmapbt requires a parameter\n"));
+ if (strtol(val, NULL, 0) != 1)
+ do_abort(
+ _("-c rmapbt only supports upgrades\n"));
+ add_rmapbt = true;
+ break;
default:
unknown('c', val);
break;