From 0ef870741a2f49d47a02725aed13a95335a6e42f Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Fri, 27 Feb 2015 15:14:08 +0530 Subject: Features/trash : Combined patches for trash translator This is the combined patch set for supporting trash feature. http://www.gluster.org/community/documentation/index.php/Features/Trash Current patch includes the following features: * volume set options for enabling trash globally and exclusively for internal operations like self-heal and re-balance * volume set options for setting the eliminate path, trash directory path and maximum trashable file size. * test script for checking the functionality of the feature * brief documentation on different aspects of trash feature. Change-Id: Ic7486982dcd6e295d1eba0f4d5ee6d33bf1b4cb3 BUG: 1132465 Signed-off-by: Anoop C S Signed-off-by: Jiffin Tony Thottan Reviewed-on: http://review.gluster.org/8312 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-volgen.c | 34 ++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 1af7a77cff1..779d6be34a4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1421,6 +1421,7 @@ brick_graph_add_posix (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, { int ret = -1; gf_boolean_t quota_enabled = _gf_true; + gf_boolean_t trash_enabled = _gf_false; gf_boolean_t pgfid_feat = _gf_false; char *value = NULL; xlator_t *xl = NULL; @@ -1435,6 +1436,13 @@ brick_graph_add_posix (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, goto out; } + ret = glusterd_volinfo_get (volinfo, VKEY_FEATURES_TRASH, &value); + if (value) { + ret = gf_string2boolean (value, &trash_enabled); + if (ret) + goto out; + } + ret = glusterd_volinfo_get (volinfo, "update-link-count-parent", &value); @@ -1459,13 +1467,36 @@ brick_graph_add_posix (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, if (ret) goto out; - if (quota_enabled || pgfid_feat) + if (quota_enabled || pgfid_feat || trash_enabled) xlator_set_option (xl, "update-link-count-parent", "on"); out: return ret; } +static int +brick_graph_add_trash (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, + dict_t *set_dict, glusterd_brickinfo_t *brickinfo) +{ + int ret = -1; + xlator_t *xl = NULL; + + xl = volgen_graph_add (graph, "features/trash", volinfo->volname); + if (!xl) + goto out; + ret = xlator_set_option (xl, "trash-dir", ".trashcan"); + if (ret) + goto out; + ret = xlator_set_option (xl, "brick-path", brickinfo->path); + if (ret) + goto out; + ret = xlator_set_option (xl, "trash-internal-op", "off"); + if (ret) + goto out; +out: + return ret; +} + static int brick_graph_add_bd (volgen_graph_t *graph, glusterd_volinfo_t *volinfo, dict_t *set_dict, glusterd_brickinfo_t *brickinfo) @@ -2018,6 +2049,7 @@ static volgen_brick_xlator_t server_graph_table[] = { {brick_graph_add_acl, "acl"}, {brick_graph_add_changelog, "changelog"}, {brick_graph_add_bd, "bd"}, + {brick_graph_add_trash, "trash"}, {brick_graph_add_posix, "posix"}, }; -- cgit