xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / overlay / 067
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 CTERA Networks. All Rights Reserved.
4 #
5 # FSQA Test No. 067
6 #
7 # Test unique st_dev;st_ino on non-samefs setup.
8 #
9 # Check that files from middle layer on same fs as upper layer
10 # are not allowed to export the real inode st_dev;st_ino.
11 #
12 # This is a regression test for kernel commit:
13 #   9c6d8f13e9da ovl: fix corner case of non-unique st_dev;st_ino
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26         cd /
27         rm -f $tmp.*
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs overlay
38 # Use non-default scratch underlying overlay dirs, we need to check
39 # them explicity after test.
40 _require_scratch_nocheck
41 _require_test
42
43 # Lower is on test partition
44 lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq
45 # Upper/work are on scratch partition
46 middle=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
47 upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
48 work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
49
50 rm -rf $lower
51 mkdir $lower
52
53 _scratch_mkfs >>$seqres.full 2>&1
54
55 realfile=$middle/file
56 testfile=$SCRATCH_MNT/file
57
58 # Create a file on middle layer on same fs as upper layer
59 echo wrong > $realfile
60
61 # Mount an overlay on $SCRATCH_MNT with lower layer on test partition
62 # and middle and upper layer on scratch partition.
63 # Disable xino, so not all overlay inodes are on the same st_dev.
64 _overlay_scratch_mount_dirs $middle:$lower $upper $work -o xino=off || \
65         _notrun "cannot mount overlay with xino=off option"
66
67 stat $realfile >>$seqres.full
68 stat $testfile >>$seqres.full
69
70 # Diverge the content of the overlay file from its origin
71 echo right > $testfile
72
73 stat $testfile >>$seqres.full
74
75 # Expect the overlay file to differ from the original lower file
76 diff -q $realfile $testfile >>$seqres.full &&
77         echo "diff with middle layer file doesn't know right from wrong! (warm cache)"
78
79 echo 3 > /proc/sys/vm/drop_caches
80
81 stat $testfile >>$seqres.full
82
83 # Expect the overlay file to differ from the original lower file
84 diff -q $realfile $testfile >>$seqres.full &&
85         echo "diff with middle layer file doesn't know right from wrong! (cold cache)"
86
87 $UMOUNT_PROG $SCRATCH_MNT
88 # check overlayfs
89 _overlay_check_scratch_dirs $middle:$lower $upper $work -o xino=off
90
91 echo "Silence is golden"
92 status=0
93 exit