Consistent d_ino test for non-samefs setup
PATCH v2 1/1 Consistent d_ino test for non-samefs setup
---
Changelog:v1->v2:
Address the following review comments from Amir.
1. overlay/041 now uses _overlay_scratch_mount_dirs() introduced by the patch "overlay: create helper _overlay_scratch_mount_dirs()".
2. Use _scratch_mkfs() instead of manually setting of the base filesystem.
3. Use a directory in $OVL_BASE_TEST_DIR as the overlay instance's lowerdir.
4. Remove redundant invocation of "chown" operation on a regular file to cause copy-up to occur.
tests/overlay/041 | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/041.out | 2 + tests/overlay/group | 1 + 3 files changed, 200 insertions(+) create mode 100755 tests/overlay/041 create mode 100644 tests/overlay/041.out
tests/overlay/041 new file +197 -0
@@ -0,0 +1,197 @@ +#! /bin/bash +# FSQA Test No. 041 +# +# Test consistent d_ino numbers on non-samefs setup +# This is a variant of overlay/038 to test consistent d_ino numbers +# for 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 + +lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower +rm -rf $lowerdir +mkdir $lowerdir + +# 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 + +_scratch_mkfs + +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir + +# mount | grep -i overlay +# echo "\$SCRATCH_MNT = $SCRATCH_MNT" +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 ." + + +mv $SCRATCH_MNT/test_file $impure_dir +test_file_st_ino=$(stat -c '%i' $impure_dir/test_file) + +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' $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 .." + +_overlay_scratch_unmount + +# Verify pure lower residing in dir which has another lower layer +middir=$OVL_BASE_TEST_DIR/$seq-ovl-mid +lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower +rm -rf $middir +rm -rf $lowerdir +mkdir $middir +mkdir $lowerdir + +mkdir -p $middir/test_dir +mkdir -p $lowerdir/test_dir/pure_lower_dir + +_scratch_mkfs + +upperdir=$OVL_BASE_SCRATCH_MNT/ovl-upper +workdir=$OVL_BASE_SCRATCH_MNT/ovl-work + +_overlay_scratch_mount_dirs $middir:$lowerdir $upperdir $workdir + +# 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 .." + +_overlay_scratch_unmount + +echo "Silence is golden" +status=0 +exit
tests/overlay/041.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 041 +Silence is golden
tests/overlay/group +1 -0
@@ -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
Quoted 7 lines · Chandan Rajendra
Signed-off-by Chandan Rajendra <[email protected]>---
Changelog:v1->v2:
Address the following review comments from Amir.
1. overlay/041 now uses_overlay_scratch_mount_dirs()introduced by the patch "overlay: create helper_overlay_scratch_mount_dirs()".
Just to mention explicitly to eryu this depends on a not yet merged patch on mine
Quoted 84 lines
2. Use
_scratch_mkfs()instead of manually setting of the base filesystem.
3. Use a directory in $OVL_BASE_TEST_DIR as the overlay instance's lowerdir.
4. Remove redundant invocation of "chown" operation on a regular file to cause copy-up to occur.tests/overlay/041 | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/041.out | 2 + tests/overlay/group | 1 + 3 files changed, 200 insertions(+) create mode 100755 tests/overlay/041 create mode 100644 tests/overlay/041.outtests/overlay/041 new file +66
-0@@ -0,0 +1,197 @@ +#! /bin/bash +# FSQA Test No. 041 +# +# Test consistent d_ino numbers on non-samefs setup +# This is a variant of overlay/038 to test consistent d_ino numbers +# for 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 + +lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower +rm -rf $lowerdir +mkdir $lowerdir + +# 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
tests/overlay/041 line 76
Quoted 10 lines
tests/overlay/041 new file +10
-0+ +_scratch_mkfs + +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir + +# mount | grep -i overlay +# echo "\$SCRATCH_MNT = $SCRATCH_MNT"
Leftover
Quoted 107 lines
tests/overlay/041 new file +107
-0+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 ." + + +mv $SCRATCH_MNT/test_file $impure_dir +test_file_st_ino=$(stat -c '%i' $impure_dir/test_file) + +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' $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 .." + +_overlay_scratch_unmount + +# Verify pure lower residing in dir which has another lower layer +middir=$OVL_BASE_TEST_DIR/$seq-ovl-mid +lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower +rm -rf $middir +rm -rf $lowerdir +mkdir $middir +mkdir $lowerdir + +mkdir -p $middir/test_dir +mkdir -p $lowerdir/test_dir/pure_lower_dir + +_scratch_mkfs + +upperdir=$OVL_BASE_SCRATCH_MNT/ovl-upper +workdir=$OVL_BASE_SCRATCH_MNT/ovl-work + +_overlay_scratch_mount_dirs $middir:$lowerdir $upperdir $workdir +
tests/overlay/041 line 193
Quoted 10 lines
tests/overlay/041 new file +10
-0+# 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 .." + +_overlay_scratch_unmount
Umount of scratch not really needed at end of test but it's fine
Quoted 24 lines
tests/overlay/041 new file +4
-0+ +echo "Silence is golden" +status=0 +exittests/overlay/041.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 041 +Silence is goldentests/overlay/group +1
-1@@ -43,3 +43,4 @@ 038 auto quick copyup 039 auto quick atime 040 auto quick +041 auto quick copyup --2.9.5
Quoted 101 lines · IST Amir Goldstein
Quoted 7 lines · Chandan Rajendra
Signed-off-by Chandan Rajendra <[email protected]>---
Changelog:v1->v2:
Address the following review comments from Amir.
1. overlay/041 now uses_overlay_scratch_mount_dirs()introduced by the patch "overlay: create helper_overlay_scratch_mount_dirs()".Just to mention explicitly to eryu this depends on a not yet merged patch on mine
Quoted 88 lines
2. Use
_scratch_mkfs()instead of manually setting of the base filesystem.
3. Use a directory in $OVL_BASE_TEST_DIR as the overlay instance's lowerdir.
4. Remove redundant invocation of "chown" operation on a regular file to cause copy-up to occur.tests/overlay/041 | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/041.out | 2 + tests/overlay/group | 1 + 3 files changed, 200 insertions(+) create mode 100755 tests/overlay/041 create mode 100644 tests/overlay/041.outtests/overlay/041 new file +70
-0@@ -0,0 +1,197 @@ +#! /bin/bash +# FSQA Test No. 041 +# +# Test consistent d_ino numbers on non-samefs setup +# This is a variant of overlay/038 to test consistent d_ino numbers +# for 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 + +lowerdir=$OVL_BASE_TEST_DIR/$seq-ovl-lower +rm -rf $lowerdir +mkdir $lowerdir + +# 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 + +_scratch_mkfs + +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
Quoted 9 lines
tests/overlay/041 line 76
Quoted 6 lines
tests/overlay/041 new file +6
-0+workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +_overlay_scratch_mount_dirs $lowerdir $upperdir $workdir + +# mount | grep -i overlay +# echo "\$SCRATCH_MNT = $SCRATCH_MNT"Leftover
Sorry, I will post the next version of the patch with those statements removed.
Thanks once again for reviewing the patch.
Signature · 1 line
chandan
Quoted 1 line · Chandan Rajendra
Signed-off-by Chandan Rajendra <[email protected]>
Can you please describe the test, what bug it's addressing, what a "non-samefs" configuration is, etc in the commit message?
I've got absolutely no clue what this test is actually trying to exercise, and I doubt anyone not intimately familiar with overlay has any idea, either...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 6 lines · Dave Chinner
Quoted 1 line · Chandan Rajendra
Signed-off-by Chandan Rajendra <[email protected]>Can you please describe the test, what bug it's addressing, what a "non-samefs" configuration is, etc in the commit message?
Chandan I suggest that you include the elaborate description That was part of 038 commit message in both test descriptions.
To be clear, please State the goal of this test is to verify that Inode numbers returned by readdir d_ino are consistent with Inode numbers returned by stat st_ino in all the listed cases.
Quoted 10 lines
I've got absolutely no clue what this test is actually trying to exercise, and I doubt anyone not intimately familiar with overlay has any idea, either...
Cheers,
Dave.
--
Dave Chinner
[email protected]