diff options
author | Kotresh HR <khiremat@redhat.com> | 2017-07-16 15:16:56 -0400 |
---|---|---|
committer | Krutika Dhananjay <kdhananj@redhat.com> | 2017-07-28 05:21:46 +0000 |
commit | ab2558a3e7a1b2de2d63a3812ab4ed58d10d8619 (patch) | |
tree | 8f0baa0697c37abd5a113334e6452138d8a7a5c0 /tests | |
parent | 1477fa442a733d7b1a5ea74884cac8f29fbe7e6a (diff) |
storage/posix: Add virtual xattr to fetch path from gfid
The gfid2path infra stores the "pargfid/bname" as on xattr
value for each non directory entry. Hardlinks would have a
separate xattr. This xattr key is internal and is not
exposed to applications. A virtual xattr is exposed for
the applications to fetch the path from gfid.
Internal xattr:
trusted.gfid2path.<xxhash>
Virtual xattr:
glusterfs.gfidtopath
getfattr -h -n glusterfs.gfidtopath /<aux-mnt>/.gfid/<gfid>
If there are hardlinks, it returns all the paths separated
by ':'.
A volume set option is introduced to change the delimiter
to required string of max length 7.
gluster vol set gfid2path-separator ":::"
Updates: #139
Change-Id: Ie3b0c3fd8bd5333c4a27410011e608333918c02a
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: https://review.gluster.org/17785
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gfid2path/get-gfid-to-path.t | 75 | ||||
-rw-r--r-- | tests/volume.rc | 5 |
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/gfid2path/get-gfid-to-path.t b/tests/gfid2path/get-gfid-to-path.t new file mode 100644 index 00000000000..71c2c2fab70 --- /dev/null +++ b/tests/gfid2path/get-gfid-to-path.t @@ -0,0 +1,75 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../afr.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +## Create a 1*2 volume +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1} +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; + +## Start the volume +TEST $CLI volume start $V0 +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 + +## enable gfid2path +TEST $CLI volume set $V0 gfid2path enable + +## Mount the volume +TEST $GFS --volfile-server=$H0 --aux-gfid-mount --volfile-id=$V0 $M0; + +root_gfid="00000000-0000-0000-0000-000000000001" + +#Check for ROOT +EXPECT "/" get_gfid2path $M0/.gfid/$root_gfid + +#CREATE +fname=$M0/file1 +touch $fname; + +#Get gfid of file1 +gfid=$(getfattr -h --only-values -n glusterfs.gfid.string $M0/file1) + +#Get path from virt xattr +EXPECT "/file1" get_gfid2path $M0/.gfid/$gfid + +#Create hardlink and get path +ln $fname $M0/hl_file1 +EXPECT "/file1" get_gfid2path $M0/.gfid/$gfid +EXPECT "/hl_file1" get_gfid2path $M0/.gfid/$gfid + +#Rename and get path +mv $fname $M0/rn_file1 +EXPECT "/hl_file1" get_gfid2path $M0/.gfid/$gfid +EXPECT "/rn_file1" get_gfid2path $M0/.gfid/$gfid + +#Create symlink and get path +ln -s $fname $M0/sym_file1 +gfid=$(getfattr -h --only-values -n glusterfs.gfid.string $M0/sym_file1) +EXPECT "/sym_file1" get_gfid2path $M0/.gfid/$gfid + +#Create dir and get path +mkdir -p $M0/dir1/dir2 +gfid=$(getfattr -h --only-values -n glusterfs.gfid.string $M0/dir1/dir2) +EXPECT "/dir1/dir2" get_gfid2path $M0/.gfid/$gfid + +#Create file under dir2 and get path +touch $M0/dir1/dir2/file1 +gfid=$(getfattr -h --only-values -n glusterfs.gfid.string $M0/dir1/dir2/file1) +EXPECT "/dir1/dir2/file1" get_gfid2path $M0/.gfid/$gfid + +#Create hardlink under dir2 and get path +ln $M0/dir1/dir2/file1 $M0/dir1/hl_file1 +gfid=$(getfattr -h --only-values -n glusterfs.gfid.string $M0/dir1/dir2/file1) +EXPECT "/dir1/dir2/file1" get_gfid2path $M0/.gfid/$gfid +EXPECT "/dir1/hl_file1" get_gfid2path $M0/.gfid/$gfid + +cleanup; diff --git a/tests/volume.rc b/tests/volume.rc index 402bb9dbf19..369e5a706c6 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -359,6 +359,11 @@ function get_text_xattr { getfattr -h -d -m. -e text $path 2>/dev/null | grep -a $key | cut -f2 -d'=' } +function get_gfid2path { + local path=$1 + getfattr -h --only-values -n glusterfs.gfidtopath $path 2>/dev/null +} + function get_xattr_key { local key=$1 local path=$2 |