Skip to contentSkip to conversation

constant d_ino test for non-samefs setup

PATCH Superseded Chandan Rajendra 2 participants 2 messages Oct 6, 2017

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 constant d_ino test for non-samefs setup

---
 tests/overlay/041     | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/041.out |   2 +
 tests/overlay/group   |   1 +
 3 files changed, 213 insertions(+)
 create mode 100755 tests/overlay/041
 create mode 100644 tests/overlay/041.out
tests/overlay/041 new file +210 -0
new file mode 100755
index 0000000..b992346
@@ -0,0 +1,210 @@
+#! /bin/bash
+# FSQA Test No. 041
+#
+# Test constant d_ino numbers on non-samefs setup
+#
+#-----------------------------------------------------------------------
+#
+# Copyright (C) 2017 IBM Corporation. All Rights Reserved.
+# Author: Chandan Rajendra <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_test
+_require_attrs
+_require_test_program "t_dir_type"
+
+rm -f $seqres.full
+
+_scratch_unmount &>>$seqres.full
+_test_unmount &>>$seqres.full
+
+$MOUNT_PROG $OVL_BASE_SCRATCH_DEV $OVL_BASE_SCRATCH_MNT
+$MOUNT_PROG $OVL_BASE_TEST_DEV $OVL_BASE_TEST_DIR
+
+rm -rf $OVL_BASE_SCRATCH_MNT/*
+rm -rf $OVL_BASE_TEST_DIR/*
+
+lowerdir=$OVL_BASE_TEST_DIR/ovl-lower
+upperdir=$OVL_BASE_SCRATCH_MNT/ovl-upper
+workdir=$OVL_BASE_SCRATCH_MNT/ovl-work
+ovlmnt=$OVL_BASE_SCRATCH_MNT/ovl-mnt
+
+mkdir $lowerdir
+mkdir $upperdir
+mkdir $workdir
+mkdir $ovlmnt
+
+# Create our test files.
+mkdir $lowerdir/test_dir/
+mkdir $lowerdir/test_dir/pure_lower_dir
+mkdir $lowerdir/test_dir/merged_dir
+
+touch $lowerdir/test_file
+
+$MOUNT_PROG -t overlay overlay -o lowerdir=$lowerdir \
+	    -o upperdir=$upperdir -o workdir=$workdir $ovlmnt
+
+test_dir=$ovlmnt/test_dir/
+merged_dir=$test_dir/merged_dir
+pure_upper_dir=$merged_dir/pure_upper_dir
+
+mkdir -p $pure_upper_dir
+
+merged_dir_st_ino=$(stat -c '%i' $merged_dir)
+
+# Pure dir's parent d_ino must always be calculated because
+# it can be residing inside a merged dir.
+parent_d=$($here/src/t_dir_type $pure_upper_dir $merged_dir_st_ino)
+[[ $parent_d == ".. d" ]] || \
+	echo "Pure dir inside a merged dir: Invalid d_ino reported for .."
+
+# d_ino for "." must always be calculated because the present
+# directory can have a copy-up origin.
+current_d=$($here/src/t_dir_type $merged_dir $merged_dir_st_ino)
+[[ $current_d == ". d" ]] || echo "Merged dir: Invalid d_ino reported for ."
+
+# Verify d_ino of '.' and '..' before and after dir becomes impure.
+impure_dir=$test_dir/impure_dir
+mkdir -p $impure_dir
+
+impure_dir_st_ino=$(stat -c '%i' $impure_dir)
+impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
+
+# Before $impure_dir becomes impure
+parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
+[[ $parent_d == ".. d" ]] || \
+    echo "Before dir becomes impure: Invalid d_ino reported for .."
+
+current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
+[[ $current_d == ". d" ]] || \
+    echo "Before dir becomes impure: Invalid d_ino reported for ."
+
+chown -h 100 $ovlmnt/test_file
+test_file_st_ino=$(stat -c '%i' $ovlmnt/test_file)
+
+mv $ovlmnt/test_file $impure_dir
+
+impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
+			$upperdir/test_dir/impure_dir)
+[[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
+
+# After $impure_dir becomes impure
+parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
+[[ $parent_d == ".. d" ]] || \
+    echo "After dir becomes impure: Invalid d_ino reported for .."
+
+current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
+[[ $current_d == ". d" ]] || \
+    echo "After dir becomes impure: Invalid d_ino reported for ."
+
+# Verify copy up file's d_ino
+file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino)
+[[ $file_d == "test_file f" ]] || \
+	echo "Impure dir: Invalid d_ino reported for entry with copy-up origin"
+
+# Make $impure_dir pure
+rm -rf $impure_dir/test_file
+
+# Verify invalidation of readdir cache
+$here/src/t_dir_type $impure_dir $test_file_st_ino
+[[ $? != 0 ]] || echo "Directory's readdir cache has stale entries"
+
+impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
+			$upperdir/test_dir/impure_dir 2>/dev/null)
+[[ -z $impure ]] || echo "Pure directory has impure xattr"
+
+# Verify d_ino values corresponding to "." and ".." entries of a
+# pure lower dir.
+parent_st_ino=$(stat -c '%i' $ovlmnt/test_dir)
+pure_lower_dir=$ovlmnt/test_dir/pure_lower_dir
+
+parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
+[[ $parent_d == ".. d" ]] || echo "Pure lower dir: Invalid d_ino reported for .."
+
+pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
+
+current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
+[[ $current_d == ". d" ]] || echo "Pure lower dir: Invalid d_ino reported for ."
+
+# Verify d_ino of ".." entry of a merged dir.
+merged_dir=$ovlmnt/test_dir/merged_dir
+
+parent_d=$($here/src/t_dir_type $merged_dir $parent_st_ino)
+[[ $parent_d == ".. d" ]] || echo "Merged dir: Invalid d_ino reported for .."
+
+$UMOUNT_PROG $ovlmnt
+
+# Verify pure lower residing in dir which has another lower layer
+rm -rf $OVL_BASE_SCRATCH_MNT/*
+rm -rf $OVL_BASE_TEST_DIR/*
+
+middir=$OVL_BASE_TEST_DIR/ovl-lower0
+lowerdir=$OVL_BASE_TEST_DIR/ovl-lower1
+upperdir=$OVL_BASE_SCRATCH_MNT/ovl-upper
+workdir=$OVL_BASE_SCRATCH_MNT/ovl-work
+ovlmnt=$OVL_BASE_SCRATCH_MNT/ovl-mnt
+
+mkdir -p $middir
+mkdir -p $lowerdir
+mkdir -p $upperdir
+mkdir -p $workdir
+mkdir -p $ovlmnt
+
+mkdir -p $middir/test_dir
+mkdir -p $lowerdir/test_dir/pure_lower_dir
+
+$MOUNT_PROG -t overlay overlay -o lowerdir=$middir:$lowerdir \
+	    -o upperdir=$upperdir -o workdir=$workdir $ovlmnt
+
+# Copy up test_dir
+touch $ovlmnt/test_dir/test_file
+
+test_dir_st_ino=$(stat -c '%i' $ovlmnt/test_dir)
+
+parent_d=$($here/src/t_dir_type $ovlmnt/test_dir/pure_lower_dir $test_dir_st_ino)
+[[ $parent_d == ".. d" ]] || \
+	echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for .."
+
+$UMOUNT_PROG $ovlmnt
+
+echo "Silence is golden"
+status=0
+exit
tests/overlay/041.out new file +2 -0
new file mode 100644
index 0000000..04f5bf1
@@ -0,0 +1,2 @@
+QA output created by 041
+Silence is golden
tests/overlay/group +1 -0
index 022f2ef..89f6325 100644
@@ -43,3 +43,4 @@
 038 auto quick copyup
 039 auto quick atime
 040 auto quick
+041 auto quick copyup
Signature · 1 line
2.9.5
#1 lore raw
Quoted 15 lines · Chandan Rajendra
---
 tests/overlay/041     | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/overlay/041.out |   2 +
 tests/overlay/group   |   1 +
 3 files changed, 213 insertions(+)
 create mode 100755 tests/overlay/041
 create mode 100644 tests/overlay/041.out
tests/overlay/041 new file +0 -0
new file mode 100755
index 0000000..b992346

tests/overlay/041 line 4

Quoted 4 lines
tests/overlay/041 new file +4 -0
@@ -0,0 +1,210 @@
+#! /bin/bash
+# FSQA Test No. 041
+#
+# Test constant d_ino numbers on non-samefs setup

Chandan,

Some of my comments may also apply to the origin 038 test, which I missed in review, starting with the description of the test - "Test constant d_ino numbers" is not really what this test does, what it really does is "Test consistent d_ino/st_ino numbers"

Also, please note in description that this is a variant of test 038, so if someone fixes this test, they will know to fix the origin as well.

BTW, it would be good, when you are done with this test to also add a test for "Test constant inode numbers on non-samefs setup", a variant of overlay/017, which also checks the st_dev assertions.
I know you wrote these tests for unionmount testsuite, but an xfstest has greater value.

...

tests/overlay/041 line 60

Quoted 6 lines
tests/overlay/041 new file +6 -0
+
+_scratch_unmount &>>$seqres.full
+_test_unmount &>>$seqres.full
+
+$MOUNT_PROG $OVL_BASE_SCRATCH_DEV $OVL_BASE_SCRATCH_MNT
+$MOUNT_PROG $OVL_BASE_TEST_DEV $OVL_BASE_TEST_DIR

FYI, OVL_BASE_SCRATCH_DEV/OVL_BASE_TEST_DEV may not be configured at all. Doesn't matter because you shouldn't be using those commands anyway (see below)

tests/overlay/041 line 64

Quoted 4 lines
tests/overlay/041 new file +4 -0
+
+rm -rf $OVL_BASE_SCRATCH_MNT/*
+rm -rf $OVL_BASE_TEST_DIR/*
+

Wiping out TEST_DIR is not playing by the rules.
Tests should not format TEST partition.
You can either use tmpfs for lower dir, like some other tests do or you can use a directory in BASE_TEST_DIR for lower dir, for example:
lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower
rm -rf $lowerdir

tests/overlay/041 line 74

Quoted 10 lines
tests/overlay/041 new file +10 -0
+lowerdir=$OVL_BASE_TEST_DIR/ovl-lower
+upperdir=$OVL_BASE_SCRATCH_MNT/ovl-upper
+workdir=$OVL_BASE_SCRATCH_MNT/ovl-work
+ovlmnt=$OVL_BASE_SCRATCH_MNT/ovl-mnt
+
+mkdir $lowerdir
+mkdir $upperdir
+mkdir $workdir
+mkdir $ovlmnt
+

All of the operations above with SCRATCH partition beginning with _scratch_unmount should be replaced with a single command that does exactly what you re-implemented:

_scratch_mkfs

tests/overlay/041 line 84

Quoted 10 lines
tests/overlay/041 new file +10 -0
+# Create our test files.
+mkdir $lowerdir/test_dir/
+mkdir $lowerdir/test_dir/pure_lower_dir
+mkdir $lowerdir/test_dir/merged_dir
+
+touch $lowerdir/test_file
+
+$MOUNT_PROG -t overlay overlay -o lowerdir=$lowerdir \
+           -o upperdir=$upperdir -o workdir=$workdir $ovlmnt
+

This should be using _overlay_mount_dirs()
I already fixed this for overlay/038 on my overlayfs-devel branch that was posted for review last week.

...

tests/overlay/041 line 36

Quoted 2 lines
tests/overlay/041 new file +2 -0
+
+chown -h 100 $ovlmnt/test_file

This chown looks like a leftover from test overlay/017 Not sure what is the role it is playing in this test, unless I am missing something (mv will already copy up test_file). Same comment applies to test 038.

tests/overlay/041 line 124

Quoted 4 lines
tests/overlay/041 new file +4 -0
+test_file_st_ino=$(stat -c '%i' $ovlmnt/test_file)
+
+mv $ovlmnt/test_file $impure_dir
+

Thanks,
Amir.