generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 477
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 477
6 #
7 # Check open by file handle after cycle mount.
8 #
9 # This test uses load and store of file handles from a temp file to test
10 # decoding file handles after cycle mount and after directory renames.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick exportfs
14
15 # Import common functions.
16 . ./common/filter
17
18 # real QA test starts here
19
20 # Modify as appropriate.
21 _supported_fs generic
22 _require_test
23 # _require_exportfs already requires open_by_handle, but let's not count on it
24 _require_test_program "open_by_handle"
25 _require_exportfs
26
27 NUMFILES=10
28 testroot=$TEST_DIR/$seq-dir
29 testdir=$testroot/testdir
30
31 # Create test dir and test files, encode file handles and store to tmp file
32 create_test_files()
33 {
34         rm -rf $testdir
35         mkdir -p $testdir
36         $here/src/open_by_handle -cwp -o $tmp.handles_file $testdir $NUMFILES
37 }
38
39 # Decode file handles loaded from tmp file
40 test_file_handles()
41 {
42         local opt=$1
43         local when=$2
44
45         echo test_file_handles after $when
46         $here/src/open_by_handle $opt -i $tmp.handles_file $TEST_DIR $NUMFILES
47 }
48
49 # Decode file handles of files/dir after cycle mount
50 create_test_files
51 _test_cycle_mount
52 test_file_handles -rp "cycle mount"
53
54 # Decode file handles of files/dir after rename of parent and cycle mount
55 create_test_files $testdir
56 rm -rf $testdir.renamed
57 mv $testdir $testdir.renamed/
58 _test_cycle_mount
59 test_file_handles -rp "rename parent"
60
61 # Decode file handles of files/dir after rename of grandparent and cycle mount
62 create_test_files $testdir
63 rm -rf $testroot.renamed
64 mv $testroot $testroot.renamed/
65 _test_cycle_mount
66 test_file_handles -rp "rename grandparent"
67
68 # Decode file handles of files/dir after move to new parent and cycle mount
69 create_test_files $testdir
70 rm -rf $testdir.new
71 mkdir -p $testdir.new
72 mv $testdir/* $testdir.new/
73 _test_cycle_mount
74 test_file_handles -r "move to new parent"
75
76 status=0
77 exit