Skip to contentSkip to conversation

xfs: test xfsdump subtree restores

PATCH In review Donald Douwsma 3 participants 8 messages Jul 23 – Aug 11

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xfs: test xfsdump subtree restores

Regression test for cumulative restores where a directory has been renamed outside of the subtree being restored triggering the assert:

xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed

---
Changes since v1
- Fix use of _do, including label quoting
- Update test output
- Add tests for additional edge cases

---
 tests/xfs/995     | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/995.out |  8 +++++++
 2 files changed, 66 insertions(+)
 create mode 100755 tests/xfs/995
 create mode 100644 tests/xfs/995.out
tests/xfs/995 new file +58 -0
new file mode 100755
index 000000000..bba0bcd52
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Red Hat.  All Rights Reserved.
+#
+# FS QA Test 995
+#
+# Regression test for cumulative restores where a directory has been
+# renamed outside of the subtree being restored resulting in
+#
+#   xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed
+#
+. ./common/preamble
+_begin_fstest auto dump
+_do_die_on_error="always"
+
+_fixed_by_git_commit xfsdump dd63de5 \
+	"xfsrestore: only process subtrees that are selected"
+
+# Override the default cleanup function.
+_cleanup()
+{
+	_cleanup_dump
+	cd /
+	rm -r -f $tmp.*
+}
+
+# Import common functions.
+. ./common/dump
+
+# Modify as appropriate.
+_require_scratch
+_scratch_mkfs_xfs >>$seqres.full
+_scratch_mount
+
+mkdir -p $SCRATCH_MNT/a/b/c/d/e/f/g
+mkdir -p $SCRATCH_MNT/restore_me/B/C/D/E/F/G
+
+_do "Creating l0 dump" "$XFSDUMP_PROG -L lab_l0 -M test -l0 -f $tmp.dump.l0 $SCRATCH_MNT"
+
+mv $SCRATCH_MNT/a/b/c $SCRATCH_MNT/1
+
+_do "Creating l2 dump" "$XFSDUMP_PROG -L lab_l2.0 -M test -l2 -f $tmp.dump.l2.0 $SCRATCH_MNT"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r $dir"
+_do "Cumulative restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative subtree restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r -s restore_me $dir"
+# The next command core dumps prior to xfsdump v3.3.0 when noref_elim_recurse attempts to
+# rename directories outside of the subtree when their parent has not been created.
+_do "Cumulative subtree restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Restore l2 on its own" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r -s restore_me $dir"
+
+# success, all done
+_exit 0
tests/xfs/995.out new file +8 -0
new file mode 100644
index 000000000..9a620eb31
@@ -0,0 +1,8 @@
+QA output created by 995
+Creating l0 dump... done
+Creating l2 dump... done
+Cumulative restore l0... done
+Cumulative restore l2... done
+Cumulative subtree restore l0... done
+Cumulative subtree restore l2... done
+Restore l2 on its own... done
Signature · 1 line
2.52.0
Reviewed-by on v2 1/1
#1 lore raw

tests/xfs/995 line 52

Quoted 12 lines · Donald Douwsma
tests/xfs/995 new file +12 -0
+
+_do "Creating l2 dump" "$XFSDUMP_PROG -L lab_l2.0 -M test -l2 -f $tmp.dump.l2.0 $SCRATCH_MNT"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r $dir"
+_do "Cumulative restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative subtree restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r -s restore_me $dir"
+# The next command core dumps prior to xfsdump v3.3.0 when noref_elim_recurse attempts to
+# rename directories outside of the subtree when their parent has not been created.
+_do "Cumulative subtree restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"

Maybe break these lines up with \ after the description to make it a bit more readable?

Otherwise looks good:

#2 lore raw
Quoted 16 lines · Christoph Hellwig

tests/xfs/995 line 52

Quoted 12 lines · Donald Douwsma
tests/xfs/995 new file +12 -0
+
+_do "Creating l2 dump" "$XFSDUMP_PROG -L lab_l2.0 -M test -l2 -f $tmp.dump.l2.0 $SCRATCH_MNT"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r $dir"
+_do "Cumulative restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative subtree restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r -s restore_me $dir"
+# The next command core dumps prior to xfsdump v3.3.0 when noref_elim_recurse attempts to
+# rename directories outside of the subtree when their parent has not been created.
+_do "Cumulative subtree restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"

Maybe break these lines up with \ after the description to make it a bit more readable?

Sure, I'll help to do this change when I merge it. Thanks Christoph!

Quoted 6 lines

Otherwise looks good:

Reviewed-by on v2 1/1
#3 lore raw
In reply to Donald Douwsma
Quoted 11 lines · Donald Douwsma

Regression test for cumulative restores where a directory has been renamed outside of the subtree being restored triggering the assert:

xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed

---
Changes since v1
- Fix use of _do, including label quoting
- Update test output
- Add tests for additional edge cases

Hi Donald, This version is good to me now.

Quoted 89 lines
---
 tests/xfs/995     | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/995.out |  8 +++++++
 2 files changed, 66 insertions(+)
 create mode 100755 tests/xfs/995
 create mode 100644 tests/xfs/995.out
tests/xfs/995 new file +58 -0
new file mode 100755
index 000000000..bba0bcd52
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Red Hat.  All Rights Reserved.
+#
+# FS QA Test 995
+#
+# Regression test for cumulative restores where a directory has been
+# renamed outside of the subtree being restored resulting in
+#
+#   xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed
+#
+. ./common/preamble
+_begin_fstest auto dump
+_do_die_on_error="always"
+
+_fixed_by_git_commit xfsdump dd63de5 \
+	"xfsrestore: only process subtrees that are selected"
+
+# Override the default cleanup function.
+_cleanup()
+{
+	_cleanup_dump
+	cd /
+	rm -r -f $tmp.*
+}
+
+# Import common functions.
+. ./common/dump
+
+# Modify as appropriate.
+_require_scratch
+_scratch_mkfs_xfs >>$seqres.full
+_scratch_mount
+
+mkdir -p $SCRATCH_MNT/a/b/c/d/e/f/g
+mkdir -p $SCRATCH_MNT/restore_me/B/C/D/E/F/G
+
+_do "Creating l0 dump" "$XFSDUMP_PROG -L lab_l0 -M test -l0 -f $tmp.dump.l0 $SCRATCH_MNT"
+
+mv $SCRATCH_MNT/a/b/c $SCRATCH_MNT/1
+
+_do "Creating l2 dump" "$XFSDUMP_PROG -L lab_l2.0 -M test -l2 -f $tmp.dump.l2.0 $SCRATCH_MNT"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r $dir"
+_do "Cumulative restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative subtree restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r -s restore_me $dir"
+# The next command core dumps prior to xfsdump v3.3.0 when noref_elim_recurse attempts to
+# rename directories outside of the subtree when their parent has not been created.
+_do "Cumulative subtree restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Restore l2 on its own" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r -s restore_me $dir"
+
+# success, all done
+_exit 0
tests/xfs/995.out new file +8 -0
new file mode 100644
index 000000000..9a620eb31
@@ -0,0 +1,8 @@
+QA output created by 995
+Creating l0 dump... done
+Creating l2 dump... done
+Cumulative restore l0... done
+Cumulative restore l2... done
+Cumulative subtree restore l0... done
+Cumulative subtree restore l2... done
+Restore l2 on its own... done
Signature · 1 line
2.52.0
#4 lore raw
In reply to Donald Douwsma
Quoted 28 lines · Donald Douwsma

Regression test for cumulative restores where a directory has been renamed outside of the subtree being restored triggering the assert:

xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed

---
Changes since v1
- Fix use of _do, including label quoting
- Update test output
- Add tests for additional edge cases

---
 tests/xfs/995     | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/995.out |  8 +++++++
 2 files changed, 66 insertions(+)
 create mode 100755 tests/xfs/995
 create mode 100644 tests/xfs/995.out
tests/xfs/995 new file +4 -0
new file mode 100755
index 000000000..bba0bcd52
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Red Hat.  All Rights Reserved.
+#

tests/xfs/995 line 14

Quoted 10 lines
tests/xfs/995 new file +10 -0
+# FS QA Test 995
+#
+# Regression test for cumulative restores where a directory has been
+# renamed outside of the subtree being restored resulting in
+#
+#   xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed
+#
+. ./common/preamble
+_begin_fstest auto dump
+_do_die_on_error="always"

I think this line is useless now, right? I'll remove it.

Quoted 62 lines
tests/xfs/995 new file +44 -0
+
+_fixed_by_git_commit xfsdump dd63de5 \
+	"xfsrestore: only process subtrees that are selected"
+
+# Override the default cleanup function.
+_cleanup()
+{
+	_cleanup_dump
+	cd /
+	rm -r -f $tmp.*
+}
+
+# Import common functions.
+. ./common/dump
+
+# Modify as appropriate.
+_require_scratch
+_scratch_mkfs_xfs >>$seqres.full
+_scratch_mount
+
+mkdir -p $SCRATCH_MNT/a/b/c/d/e/f/g
+mkdir -p $SCRATCH_MNT/restore_me/B/C/D/E/F/G
+
+_do "Creating l0 dump" "$XFSDUMP_PROG -L lab_l0 -M test -l0 -f $tmp.dump.l0 $SCRATCH_MNT"
+
+mv $SCRATCH_MNT/a/b/c $SCRATCH_MNT/1
+
+_do "Creating l2 dump" "$XFSDUMP_PROG -L lab_l2.0 -M test -l2 -f $tmp.dump.l2.0 $SCRATCH_MNT"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r $dir"
+_do "Cumulative restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Cumulative subtree restore l0" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r -s restore_me $dir"
+# The next command core dumps prior to xfsdump v3.3.0 when noref_elim_recurse attempts to
+# rename directories outside of the subtree when their parent has not been created.
+_do "Cumulative subtree restore l2" "$XFSRESTORE_PROG -f $tmp.dump.l2.0 -r $dir"
+
+dir=$(mktemp -d $SCRATCH_MNT/restore_XXX)
+_do "Restore l2 on its own" "$XFSRESTORE_PROG -f $tmp.dump.l0 -r -s restore_me $dir"
+
+# success, all done
+_exit 0
tests/xfs/995.out new file +8 -0
new file mode 100644
index 000000000..9a620eb31
@@ -0,0 +1,8 @@
+QA output created by 995
+Creating l0 dump... done
+Creating l2 dump... done
+Cumulative restore l0... done
+Cumulative restore l2... done
+Cumulative subtree restore l0... done
+Cumulative subtree restore l2... done
+Restore l2 on its own... done
Signature · 1 line
2.52.0
#5 lore raw
Quoted 33 lines · Zorro Lang
Quoted 32 lines · Donald Douwsma

Regression test for cumulative restores where a directory has been renamed outside of the subtree being restored triggering the assert:

xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed

---
Changes since v1
- Fix use of _do, including label quoting
- Update test output
- Add tests for additional edge cases

---
 tests/xfs/995     | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/995.out |  8 +++++++
 2 files changed, 66 insertions(+)
 create mode 100755 tests/xfs/995
 create mode 100644 tests/xfs/995.out
tests/xfs/995 new file +8 -0
new file mode 100755
index 000000000..bba0bcd52
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Red Hat.  All Rights Reserved.
+#
+# FS QA Test 995
+#
+# Regression test for cumulative restores where a directory has been
+# renamed outside of the subtree being restored resulting in
Quoted 9 lines

tests/xfs/995 line 14

Quoted 6 lines
tests/xfs/995 new file +6 -0
+#
+#   xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed
+#
+. ./common/preamble
+_begin_fstest auto dump
+_do_die_on_error="always"

I think this line is useless now, right? I'll remove it.

Yes, thanks.

I did have a general question about how _do_die_on_error is used

$ git grep _do_die_on_error
common/rc:# second argument. If the command fails and the variable _do_die_on_error
common/rc:# is set to "always" or the two argument form is used and _do_die_on_error
common/rc:      && [ "$_do_die_on_error" = "always" \
common/rc:          -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
tests/generic/017:_do_die_on_error=y
tests/generic/053:_do_die_on_error=y
tests/xfs/041:_do_die_on_error=message_only
tests/xfs/042:_do_die_on_error=message_only
tests/xfs/596:_do_die_on_error=message_only
tests/xfs/635:_do_die_on_error=message_only

_do_die_on_error=y doesn't seem valid.

generic/017 doesn't use _do, and I think generic/053 wants _do_die_on_error=always

Thoughts?

Don

#6 lore raw
Quoted 46 lines · Donald Douwsma
Quoted 33 lines · Zorro Lang
Quoted 32 lines · Donald Douwsma

Regression test for cumulative restores where a directory has been renamed outside of the subtree being restored triggering the assert:

xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed

---
Changes since v1
- Fix use of _do, including label quoting
- Update test output
- Add tests for additional edge cases

---
 tests/xfs/995     | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/995.out |  8 +++++++
 2 files changed, 66 insertions(+)
 create mode 100755 tests/xfs/995
 create mode 100644 tests/xfs/995.out
tests/xfs/995 new file +8 -0
new file mode 100755
index 000000000..bba0bcd52
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Red Hat.  All Rights Reserved.
+#
+# FS QA Test 995
+#
+# Regression test for cumulative restores where a directory has been
+# renamed outside of the subtree being restored resulting in
Quoted 9 lines

tests/xfs/995 line 14

Quoted 6 lines
tests/xfs/995 new file +6 -0
+#
+#   xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed
+#
+. ./common/preamble
+_begin_fstest auto dump
+_do_die_on_error="always"

I think this line is useless now, right? I'll remove it.

Yes, thanks.

Quoted 7 lines

I did have a general question about how _do_die_on_error is used

$ git grep _do_die_on_error
common/rc:# second argument. If the command fails and the variable _do_die_on_error
common/rc:# is set to "always" or the two argument form is used and _do_die_on_error
common/rc:      && [ "$_do_die_on_error" = "always" \
common/rc:          -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]

Oh, my bad. I confused this parameter with the "enable_error" parameter you tried to introduce in your previous patch.

Since this variable is used by the current _do helper, setting it to "always" or "message_only" here is good. I will keep this line.

Quoted 8 lines

tests/generic/017:_do_die_on_error=y
tests/generic/053:_do_die_on_error=y
tests/xfs/041:_do_die_on_error=message_only
tests/xfs/042:_do_die_on_error=message_only
tests/xfs/596:_do_die_on_error=message_only
tests/xfs/635:_do_die_on_error=message_only

_do_die_on_error=y doesn't seem valid.

I think you're right, "y" isn't valid. The _do() helper is quite old and rarely used. If you have any optimization suggestions, feel free to send a patch to improve it. For this patch, I'll merge your current version directly.

Thanks,
Zorro

Quoted 11 lines

generic/017 doesn't use _do, and I think generic/053 wants _do_die_on_error=always

Thoughts?

Don

#7 lore raw
Quoted 49 lines · Zorro Lang
Quoted 48 lines · Donald Douwsma
Quoted 33 lines · Zorro Lang
Quoted 32 lines · Donald Douwsma

Regression test for cumulative restores where a directory has been renamed outside of the subtree being restored triggering the assert:

xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed

---
Changes since v1
- Fix use of _do, including label quoting
- Update test output
- Add tests for additional edge cases

---
 tests/xfs/995     | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/995.out |  8 +++++++
 2 files changed, 66 insertions(+)
 create mode 100755 tests/xfs/995
 create mode 100644 tests/xfs/995.out
tests/xfs/995 new file +8 -0
new file mode 100755
index 000000000..bba0bcd52
@@ -0,0 +1,58 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Red Hat.  All Rights Reserved.
+#
+# FS QA Test 995
+#
+# Regression test for cumulative restores where a directory has been
+# renamed outside of the subtree being restored resulting in
Quoted 9 lines

tests/xfs/995 line 14

Quoted 6 lines
tests/xfs/995 new file +6 -0
+#
+#   xfsrestore: tree.c:1421: noref_elim_recurse: Assertion 'isrealpr' failed
+#
+. ./common/preamble
+_begin_fstest auto dump
+_do_die_on_error="always"

I think this line is useless now, right? I'll remove it.

Yes, thanks.

I did have a general question about how _do_die_on_error is used

Quoted 8 lines
Quoted 5 lines
$ git grep _do_die_on_error
common/rc:# second argument. If the command fails and the variable _do_die_on_error
common/rc:# is set to "always" or the two argument form is used and _do_die_on_error
common/rc:      && [ "$_do_die_on_error" = "always" \
common/rc:          -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]

Oh, my bad. I confused this parameter with the "enable_error" parameter you tried to introduce in your previous patch.

You mean the attr one that ended up as tests/xfs/649"
lol, no. Though that was helpful when creating/debugging a test that panics a box.

Quoted 2 lines

Since this variable is used by the current _do helper, setting it to "always" or "message_only" here is good. I will keep this line.

Cool, I think i added _do_die_on_error when working on the v2 because I was testing it on an older xfstests where the coredump functionality wasn't available.

The v1 of this test only had a 'Silence is Golden', so the test would pass which was really confusing, I fixed that by adding a better 995.out, so this should work with or without it now.

Quoted 8 lines
Quoted 8 lines

tests/generic/017:_do_die_on_error=y
tests/generic/053:_do_die_on_error=y
tests/xfs/041:_do_die_on_error=message_only
tests/xfs/042:_do_die_on_error=message_only
tests/xfs/596:_do_die_on_error=message_only
tests/xfs/635:_do_die_on_error=message_only

Quoted 5 lines
Quoted 1 line

_do_die_on_error=y doesn't seem valid.

I think you're right, "y" isn't valid. The _do() helper is quite old and rarely used. If you have any optimization suggestions, feel free to send a patch to improve it. For this patch, I'll merge your current version directly.

I'll have a think about that, it seemed handy for this test, but I don't understand how the other tests use it.

Cheers,
Don

Quoted 7 lines
Quoted 7 lines

generic/017 doesn't use _do, and I think generic/053 wants _do_die_on_error=always

Thoughts?

Don