echo "QA output created by $seq"
here="`pwd`"
tmp=/tmp/$$
-cnt=11999
+cnt=119
filesize=48000
status=1 # failure is the default!
_btrfs_online_defrag()
{
str=""
+ # start = -1 is invalid, should fail
if [ "$2" = "2" ];then
str="$str -s -1 -l $((filesize / 2)) "
elif [ "$2" = "3" ];then
str="$str -s $((filesize + 1)) -l $((filesize / 2)) "
- HAVE_DEFRAG=1
+ # len = -1 is invalid, should fail
elif [ "$2" = "4" ];then
str="$str -l -1 "
elif [ "$2" = "5" ];then
fi
if [ "$str" != "" ]; then
- $BTRFS_UTIL_PROG filesystem defragment $str $SCRATCH_MNT/tmp_file
+ $BTRFS_UTIL_PROG filesystem defragment $str $SCRATCH_MNT/tmp_file >> $seq.full 2>&1
else
if [ "$1" = "1" ];then
- $BTRFS_UTIL_PROG filesystem defragment $SCRATCH_MNT/tmp_file
+ $BTRFS_UTIL_PROG filesystem defragment $SCRATCH_MNT/tmp_file >> $seq.full 2>&1
elif [ "$1" = "2" ];then
- $BTRFS_UTIL_PROG filesystem defragment $SCRATCH_MNT/tmp_dir
+ $BTRFS_UTIL_PROG filesystem defragment $SCRATCH_MNT/tmp_dir >> $seq.full 2>&1
elif [ "$1" = "3" ];then
- $BTRFS_UTIL_PROG filesystem defragment $SCRATCH_MNT
+ $BTRFS_UTIL_PROG filesystem defragment $SCRATCH_MNT >> $seq.full 2>&1
fi
fi
ret_val=$?
_scratch_remount
- if [ $ret_val -ne 20 ];then
- echo "btrfs filesystem defragment failed! err is $ret_val"
+ # Older defrag returned "20" for success
+ # e9393c2 btrfs-progs: defrag return zero on success
+ if [ $ret_val -ne 0 -a $ret_val -ne 20 ]; then
+ echo "btrfs filesystem defragment failed!"
fi
}
_require_defrag
echo "defrag object | defragment range | defragment compress"
-echo "a single file | default | off"
+echo "a single file | default | off"
_rundefrag 1 1 1
echo "a single file | default | on"
_rundefrag 1 1 2
-echo "a single file | start < 0 && 0 < len < file size | off"
+echo "a single file | start < 0 && 0 < len < file size | off (should fail)"
_rundefrag 1 2 1
echo "a single file | start > file size && 0 < len < file size | off"
_rundefrag 1 3 1
-echo "a single file | start = 0 && len < 0 | off"
+echo "a single file | start = 0 && len < 0 | off (should fail)"
_rundefrag 1 4 1
echo "a single file | start = 0 && len > file size | off"
QA output created by 284
defrag object | defragment range | defragment compress
-a single file | default | off
+a single file | default | off
a single file | default | on
-a single file | start < 0 && 0 < len < file size | off
+a single file | start < 0 && 0 < len < file size | off (should fail)
+btrfs filesystem defragment failed!
a single file | start > file size && 0 < len < file size | off
-a single file | start = 0 && len < 0 | off
+a single file | start = 0 && len < 0 | off (should fail)
+btrfs filesystem defragment failed!
a single file | start = 0 && len > file size | off
a single file | start = 0 && 0 < len < file size | off
a directory | default | off