Skip to content

Commit

Permalink
ovlsnapshot: make tests more robust
Browse files Browse the repository at this point in the history
* Create mount point on first time use
* Abort early on old snapshots mount failure
* Do not use direct IO by default so test can runn on tmpfs

Signed-off-by: Amir Goldstein <[email protected]>
  • Loading branch information
amir73il committed Dec 14, 2018
1 parent 93dbbf5 commit 73ed9ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions scripts/mount.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,18 @@ mount_old_snapshots()
# Before merging prev snapshot upper with a new lower
# (curr snapshot), we need to remove the "origin" xattr
# of old $lower, otherwise mount will fail (-ESTALE)
setfattr -x "trusted.overlay.origin" $oldsnap/u
setfattr -x "trusted.overlay.origin" $oldsnap/u || \
error "failed removing 'origin' xattr"
# ...and mount with nfs_export=nested, otherwise merge
# dir origin fh verification will fail
snapmntopts="$snapmntopts,nfs_export=nested"
mount -i -t overlay "$dev@$old" "$oldmnt" \
-o"ro,upperdir=$oldsnap/u,workdir=$oldsnap/w,lowerdir=$old_snapshots,$snapmntopts"
-o"ro,upperdir=$oldsnap/u,workdir=$oldsnap/w,lowerdir=$old_snapshots,$snapmntopts" || exit 1
fi
old_snapshots="$oldsnap/u:$old_snapshots"
[ -z "$prev" ] || \
mount -i -t overlay "$dev@$old" "$oldmnt" \
-o"ro,lowerdir=$old_snapshots,$oldsnapmntopts"
-o"ro,lowerdir=$old_snapshots,$oldsnapmntopts" || exit 1
prev=$old
done
}
Expand Down
10 changes: 5 additions & 5 deletions scripts/ovlsnapshot
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ debug()
# parse <path>[[/]@[/]<snapshot-name>] argument
parse_path_snapshot_arg()
{
MNT=$( echo $1 | ( IFS=$IFS@ ; read a b ; echo $a ) )
snap=$( echo $1 | ( IFS=$IFS@ ; read a b ; echo $b ) )
set -- $( IFS=@; echo $1 )
# strip / from <path>/ and /<snapshot-name>
MNT=${MNT%/}
snap=${snap#/}
MNT=${1%/}
snap=${2#/}
# directory inside <path> to store snapshot related files
SNAPDIR=$MNT/@
# directory prefix for snapshot mount points
Expand All @@ -133,6 +132,7 @@ parse_path_snapshot_arg()
fi
[ -n "$MNT" ] || usage 1
[ -d "$MNT" ] || error "'$MNT' is not a directory!"
mkdir -p $SNAPMNT || error "creating snapshot mount point"
export MNT
S=$MNT@$snap
SNAPTEST="ovlsnaptest"
Expand Down Expand Up @@ -660,7 +660,7 @@ case "$CMD" in
# uncomment the following line to run in-place write tests
INPLACE=$NOTRUNC
# uncomment the following line to run direct I/O write tests
DIRECT="oflag=direct"
#DIRECT="oflag=direct"
TRUNCSIZE=4
echo Appending $F zeros to $F.1 $DIRECT
# append writes to new allocated blocks
Expand Down

0 comments on commit 73ed9ce

Please sign in to comment.