From dbd30776f26e9c3c0ce1cf8ad66ee95fc1adf484 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 15 Aug 2017 16:50:13 -0700 Subject: 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 Reviewed-by: Shreyas Siravara CentOS-regression: Gluster Build System --- libglusterfs/src/stack.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libglusterfs/src/stack.h') diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index 393fdac8e73..9e5355a6044 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -32,6 +32,7 @@ typedef struct call_pool call_pool_t; #include "globals.h" #include "lkowner.h" #include "client_t.h" +#include "fd.h" #include "libglusterfs-messages.h" #define NFS_PID 1 @@ -78,6 +79,13 @@ struct _call_frame_t { const char *unwind_to; }; +struct _ns_info { + uint32_t hash; /* Hash of the namespace from SuperFastHash */ + gf_boolean_t found; /* Set to true if we found a namespace */ +}; + +typedef struct _ns_info ns_info_t; + #define SMALL_GROUP_COUNT 128 struct _call_stack_t { @@ -110,6 +118,8 @@ struct _call_stack_t { int32_t op; int8_t type; struct timeval tv; + + ns_info_t ns_info; }; -- cgit