summaryrefslogtreecommitdiff
path: root/tests/overlay/067
blob: 3f54a418d84dd75ad0857d27419524e1846b7498 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2019 CTERA Networks. All Rights Reserved.
#
# FSQA Test No. 067
#
# Test unique st_dev;st_ino on non-samefs setup.
#
# Check that files from middle layer on same fs as upper layer
# are not allowed to export the real inode st_dev;st_ino.
#
# This is a regression test for kernel commit:
#   9c6d8f13e9da ovl: fix corner case of non-unique st_dev;st_ino
#
. ./common/preamble
_begin_fstest auto quick copyup nonsamefs

# Import common functions.
. ./common/filter

# real QA test starts here
_supported_fs overlay
_fixed_by_kernel_commit 9c6d8f13e9da \
	"ovl: fix corner case of non-unique st_dev;st_ino"

# Use non-default scratch underlying overlay dirs, we need to check
# them explicity after test.
_require_scratch_nocheck
_require_test

# Lower is on test partition
lower=$OVL_BASE_TEST_DIR/$OVL_LOWER-$seq
# Upper/work are on scratch partition
middle=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
work=$OVL_BASE_SCRATCH_MNT/$OVL_WORK

rm -rf $lower
mkdir $lower

_scratch_mkfs >>$seqres.full 2>&1

realfile=$middle/file
testfile=$SCRATCH_MNT/file

# Create a file on middle layer on same fs as upper layer
echo wrong > $realfile

# Mount an overlay on $SCRATCH_MNT with lower layer on test partition
# and middle and upper layer on scratch partition.
# Disable xino, so not all overlay inodes are on the same st_dev.
_overlay_scratch_mount_dirs $middle:$lower $upper $work -o xino=off || \
	_notrun "cannot mount overlay with xino=off option"

stat $realfile >>$seqres.full
stat $testfile >>$seqres.full

# Diverge the content of the overlay file from its origin
echo right > $testfile

stat $testfile >>$seqres.full

# Expect the overlay file to differ from the original lower file
diff -q $realfile $testfile >>$seqres.full &&
	echo "diff with middle layer file doesn't know right from wrong! (warm cache)"

echo 3 > /proc/sys/vm/drop_caches

stat $testfile >>$seqres.full

# Expect the overlay file to differ from the original lower file
diff -q $realfile $testfile >>$seqres.full &&
	echo "diff with middle layer file doesn't know right from wrong! (cold cache)"

$UMOUNT_PROG $SCRATCH_MNT
# check overlayfs
_overlay_check_scratch_dirs $middle:$lower $upper $work -o xino=off

echo "Silence is golden"
status=0
exit