@@ -170,6 +170,12 @@ .SH OPTIONS
This upgrade can fail if any AG has less than 1% free space remaining.
The filesystem cannot be downgraded after this feature is enabled.
This feature was added to Linux 3.16.
+.TP 0.4i
+.B reflink
+Enable sharing of file data blocks.
+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.
.RE
.TP
.BI \-U " uuid"
@@ -54,6 +54,7 @@ bool add_bigtime; /* add support for timestamps up to 2486 */
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 */
/* misc status variables */
@@ -95,6 +95,7 @@ extern bool add_bigtime; /* add support for timestamps up to 2486 */
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 */
/* misc status variables */
@@ -200,7 +200,7 @@ set_exchrange(
exit(0);
}
- if (!xfs_has_reflink(mp)) {
+ if (!xfs_has_reflink(mp) && !add_reflink) {
printf(
_("File exchange-range feature cannot be added without reflink.\n"));
exit(0);
@@ -234,6 +234,33 @@ set_finobt(
return true;
}
+static bool
+set_reflink(
+ struct xfs_mount *mp,
+ struct xfs_sb *new_sb)
+{
+ if (xfs_has_reflink(mp)) {
+ printf(_("Filesystem already supports reflink.\n"));
+ exit(0);
+ }
+
+ if (!xfs_has_crc(mp)) {
+ printf(
+ _("Reflink feature only supported on V5 filesystems.\n"));
+ exit(0);
+ }
+
+ if (xfs_has_realtime(mp)) {
+ printf(_("Reflink feature not supported with realtime.\n"));
+ exit(0);
+ }
+
+ printf(_("Adding reflink support to filesystem.\n"));
+ new_sb->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK;
+ new_sb->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR;
+ return true;
+}
+
struct check_state {
struct xfs_sb sb;
uint64_t features;
@@ -402,6 +429,8 @@ need_check_fs_free_space(
{
if (xfs_has_finobt(mp) && !(old->features & XFS_FEAT_FINOBT))
return true;
+ if (xfs_has_reflink(mp) && !(old->features & XFS_FEAT_REFLINK))
+ return true;
return false;
}
@@ -481,6 +510,8 @@ upgrade_filesystem(
dirty |= set_exchrange(mp, &new_sb);
if (add_finobt)
dirty |= set_finobt(mp, &new_sb);
+ if (add_reflink)
+ dirty |= set_reflink(mp, &new_sb);
if (!dirty)
return;
@@ -68,7 +68,7 @@ bool
rmap_needs_work(
struct xfs_mount *mp)
{
- return xfs_has_reflink(mp) ||
+ return xfs_has_reflink(mp) || add_reflink ||
xfs_has_rmapbt(mp);
}
@@ -1800,7 +1800,7 @@ check_refcounts(
struct xfs_perag *pag = NULL;
int error;
- if (!xfs_has_reflink(mp))
+ if (!xfs_has_reflink(mp) || add_reflink)
return;
if (refcbt_suspect) {
if (no_modify && agno == 0)
@@ -1859,7 +1859,7 @@ check_rtrefcounts(
struct xfs_inode *ip = NULL;
int error;
- if (!xfs_has_reflink(mp))
+ if (!xfs_has_reflink(mp) || add_reflink)
return;
if (refcbt_suspect) {
if (no_modify && rgno == 0)
@@ -72,6 +72,7 @@ enum c_opt_nums {
CONVERT_NREXT64,
CONVERT_EXCHRANGE,
CONVERT_FINOBT,
+ CONVERT_REFLINK,
C_MAX_OPTS,
};
@@ -82,6 +83,7 @@ static char *c_opts[] = {
[CONVERT_NREXT64] = "nrext64",
[CONVERT_EXCHRANGE] = "exchange",
[CONVERT_FINOBT] = "finobt",
+ [CONVERT_REFLINK] = "reflink",
[C_MAX_OPTS] = NULL,
};
@@ -383,6 +385,15 @@ process_args(int argc, char **argv)
_("-c finobt only supports upgrades\n"));
add_finobt = true;
break;
+ case CONVERT_REFLINK:
+ if (!val)
+ do_abort(
+ _("-c reflink requires a parameter\n"));
+ if (strtol(val, NULL, 0) != 1)
+ do_abort(
+ _("-c reflink only supports upgrades\n"));
+ add_reflink = true;
+ break;
default:
unknown('c', val);
break;