2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 HUAWEI. All Rights Reserved.
4 # Copyright (c) 2021 Red Hat Inc. All Rights Reserved.
8 # Test RENAME_WHITEOUT on filesystem without space to create one more inodes.
9 # This is a regression test for kernel commit:
10 # 6b4b8e6b4ad8 ("ext4: ext4: fix bug for rename with RENAME_WHITEOUT")
13 _begin_fstest auto quick rename enospc
15 # Import common functions.
20 # real QA test starts here
23 _require_renameat2 whiteout
25 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
28 # Create lots of files, to help to trigger the bug easily
30 for ((i=0; i<NR_FILE; i++));do
31 touch $SCRATCH_MNT/srcfile$i
33 # Try to fill the whole fs
34 nr_free=$(stat -f -c '%f' $SCRATCH_MNT)
35 blksz="$(_get_block_size $SCRATCH_MNT)"
36 _fill_fs $((nr_free * blksz)) $SCRATCH_MNT/fill_space $blksz 0 >> $seqres.full 2>&1
37 # Use empty files to fill the rest
38 for ((i=0; i<10000; i++));do
39 touch $SCRATCH_MNT/fill_file$i 2>/dev/null
40 # Until no more files can be created
45 # ENOSPC is expected here
46 for ((i=0; i<NR_FILE; i++));do
47 $here/src/renameat2 -w $SCRATCH_MNT/srcfile$i $SCRATCH_MNT/dstfile$i >> $seqres.full 2>&1
50 # Expect no errors at here
51 for ((i=0; i<NR_FILE; i++));do
52 ls -l $SCRATCH_MNT/srcfile$i >/dev/null
55 echo "Silence is golden"