Skip to contentSkip to conversation

RFE: Do not check NEEDSREPAIR if ro,norecovery mount.

PATCH Applied Lukas Herbolt 5 participants 8 messages Feb 3, 2025 – Feb 11, 2025 XFS filesystem

lore
Share & tools
lore
#0 lore raw

cover RFE: Do not check NEEDSREPAIR if ro,norecovery mount.

Hi,
I disccussed this shortly with Eric Sandeen. I have came across corruption where xfs_repair fails and the only way how to get at least some of the data is to use manually clear out the NEEDSREPAIR flag. I do not think there is needs of checking if we are about to mount the FS with norecovery,ro.

Lukas Herbolt (1):
xfs: do not check NEEDSREPAIR if ro,norecovery mount.

 fs/xfs/xfs_super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/1 xfs: do not check NEEDSREPAIR if ro,norecovery mount.

If there is corrutpion on the filesystem andxfs_repair fails to repair it. The last resort of getting the data is to use norecovery,ro mount. But if the NEEDSREPAIR is set the filesystem cannot be mounted. The flag must be cleared out manually using xfs_db, to get access to what left over of the corrupted fs.

---
 fs/xfs/xfs_super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/xfs/xfs_super.c +6 -2
index 394fdf3bb535..c2566dcc4f88 100644
@@ -1635,8 +1635,12 @@ xfs_fs_fill_super(
 #endif
 	}
 
-	/* Filesystem claims it needs repair, so refuse the mount. */
-	if (xfs_has_needsrepair(mp)) {
+	/*
+	 * Filesystem claims it needs repair, so refuse the mount unless
+	 * norecovery is also specified, in which case the filesystem can
+	 * be mounted with no risk of further damage.
+	 */
+	if (xfs_has_needsrepair(mp) && !xfs_has_norecovery(mp)) {
 		xfs_warn(mp, "Filesystem needs repair.  Please run xfs_repair.");
 		error = -EFSCORRUPTED;
 		goto out_free_sb;
Signature · 1 line
2.48.1
#2 lore raw

Re: [PATCH 1/1] xfs: do not check NEEDSREPAIR if ro,norecovery mount.

Quoted 18 lines · Lukas Herbolt

If there is corrutpion on the filesystem andxfs_repair fails to repair it. The last resort of getting the data is to use norecovery,ro mount. But if the NEEDSREPAIR is set the filesystem cannot be mounted. The flag must be cleared out manually using xfs_db, to get access to what left over of the corrupted fs.

---
 fs/xfs/xfs_super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/xfs/xfs_super.c +0 -0
index 394fdf3bb535..c2566dcc4f88 100644
@@ -1635,8 +1635,12 @@ xfs_fs_fill_super(
 #endif

fs/xfs/xfs_super.c xfs_fs_fill_super( · line 1643

Quoted 10 lines
fs/xfs/xfs_super.c +6 -2
 	}
 
-	/* Filesystem claims it needs repair, so refuse the mount. */
-	if (xfs_has_needsrepair(mp)) {
+	/*
+	 * Filesystem claims it needs repair, so refuse the mount unless
+	 * norecovery is also specified, in which case the filesystem can
+	 * be mounted with no risk of further damage.
+	 */
+	if (xfs_has_needsrepair(mp) && !xfs_has_norecovery(mp)) {

I think a better way to handle badly damaged filesystems is for us to provide a means to extract directory trees in userspace, rather than making the user take the risk of mounting a known-bad filesystem. I've a draft of an xfs_db subcommand for doing exactly that and will share for xfsprogs 6.14.

--D

Quoted 7 lines
fs/xfs/xfs_super.c +0 -0
 		xfs_warn(mp, "Filesystem needs repair.  Please run xfs_repair.");
 		error = -EFSCORRUPTED;
 		goto out_free_sb;
Signature · 1 line
2.48.1
#3 lore raw

Re: [PATCH 1/1] xfs: do not check NEEDSREPAIR if ro,norecovery mount.

Quoted 21 lines · Darrick J. Wong
Quoted 20 lines · Lukas Herbolt

If there is corrutpion on the filesystem andxfs_repair fails to repair it. The last resort of getting the data is to use norecovery,ro mount. But if the NEEDSREPAIR is set the filesystem cannot be mounted. The flag must be cleared out manually using xfs_db, to get access to what left over of the corrupted fs.

---
 fs/xfs/xfs_super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/xfs/xfs_super.c +0 -0
index 394fdf3bb535..c2566dcc4f88 100644
@@ -1635,8 +1635,12 @@ xfs_fs_fill_super(
 #endif
 	}
 
Quoted 14 lines

fs/xfs/xfs_super.c xfs_fs_fill_super( · line 1643

Quoted 8 lines
fs/xfs/xfs_super.c +6 -2
-	/* Filesystem claims it needs repair, so refuse the mount. */
-	if (xfs_has_needsrepair(mp)) {
+	/*
+	 * Filesystem claims it needs repair, so refuse the mount unless
+	 * norecovery is also specified, in which case the filesystem can
+	 * be mounted with no risk of further damage.
+	 */
+	if (xfs_has_needsrepair(mp) && !xfs_has_norecovery(mp)) {

I think a better way to handle badly damaged filesystems is for us to provide a means to extract directory trees in userspace, rather than making the user take the risk of mounting a known-bad filesystem. I've a draft of an xfs_db subcommand for doing exactly that and will share for xfsprogs 6.14.

I think whether a userspace extractor is better or not depends on the usecase. I suppose there's some truth that a NEEDSREPAIR filesystem is "known bad" but we already suffer the risk of "unknown bad" filesystems today. (Or for that matter, the fact that we allow "norecovery" today, which also guarantees a mount of an inconsistent filesystem.)

"Something is wrong with this filesystem, let's mount it readonly and copy off the data" is a pretty time-tested approach, I think, hampered only by the fairly recent addition of NEEDSREPAIR.

a userspace scrape-the-device tool may well be useful for some, but I don't think that vs. this kernelspace option needs to be an either/or decision.

Thanks,

-Eric

Quoted 10 lines

--D

Quoted 7 lines
fs/xfs/xfs_super.c +0 -0
 		xfs_warn(mp, "Filesystem needs repair.  Please run xfs_repair.");
 		error = -EFSCORRUPTED;
 		goto out_free_sb;
Signature · 1 line
2.48.1
#4 lore raw

Re: [PATCH 1/1] xfs: do not check NEEDSREPAIR if ro,norecovery mount.

Quoted 43 lines · Eric Sandeen
Quoted 21 lines · Darrick J. Wong
Quoted 20 lines · Lukas Herbolt

If there is corrutpion on the filesystem andxfs_repair fails to repair it. The last resort of getting the data is to use norecovery,ro mount. But if the NEEDSREPAIR is set the filesystem cannot be mounted. The flag must be cleared out manually using xfs_db, to get access to what left over of the corrupted fs.

---
 fs/xfs/xfs_super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/xfs/xfs_super.c +0 -0
index 394fdf3bb535..c2566dcc4f88 100644
@@ -1635,8 +1635,12 @@ xfs_fs_fill_super(
 #endif
 	}
 
Quoted 14 lines

fs/xfs/xfs_super.c xfs_fs_fill_super( · line 1643

Quoted 8 lines
fs/xfs/xfs_super.c +6 -2
-	/* Filesystem claims it needs repair, so refuse the mount. */
-	if (xfs_has_needsrepair(mp)) {
+	/*
+	 * Filesystem claims it needs repair, so refuse the mount unless
+	 * norecovery is also specified, in which case the filesystem can
+	 * be mounted with no risk of further damage.
+	 */
+	if (xfs_has_needsrepair(mp) && !xfs_has_norecovery(mp)) {

I think a better way to handle badly damaged filesystems is for us to provide a means to extract directory trees in userspace, rather than making the user take the risk of mounting a known-bad filesystem. I've a draft of an xfs_db subcommand for doing exactly that and will share for xfsprogs 6.14.

I think whether a userspace extractor is better or not depends on the usecase. I suppose there's some truth that a NEEDSREPAIR filesystem is "known bad" but we already suffer the risk of "unknown bad" filesystems today. (Or for that matter, the fact that we allow "norecovery" today, which also guarantees a mount of an inconsistent filesystem.)

Quoted 7 lines

"Something is wrong with this filesystem, let's mount it readonly and copy off the data" is a pretty time-tested approach, I think, hampered only by the fairly recent addition of NEEDSREPAIR.

a userspace scrape-the-device tool may well be useful for some, but I don't think that vs. this kernelspace option needs to be an either/or decision.

Fair enough; it's not like we have a tool today that can extract directory trees from an unmountable filesystem. Do you want to rvb this one, then?

--D

Quoted 16 lines

Thanks,

-Eric

Quoted 10 lines

--D

Quoted 7 lines
fs/xfs/xfs_super.c +0 -0
 		xfs_warn(mp, "Filesystem needs repair.  Please run xfs_repair.");
 		error = -EFSCORRUPTED;
 		goto out_free_sb;
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#5 lore raw

Re: [PATCH 1/1] xfs: do not check NEEDSREPAIR if ro,norecovery mount.

In reply to Lukas Herbolt
Quoted 21 lines · Lukas Herbolt

If there is corrutpion on the filesystem andxfs_repair fails to repair it. The last resort of getting the data is to use norecovery,ro mount. But if the NEEDSREPAIR is set the filesystem cannot be mounted. The flag must be cleared out manually using xfs_db, to get access to what left over of the corrupted fs.

---
 fs/xfs/xfs_super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/xfs/xfs_super.c +0 -1
index 394fdf3bb535..c2566dcc4f88 100644
@@ -1635,8 +1635,12 @@ xfs_fs_fill_super(
 #endif
 	}
 
-	/* Filesystem claims it needs repair, so refuse the mount. */

fs/xfs/xfs_super.c xfs_fs_fill_super( · line 1646

Quoted 10 lines
fs/xfs/xfs_super.c +6 -1
-	if (xfs_has_needsrepair(mp)) {
+	/*
+	 * Filesystem claims it needs repair, so refuse the mount unless
+	 * norecovery is also specified, in which case the filesystem can
+	 * be mounted with no risk of further damage.
+	 */
+	if (xfs_has_needsrepair(mp) && !xfs_has_norecovery(mp)) {
 		xfs_warn(mp, "Filesystem needs repair.  Please run xfs_repair.");
 		error = -EFSCORRUPTED;
 		goto out_free_sb;

Look fine. I've had to hack around this with xfs_db when testing (broken) xfs_repair mods a couple of times myself...

Signature · 2 lines
Dave Chinner
[email protected]
Reviewed-by on v1 1/1
#6 lore raw

Re: [PATCH 1/1] xfs: do not check NEEDSREPAIR if ro,norecovery mount.

In reply to Lukas Herbolt
Quoted 21 lines · Lukas Herbolt

If there is corrutpion on the filesystem andxfs_repair fails to repair it. The last resort of getting the data is to use norecovery,ro mount. But if the NEEDSREPAIR is set the filesystem cannot be mounted. The flag must be cleared out manually using xfs_db, to get access to what left over of the corrupted fs.

---
 fs/xfs/xfs_super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/xfs/xfs_super.c +0 -1
index 394fdf3bb535..c2566dcc4f88 100644
@@ -1635,8 +1635,12 @@ xfs_fs_fill_super(
 #endif
 	}
 
-	/* Filesystem claims it needs repair, so refuse the mount. */

fs/xfs/xfs_super.c xfs_fs_fill_super( · line 1646

Quoted 10 lines
fs/xfs/xfs_super.c +6 -1
-	if (xfs_has_needsrepair(mp)) {
+	/*
+	 * Filesystem claims it needs repair, so refuse the mount unless
+	 * norecovery is also specified, in which case the filesystem can
+	 * be mounted with no risk of further damage.
+	 */
+	if (xfs_has_needsrepair(mp) && !xfs_has_norecovery(mp)) {
 		xfs_warn(mp, "Filesystem needs repair.  Please run xfs_repair.");
 		error = -EFSCORRUPTED;
 		goto out_free_sb;

thanks Lukas, this looks good to me as well. And with ro,norecovery there should (tm) be no writes whatever to the filesystem so risk of introducing further corruption from the mount should be zero.

maintainer Applied
#7 lore raw

Re: [PATCH 1/1] xfs: do not check NEEDSREPAIR if ro,norecovery mount.

In reply to Lukas Herbolt
Quoted 8 lines · Lukas Herbolt

If there is corrutpion on the filesystem andxfs_repair fails to repair it. The last resort of getting the data is to use norecovery,ro mount. But if the NEEDSREPAIR is set the filesystem cannot be mounted. The flag must be cleared out manually using xfs_db, to get access to what left over of the corrupted fs.

[...]

Applied to for-next, thanks!

[1/1] xfs: do not check NEEDSREPAIR if ro,norecovery mount.

      commit: 263b984ae26bbc320581d2872a125bc305bea0b8

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>