mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
11d3da6a7f
There are some testcases use below two kind of commands to get file
size, generalize the second way as global function _get_filesize()
to simply codes.
1. ls -l $1 | $AWK_PROG '{print $5}'
2. stat -c %s $1
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
61 lines
1.7 KiB
Bash
Executable File
61 lines
1.7 KiB
Bash
Executable File
#! /bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
|
|
#
|
|
# FS QA Test No. btrfs/086
|
|
#
|
|
# Test cloning a file range with a length of zero into a destination offset
|
|
# greater than zero.
|
|
#
|
|
# This made btrfs create an extent state record with a start offset greater than
|
|
# the end offset, resulting in chaos such as an infinite loop when evicting an
|
|
# inode.
|
|
#
|
|
# This issue was fixed by the following linux kernel patch:
|
|
#
|
|
# Btrfs: fix inode eviction infinite loop after cloning into it
|
|
#
|
|
seq=`basename $0`
|
|
seqres=$RESULT_DIR/$seq
|
|
echo "QA output created by $seq"
|
|
|
|
tmp=/tmp/$$
|
|
status=1 # failure is the default!
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
_cleanup()
|
|
{
|
|
rm -f $tmp.*
|
|
}
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common/rc
|
|
. ./common/filter
|
|
|
|
# real QA test starts here
|
|
_supported_fs btrfs
|
|
_supported_os Linux
|
|
_require_scratch
|
|
_require_cloner
|
|
|
|
rm -f $seqres.full
|
|
|
|
_scratch_mkfs >>$seqres.full 2>&1
|
|
_scratch_mount
|
|
|
|
touch $SCRATCH_MNT/foo
|
|
touch $SCRATCH_MNT/bar
|
|
|
|
# Now attempt to clone foo into bar. Because we pass a length of zero, the
|
|
# clone ioctl will adjust the length to match the size of the file foo (minus
|
|
# the source offset which is zero) - because the adjusted length value is
|
|
# zero, it made btrfs create an extent state record for file bar with a start
|
|
# offset (64k) greater then its end offset (64k - 1), which is something never
|
|
# supposed to happen and for example it made inode eviction enter an infinite
|
|
# loop that dumped a warning trace on each iteration.
|
|
$CLONER_PROG -s 0 -d 65536 -l 0 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
|
|
echo "bar file size after clone operation: `_get_filesize $SCRATCH_MNT/bar`"
|
|
|
|
status=0
|
|
exit
|