Files
apfstests/tests/overlay/038
T

216 lines
6.9 KiB
Bash
Raw Normal View History

2017-09-03 18:43:09 +05:30
#! /bin/bash
# FSQA Test No. 038
#
2017-10-08 16:55:35 +05:30
# Test consistent d_ino numbers for samefs setup.
2017-09-03 18:43:09 +05:30
#
#-----------------------------------------------------------------------
#
# 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
. ./common/attr
# real QA test starts here
_supported_fs overlay
_supported_os Linux
2018-03-01 20:13:47 +08:00
# Use non-default scratch underlying overlay dirs, we need to check
# them explicity after test.
_require_scratch_nocheck
2017-09-03 18:43:09 +05:30
_require_attrs
_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 -p $lowerdir/test_dir/pure_lower_dir/subdir
2017-09-03 18:43:09 +05:30
touch $lowerdir/test_file
_scratch_mount
test_dir=$SCRATCH_MNT/test_dir/
# Verify d_ino of '.' and '..' before and after dir becomes impure.
impure_dir=$test_dir/impure_dir
mkdir -p $impure_dir/subdir
2017-09-03 18:43:09 +05:30
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)
2017-09-03 18:43:09 +05:30
# Before $impure_dir becomes impure
parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
[[ $parent_d == ".. d" ]] || \
2017-11-20 20:04:09 +05:30
echo "Pure upper dir: Invalid d_ino reported for .."
2017-09-03 18:43:09 +05:30
current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
[[ $current_d == ". d" ]] || \
2017-11-20 20:04:09 +05:30
echo "Pure upper dir: Invalid d_ino reported for ."
2017-09-03 18:43:09 +05:30
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"
2017-11-20 20:04:09 +05:30
# Move a copied up file into pure dir to make it impure
2017-09-03 18:43:09 +05:30
mv $SCRATCH_MNT/test_file $impure_dir
2017-10-08 16:55:35 +05:30
test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
2017-09-03 18:43:09 +05:30
2017-09-15 13:47:28 +03:00
impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
$upperdir/test_dir/impure_dir)
[[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
2017-09-03 18:43:09 +05:30
# After $impure_dir becomes impure
parent_d=$($here/src/t_dir_type $impure_dir $impure_dir_parent_st_ino)
[[ $parent_d == ".. d" ]] || \
2017-11-20 20:04:09 +05:30
echo "Impure dir: Invalid d_ino reported for .."
2017-09-03 18:43:09 +05:30
current_d=$($here/src/t_dir_type $impure_dir $impure_dir_st_ino)
[[ $current_d == ". d" ]] || \
2017-11-20 20:04:09 +05:30
echo "Impure dir: Invalid d_ino reported for ."
2017-09-03 18:43:09 +05:30
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"
2017-09-03 18:43:09 +05:30
# 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
rm -rf $impure_dir/subdir
2017-09-03 18:43:09 +05:30
# Verify invalidation of readdir cache
$here/src/t_dir_type $impure_dir $test_file_st_ino
2017-11-20 20:04:09 +05:30
[[ $? != 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"
2017-09-03 18:43:09 +05:30
2017-09-15 13:47:28 +03:00
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"
2017-09-03 18:43:09 +05:30
# Verify d_ino values of subdir entries of a pure lower dir.
2017-11-20 20:04:09 +05:30
parent_st_ino=$(stat -c '%i' $test_dir)
2017-09-03 18:43:09 +05:30
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)
2017-09-03 18:43:09 +05:30
2017-11-20 20:04:09 +05:30
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 .."
2017-09-03 18:43:09 +05:30
current_d=$($here/src/t_dir_type $pure_lower_dir $pure_lower_dir_st_ino)
2017-11-20 20:04:09 +05:30
[[ $current_d == ". d" ]] || \
echo "Pure lower dir: Invalid d_ino reported for ."
2017-09-03 18:43:09 +05:30
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"
2017-11-20 20:04:09 +05:30
# Create a file in pure lower dir to make it a merge dir
touch $pure_lower_dir/newfile
2017-09-03 18:43:09 +05:30
2017-11-20 20:04:09 +05:30
parent_d=$($here/src/t_dir_type $pure_lower_dir $parent_st_ino)
[[ $parent_d == ".. d" ]] || \
echo "Merged dir: Invalid d_ino reported for .."
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 ."
2017-09-03 18:43:09 +05:30
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"
2017-09-03 18:43:09 +05:30
_scratch_unmount
2018-03-01 20:13:47 +08:00
# check overlayfs
_check_scratch_fs
2017-09-03 18:43:09 +05:30
# 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 $lowerdir/test_dir/pure_lower_dir/subdir
2017-09-03 18:43:09 +05:30
_overlay_scratch_mount_dirs "$middir:$lowerdir" $upperdir $workdir
2017-09-03 18:43:09 +05:30
# Copy up test_dir
2017-11-20 20:04:09 +05:30
touch $test_dir/test_file
2017-09-03 18:43:09 +05:30
2017-11-20 20:04:09 +05:30
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)
2017-09-03 18:43:09 +05:30
2017-11-20 20:04:09 +05:30
parent_d=$($here/src/t_dir_type $pure_lower_dir $test_dir_st_ino)
2017-09-03 18:43:09 +05:30
[[ $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"
2017-09-03 18:43:09 +05:30
2018-03-01 20:13:47 +08:00
# check overlayfs
_overlay_check_scratch_dirs "$middir:$lowerdir" $upperdir $workdir
2017-09-03 18:43:09 +05:30
echo "Silence is golden"
status=0
exit