summaryrefslogtreecommitdiffstats
path: root/xlators/meta/src/plugins
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2014-03-26 11:52:53 -0700
committerAnand Avati <avati@redhat.com>2014-05-05 17:28:55 -0700
commit8160399a36eff62a49a066f16dea9140d877c5e8 (patch)
treee51d49bd93ff98822986569fdfada5d2819546b0 /xlators/meta/src/plugins
parent7fba3a88f1ced610eca0c23516a1e720d75160cd (diff)
meta: (re-)Implement Meta translator
The meta translator exposes details about glusterfs itself in the form of a virtual namespace. Loading the translator on the client side creates the meta virtual view under $mntpoint/.meta by default. The directory is not listed (even with ls -a) and can be accessed by doing a "cd /mnt/.meta" Change-Id: I5ffdf39203841a9562a8280a1f79dc76d4dded5d BUG: 1089216 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/7509 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Diffstat (limited to 'xlators/meta/src/plugins')
-rw-r--r--xlators/meta/src/plugins/active-link.c44
-rw-r--r--xlators/meta/src/plugins/cmdline-file.c47
-rw-r--r--xlators/meta/src/plugins/frames-file.c96
-rw-r--r--xlators/meta/src/plugins/graph-dir.c106
-rw-r--r--xlators/meta/src/plugins/graphs-dir.c79
-rw-r--r--xlators/meta/src/plugins/logfile-link.c44
-rw-r--r--xlators/meta/src/plugins/logging-dir.c51
-rw-r--r--xlators/meta/src/plugins/loglevel-file.c93
-rw-r--r--xlators/meta/src/plugins/name-file.c53
-rw-r--r--xlators/meta/src/plugins/option-file.c56
-rw-r--r--xlators/meta/src/plugins/options-dir.c76
-rw-r--r--xlators/meta/src/plugins/process_uuid-file.c46
-rw-r--r--xlators/meta/src/plugins/root-dir.c67
-rw-r--r--xlators/meta/src/plugins/subvolume-link.c66
-rw-r--r--xlators/meta/src/plugins/subvolumes-dir.c72
-rw-r--r--xlators/meta/src/plugins/top-link.c50
-rw-r--r--xlators/meta/src/plugins/type-file.c53
-rw-r--r--xlators/meta/src/plugins/version-file.c46
-rw-r--r--xlators/meta/src/plugins/view-dir.c45
-rw-r--r--xlators/meta/src/plugins/volfile-file.c91
-rw-r--r--xlators/meta/src/plugins/xlator-dir.c72
21 files changed, 1353 insertions, 0 deletions
diff --git a/xlators/meta/src/plugins/active-link.c b/xlators/meta/src/plugins/active-link.c
new file mode 100644
index 00000000000..99d38597bdf
--- /dev/null
+++ b/xlators/meta/src/plugins/active-link.c
@@ -0,0 +1,44 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+
+
+static int
+active_link_fill (xlator_t *this, inode_t *inode, strfd_t *strfd)
+{
+ strprintf (strfd, "%s", this->ctx->active->graph_uuid);
+
+ return 0;
+}
+
+
+struct meta_ops active_link_ops = {
+ .link_fill = active_link_fill
+};
+
+
+int
+meta_active_link_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &active_link_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/cmdline-file.c b/xlators/meta/src/plugins/cmdline-file.c
new file mode 100644
index 00000000000..1eded6d19b8
--- /dev/null
+++ b/xlators/meta/src/plugins/cmdline-file.c
@@ -0,0 +1,47 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "strfd.h"
+#include "globals.h"
+#include "lkowner.h"
+
+
+static int
+cmdline_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd)
+{
+ if (this->ctx->cmdlinestr)
+ strprintf (strfd, "%s\n", this->ctx->cmdlinestr);
+ return strfd->size;
+}
+
+
+static struct meta_ops cmdline_file_ops = {
+ .file_fill = cmdline_file_fill,
+};
+
+
+int
+meta_cmdline_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &cmdline_file_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/frames-file.c b/xlators/meta/src/plugins/frames-file.c
new file mode 100644
index 00000000000..0c3b9a2eb71
--- /dev/null
+++ b/xlators/meta/src/plugins/frames-file.c
@@ -0,0 +1,96 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "strfd.h"
+#include "globals.h"
+#include "lkowner.h"
+
+
+static int
+frames_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd)
+{
+ struct call_pool *pool = NULL;
+ call_stack_t *stack = NULL;
+ call_frame_t *frame = NULL;
+ int i = 0;
+ int j = 0;
+
+ pool = this->ctx->pool;
+
+ LOCK (&pool->lock);
+ {
+ strprintf (strfd, "Call_Count: %d\n", (int)pool->cnt);
+
+ list_for_each_entry (stack, &pool->all_frames, all_frames) {
+ strprintf (strfd, "== Stack %d ==\n", i++);
+ strprintf (strfd, "Unique: %"PRId64"\n", stack->unique);
+ strprintf (strfd, "Type: %s\n", gf_fop_list[stack->op]);
+ strprintf (strfd, "UID: %d\n", stack->uid);
+ strprintf (strfd, "GID: %d\n", stack->gid);
+ strprintf (strfd, "LK_owner: %s\n",
+ lkowner_utoa (&stack->lk_owner));
+
+ j = 0;
+ for (frame = &stack->frames; frame; frame = frame->next) {
+ strprintf (strfd, "\t-- Frame %d --\n", j++);
+ strprintf (strfd, "\tXlator: %s\n", frame->this->name);
+ if (frame->begin.tv_sec)
+ strprintf (strfd, "\tCreation_time: %d.%d\n",
+ (int)frame->begin.tv_sec,
+ (int)frame->begin.tv_usec);
+ strprintf (strfd, "\tRefcount: %d\n", frame->ref_count);
+ strprintf (strfd, "\tComplete: %d\n", frame->complete);
+ if (frame->parent)
+ strprintf (strfd, "\tParent: %s\n",
+ frame->parent->this->name);
+ if (frame->wind_from)
+ strprintf (strfd, "\tWind_from: %s\n",
+ frame->wind_from);
+ if (frame->wind_to)
+ strprintf (strfd, "\tWind_to: %s\n",
+ frame->wind_to);
+ if (frame->unwind_from)
+ strprintf (strfd, "\tUnwind_from: %s\n",
+ frame->unwind_from);
+ if (frame->unwind_to)
+ strprintf (strfd, "\tUnwind_to: %s\n",
+ frame->unwind_to);
+ }
+ }
+ }
+ UNLOCK (&pool->lock);
+
+ return strfd->size;
+}
+
+
+static struct meta_ops frames_file_ops = {
+ .file_fill = frames_file_fill,
+};
+
+
+int
+meta_frames_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &frames_file_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/graph-dir.c b/xlators/meta/src/plugins/graph-dir.c
new file mode 100644
index 00000000000..3cd6b482e74
--- /dev/null
+++ b/xlators/meta/src/plugins/graph-dir.c
@@ -0,0 +1,106 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static struct meta_dirent graph_dir_dirents[] = {
+ DOT_DOTDOT,
+
+ { .name = "top",
+ .type = IA_IFLNK,
+ .hook = meta_top_link_hook,
+ },
+ { .name = "volfile",
+ .type = IA_IFREG,
+ .hook = meta_volfile_file_hook,
+ },
+ { .name = NULL }
+};
+
+
+static int
+graph_dir_fill (xlator_t *this, inode_t *inode, struct meta_dirent **dp)
+{
+ struct meta_dirent *dirents = NULL;
+ glusterfs_graph_t *graph = NULL;
+ int i = 0;
+ int count = 0;
+ xlator_t *xl = NULL;
+
+ graph = meta_ctx_get (inode, this);
+
+ for (xl = graph->first; xl; xl = xl->next)
+ count++;
+
+ dirents = GF_CALLOC (sizeof (*dirents), count, gf_meta_mt_dirents_t);
+ if (!dirents)
+ return -1;
+
+ i = 0;
+ for (xl = graph->first; xl; xl = xl->next) {
+ dirents[i].name = gf_strdup (xl->name);
+ dirents[i].type = IA_IFDIR;
+ dirents[i].hook = meta_xlator_dir_hook;
+ i++;
+ }
+
+ *dp = dirents;
+ return i;
+}
+
+
+struct meta_ops graph_dir_ops = {
+ .fixed_dirents = graph_dir_dirents,
+ .dir_fill = graph_dir_fill,
+};
+
+
+static glusterfs_graph_t *
+glusterfs_graph_lookup (xlator_t *this, const char *graph_uuid)
+{
+ glusterfs_graph_t *graph = NULL;
+ glusterfs_graph_t *tmp = NULL;
+
+ list_for_each_entry (tmp, &this->ctx->graphs, list) {
+ if (strcmp (graph_uuid, tmp->graph_uuid) == 0) {
+ graph = tmp;
+ break;
+ }
+ }
+
+ return graph;
+}
+
+
+int
+meta_graph_dir_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ glusterfs_graph_t *graph = NULL;
+
+ graph = glusterfs_graph_lookup (this, loc->name);
+
+ meta_ops_set (loc->inode, this, &graph_dir_ops);
+
+ meta_ctx_set (loc->inode, this, (void *) graph);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/graphs-dir.c b/xlators/meta/src/plugins/graphs-dir.c
new file mode 100644
index 00000000000..4a538fb6176
--- /dev/null
+++ b/xlators/meta/src/plugins/graphs-dir.c
@@ -0,0 +1,79 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static struct meta_dirent graphs_dir_dirents[] = {
+ DOT_DOTDOT,
+
+ { .name = "active",
+ .type = IA_IFLNK,
+ .hook = meta_active_link_hook,
+ },
+ { .name = NULL }
+};
+
+
+static int
+graphs_dir_fill (xlator_t *this, inode_t *dir, struct meta_dirent **dp)
+{
+ glusterfs_graph_t *graph = NULL;
+ int graphs_count = 0;
+ int i = 0;
+ struct meta_dirent *dirents = NULL;
+
+ list_for_each_entry (graph, &this->ctx->graphs, list) {
+ graphs_count++;
+ }
+
+ dirents = GF_CALLOC (sizeof (*dirents), graphs_count + 3,
+ gf_meta_mt_dirents_t);
+ if (!dirents)
+ return -1;
+
+ i = 0;
+ list_for_each_entry (graph, &this->ctx->graphs, list) {
+ dirents[i].name = gf_strdup (graph->graph_uuid);
+ dirents[i].type = IA_IFDIR;
+ dirents[i].hook = meta_graph_dir_hook;
+ i++;
+ }
+
+ *dp = dirents;
+
+ return i;
+}
+
+
+struct meta_ops graphs_dir_ops = {
+ .fixed_dirents = graphs_dir_dirents,
+ .dir_fill = graphs_dir_fill
+};
+
+
+int
+meta_graphs_dir_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &graphs_dir_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/logfile-link.c b/xlators/meta/src/plugins/logfile-link.c
new file mode 100644
index 00000000000..435cab80c33
--- /dev/null
+++ b/xlators/meta/src/plugins/logfile-link.c
@@ -0,0 +1,44 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+
+
+static int
+logfile_link_fill (xlator_t *this, inode_t *inode, strfd_t *strfd)
+{
+ strprintf (strfd, "%s", this->ctx->log.filename);
+
+ return 0;
+}
+
+
+struct meta_ops logfile_link_ops = {
+ .link_fill = logfile_link_fill
+};
+
+
+int
+meta_logfile_link_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &logfile_link_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/logging-dir.c b/xlators/meta/src/plugins/logging-dir.c
new file mode 100644
index 00000000000..783d38e8e12
--- /dev/null
+++ b/xlators/meta/src/plugins/logging-dir.c
@@ -0,0 +1,51 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static struct meta_dirent logging_dir_dirents[] = {
+ DOT_DOTDOT,
+
+ { .name = "logfile",
+ .type = IA_IFLNK,
+ .hook = meta_logfile_link_hook,
+ },
+ { .name = "loglevel",
+ .type = IA_IFREG,
+ .hook = meta_loglevel_file_hook,
+ },
+ { .name = NULL }
+};
+
+
+struct meta_ops logging_dir_ops = {
+ .fixed_dirents = logging_dir_dirents,
+};
+
+
+int
+meta_logging_dir_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &logging_dir_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/loglevel-file.c b/xlators/meta/src/plugins/loglevel-file.c
new file mode 100644
index 00000000000..24ac68ddc69
--- /dev/null
+++ b/xlators/meta/src/plugins/loglevel-file.c
@@ -0,0 +1,93 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "strfd.h"
+
+
+static int
+loglevel_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd)
+{
+ strprintf (strfd, "%d\n", this->ctx->log.loglevel);
+
+ return strfd->size;
+}
+
+
+static int
+loglevel_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ struct iovec *iov, int count, off_t offset,
+ uint32_t flags, struct iobref *iobref, dict_t *xdata)
+{
+ struct iatt dummy = { };
+ long int level = -1;
+
+ level = strtol (iov[0].iov_base, NULL, 0);
+ if (level >= GF_LOG_NONE && level <= GF_LOG_TRACE)
+ gf_log_set_loglevel (level);
+
+ META_STACK_UNWIND (writev, frame, iov_length (iov, count), 0,
+ &dummy, &dummy, xdata);
+ return 0;
+}
+
+
+int
+loglevel_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ off_t offset, dict_t *xdata)
+{
+ struct iatt iatt = { };
+
+ meta_iatt_fill (&iatt, loc->inode, IA_IFREG);
+
+ META_STACK_UNWIND (truncate, frame, 0, 0, &iatt, &iatt, xdata);
+ return 0;
+}
+
+
+int
+loglevel_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ off_t offset, dict_t *xdata)
+{
+ struct iatt iatt = { };
+
+ meta_iatt_fill (&iatt, fd->inode, IA_IFREG);
+
+ META_STACK_UNWIND (ftruncate, frame, 0, 0, &iatt, &iatt, xdata);
+ return 0;
+}
+
+static struct meta_ops loglevel_file_ops = {
+ .file_fill = loglevel_file_fill,
+ .fops = {
+ .truncate = loglevel_truncate,
+ .ftruncate = loglevel_ftruncate,
+ .writev = loglevel_writev
+ }
+};
+
+
+int
+meta_loglevel_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &loglevel_file_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/name-file.c b/xlators/meta/src/plugins/name-file.c
new file mode 100644
index 00000000000..8ddd42945d7
--- /dev/null
+++ b/xlators/meta/src/plugins/name-file.c
@@ -0,0 +1,53 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "strfd.h"
+#include "globals.h"
+#include "lkowner.h"
+
+
+static int
+name_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd)
+{
+ xlator_t *xl = NULL;
+
+ xl = meta_ctx_get (file, this);
+
+ strprintf (strfd, "%s\n", xl->name);
+
+ return strfd->size;
+}
+
+
+static struct meta_ops name_file_ops = {
+ .file_fill = name_file_fill,
+};
+
+
+int
+meta_name_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &name_file_ops);
+
+ meta_ctx_set (loc->inode, this, meta_ctx_get (loc->parent, this));
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/option-file.c b/xlators/meta/src/plugins/option-file.c
new file mode 100644
index 00000000000..4f9067e1490
--- /dev/null
+++ b/xlators/meta/src/plugins/option-file.c
@@ -0,0 +1,56 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static int
+option_file_fill (xlator_t *this, inode_t *inode, strfd_t *strfd)
+{
+ data_t *data = NULL;
+
+ data = meta_ctx_get (inode, this);
+
+ strprintf (strfd, "%s\n", data_to_str (data));
+
+ return strfd->size;
+}
+
+
+static struct meta_ops option_file_ops = {
+ .file_fill = option_file_fill
+};
+
+
+int
+meta_option_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ xlator_t *xl = NULL;
+
+ xl = meta_ctx_get (loc->parent, this);
+
+ meta_ctx_set (loc->inode, this,
+ dict_get (xl->options, (char *) loc->name));
+
+ meta_ops_set (loc->inode, this, &option_file_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/options-dir.c b/xlators/meta/src/plugins/options-dir.c
new file mode 100644
index 00000000000..229d365a9c7
--- /dev/null
+++ b/xlators/meta/src/plugins/options-dir.c
@@ -0,0 +1,76 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static int
+dict_key_add (dict_t *dict, char *key, data_t *value, void *data)
+{
+ struct meta_dirent **direntp = data;
+
+ (*direntp)->name = gf_strdup (key);
+ (*direntp)->type = IA_IFREG;
+ (*direntp)->hook = meta_option_file_hook;
+
+ (*direntp)++;
+ return 0;
+}
+
+
+static int
+options_dir_fill (xlator_t *this, inode_t *inode, struct meta_dirent **dp)
+{
+ struct meta_dirent *dirent = NULL;
+ struct meta_dirent *direntp = NULL;
+ xlator_t *xl = NULL;
+
+ xl = meta_ctx_get (inode, this);
+
+ dirent = GF_CALLOC (sizeof (*dirent), xl->options->count,
+ gf_meta_mt_dirents_t);
+ if (!dirent)
+ return -1;
+
+ direntp = dirent;
+
+ dict_foreach (xl->options, dict_key_add, &direntp);
+
+ *dp = dirent;
+
+ return xl->options->count;
+}
+
+
+static struct meta_ops options_dir_ops = {
+ .dir_fill = options_dir_fill
+};
+
+
+int
+meta_options_dir_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ctx_set (loc->inode, this, meta_ctx_get (loc->parent, this));
+
+ meta_ops_set (loc->inode, this, &options_dir_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/process_uuid-file.c b/xlators/meta/src/plugins/process_uuid-file.c
new file mode 100644
index 00000000000..c16ceaac150
--- /dev/null
+++ b/xlators/meta/src/plugins/process_uuid-file.c
@@ -0,0 +1,46 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "strfd.h"
+#include "globals.h"
+#include "lkowner.h"
+
+
+static int
+process_uuid_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd)
+{
+ strprintf (strfd, "%s\n", this->ctx->process_uuid);
+ return strfd->size;
+}
+
+
+static struct meta_ops process_uuid_file_ops = {
+ .file_fill = process_uuid_file_fill,
+};
+
+
+int
+meta_process_uuid_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &process_uuid_file_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/root-dir.c b/xlators/meta/src/plugins/root-dir.c
new file mode 100644
index 00000000000..bd6870b21d7
--- /dev/null
+++ b/xlators/meta/src/plugins/root-dir.c
@@ -0,0 +1,67 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static struct meta_dirent root_dir_dirents[] = {
+ DOT_DOTDOT,
+
+ { .name = "graphs",
+ .type = IA_IFDIR,
+ .hook = meta_graphs_dir_hook,
+ },
+ { .name = "frames",
+ .type = IA_IFREG,
+ .hook = meta_frames_file_hook,
+ },
+ { .name = "logging",
+ .type = IA_IFDIR,
+ .hook = meta_logging_dir_hook,
+ },
+ { .name = "process_uuid",
+ .type = IA_IFREG,
+ .hook = meta_process_uuid_file_hook,
+ },
+ { .name = "version",
+ .type = IA_IFREG,
+ .hook = meta_version_file_hook,
+ },
+ { .name = "cmdline",
+ .type = IA_IFREG,
+ .hook = meta_cmdline_file_hook,
+ },
+ { .name = NULL }
+};
+
+
+static struct meta_ops meta_root_dir_ops = {
+ .fixed_dirents = root_dir_dirents
+};
+
+
+int
+meta_root_dir_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &meta_root_dir_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/subvolume-link.c b/xlators/meta/src/plugins/subvolume-link.c
new file mode 100644
index 00000000000..ca71a751541
--- /dev/null
+++ b/xlators/meta/src/plugins/subvolume-link.c
@@ -0,0 +1,66 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+
+
+static int
+subvolume_link_fill (xlator_t *this, inode_t *inode, strfd_t *strfd)
+{
+ xlator_t *xl = NULL;
+
+ xl = meta_ctx_get (inode, this);
+
+ strprintf (strfd, "../../%s", xl->name);
+
+ return 0;
+}
+
+
+struct meta_ops subvolume_link_ops = {
+ .link_fill = subvolume_link_fill
+};
+
+
+int
+meta_subvolume_link_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ int count = 0;
+ int i = 0;
+ xlator_t *xl = NULL;
+ xlator_list_t *subv = NULL;
+ xlator_t *subvol = NULL;
+
+ count = strtol (loc->name, 0, 0);
+ xl = meta_ctx_get (loc->parent, this);
+
+ for (subv = xl->children; subv; subv = subv->next) {
+ if (i == count) {
+ subvol = subv->xlator;
+ break;
+ }
+ i++;
+ }
+
+ meta_ctx_set (loc->inode, this, subvol);
+
+ meta_ops_set (loc->inode, this, &subvolume_link_ops);
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/subvolumes-dir.c b/xlators/meta/src/plugins/subvolumes-dir.c
new file mode 100644
index 00000000000..f8d0e8039a1
--- /dev/null
+++ b/xlators/meta/src/plugins/subvolumes-dir.c
@@ -0,0 +1,72 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static int
+subvolumes_dir_fill (xlator_t *this, inode_t *dir, struct meta_dirent **dp)
+{
+ struct meta_dirent *dirents = NULL;
+ xlator_t *xl = NULL;
+ xlator_list_t *subv = NULL;
+ int i = 0;
+ int count = 0;
+
+ xl = meta_ctx_get (dir, this);
+
+ for (subv = xl->children; subv; subv = subv->next)
+ count++;
+
+ dirents = GF_CALLOC (sizeof (*dirents), count, gf_meta_mt_dirents_t);
+ if (!dirents)
+ return -1;
+
+ for (subv = xl->children; subv; subv = subv->next) {
+ char num[16] = { };
+ snprintf (num, 16, "%d", i);
+
+ dirents[i].name = gf_strdup (num);
+ dirents[i].type = IA_IFLNK;
+ dirents[i].hook = meta_subvolume_link_hook;
+ i++;
+ }
+
+ *dp = dirents;
+
+ return count;
+}
+
+
+static struct meta_ops subvolumes_dir_ops = {
+ .dir_fill = subvolumes_dir_fill
+};
+
+
+int
+meta_subvolumes_dir_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ctx_set (loc->inode, this, meta_ctx_get (loc->parent, this));
+
+ meta_ops_set (loc->inode, this, &subvolumes_dir_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/top-link.c b/xlators/meta/src/plugins/top-link.c
new file mode 100644
index 00000000000..94b7f7a9f56
--- /dev/null
+++ b/xlators/meta/src/plugins/top-link.c
@@ -0,0 +1,50 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+
+
+static int
+top_link_fill (xlator_t *this, inode_t *inode, strfd_t *strfd)
+{
+ glusterfs_graph_t *graph = NULL;
+
+ graph = meta_ctx_get (inode, this);
+
+ strprintf (strfd, "%s", ((xlator_t *)graph->top)->name);
+
+ return 0;
+}
+
+
+struct meta_ops top_link_ops = {
+ .link_fill = top_link_fill
+};
+
+
+int
+meta_top_link_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &top_link_ops);
+
+ meta_ctx_set (loc->inode, this, meta_ctx_get (loc->parent, this));
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/type-file.c b/xlators/meta/src/plugins/type-file.c
new file mode 100644
index 00000000000..1970f4e33e8
--- /dev/null
+++ b/xlators/meta/src/plugins/type-file.c
@@ -0,0 +1,53 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "strfd.h"
+#include "globals.h"
+#include "lkowner.h"
+
+
+static int
+type_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd)
+{
+ xlator_t *xl = NULL;
+
+ xl = meta_ctx_get (file, this);
+
+ strprintf (strfd, "%s\n", xl->type);
+
+ return strfd->size;
+}
+
+
+static struct meta_ops type_file_ops = {
+ .file_fill = type_file_fill,
+};
+
+
+int
+meta_type_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &type_file_ops);
+
+ meta_ctx_set (loc->inode, this, meta_ctx_get (loc->parent, this));
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/version-file.c b/xlators/meta/src/plugins/version-file.c
new file mode 100644
index 00000000000..77f2dea3d66
--- /dev/null
+++ b/xlators/meta/src/plugins/version-file.c
@@ -0,0 +1,46 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "strfd.h"
+#include "globals.h"
+#include "lkowner.h"
+
+
+static int
+version_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd)
+{
+ strprintf (strfd, "%s\n", PACKAGE_VERSION);
+ return strfd->size;
+}
+
+
+static struct meta_ops version_file_ops = {
+ .file_fill = version_file_fill,
+};
+
+
+int
+meta_version_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &version_file_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/view-dir.c b/xlators/meta/src/plugins/view-dir.c
new file mode 100644
index 00000000000..6edd455b072
--- /dev/null
+++ b/xlators/meta/src/plugins/view-dir.c
@@ -0,0 +1,45 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static struct meta_dirent view_dir_dirents[] = {
+ DOT_DOTDOT,
+
+ { .name = NULL }
+};
+
+
+static struct meta_ops view_dir_ops = {
+ .fixed_dirents = view_dir_dirents
+};
+
+
+int
+meta_view_dir_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ctx_set (loc->inode, this, meta_ctx_get (loc->parent, this));
+
+ meta_ops_set (loc->inode, this, &view_dir_ops);
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/volfile-file.c b/xlators/meta/src/plugins/volfile-file.c
new file mode 100644
index 00000000000..899285763e0
--- /dev/null
+++ b/xlators/meta/src/plugins/volfile-file.c
@@ -0,0 +1,91 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "strfd.h"
+
+
+
+static int
+xldump_options (dict_t *this, char *key, data_t *value, void *strfd)
+{
+ strprintf (strfd, " option %s %s\n", key, value->data);
+ return 0;
+}
+
+
+static void
+xldump_subvolumes (xlator_t *this, void *strfd)
+{
+ xlator_list_t *subv = NULL;
+
+ if (!this->children)
+ return;
+
+ strprintf (strfd, " subvolumes");
+
+ for (subv = this->children; subv; subv= subv->next)
+ strprintf (strfd, " %s", subv->xlator->name);
+
+ strprintf (strfd, "\n");
+}
+
+
+static void
+xldump (xlator_t *each, void *strfd)
+{
+ strprintf (strfd, "volume %s\n", each->name);
+ strprintf (strfd, " type %s\n", each->type);
+ dict_foreach (each->options, xldump_options, strfd);
+
+ xldump_subvolumes (each, strfd);
+
+ strprintf (strfd, "end-volume\n");
+ strprintf (strfd, "\n");
+}
+
+
+static int
+volfile_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd)
+{
+ glusterfs_graph_t *graph = NULL;
+
+ graph = meta_ctx_get (file, this);
+
+ xlator_foreach_depth_first (graph->top, xldump, strfd);
+
+ return strfd->size;
+}
+
+
+static struct meta_ops volfile_file_ops = {
+ .file_fill = volfile_file_fill,
+};
+
+
+int
+meta_volfile_file_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ meta_ops_set (loc->inode, this, &volfile_file_ops);
+
+ meta_ctx_set (loc->inode, this, meta_ctx_get (loc->parent, this));
+
+ return 0;
+}
diff --git a/xlators/meta/src/plugins/xlator-dir.c b/xlators/meta/src/plugins/xlator-dir.c
new file mode 100644
index 00000000000..279df385cef
--- /dev/null
+++ b/xlators/meta/src/plugins/xlator-dir.c
@@ -0,0 +1,72 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "defaults.h"
+
+#include "meta-mem-types.h"
+#include "meta.h"
+#include "meta-hooks.h"
+
+
+static struct meta_dirent xlator_dir_dirents[] = {
+ DOT_DOTDOT,
+
+ { .name = "view",
+ .type = IA_IFDIR,
+ .hook = meta_view_dir_hook,
+ },
+ { .name = "type",
+ .type = IA_IFREG,
+ .hook = meta_type_file_hook,
+ },
+ { .name = "name",
+ .type = IA_IFREG,
+ .hook = meta_name_file_hook,
+ },
+ { .name = "subvolumes",
+ .type = IA_IFDIR,
+ .hook = meta_subvolumes_dir_hook,
+ },
+ { .name = "options",
+ .type = IA_IFDIR,
+ .hook = meta_options_dir_hook,
+ },
+ { .name = NULL }
+};
+
+
+static struct meta_ops xlator_dir_ops = {
+ .fixed_dirents = xlator_dir_dirents
+};
+
+
+int
+meta_xlator_dir_hook (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ dict_t *xdata)
+{
+ glusterfs_graph_t *graph = NULL;
+ xlator_t *xl = NULL;
+
+ graph = meta_ctx_get (loc->parent, this);
+
+ xl = xlator_search_by_name (graph->first, loc->name);
+
+ meta_ctx_set (loc->inode, this, xl);
+
+ meta_ops_set (loc->inode, this, &xlator_dir_ops);
+
+ return 0;
+}