Skip to contentSkip to conversation

xfsrestore: suggest -x rather than assert for false roots

PATCH Superseded Donald Douwsma 2 participants 3 messages Aug 7, 2023 – Aug 24, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xfsrestore: suggest -x rather than assert for false roots

If we're going to have a fix for false root problems its a good idea to let people know that there's a way to recover, error out with a useful message that mentions the -x option rather than just assert.

Before

xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: tree.c:757: tree_begindir: Assertion `ino != persp->p_rootino || hardh == persp->p_rooth' failed. Aborted

After

xfsrestore: ERROR: tree.c:791: tree_begindir: Assertion ino != persp->p_rootino || hardh == persp->p_rooth failed.
xfsrestore: ERROR: False root detected. Recovery may be possible using the -x option
Aborted

Fixes d7cba7410710 ("xfsrestore: fix rootdir due to xfsdump bulkstat misuse")

---
Changes for v2
- Use xfsprogs style for conditional
- Remove trailing white-space
- Place printf format all on one line for grepability
- use __func__ instead of gcc specific __FUNCTION__

---
 restore/tree.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
restore/tree.c +9 -2
index bfa07fe..e959aa1 100644
@@ -783,8 +783,15 @@ tree_begindir(filehdr_t *fhdrp, dah_t *dahp)
 	/* lookup head of hardlink list
 	 */
 	hardh = link_hardh(ino, gen);
-	if (need_fixrootdir == BOOL_FALSE)
-		assert(ino != persp->p_rootino || hardh == persp->p_rooth);
+	if (need_fixrootdir == BOOL_FALSE &&
+		!(ino != persp->p_rootino || hardh == persp->p_rooth)) {
+		mlog(MLOG_ERROR | MLOG_TREE,
+"%s:%d: %s: Assertion `ino != persp->p_rootino || hardh == persp->p_rooth` failed.\n",
+			__FILE__, __LINE__, __func__);
+		mlog(MLOG_ERROR | MLOG_TREE, _(
+"False root detected. Recovery may be possible using the `-x` option\n"));
+		return NH_NULL;
+	}
 
 	/* already present
 	 */
Signature · 1 line
2.39.3
Reviewed-by on v2 1/1
#1 lore raw
Quoted 35 lines · Donald Douwsma

If we're going to have a fix for false root problems its a good idea to let people know that there's a way to recover, error out with a useful message that mentions the -x option rather than just assert.

Before

xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: tree.c:757: tree_begindir: Assertion `ino != persp->p_rootino || hardh == persp->p_rooth' failed. Aborted

After

xfsrestore: ERROR: tree.c:791: tree_begindir: Assertion ino != persp->p_rootino || hardh == persp->p_rooth failed.
xfsrestore: ERROR: False root detected. Recovery may be possible using the -x option
Aborted

Fixes d7cba7410710 ("xfsrestore: fix rootdir due to xfsdump bulkstat misuse")

---
Changes for v2
- Use xfsprogs style for conditional
- Remove trailing white-space
- Place printf format all on one line for grepability
- use __func__ instead of gcc specific __FUNCTION__

---
 restore/tree.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
restore/tree.c +0 -0
index bfa07fe..e959aa1 100644

restore/tree.c tree_begindir(filehdr_t *fhdrp, dah_t *dahp) · line 788

Quoted 8 lines
restore/tree.c +3 -2
@@ -783,8 +783,15 @@ tree_begindir(filehdr_t *fhdrp, dah_t *dahp)
 	/* lookup head of hardlink list
 	 */
 	hardh = link_hardh(ino, gen);
-	if (need_fixrootdir == BOOL_FALSE)
-		assert(ino != persp->p_rootino || hardh == persp->p_rooth);
+	if (need_fixrootdir == BOOL_FALSE &&
+		!(ino != persp->p_rootino || hardh == persp->p_rooth)) {
+		mlog(MLOG_ERROR | MLOG_TREE,

Nit: Second line of the if test has the same level of indentation as the if body.

With that fixed,

--D

Quoted 12 lines
restore/tree.c +6 -0
+"%s:%d: %s: Assertion `ino != persp->p_rootino || hardh == persp->p_rooth` failed.\n",
+			__FILE__, __LINE__, __func__);
+		mlog(MLOG_ERROR | MLOG_TREE, _(
+"False root detected. Recovery may be possible using the `-x` option\n"));
+		return NH_NULL;
+	}
 
 	/* already present
 	 */
Signature · 1 line
2.39.3
#2 lore raw
Quoted 31 lines · Darrick J. Wong
Quoted 30 lines · Donald Douwsma

If we're going to have a fix for false root problems its a good idea to let people know that there's a way to recover, error out with a useful message that mentions the -x option rather than just assert.

Before

xfsrestore: searching media for directory dump
xfsrestore: reading directories
xfsrestore: tree.c:757: tree_begindir: Assertion `ino != persp->p_rootino || hardh == persp->p_rooth' failed. Aborted

After

xfsrestore: ERROR: tree.c:791: tree_begindir: Assertion ino != persp->p_rootino || hardh == persp->p_rooth failed.
xfsrestore: ERROR: False root detected. Recovery may be possible using the -x option
Aborted

Fixes d7cba7410710 ("xfsrestore: fix rootdir due to xfsdump bulkstat misuse")

---
Changes for v2
- Use xfsprogs style for conditional
- Remove trailing white-space
- Place printf format all on one line for grepability
- use __func__ instead of gcc specific __FUNCTION__

---
  restore/tree.c | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)
Quoted 16 lines

restore/tree.c tree_begindir(filehdr_t *fhdrp, dah_t *dahp) · line 788

Quoted 13 lines
restore/tree.c +3 -2
index bfa07fe..e959aa1 100644
@@ -783,8 +783,15 @@ tree_begindir(filehdr_t *fhdrp, dah_t *dahp)
  	/* lookup head of hardlink list
  	 */
  	hardh = link_hardh(ino, gen);
-	if (need_fixrootdir == BOOL_FALSE)
-		assert(ino != persp->p_rootino || hardh == persp->p_rooth);
+	if (need_fixrootdir == BOOL_FALSE &&
+		!(ino != persp->p_rootino || hardh == persp->p_rooth)) {
+		mlog(MLOG_ERROR | MLOG_TREE,

Nit: Second line of the if test has the same level of indentation as the if body.

Urg, I cant unsee it now, will fix.

Thanks for the Review(s)
Don

Quoted 19 lines

With that fixed,

--D

Quoted 12 lines
restore/tree.c +6 -0
+"%s:%d: %s: Assertion `ino != persp->p_rootino || hardh == persp->p_rooth` failed.\n",
+			__FILE__, __LINE__, __func__);
+		mlog(MLOG_ERROR | MLOG_TREE, _(
+"False root detected. Recovery may be possible using the `-x` option\n"));
+		return NH_NULL;
+	}
 
  	/* already present
  	 */
Signature · 1 line
2.39.3