generic: test adding filesystem-level fscrypt key via key_id
[xfstests-dev.git] / tests / generic / 150
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 150
6 #
7 # Ensure that reflinking a file N times doesn't eat a lot of blocks
8 #   - Create a file and record fs block usage
9 #   - Create some reflink copies
10 #   - Compare fs block usage to before
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     cd /
24     rm -rf $tmp.* $testdir
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/reflink
31
32 # real QA test starts here
33 _supported_os Linux
34 _require_test_reflink
35 _require_cp_reflink
36
37 rm -f $seqres.full
38
39 testdir=$TEST_DIR/test-$seq
40 rm -rf $testdir
41 mkdir $testdir
42
43 echo "Create the original file blocks"
44 blksz="$(_get_block_size $testdir)"
45 blks=2000
46 margin='15%'
47 sz=$((blksz * blks))
48 nr=7
49 filesize=$((blksz * nr))
50 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
51 sync
52 free_blocks0=$(stat -f $testdir -c '%f')
53
54 echo "Create the reflink copies"
55 for i in `seq 2 $nr`; do
56         _cp_reflink $testdir/file1 $testdir/file.$i
57 done
58 _test_cycle_mount
59 free_blocks1=$(stat -f $testdir -c '%f')
60
61 _within_tolerance "free blocks after reflink" $free_blocks1 $free_blocks0 $margin -v
62
63 # success, all done
64 status=0
65 exit