generic: test for file fsync after moving it to a new parent directory
[xfstests-dev.git] / tests / generic / 350
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 350
6 #
7 # Test fallocate(PUNCH_HOLE) on a block device, which should be able to
8 # zero-TRIM (or equivalent) the range.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
18
19 _cleanup()
20 {
21     cd /
22     rm -rf $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/scsi_debug
29
30 # real QA test starts here
31 _supported_os Linux
32 _require_scsi_debug
33 _require_xfs_io_command "fpunch"
34
35 echo "Create and format"
36 dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=1 lbpws10=1")
37 _pwrite_byte 0x62 0 4m $dev >> $seqres.full
38
39 echo "Zero punch"
40 $XFS_IO_PROG -c "fpunch 512k 1m" $dev
41
42 echo "Punch range past EOD"
43 $XFS_IO_PROG -c "fpunch 3m 4m" $dev
44
45 echo "Check contents"
46 md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
47
48 echo "Punch to MAX_LFS_FILESIZE"
49 # zod = MAX_LFS_FILESIZE
50 case "$(getconf LONG_BIT)" in
51 "32")
52         zod=$(( ($(getconf PAGE_SIZE) << ($(getconf LONG_BIT) - 1) ) - 1))
53         ;;
54 "64")
55         zod=9223372036854775807
56         ;;
57 *)
58         _fail "sizeof(long) == $(getconf LONG_BIT)?"
59         ;;
60 esac
61 $XFS_IO_PROG -c "fpunch 0 $zod" $dev
62
63 echo "Check contents"
64 md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
65
66 echo "Destroy device"
67 _put_scsi_debug_dev
68
69 # success, all done
70 status=0
71 exit