diff options
| author | Michael Goulet <mgoulet@fb.com> | 2017-08-15 16:50:13 -0700 |
|---|---|---|
| committer | Shreyas Siravara <sshreyas@fb.com> | 2017-09-07 23:02:56 +0000 |
| commit | dbd30776f26e9c3c0ce1cf8ad66ee95fc1adf484 (patch) | |
| tree | 109737d0655931ee598eac9c5211857de28cfa92 /tests/basic | |
| parent | 7981d5147feca3f459dd5377dc92cc5a3e6ad953 (diff) | |
features/namespace: Add namespace xlator and link into brick graph
Summary:
This translator tags namespaces with a unique hash that corresponds to the
top-level directory (right under the gluster root) of the file the fop acts
on. The hash information is injected into the call frame by this translator,
so this namespace information can later be used to do throttling, QoS and
other namespace-specific stats collection and actions in later xlators
further down the stack.
When the translator can't find a path directly for the fd_t or loc_t, it winds
a GET_ANCESTRY_PATH_KEY down to the posix xlator to get the path manually.
Caching this namespace information in the inode makes sure that most requests
don't need to recalculate the hash, so that typically fops are just doing an
inode_ctx_get instead of the more expensive code paths that this xlator can take.
Right now the xlator is hard-coded to only hash the top-level directory, but
this could be easily extended to more sophisticated matching by modification
of the parse_path function.
Test Plan:
Run `prove -v tests/basic/namespace.t` to see that tagging works.
Change-Id: I960ddadba114120ac449d27a769d409cc3759ebc
Reviewed-on: https://review.gluster.org/18041
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shreyas Siravara <sshreyas@fb.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'tests/basic')
| -rw-r--r-- | tests/basic/namespace.t | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/basic/namespace.t b/tests/basic/namespace.t new file mode 100644 index 00000000000..ac1b4970a60 --- /dev/null +++ b/tests/basic/namespace.t @@ -0,0 +1,98 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../nfs.rc + +# These hashes are a result of calling SuperFastHash +# on the corresponding folder names. +NAMESPACE_HASH=28153613 +NAMESPACE2_HASH=3926991974 +NAMESPACE3_HASH=3493960770 + +function check_samples() { + local FOP_TYPE=$1 + local NS_HASH=$2 + local FILE=$3 + local BRICK=$4 + local GFID="$(getfattr -n trusted.gfid -e text --only-values $B0/$BRICK$FILE | xxd -p)" + + grep -i "ns_$OP" /var/log/glusterfs/bricks/d-backends-$BRICK.log | + grep -- $NS_HASH | sed 's/\-//g' | grep -- $GFID + if [ $? -eq 0 ]; then + echo "Y" + else + echo "N" + fi +} + +cleanup; + +TEST mkdir -p $B0/${V0}{0,1,2,3,4,5,6,7,8,9} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2,3,4,5,6,7,8} +TEST $CLI volume set $V0 nfs.disable off +TEST $CLI volume set $V0 performance.stat-prefetch off +TEST $CLI volume set $V0 performance.nfs.stat-prefetch off +TEST $CLI volume set $V0 cluster.read-subvolume-index 0 +TEST $CLI volume set $V0 diagnostics.brick-log-level DEBUG +TEST $CLI volume set $V0 features.tag-namespaces on +TEST $CLI volume set $V0 storage.build-pgfid on +TEST $CLI volume start $V0 + +sleep 2 + +TEST mount_nfs $H0:/$V0 $N0 nolock; + +################################ +# Paths in the samples # +################################ + +mkdir -p $N0/namespace + +# subvol_1 = bar, subvol_2 = foo, subvol_3 = hey +# Test create, write (tagged by loc, fd respectively). +touch $N0/namespace/{bar,foo,hey} +echo "garbage" > $N0/namespace/bar +echo "garbage" > $N0/namespace/foo +echo "garbage" > $N0/namespace/hey +EXPECT_WITHIN 10 "Y" check_samples CREATE $NAMESPACE_HASH /namespace/bar patchy0 +EXPECT_WITHIN 10 "Y" check_samples CREATE $NAMESPACE_HASH /namespace/foo patchy3 +EXPECT_WITHIN 10 "Y" check_samples CREATE $NAMESPACE_HASH /namespace/hey patchy6 +EXPECT_WITHIN 10 "Y" check_samples WRITEV $NAMESPACE_HASH /namespace/bar patchy0 +EXPECT_WITHIN 10 "Y" check_samples WRITEV $NAMESPACE_HASH /namespace/foo patchy3 +EXPECT_WITHIN 10 "Y" check_samples WRITEV $NAMESPACE_HASH /namespace/hey patchy6 + +# Test stat (tagged by loc) +stat $N0/namespace/bar &> /dev/null +stat $N0/namespace/foo &> /dev/null +stat $N0/namespace/hey &> /dev/null +EXPECT_WITHIN 10 "Y" check_samples STAT $NAMESPACE_HASH /namespace/bar patchy0 +EXPECT_WITHIN 10 "Y" check_samples STAT $NAMESPACE_HASH /namespace/foo patchy3 +EXPECT_WITHIN 10 "Y" check_samples STAT $NAMESPACE_HASH /namespace/hey patchy6 + +EXPECT_WITHIN 10 "Y" umount_nfs $N0; +sleep 1 +TEST mount_nfs $H0:/$V0 $N0 nolock; + +cat $N0/namespace/bar &> /dev/null +EXPECT_WITHIN 10 "Y" check_samples READ $NAMESPACE_HASH /namespace/bar patchy0 + +dir $N0/namespace &> /dev/null +EXPECT_WITHIN 10 "Y" check_samples LOOKUP $NAMESPACE_HASH /namespace patchy0 + +mkdir -p $N0/namespace{2,3} +EXPECT_WITHIN 10 "Y" check_samples MKDIR $NAMESPACE2_HASH /namespace2 patchy0 +EXPECT_WITHIN 10 "Y" check_samples MKDIR $NAMESPACE3_HASH /namespace3 patchy0 + +touch $N0/namespace2/file +touch $N0/namespace3/file +EXPECT_WITHIN 10 "Y" check_samples CREATE $NAMESPACE2_HASH /namespace2/file patchy0 +EXPECT_WITHIN 10 "Y" check_samples CREATE $NAMESPACE3_HASH /namespace3/file patchy0 + +# TODO(mgoulet): Add more fd-based fops, check more complex loc-based +# fops like linking, truncate, etc. + +cleanup; |
