* [PATCH V4] overlay: Test constant d_ino feature
@ 2017-09-03 8:40 Chandan Rajendra
2017-09-03 10:02 ` Amir Goldstein
0 siblings, 1 reply; 3+ messages in thread
From: Chandan Rajendra @ 2017-09-03 8:40 UTC (permalink / raw)
To: amir73il, eguan; +Cc: Chandan Rajendra, fstests, miklos, linux-unionfs
This commit adds a test to verify constant d_ino feature. The following
scenarios are checked,
- Parent's (i.e. "..") d_ino must always be calculated because a pure
dir can be residing inside a merged dir.
- d_ino for "." must always be calculated because the present directory
can have a copy-up origin.
- Verify d_ino of '.' and '..' before and after dir becomes
impure. While at it also verify if trusted.overlay.impure xattr is
set/reset appropriately and invalidation of readdir cache.
- Verify copied up file's (inside a impure dir) d_ino.
- Verify d_ino values corresponding to "." and ".." entries of a pure
lower dir.
- Verify d_ino of ".." entry of a merged dir.
- Verify pure lower residing in dir which has another lower layer
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
Changelog:
v3->v4:
1. Fix error handling as suggested by Amir.
2. Use sane variable names for "Verify pure lower residing in dir which has
another lower layer" test.
v2->v3:
1. Add the following new test scenarios.
- Verify d_ino of '.' and '..' before and after dir becomes impure.
- Verify copied up file's (inside a impure dir) d_ino.
2. For the "Verify pure lower residing in dir which has another lower layer"
test, use sane variable names.
Once again, Thanks to Amir for his suggestions.
v1->v2:
1. Removed tests copied over from overlay/017.
2. Removed src/t_dir_ino.c.
3. Add code for testing,
- d_ino of . and .. entries of pure_lower_dir.
- d_ino of .. entry of merged_dir.
- Verify pure lower residing in dir which has another lower layer.
Thanks to Amir for suggesting these tests.
tests/overlay/038 | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/overlay/038.out | 2 +
tests/overlay/group | 1 +
3 files changed, 197 insertions(+)
create mode 100755 tests/overlay/038
create mode 100644 tests/overlay/038.out
diff --git a/tests/overlay/038 b/tests/overlay/038
new file mode 100755
index 0000000..e11539a
--- /dev/null
+++ b/tests/overlay/038
@@ -0,0 +1,194 @@
+#! /bin/bash
+# FSQA Test No. 038
+#
+# Test constant d_ino numbers
+#
+#-----------------------------------------------------------------------
+#
+# Copyright (C) 2017 IBM Corporation. All Rights Reserved.
+# Author: Chandan Rajendra <chandan@linux.vnet.ibm.com>
+#
+# 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
+
+# real QA test starts here
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_test_program "af_unix"
+_require_test_program "t_dir_type"
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+
+# Create our test files.
+upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
+mkdir -p $lowerdir
+
+mkdir $lowerdir/test_dir/
+mkdir $lowerdir/test_dir/pure_lower_dir
+mkdir $lowerdir/test_dir/merged_dir
+
+touch $lowerdir/test_file
+
+_scratch_mount
+
+test_dir=$SCRATCH_MNT/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 $SCRATCH_MNT/test_file
+test_file_st_ino=$(stat -c '%i' $SCRATCH_MNT/test_file)
+
+mv $SCRATCH_MNT/test_file $impure_dir
+
+$GETFATTR_PROG --absolute-names -n 'trusted.overlay.impure' \
+ $upperdir/test_dir/impure_dir >>$seqres.full 2>&1
+[[ $? == 0 ]] || 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"
+
+$GETFATTR_PROG --absolute-names -n 'trusted.overlay.impure' \
+ $upperdir/test_dir/impure_dir >>$seqres.full 2>&1
+[[ $? == 0 ]] && 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' $SCRATCH_MNT/test_dir)
+pure_lower_dir=$SCRATCH_MNT/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=$SCRATCH_MNT/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 .."
+
+_scratch_unmount
+
+# Verify pure lower residing in dir which has another lower layer
+_scratch_mkfs
+
+OVL_LOWER0=${OVL_LOWER}0
+OVL_LOWER1=${OVL_LOWER}1
+
+middir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER0
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER1
+upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
+workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK
+
+mkdir -p $middir
+mkdir -p $lowerdir
+mkdir -p $upperdir
+mkdir -p $workdir
+
+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 $SCRATCH_MNT
+
+# Copy up test_dir
+touch $SCRATCH_MNT/test_dir/test_file
+
+test_dir_st_ino=$(stat -c '%i' $SCRATCH_MNT/test_dir)
+
+parent_d=$($here/src/t_dir_type $SCRATCH_MNT/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 $SCRATCH_MNT
+
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/overlay/038.out b/tests/overlay/038.out
new file mode 100644
index 0000000..5e0f13e
--- /dev/null
+++ b/tests/overlay/038.out
@@ -0,0 +1,2 @@
+QA output created by 038
+Silence is golden
diff --git a/tests/overlay/group b/tests/overlay/group
index 28f1e63..ac66bc7 100644
--- a/tests/overlay/group
+++ b/tests/overlay/group
@@ -40,3 +40,4 @@
035 auto quick mount
036 auto quick mount
037 auto quick mount
+038 auto quick copyup
--
2.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V4] overlay: Test constant d_ino feature
2017-09-03 8:40 [PATCH V4] overlay: Test constant d_ino feature Chandan Rajendra
@ 2017-09-03 10:02 ` Amir Goldstein
2017-09-03 12:58 ` Chandan Rajendra
0 siblings, 1 reply; 3+ messages in thread
From: Amir Goldstein @ 2017-09-03 10:02 UTC (permalink / raw)
To: Chandan Rajendra; +Cc: Eryu Guan, fstests, Miklos Szeredi, overlayfs
On Sun, Sep 3, 2017 at 11:40 AM, Chandan Rajendra
<chandan@linux.vnet.ibm.com> wrote:
> This commit adds a test to verify constant d_ino feature. The following
> scenarios are checked,
> - Parent's (i.e. "..") d_ino must always be calculated because a pure
> dir can be residing inside a merged dir.
> - d_ino for "." must always be calculated because the present directory
> can have a copy-up origin.
> - Verify d_ino of '.' and '..' before and after dir becomes
> impure. While at it also verify if trusted.overlay.impure xattr is
> set/reset appropriately and invalidation of readdir cache.
> - Verify copied up file's (inside a impure dir) d_ino.
> - Verify d_ino values corresponding to "." and ".." entries of a pure
> lower dir.
> - Verify d_ino of ".." entry of a merged dir.
> - Verify pure lower residing in dir which has another lower layer
>
> Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> ---
> Changelog:
> v3->v4:
> 1. Fix error handling as suggested by Amir.
> 2. Use sane variable names for "Verify pure lower residing in dir which has
> another lower layer" test.
>
...
> +# 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"
> +
> +$GETFATTR_PROG --absolute-names -n 'trusted.overlay.impure' \
> + $upperdir/test_dir/impure_dir >>$seqres.full 2>&1
> +[[ $? == 0 ]] && echo "Pure directory has impure xattr"
> +
Sorry, I overlooked a few things in v3:
1. Why did I say use && echo here I'm not sure. looking again feels
much better to conform to all other tests
2. I wanted to write and forgot that you need _require_attrs and
include common/attr
3. This test is using double brackets [[ == comparison all around,
which apparently
saves the need to surround left side in quotes "". This seems to
be recommended
so I have no objection. Just pointing out to Eryu in case he has
reservations.
Amir.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V4] overlay: Test constant d_ino feature
2017-09-03 10:02 ` Amir Goldstein
@ 2017-09-03 12:58 ` Chandan Rajendra
0 siblings, 0 replies; 3+ messages in thread
From: Chandan Rajendra @ 2017-09-03 12:58 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Eryu Guan, fstests, Miklos Szeredi, overlayfs
On Sunday, September 3, 2017 3:32:11 PM IST Amir Goldstein wrote:
> On Sun, Sep 3, 2017 at 11:40 AM, Chandan Rajendra
> <chandan@linux.vnet.ibm.com> wrote:
> > This commit adds a test to verify constant d_ino feature. The following
> > scenarios are checked,
> > - Parent's (i.e. "..") d_ino must always be calculated because a pure
> > dir can be residing inside a merged dir.
> > - d_ino for "." must always be calculated because the present directory
> > can have a copy-up origin.
> > - Verify d_ino of '.' and '..' before and after dir becomes
> > impure. While at it also verify if trusted.overlay.impure xattr is
> > set/reset appropriately and invalidation of readdir cache.
> > - Verify copied up file's (inside a impure dir) d_ino.
> > - Verify d_ino values corresponding to "." and ".." entries of a pure
> > lower dir.
> > - Verify d_ino of ".." entry of a merged dir.
> > - Verify pure lower residing in dir which has another lower layer
> >
> > Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
> > ---
> > Changelog:
> > v3->v4:
> > 1. Fix error handling as suggested by Amir.
> > 2. Use sane variable names for "Verify pure lower residing in dir which has
> > another lower layer" test.
> >
> ...
> > +# 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"
> > +
> > +$GETFATTR_PROG --absolute-names -n 'trusted.overlay.impure' \
> > + $upperdir/test_dir/impure_dir >>$seqres.full 2>&1
> > +[[ $? == 0 ]] && echo "Pure directory has impure xattr"
> > +
>
> Sorry, I overlooked a few things in v3:
> 1. Why did I say use && echo here I'm not sure. looking again feels
> much better to conform to all other tests
Right. I will fix it up.
> 2. I wanted to write and forgot that you need _require_attrs and
> include common/attr
I will add these lines.
> 3. This test is using double brackets [[ == comparison all around,
> which apparently
> saves the need to surround left side in quotes "". This seems to
> be recommended
> so I have no objection. Just pointing out to Eryu in case he has
> reservations.
--
chandan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-03 12:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-03 8:40 [PATCH V4] overlay: Test constant d_ino feature Chandan Rajendra
2017-09-03 10:02 ` Amir Goldstein
2017-09-03 12:58 ` Chandan Rajendra
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.