diff options
author | Kotresh HR <khiremat@redhat.com> | 2017-06-29 05:45:34 -0400 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-07-10 14:51:14 +0000 |
commit | a62b16b72b03f2b7c25c24ea9ac5968453a92009 (patch) | |
tree | 7521978a597377f082172a2b5454e83bbab02bbf /tests | |
parent | 9156a743aa76c955d18c9bfcb7c1a38ba00da890 (diff) |
storage/posix: New gfid2path infra
With this infra, a new xattr is stored on each entry
creation as below.
trusted.gfid2path.<xxhash> = <pargfid>/<basename>
If there are hardlinks, multiple xattrs would be present.
Fops which are impacted:
create, mknod, link, symlink, rename, unlink
Option to enable:
gluster vol set <VOLNAME> storage.gfid2path on
Updates: #139
Change-Id: I369974cd16703c45ee87f82e6c2ff5a987a6cc6a
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: https://review.gluster.org/17488
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gfid2path/gfid2path_fuse.t | 146 | ||||
-rw-r--r-- | tests/gfid2path/gfid2path_nfs.t | 153 | ||||
-rw-r--r-- | tests/volume.rc | 2 |
3 files changed, 300 insertions, 1 deletions
diff --git a/tests/gfid2path/gfid2path_fuse.t b/tests/gfid2path/gfid2path_fuse.t new file mode 100644 index 00000000000..38798cf60d0 --- /dev/null +++ b/tests/gfid2path/gfid2path_fuse.t @@ -0,0 +1,146 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +XXHSUM_SOURCE="$(dirname $0)/../../contrib/xxhash/xxhsum.c $(dirname $0)/../../contrib/xxhash/xxhash.c" +XXHSUM_EXEC=$(dirname $0)/xxhsum + +## Build xxhsum C source +build_tester $XXHSUM_SOURCE -o $XXHSUM_EXEC -I$(dirname $0)/../../contrib/xxhash +TEST [ -e $XXHSUM_EXEC ] + +TEST glusterd +TEST pidof glusterd + +## Create a single brick volume (B=1) +TEST $CLI volume create $V0 $H0:$B0/${V0}1; +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '1' brick_count $V0 + +## Start the volume +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## enable gfid2path +TEST $CLI volume set $V0 gfid2path enable + +## Mount the volume +TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0; + +pgfid="00000000-0000-0000-0000-000000000001" +xxh64_file=$B0/${V0}1/xxh64_file + +#CREATE +fname=$M0/file1 +touch $fname; +backpath=$B0/${V0}1/file1 + +#Check for the presence of xattr +pgfid_bname=$pgfid/file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#MKNOD +fname=$M0/mknod_file1 +mknod $fname p; +backpath=$B0/${V0}1/mknod_file1 + +#Check for the presence of xattr +pgfid_bname=$pgfid/mknod_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#LINK +fname1=$M0/file1 +fname2=$M0/hl_file1 +ln $fname1 $fname2 +backpath1=$B0/${V0}1/file1 +backpath2=$B0/${V0}1/hl_file1 + +#Check for the presence of two xattrs +pgfid_bname=$pgfid/file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath1 + +pgfid_bname=$pgfid/hl_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath2 + +#RENAME +fname1=$M0/file1 +fname2=$M0/rn_file1 +mv $fname1 $fname2 +backpath=$B0/${V0}1/rn_file1 + +#Check for the presence of new xattr +pgfid_bname=$pgfid/file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT_NOT $pgfid_bname get_text_xattr $key $backpath + +pgfid_bname=$pgfid/rn_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#UNLINK +fname1=$M0/hl_file1 +rm -f $fname1 +fname2=$M0/rn_file1 +backpath=$B0/${V0}1/rn_file1 + +#Check removal of xattr +pgfid_bname=$pgfid/hl_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT_NOT $pgfid_bname get_text_xattr $key $backpath + +pgfid_bname=$pgfid/rn_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#SYMLINK +fname=rn_file1 +sym_fname=$M0/sym_file1 +ln -s $fname $sym_fname +backpath=$B0/${V0}1/sym_file1 + +#Check for the presence of xattr +pgfid_bname=$pgfid/sym_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#FINAL UNLINK +fname=$M0/rn_file1 +sym_fname=$M0/sym_file1 +mknod_fname=$M0/mknod_file1 + +rm -f $fname +rm -f $sym_fname +rm -f $mknod_fname +TEST ! stat $fname +TEST ! stat $sym_fname +TEST ! stat $mknod_fname + +#Cleanups +rm -f $STUB_EXEC +cleanup; diff --git a/tests/gfid2path/gfid2path_nfs.t b/tests/gfid2path/gfid2path_nfs.t new file mode 100644 index 00000000000..4e229dbb99f --- /dev/null +++ b/tests/gfid2path/gfid2path_nfs.t @@ -0,0 +1,153 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../nfs.rc + +cleanup; + +XXHSUM_SOURCE="$(dirname $0)/../../contrib/xxhash/xxhsum.c $(dirname $0)/../../contrib/xxhash/xxhash.c" +XXHSUM_EXEC=$(dirname $0)/xxhsum + +## Build xxhsum C source +build_tester $XXHSUM_SOURCE -o $XXHSUM_EXEC -I$(dirname $0)/../../contrib/xxhash +TEST [ -e $XXHSUM_EXEC ] + +TEST glusterd +TEST pidof glusterd + +## Create a single brick volume (B=1) +TEST $CLI volume create $V0 $H0:$B0/${V0}1; +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '1' brick_count $V0 + +TEST $CLI volume set $V0 nfs.disable false + +## Start the volume +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## enable gfid2path +TEST $CLI volume set $V0 gfid2path enable + +## Wait for volume to register with rpc.mountd +EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available + +## Mount the volume +TEST mount_nfs $H0:/$V0 $N0 nolock; + + +pgfid="00000000-0000-0000-0000-000000000001" +xxh64_file=$B0/${V0}1/xxh64_file + +#CREATE +fname=$N0/file1 +touch $fname; +backpath=$B0/${V0}1/file1 + +#Check for the presence of xattr +pgfid_bname=$pgfid/file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#MKNOD +fname=$N0/mknod_file1 +mknod $fname p; +backpath=$B0/${V0}1/mknod_file1 + +#Check for the presence of xattr +pgfid_bname=$pgfid/mknod_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#LINK +fname1=$N0/file1 +fname2=$N0/hl_file1 +ln $fname1 $fname2 +backpath1=$B0/${V0}1/file1 +backpath2=$B0/${V0}1/hl_file1 + +#Check for the presence of two xattrs +pgfid_bname=$pgfid/file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath1 + +pgfid_bname=$pgfid/hl_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath2 + +#RENAME +fname1=$N0/file1 +fname2=$N0/rn_file1 +mv $fname1 $fname2 +backpath=$B0/${V0}1/rn_file1 + +#Check for the presence of new xattr +pgfid_bname=$pgfid/file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT_NOT $pgfid_bname get_text_xattr $key $backpath + +pgfid_bname=$pgfid/rn_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#UNLINK +fname1=$N0/hl_file1 +rm -f $fname1 +fname2=$N0/rn_file1 +backpath=$B0/${V0}1/rn_file1 + +#Check removal of xattr +pgfid_bname=$pgfid/hl_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT_NOT $pgfid_bname get_text_xattr $key $backpath + +pgfid_bname=$pgfid/rn_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#SYMLINK +fname=rn_file1 +sym_fname=$N0/sym_file1 +ln -s $fname $sym_fname +backpath=$B0/${V0}1/sym_file1 + +#Check for the presence of xattr +pgfid_bname=$pgfid/sym_file1 +echo -n $pgfid_bname > $xxh64_file +xxh64sum=$($XXHSUM_EXEC $xxh64_file | awk '{print $1}') +key="trusted.gfid2path.$xxh64sum" +EXPECT $pgfid_bname get_text_xattr $key $backpath + +#FINAL UNLINK +fname=$N0/rn_file1 +sym_fname=$N0/sym_file1 +mknod_fname=$N0/mknod_file1 + +rm -f $fname +rm -f $sym_fname +rm -f $mknod_fname +TEST ! stat $fname +TEST ! stat $sym_fname +TEST ! stat $mknod_fname + +#Cleanups +rm -f $STUB_EXEC +cleanup; diff --git a/tests/volume.rc b/tests/volume.rc index 94162cfb5e4..935382b8531 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -356,7 +356,7 @@ function gf_gfid_xattr_to_str { function get_text_xattr { local key=$1 local path=$2 - getfattr -d -m. -e text $path 2>/dev/null | grep -a $key | cut -f2 -d'=' + getfattr -h -d -m. -e text $path 2>/dev/null | grep -a $key | cut -f2 -d'=' } function gf_check_file_opened_in_brick { |