forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test with two kinds of file creation orders
Data loss was identified in openzfs#7401 when many small files were copied. This adds a reproducer for this bug and other similar ones: randomly generate N files. Then, listing M of them by `ls -U` order, produce those same files in a directory of the same name. This triggers the bug consistently, provided N and M are large enough. Here, N=2^16 and M=2^13. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Antonio Russo <antonio.e.russo@gmail.com> Closes openzfs#7411
- Loading branch information
1 parent
5bfd955
commit 2bb4e7a
Showing
4 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
tests/zfs-tests/tests/functional/mv_files/random_creation.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/ksh -p | ||
|
||
source "${STF_SUITE}/include/libtest.shlib" | ||
source "${STF_SUITE}/tests/functional/mv_files/mv_files.cfg" | ||
|
||
# This will test the #7401 regression. | ||
log_assert "Check that creating many files quickly is safe" | ||
|
||
DIR="${TESTDIR}/RANDOM_SMALL" | ||
|
||
log_must mkdir "${DIR}" | ||
|
||
count=0 | ||
for i in $(shuf -i 1-"${RC_PASS1}") ; do | ||
if ! touch "${DIR}/${i}" ; then | ||
log_fail "error creating ${i} after ${count} files" | ||
fi | ||
count=$((count+1)) | ||
done | ||
|
||
visible="$(find "${DIR}" -type f|wc -l)" | ||
|
||
log_must [ "${visible}" -eq "${RC_PASS1}" ] | ||
|
||
log_assert "Check that creating them in another order is safe" | ||
|
||
DIR1="${TESTDIR}/RANDOM2" | ||
|
||
log_must mv "${DIR}" "${DIR1}" | ||
|
||
log_must mkdir "${DIR}" | ||
|
||
count=0 | ||
for i in $(cd "${DIR1}" ; ls -U . ) ; do | ||
if ! touch "${DIR}/${i}" ; then | ||
log_fail "error creating ${i} after ${count} files" | ||
fi | ||
count=$((count+1)) | ||
[ "${count}" -eq "${RC_PASS2}" ] && break | ||
done | ||
|
||
visible="$(find "${DIR}" -type f|wc -l)" | ||
|
||
if [ "${visible}" -eq "${RC_PASS2}" ] ; then | ||
log_pass "Created all ${RC_PASS2} files" | ||
else | ||
log_fail "Number of created files ${visible} is not ${RC_PASS2}" | ||
fi |