overlay/038: test consistent values of st_ino/d_ino for subdirs
authorChandan Rajendra <chandan@linux.vnet.ibm.com>
Mon, 20 Nov 2017 14:34:10 +0000 (20:04 +0530)
committerEryu Guan <eguan@redhat.com>
Sun, 26 Nov 2017 07:38:55 +0000 (15:38 +0800)
This commit implements similar changes made to overlay/038 test i.e. in
addition to checking consistent values of st_ino/d_ino for "."  and ".."
entries, check also the values for subdir inside each tested directory
setup.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
tests/overlay/038

index ef28f9ba45b03c4c5e24fb712cfc063ed1a82511..bd87156c8205e083ea735da6289c5c738b9d4cab 100755 (executable)
@@ -59,7 +59,7 @@ upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
 mkdir -p $lowerdir
 
 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
 mkdir -p $lowerdir
 
-mkdir -p $lowerdir/test_dir/pure_lower_dir
+mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
 
 touch $lowerdir/test_file
 
 
 touch $lowerdir/test_file
 
@@ -69,10 +69,11 @@ test_dir=$SCRATCH_MNT/test_dir/
 
 # Verify d_ino of '.' and '..' before and after dir becomes impure.
 impure_dir=$test_dir/impure_dir
 
 # Verify d_ino of '.' and '..' before and after dir becomes impure.
 impure_dir=$test_dir/impure_dir
-mkdir -p $impure_dir
+mkdir -p $impure_dir/subdir
 
 impure_dir_st_ino=$(stat -c '%i' $impure_dir)
 impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
 
 impure_dir_st_ino=$(stat -c '%i' $impure_dir)
 impure_dir_parent_st_ino=$(stat -c '%i' $test_dir)
+impure_subdir_st_ino=$(stat -c '%i' $impure_dir/subdir)
 
 # Before $impure_dir becomes impure
 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
 
 # Before $impure_dir becomes impure
 parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
@@ -83,6 +84,10 @@ current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
 [[ $current_d == ". d" ]] || \
     echo "Pure upper dir: Invalid d_ino reported for ."
 
 [[ $current_d == ". d" ]] || \
     echo "Pure upper dir: Invalid d_ino reported for ."
 
+subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
+[[ $subdir_d == "subdir d" ]] || \
+    echo "Pure upper dir: Invalid d_ino reported for subdir"
+
 # Move a copied up file into pure dir to make it impure
 mv $SCRATCH_MNT/test_file $impure_dir
 test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
 # Move a copied up file into pure dir to make it impure
 mv $SCRATCH_MNT/test_file $impure_dir
 test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
@@ -100,6 +105,10 @@ current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
 [[ $current_d == ". d" ]] || \
     echo "Impure dir: Invalid d_ino reported for ."
 
 [[ $current_d == ". d" ]] || \
     echo "Impure dir: Invalid d_ino reported for ."
 
+subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
+[[ $subdir_d == "subdir d" ]] || \
+    echo "Impure dir: Invalid d_ino reported for subdir"
+
 # 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" ]] || \
 # 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" ]] || \
@@ -107,19 +116,23 @@ file_d=$($here/src/t_dir_type $impure_dir $test_file_st_ino)
 
 # Make $impure_dir pure
 rm -rf $impure_dir/test_file
 
 # Make $impure_dir pure
 rm -rf $impure_dir/test_file
+rm -rf $impure_dir/subdir
 
 # Verify invalidation of readdir cache
 $here/src/t_dir_type $impure_dir $test_file_st_ino
 [[ $? != 0 ]] || echo "Directory's readdir cache has stale file entries"
 
 # Verify invalidation of readdir cache
 $here/src/t_dir_type $impure_dir $test_file_st_ino
 [[ $? != 0 ]] || echo "Directory's readdir cache has stale file entries"
+$here/src/t_dir_type $impure_dir $impure_subdir_st_ino
+[[ $? != 0 ]] || echo "Directory's readdir cache has stale subdir 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"
 
 
 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 of '.' and '..' before and after dir becomes merge dir.
+# Verify d_ino values of subdir entries of a pure lower dir.
 parent_st_ino=$(stat -c '%i' $test_dir)
 pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir
 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
 parent_st_ino=$(stat -c '%i' $test_dir)
 pure_lower_dir=$SCRATCH_MNT/test_dir/pure_lower_dir
 pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
+pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
 
 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
 [[ $parent_d == ".. d" ]] || \
 
 parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
 [[ $parent_d == ".. d" ]] || \
@@ -129,6 +142,10 @@ 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 ."
 
 [[ $current_d == ". d" ]] || \
        echo "Pure lower dir: Invalid d_ino reported for ."
 
+subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
+[[ $subdir_d == "subdir d" ]] || \
+       echo "Pure lower dir: Invalid d_ino reported for subdir"
+
 # Create a file in pure lower dir to make it a merge dir
 touch $pure_lower_dir/newfile
 
 # Create a file in pure lower dir to make it a merge dir
 touch $pure_lower_dir/newfile
 
@@ -140,6 +157,10 @@ current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
 [[ $current_d == ". d" ]] || \
        echo "Merged dir: Invalid d_ino reported for ."
 
 [[ $current_d == ". d" ]] || \
        echo "Merged dir: Invalid d_ino reported for ."
 
+subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
+[[ $subdir_d == "subdir d" ]] || \
+       echo "Merged dir: Invalid d_ino reported for subdir"
+
 _scratch_unmount
 
 # Verify pure lower residing in dir which has another lower layer
 _scratch_unmount
 
 # Verify pure lower residing in dir which has another lower layer
@@ -158,8 +179,7 @@ mkdir -p $lowerdir
 mkdir -p $upperdir
 mkdir -p $workdir
 
 mkdir -p $upperdir
 mkdir -p $workdir
 
-mkdir -p $middir/test_dir
-mkdir -p $lowerdir/test_dir/pure_lower_dir
+mkdir -p $lowerdir/test_dir/pure_lower_dir/subdir
 
 _overlay_scratch_mount_dirs "$middir:$lowerdir" $upperdir $workdir
 
 
 _overlay_scratch_mount_dirs "$middir:$lowerdir" $upperdir $workdir
 
@@ -168,10 +188,19 @@ touch $test_dir/test_file
 
 test_dir_st_ino=$(stat -c '%i' $test_dir)
 pure_lower_dir=$test_dir/pure_lower_dir
 
 test_dir_st_ino=$(stat -c '%i' $test_dir)
 pure_lower_dir=$test_dir/pure_lower_dir
+pure_lower_dir_st_ino=$(stat -c '%i' $pure_lower_dir)
+pure_lower_subdir_st_ino=$(stat -c '%i' $pure_lower_dir/subdir)
 
 parent_d=$($here/src/t_dir_type $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 .."
 
 parent_d=$($here/src/t_dir_type $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 .."
+current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
+[[ $current_d == ". d" ]] || \
+       echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for ."
+
+subdir_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_subdir_st_ino)
+[[ $subdir_d == "subdir d" ]] || \
+       echo "Pure lower in dir which has another lower layer: Invalid d_ino reported for subdir"
 
 echo "Silence is golden"
 status=0
 
 echo "Silence is golden"
 status=0