xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / generic / 426
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 426
6 #
7 # Check stale handles pointing to unlinked files
8 # and non-stale handles pointing to linked files
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 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30
31 # Modify as appropriate.
32 _supported_fs generic
33 _require_test
34 # _require_exportfs already requires open_by_handle, but let's not count on it
35 _require_test_program "open_by_handle"
36 _require_exportfs
37
38 NUMFILES=1024
39 testdir=$TEST_DIR/$seq-dir
40 mkdir -p $testdir
41
42 # Create empty test files in test dir
43 create_test_files()
44 {
45         local dir=$1
46
47         mkdir -p $dir
48         rm -f $dir/*
49         $here/src/open_by_handle -c $dir $NUMFILES
50 }
51
52 # Test encode/decode file handles
53 test_file_handles()
54 {
55         local dir=$1
56         local opt=$2
57
58         echo test_file_handles $* | _filter_test_dir
59         $here/src/open_by_handle $opt $dir $NUMFILES
60 }
61
62 # Check stale handles to deleted files
63 create_test_files $testdir
64 test_file_handles $testdir -d
65
66 # Check non-stale handles to linked files
67 create_test_files $testdir
68 test_file_handles $testdir
69
70 # Check non-stale handles to files that were hardlinked and original deleted
71 create_test_files $testdir
72 test_file_handles $testdir -l
73 test_file_handles $testdir -u
74
75 status=0
76 exit