From 0423962a575a23ca710f272159349ece200aac73 Mon Sep 17 00:00:00 2001 From: vmallika Date: Thu, 30 Apr 2015 16:50:47 +0530 Subject: quota/marker: turn off inode quotas by default inode quota is a new feature implemented in glusterfs-3.7 if quota is enabled in the older version and is upgraded to a new version, we can hit setxattr spike during self-heal of inode quotas. So, when a quota is enabled, turn off inode-quotas with a xlator option. With this patch, we still account for inode quotas but only when a write operation is performed for a particular file. User will be able to query inode quotas once the Inode-quota xlator option is enabled. Change-Id: I52fb28bf7024989ce7bb08ac63a303bf3ec1ec9a BUG: 1218243 Signed-off-by: vmallika Signed-off-by: Sachin Pandit Reviewed-on: http://review.gluster.org/10152 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur Signed-off-by: Sachin Pandit Reviewed-on: http://review.gluster.org/10621 --- cli/src/cli-cmd-parser.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ cli/src/cli-cmd-volume.c | 23 ++++++++++++++++----- cli/src/cli.h | 3 +++ 3 files changed, 75 insertions(+), 5 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 7d7eee5af6f..38b3bbde13d 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -925,6 +925,60 @@ out: return ret; } +int32_t +cli_cmd_inode_quota_parse (const char **words, int wordcount, dict_t **options) +{ + dict_t *dict = NULL; + char *volname = NULL; + int ret = -1; + + GF_ASSERT (words); + GF_ASSERT (options); + + dict = dict_new (); + if (!dict) { + gf_log ("cli", GF_LOG_ERROR, "dict_new failed"); + goto out; + } + + if (wordcount != 4) + goto out; + + volname = (char *)words[2]; + if (!volname) { + ret = -1; + goto out; + } + + /* Validate the volume name here itself */ + if (cli_validate_volname (volname) < 0) + goto out; + + ret = dict_set_str (dict, "volname", volname); + if (ret < 0) + goto out; + + if (strcmp (words[3], "enable") != 0) { + cli_out ("Invalid quota option : %s", words[3]); + ret = -1; + goto out; + } + + ret = dict_set_int32 (dict, "type", + GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS); + if (ret < 0) + goto out; + + *options = dict; +out: + if (ret < 0) { + if (dict) + dict_destroy (dict); + } + + return ret; +} + int32_t cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) { diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 72a789de56c..f9d4041f3ca 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1475,11 +1475,20 @@ cli_cmd_quota_cbk (struct cli_state *state, struct cli_cmd_word *word, "configuration. Do you want to continue?"; //parse **words into options dictionary - ret = cli_cmd_quota_parse (words, wordcount, &options); - if (ret < 0) { - cli_usage_out (word->pattern); - parse_err = 1; - goto out; + if (strcmp (words[1], "inode-quota") == 0) { + ret = cli_cmd_inode_quota_parse (words, wordcount, &options); + if (ret < 0) { + cli_usage_out (word->pattern); + parse_err = 1; + goto out; + } + } else { + ret = cli_cmd_quota_parse (words, wordcount, &options); + if (ret < 0) { + cli_usage_out (word->pattern); + parse_err = 1; + goto out; + } } ret = dict_get_int32 (options, "type", &type); @@ -2586,6 +2595,10 @@ struct cli_cmd volume_cmds[] = { cli_cmd_quota_cbk, "quota translator specific operations"}, + { "volume inode-quota enable", + cli_cmd_quota_cbk, + "quota translator specific operations"}, + { "volume top {open|read|write|opendir|readdir|clear} [nfs|brick ] [list-cnt ] |\n" "volume top {read-perf|write-perf} [bs count ] [brick ] [list-cnt ]", cli_cmd_volume_top_cbk, diff --git a/cli/src/cli.h b/cli/src/cli.h index a8aa271b68e..71bf3add3d2 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -241,6 +241,9 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **opt); int32_t cli_cmd_quota_parse (const char **words, int wordcount, dict_t **opt); +int32_t +cli_cmd_inode_quota_parse (const char **words, int wordcount, dict_t **opt); + int32_t cli_cmd_bitrot_parse (const char **words, int wordcount, dict_t **opt); -- cgit