[PATCH 20/23] fix _require_scratch_duperemove ordering

Darrick J. Wong
2025-01-16T23:30:23Z

Zorro complained that generic/559 stopped working, and I noticed that
the duperemove invocation in the _require_scratch_duperemove function
would fail with:

Error 2: No such file or directory while getting path to file /opt/file1. Skipping.
Error 2: No such file or directory while getting path to file /opt/file2. Skipping.
No dedupe candidates found.
Gathering file list...

The cause of this is the incorrect placement of _require_scratch_dedupe
after a _scratch_mount. _require_scratch_dedupe formats, mounts, tests,
and unmounts the scratch filesystem, which means that it should not come
between a _scratch_mount call and code that uses $SCRATCH_MNT.

Cc: <fstests@vger.kernel.org> # v2024.12.22
Fixes: 3b9f5fc7d7d853 ("common: call _require_scratch_dedupe from _require_scratch_duperemove")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
common/reflink | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/reflink b/common/reflink
index 9177c45e70bb37..757f06c1c69fa7 100644
--- a/common/reflink
+++ b/common/reflink
@@ -80,11 +80,11 @@ _require_scratch_duperemove()
{
_require_scratch
_require_command "$DUPEREMOVE_PROG" duperemove
-
- _scratch_mkfs > /dev/null
- _scratch_mount
_require_scratch_dedupe

+ _scratch_mkfs > /dev/null
+ _scratch_mount
+
dd if=/dev/zero of="$SCRATCH_MNT/file1" bs=128k count=1 >& /dev/null
dd if=/dev/zero of="$SCRATCH_MNT/file2" bs=128k count=1 >& /dev/null
if ! "$DUPEREMOVE_PROG" -d "$SCRATCH_MNT/file1" \