2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 CTERA Networks. All Rights Reserved.
7 # Test unique st_dev;st_ino on non-samefs setup.
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.
12 # This is a regression test for kernel commit:
13 # 9c6d8f13e9da ovl: fix corner case of non-unique st_dev;st_ino
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
30 # get standard environment, filters and checks
36 # real QA test starts here
38 # Use non-default scratch underlying overlay dirs, we need to check
39 # them explicity after test.
40 _require_scratch_nocheck
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
53 _scratch_mkfs >>$seqres.full 2>&1
56 testfile=$SCRATCH_MNT/file
58 # Create a file on middle layer on same fs as upper layer
59 echo wrong > $realfile
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"
67 stat $realfile >>$seqres.full
68 stat $testfile >>$seqres.full
70 # Diverge the content of the overlay file from its origin
71 echo right > $testfile
73 stat $testfile >>$seqres.full
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)"
79 echo 3 > /proc/sys/vm/drop_caches
81 stat $testfile >>$seqres.full
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)"
87 $UMOUNT_PROG $SCRATCH_MNT
89 _overlay_check_scratch_dirs $middle:$lower $upper $work -o xino=off
91 echo "Silence is golden"