summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
authorJoseph Fernandes <josferna@redhat.com>2015-03-18 19:55:31 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-19 01:31:29 -0700
commitb4a0db5ee3b827268fe1aeeed32ad7d417460c50 (patch)
treed79b3182062aa5c1b50eee24b0866d47fa7824c3 /xlators/mgmt/glusterd/src/glusterd-volgen.c
parenta1755ee2765f3d1c9c26d51a49ad63d133932710 (diff)
Adding ChangeTimeRecorder(CTR) Xlator to GlusterFS
********************************************************************** ChangeTimeRecorder(CTR) Xlator | ********************************************************************** ChangeTimeRecorder(CTR) is server side xlator(translator) which sits just above posix xlator. The main role of this xlator is to record the access/write patterns on a file residing the brick. It records the read(only data) and write(data and metadata) times and also count on how many times a file is read or written. This xlator also captures the hard links to a file(as its required by data tiering to move files). CTR Xlator is the consumer of libgfdb. To Enable/Disable CTR Xlator: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gluster volume set <volume-name> features.ctr-enabled {on/off} To Enable/Disable Frequency Counter Recording in CTR Xlator: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gluster volume set <volume-name> features.record-counters {on/off} Change-Id: I5d3cf056af61ac8e3f8250321a27cb240a214ac2 BUG: 1194753 Signed-off-by: Joseph Fernandes <josferna@redhat.com> Reviewed-on: http://review.gluster.org/9935 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c71
1 files changed, 69 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index c140e680261..114e57485fc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1560,6 +1560,73 @@ out:
}
static int
+brick_graph_add_changetimerecorder (volgen_graph_t *graph,
+ glusterd_volinfo_t *volinfo,
+ dict_t *set_dict,
+ glusterd_brickinfo_t *brickinfo)
+{
+ xlator_t *xl = NULL;
+ int ret = -1;
+ glusterd_brickinfo_t *brickiter = NULL;
+ glusterd_brickinfo_t *tmp = NULL;
+ char *brickname = NULL;
+ char *path = NULL;
+ char *volname = NULL;
+ int bricknum = 0;
+ char index_basepath[PATH_MAX] = {0};
+
+ if (!graph || !volinfo || !set_dict || !brickinfo)
+ goto out;
+
+ path = brickinfo->path;
+
+ xl = volgen_graph_add (graph, "features/changetimerecorder",
+ volinfo->volname);
+
+
+ ret = xlator_set_option (xl, "db-type", "sqlite3");
+ if (ret)
+ goto out;
+
+ bricknum = 0;
+ list_for_each_entry_safe (brickiter, tmp, &volinfo->bricks,
+ brick_list) {
+ if (brickiter == brickinfo)
+ break;
+ bricknum++;
+ }
+ if (bricknum < volinfo->tier_info.hot_brick_count) {
+ ret = xlator_set_option (xl, "hot-brick", "on");
+ } else {
+ ret = xlator_set_option (xl, "hot-brick", "off");
+ }
+
+ brickname = strrchr(path, '/') + 1;
+ snprintf (index_basepath, sizeof (index_basepath), "%s.db",
+ brickname);
+ ret = xlator_set_option (xl, "db-name", index_basepath);
+ if (ret)
+ goto out;
+
+ snprintf (index_basepath, sizeof (index_basepath), "%s/%s",
+ path, ".glusterfs/");
+ ret = xlator_set_option (xl, "db-path", index_basepath);
+ if (ret)
+ goto out;
+
+ ret = xlator_set_option (xl, "record-exit", "off");
+ if (ret)
+ goto out;
+
+ ret = xlator_set_option (xl, "record-entry", "on");
+ if (ret)
+ goto out;
+
+out:
+ return ret;
+}
+
+static int
brick_graph_add_acl (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
dict_t *set_dict, glusterd_brickinfo_t *brickinfo)
{
@@ -2071,6 +2138,7 @@ static volgen_brick_xlator_t server_graph_table[] = {
{brick_graph_add_locks, "locks"},
{brick_graph_add_acl, "acl"},
{brick_graph_add_changelog, "changelog"},
+ {brick_graph_add_changetimerecorder, "changetimerecorder"},
{brick_graph_add_bd, "bd"},
{brick_graph_add_trash, "trash"},
{brick_graph_add_posix, "posix"},
@@ -3554,8 +3622,7 @@ nfs_option_handler (volgen_graph_t *graph,
return -1;
}
-
- if ((strcmp (vme->voltype, "nfs/server") == 0) &&
+ if ((strcmp (vme->voltype, "nfs/server") == 0) &&
(vme->option && vme->option[0]!='!') ) {
ret = xlator_set_option (xl, vme->option, vme->value);
if (ret)