xfstests: rename RENAME_WHITEOUT test on fs no enough sapce
PATCH v2 1/1 xfstests: rename RENAME_WHITEOUT test on fs no enough sapce
This's a regression test for linux 6b4b8e6b4ad8 ("ext4: fix bug for rename with RENAME_WHITEOUT"). Rename a file with RENAME_WHITEOUT flag might cause corruption when there's not enough space to complete this renaming operation.
---
Hi,
Thanks for the reviewing from Eryu. V2 did below changes:
1) Import ./common/renameat2 and _require_renameat2 whiteout
2) Replace CHUNKS with NR_FILE
3) Reduce the number of test files from 64*64 to 4*64
4) Add to quick group
More details about the reviewing history, refer to:
https://patchwork.kernel.org/project/fstests/patch/[email protected]/
Thanks,
Zorro
tests/generic/626 | 74 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/626.out | 2 ++ tests/generic/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/generic/626 create mode 100644 tests/generic/626.out
tests/generic/626 new file +74 -0
@@ -0,0 +1,74 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 HUAWEI. All Rights Reserved. +# Copyright (c) 2021 Red Hat Inc. All Rights Reserved. +# +# FS QA Test No. 626 +# +# Test RENAME_WHITEOUT on filesystem without space to create one more inodes. +# This is a regression test for kernel commit: +# 6b4b8e6b4ad8 ("ext4: ext4: fix bug for rename with RENAME_WHITEOUT") +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/populate +. ./common/renameat2 + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs generic +_require_scratch +_require_renameat2 whiteout + +_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 +_scratch_mount + +# Create lots of files, to help to trigger the bug easily +NR_FILE=$((4 * 64)) +for ((i=0; i<NR_FILE; i++));do + touch $SCRATCH_MNT/srcfile$i +done +# Try to fill the whole fs +nr_free=$(stat -f -c '%f' $SCRATCH_MNT) +blksz="$(_get_block_size $SCRATCH_MNT)" +_fill_fs $((nr_free * blksz)) $SCRATCH_MNT/fill_space $blksz 0 >> $seqres.full 2>&1 +# Use empty files to fill the rest +for ((i=0; i<10000; i++));do + touch $SCRATCH_MNT/fill_file$i 2>/dev/null + # Until no more files can be created + if [ $? -ne 0 ];then + break + fi +done +# ENOSPC is expected here +for ((i=0; i<NR_FILE; i++));do + $here/src/renameat2 -w $SCRATCH_MNT/srcfile$i $SCRATCH_MNT/dstfile$i >> $seqres.full 2>&1 +done +_scratch_cycle_mount +# Expect no errors at here +for ((i=0; i<NR_FILE; i++));do + ls -l $SCRATCH_MNT/srcfile$i >/dev/null +done + +echo "Silence is golden" +# success, all done +status=0 +exit
tests/generic/626.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 626 +Silence is golden
tests/generic/group +1 -0
@@ -628,3 +628,4 @@ 623 auto quick shutdown 624 auto quick verity 625 auto quick verity +626 auto quick rename enospc
Signature · 1 line
2.29.2
Quoted 7 lines · Zorro Lang
This's a regression test for linux
6b4b8e6b4ad8("ext4: fix bug for rename withRENAME_WHITEOUT"). Rename a file withRENAME_WHITEOUTflag might cause corruption when there's not enough space to complete this renaming operation.Signed-off-by Zorro Lang <[email protected]>Signed-off-by Sun Ke <[email protected]>
Seems reasonable to me; does it pass on xfs?
If so,
--D
Quoted 123 lines
---
Hi,
Thanks for the reviewing from Eryu. V2 did below changes:
1) Import ./common/renameat2 and_require_renameat2whiteout
2) Replace CHUNKS withNR_FILE
3) Reduce the number of test files from 64*64 to 4*64
4) Add to quick groupMore details about the reviewing history, refer to:
https://patchwork.kernel.org/project/fstests/patch/[email protected]/Thanks,
Zorrotests/generic/626 | 74 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/626.out | 2 ++ tests/generic/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/generic/626 create mode 100644 tests/generic/626.outtests/generic/626 new file +74
-0@@ -0,0 +1,74 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 HUAWEI. All Rights Reserved. +# Copyright (c) 2021 Red Hat Inc. All Rights Reserved. +# +# FS QA Test No. 626 +# +# Test RENAME_WHITEOUT on filesystem without space to create one more inodes. +# This is a regression test for kernel commit: +# 6b4b8e6b4ad8 ("ext4: ext4: fix bug for rename with RENAME_WHITEOUT") +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/populate +. ./common/renameat2 + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs generic +_require_scratch +_require_renameat2 whiteout + +_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 +_scratch_mount + +# Create lots of files, to help to trigger the bug easily +NR_FILE=$((4 * 64)) +for ((i=0; i<NR_FILE; i++));do + touch $SCRATCH_MNT/srcfile$i +done +# Try to fill the whole fs +nr_free=$(stat -f -c '%f' $SCRATCH_MNT) +blksz="$(_get_block_size $SCRATCH_MNT)" +_fill_fs $((nr_free * blksz)) $SCRATCH_MNT/fill_space $blksz 0 >> $seqres.full 2>&1 +# Use empty files to fill the rest +for ((i=0; i<10000; i++));do + touch $SCRATCH_MNT/fill_file$i 2>/dev/null + # Until no more files can be created + if [ $? -ne 0 ];then + break + fi +done +# ENOSPC is expected here +for ((i=0; i<NR_FILE; i++));do + $here/src/renameat2 -w $SCRATCH_MNT/srcfile$i $SCRATCH_MNT/dstfile$i >> $seqres.full 2>&1 +done +_scratch_cycle_mount +# Expect no errors at here +for ((i=0; i<NR_FILE; i++));do + ls -l $SCRATCH_MNT/srcfile$i >/dev/null +done + +echo "Silence is golden" +# success, all done +status=0 +exittests/generic/626.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 626 +Silence is goldentests/generic/group +1
-0@@ -628,3 +628,4 @@ 623 auto quick shutdown 624 auto quick verity 625 auto quick verity +626 auto quick rename enospcSignature · 1 line
2.29.2
Quoted 10 lines · Darrick J. Wong
Quoted 7 lines · Zorro Lang
This's a regression test for linux
6b4b8e6b4ad8("ext4: fix bug for rename withRENAME_WHITEOUT"). Rename a file withRENAME_WHITEOUTflag might cause corruption when there's not enough space to complete this renaming operation.Signed-off-by Zorro Lang <[email protected]>Signed-off-by Sun Ke <[email protected]>Seems reasonable to me; does it pass on xfs?
Yes, it's passed on xfs and latest ext4(fixed this bug).
Thanks,
Zorro
Quoted 130 lines
If so,
Reviewed-by Darrick J. Wong <[email protected]>--D
Quoted 123 lines
---
Hi,
Thanks for the reviewing from Eryu. V2 did below changes:
1) Import ./common/renameat2 and_require_renameat2whiteout
2) Replace CHUNKS withNR_FILE
3) Reduce the number of test files from 64*64 to 4*64
4) Add to quick groupMore details about the reviewing history, refer to:
https://patchwork.kernel.org/project/fstests/patch/[email protected]/Thanks,
Zorrotests/generic/626 | 74 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/626.out | 2 ++ tests/generic/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/generic/626 create mode 100644 tests/generic/626.outtests/generic/626 new file +74
-0@@ -0,0 +1,74 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 HUAWEI. All Rights Reserved. +# Copyright (c) 2021 Red Hat Inc. All Rights Reserved. +# +# FS QA Test No. 626 +# +# Test RENAME_WHITEOUT on filesystem without space to create one more inodes. +# This is a regression test for kernel commit: +# 6b4b8e6b4ad8 ("ext4: ext4: fix bug for rename with RENAME_WHITEOUT") +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/populate +. ./common/renameat2 + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs generic +_require_scratch +_require_renameat2 whiteout + +_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 +_scratch_mount + +# Create lots of files, to help to trigger the bug easily +NR_FILE=$((4 * 64)) +for ((i=0; i<NR_FILE; i++));do + touch $SCRATCH_MNT/srcfile$i +done +# Try to fill the whole fs +nr_free=$(stat -f -c '%f' $SCRATCH_MNT) +blksz="$(_get_block_size $SCRATCH_MNT)" +_fill_fs $((nr_free * blksz)) $SCRATCH_MNT/fill_space $blksz 0 >> $seqres.full 2>&1 +# Use empty files to fill the rest +for ((i=0; i<10000; i++));do + touch $SCRATCH_MNT/fill_file$i 2>/dev/null + # Until no more files can be created + if [ $? -ne 0 ];then + break + fi +done +# ENOSPC is expected here +for ((i=0; i<NR_FILE; i++));do + $here/src/renameat2 -w $SCRATCH_MNT/srcfile$i $SCRATCH_MNT/dstfile$i >> $seqres.full 2>&1 +done +_scratch_cycle_mount +# Expect no errors at here +for ((i=0; i<NR_FILE; i++));do + ls -l $SCRATCH_MNT/srcfile$i >/dev/null +done + +echo "Silence is golden" +# success, all done +status=0 +exittests/generic/626.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 626 +Silence is goldentests/generic/group +1
-0@@ -628,3 +628,4 @@ 623 auto quick shutdown 624 auto quick verity 625 auto quick verity +626 auto quick rename enospcSignature · 1 line
2.29.2
Quoted 8 lines · Zorro Lang
This's a regression test for linux
6b4b8e6b4ad8("ext4: fix bug for rename withRENAME_WHITEOUT"). Rename a file withRENAME_WHITEOUTflag might cause corruption when there's not enough space to complete this renaming operation.Signed-off-by Zorro Lang <[email protected]>Signed-off-by Sun Ke <[email protected]>---
Hi Eryu,
Sorry I made a typo mistake on the patch subject, The 'sapce' should be 'space'. If you don't mind, please help to modify it when you merge this patch. Or feel free to tell me, if you need I re-send this patch again.
Thanks,
Zorro
Quoted 122 lines
Hi,
Thanks for the reviewing from Eryu. V2 did below changes:
1) Import ./common/renameat2 and_require_renameat2whiteout
2) Replace CHUNKS withNR_FILE
3) Reduce the number of test files from 64*64 to 4*64
4) Add to quick groupMore details about the reviewing history, refer to:
https://patchwork.kernel.org/project/fstests/patch/[email protected]/Thanks,
Zorrotests/generic/626 | 74 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/626.out | 2 ++ tests/generic/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/generic/626 create mode 100644 tests/generic/626.outtests/generic/626 new file +74
-0@@ -0,0 +1,74 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 HUAWEI. All Rights Reserved. +# Copyright (c) 2021 Red Hat Inc. All Rights Reserved. +# +# FS QA Test No. 626 +# +# Test RENAME_WHITEOUT on filesystem without space to create one more inodes. +# This is a regression test for kernel commit: +# 6b4b8e6b4ad8 ("ext4: ext4: fix bug for rename with RENAME_WHITEOUT") +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/populate +. ./common/renameat2 + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs generic +_require_scratch +_require_renameat2 whiteout + +_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 +_scratch_mount + +# Create lots of files, to help to trigger the bug easily +NR_FILE=$((4 * 64)) +for ((i=0; i<NR_FILE; i++));do + touch $SCRATCH_MNT/srcfile$i +done +# Try to fill the whole fs +nr_free=$(stat -f -c '%f' $SCRATCH_MNT) +blksz="$(_get_block_size $SCRATCH_MNT)" +_fill_fs $((nr_free * blksz)) $SCRATCH_MNT/fill_space $blksz 0 >> $seqres.full 2>&1 +# Use empty files to fill the rest +for ((i=0; i<10000; i++));do + touch $SCRATCH_MNT/fill_file$i 2>/dev/null + # Until no more files can be created + if [ $? -ne 0 ];then + break + fi +done +# ENOSPC is expected here +for ((i=0; i<NR_FILE; i++));do + $here/src/renameat2 -w $SCRATCH_MNT/srcfile$i $SCRATCH_MNT/dstfile$i >> $seqres.full 2>&1 +done +_scratch_cycle_mount +# Expect no errors at here +for ((i=0; i<NR_FILE; i++));do + ls -l $SCRATCH_MNT/srcfile$i >/dev/null +done + +echo "Silence is golden" +# success, all done +status=0 +exittests/generic/626.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 626 +Silence is goldentests/generic/group +1
-0@@ -628,3 +628,4 @@ 623 auto quick shutdown 624 auto quick verity 625 auto quick verity +626 auto quick rename enospcSignature · 1 line
2.29.2
Quoted 6 lines · Zorro Lang
Quoted 5 lines · Zorro Lang
This's a regression test for linux
6b4b8e6b4ad8("ext4: fix bug for rename withRENAME_WHITEOUT"). Rename a file withRENAME_WHITEOUTflag might cause corruption when there's not enough space to complete this renaming operation.
Quoted 8 lines
Quoted 3 lines
Signed-off-by Zorro Lang <[email protected]>Signed-off-by Sun Ke <[email protected]>---
Hi Eryu,
Sorry I made a typo mistake on the patch subject, The 'sapce' should be 'space'. If you don't mind, please help to modify it when you merge this patch. Or feel
Sure, no problem :)
Thanks,
Eryu