Skip to contentSkip to conversation

libxfs: disallow filesystems with reverse mapping and reflink and realtime

PATCH Superseded Darrick J. Wong 2 participants 3 messages Sep 30, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxfs: disallow filesystems with reverse mapping and reflink and realtime

From: Darrick J. Wong <[email protected]>

Neither the kernel nor the code in xfsprogs support filesystems that have (either reverse mapping btrees or reflink) enabled and a realtime volume configured. The kernel rejects such combinations and mkfs refuses to format such a config, but xfsprogs doesn't check and can do Bad Things, so port those checks before someone shreds their filesystem.

---
 libxfs/init.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)
libxfs/init.c +14 -0
index cb8967bc77d4..1a966084ffea 100644
@@ -724,6 +724,20 @@ libxfs_mount(
 		exit(1);
 	}
 
+	if (xfs_sb_version_hasreflink(sbp) && sbp->sb_rblocks) {
+		fprintf(stderr,
+	_("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"),
+				progname);
+		exit(1);
+	}
+
+	if (xfs_sb_version_hasrmapbt(sbp) && sbp->sb_rblocks) {
+		fprintf(stderr,
+	_("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"),
+				progname);
+		exit(1);
+	}
+
 	xfs_da_mount(mp);
 
 	if (xfs_sb_version_hasattr2(&mp->m_sb))
#1 lore raw
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Neither the kernel nor the code in xfsprogs support filesystems that have (either reverse mapping btrees or reflink) enabled and a realtime volume configured. The kernel rejects such combinations and mkfs refuses to format such a config, but xfsprogs doesn't check and can do Bad Things, so port those checks before someone shreds their filesystem.

seems fine in general but a couple thoughts...

libxfs/init.c libxfs_mount( · line 727

Quoted 13 lines
---
 libxfs/init.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)
libxfs/init.c +1 -0
index cb8967bc77d4..1a966084ffea 100644
@@ -724,6 +724,20 @@ libxfs_mount(
 		exit(1);
 	}
 
+	if (xfs_sb_version_hasreflink(sbp) && sbp->sb_rblocks) {

Hm, we really don't use xfs_sb_version_hasrealtime() very consistently, but it might be worth doing here?

I wish we had a feature flag to cross-ref against, a corruption in sb_rblocks will lead to an untouchable filesystem, but I guess there's nothing we can do about that.

Actually, would it help to cross-check against the rtdev arg as well? Should we do anything different if the user actually specified a realtime device on the commandline?

I mean, I suppose

libxfs/init.c libxfs_mount( · line 729

Quoted 2 lines
libxfs/init.c +2 -0
+		fprintf(stderr,
+	_("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"),

I like this optimism. ;)

Quoted 15 lines
libxfs/init.c +11 -0
+				progname);
+		exit(1);
+	}
+
+	if (xfs_sb_version_hasrmapbt(sbp) && sbp->sb_rblocks) {
+		fprintf(stderr,
+	_("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"),
+				progname);
+		exit(1);
+	}
+
 	xfs_da_mount(mp);
 
 	if (xfs_sb_version_hasattr2(&mp->m_sb))
#2 lore raw
Quoted 25 lines · Eric Sandeen
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Neither the kernel nor the code in xfsprogs support filesystems that have (either reverse mapping btrees or reflink) enabled and a realtime volume configured. The kernel rejects such combinations and mkfs refuses to format such a config, but xfsprogs doesn't check and can do Bad Things, so port those checks before someone shreds their filesystem.

seems fine in general but a couple thoughts...

Quoted 12 lines
---
 libxfs/init.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)
libxfs/init.c +0 -0
index cb8967bc77d4..1a966084ffea 100644
@@ -724,6 +724,20 @@ libxfs_mount(
 		exit(1);
 	}
 
Quoted 4 lines

libxfs/init.c libxfs_mount( · line 727

Quoted 1 line
libxfs/init.c +1 -0
+	if (xfs_sb_version_hasreflink(sbp) && sbp->sb_rblocks) {

Hm, we really don't use xfs_sb_version_hasrealtime() very consistently, but it might be worth doing here?

Nah, I'll move it to rtmount_init.

Quoted 3 lines

I wish we had a feature flag to cross-ref against, a corruption in sb_rblocks will lead to an untouchable filesystem, but I guess there's nothing we can do about that.

I guess xfs_repair could add a -E killrt=1 flag that would read the sb, zero out sb_rblocks, and pass that to libxfs_mount.

Quoted 3 lines

Actually, would it help to cross-check against the rtdev arg as well? Should we do anything different if the user actually specified a realtime device on the commandline?

I doubt it? I mean, the fs allege it has an rt volume and some unsupported feature; it doesn't matter if the user did or didn't pass an rtdev.

Quoted 1 line

I mean, I suppose

you suppose...?

Quoted 5 lines

libxfs/init.c libxfs_mount( · line 729

Quoted 3 lines
libxfs/init.c +2 -0
+		fprintf(stderr,
+	_("%s: Reflink not compatible with realtime device. Please try a newer xfsprogs.\n"),

I like this optimism. ;)

Optimism?

/me now has an xfsprogs that /does/ support rt rmap and reflink, though at current patch review rates it won't hit the list until 2024, and that's assuming I can keep ahead of all the bitrot in rtrmap...

--D

Quoted 17 lines
Quoted 17 lines
libxfs/init.c +11 -0
+				progname);
+		exit(1);
+	}
+
+	if (xfs_sb_version_hasrmapbt(sbp) && sbp->sb_rblocks) {
+		fprintf(stderr,
+	_("%s: Reverse mapping btree not compatible with realtime device. Please try a newer xfsprogs.\n"),
+				progname);
+		exit(1);
+	}
+
 	xfs_da_mount(mp);
 
 	if (xfs_sb_version_hasattr2(&mp->m_sb))