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
39 # Use non-default scratch underlying overlay dirs, we need to check
40 # them explicity after test.
41 _require_scratch_nocheck
44 # Lower is on test partition
45 lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq
46 # Upper/work are on scratch partition
47 middle=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
48 upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
49 work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
54 _scratch_mkfs >>$seqres.full 2>&1
57 testfile=$SCRATCH_MNT/file
59 # Create a file on middle layer on same fs as upper layer
60 echo wrong > $realfile
62 # Mount an overlay on $SCRATCH_MNT with lower layer on test partition
63 # and middle and upper layer on scratch partition.
64 # Disable xino, so not all overlay inodes are on the same st_dev.
65 _overlay_scratch_mount_dirs $middle:$lower $upper $work -o xino=off || \
66 _notrun "cannot mount overlay with xino=off option"
68 stat $realfile >>$seqres.full
69 stat $testfile >>$seqres.full
71 # Diverge the content of the overlay file from its origin
72 echo right > $testfile
74 stat $testfile >>$seqres.full
76 # Expect the overlay file to differ from the original lower file
77 diff -q $realfile $testfile >>$seqres.full &&
78 echo "diff with middle layer file doesn't know right from wrong! (warm cache)"
80 echo 3 > /proc/sys/vm/drop_caches
82 stat $testfile >>$seqres.full
84 # Expect the overlay file to differ from the original lower file
85 diff -q $realfile $testfile >>$seqres.full &&
86 echo "diff with middle layer file doesn't know right from wrong! (cold cache)"
88 $UMOUNT_PROG $SCRATCH_MNT
90 _overlay_check_scratch_dirs $middle:$lower $upper $work -o xino=off
92 echo "Silence is golden"