2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
7 # Test multiple origin references to the same lower file.
9 # Multiple origin references to the same lower file from upper files that
10 # are not hardlinks will falsely return the same st_ino/st_dev for two
11 # different overlay files and will cause 'diff' to falsely report that
12 # content of files is the same when it is not.
14 # This test checks that overlayfs detects and fails lookup of a multiply
17 # The check for multiply referenced origin was a by-product of kernel
18 # commit 31747eda41ef ("ovl: hash directory inodes for fsnotify")
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
26 status=1 # failure is the default!
27 trap "_cleanup; exit \$status" 0 1 2 3 15
35 # Rename lower file to create copy up with origin xattr
40 touch $lowerdir/origin
42 # Enabling redirect_dir may seem irrelevant to rename of non-dir,
43 # but with upcoming 'metacopy' feature, redirects will be set also
44 # on non-dir and may also create multiple redirects.
45 _scratch_mount -o redirect_dir=on
46 mv $SCRATCH_MNT/origin $SCRATCH_MNT/$ref
48 $UMOUNT_PROG $SCRATCH_MNT
51 # get standard environment, filters and checks
57 # real QA test starts here
59 _require_scratch_nocheck
60 _require_scratch_feature redirect_dir
62 # remove all files from previous runs
65 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
66 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
68 # Create copied up file with origin xattr
69 create_origin_ref ref1
70 # Duplicate the copied up file
71 cp -a $upperdir/ref1 $upperdir/ref2
73 # Diverge the content of the two copies of file
74 # and the content of two copies of redirected dir
75 echo right >> $upperdir/ref1
76 echo wrong >> $upperdir/ref2
78 _scratch_mount -o redirect_dir=on
80 # If both copies of file use the same st_dev/st_ino in overlay
81 # diff won't detect that their content differs
82 diff -q $SCRATCH_MNT/ref1 $SCRATCH_MNT/ref2 &>/dev/null && \
83 echo "diff on duplicated upper files doesn't know right from wrong!"
86 echo "Silence is golden"