From 8a3331903613d54d92c0191c238bf17cb33e0e6c Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Sat, 10 Aug 2013 19:59:53 +0530 Subject: features/quota: Add support for statedump - dumps members of quota_priv_t. - also added validation count to keep track of number of validations done. Change-Id: I998fcccacf4bd7c61ead9ca9a489e0dc0e73763a Signed-off-by: Vijay Bellur --- xlators/features/quota/src/quota.c | 40 ++++++++++++++++++++++++++++++++++++++ xlators/features/quota/src/quota.h | 1 + 2 files changed, 41 insertions(+) diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 5f7c67ce..0c27b2eb 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -12,6 +12,7 @@ #include "quota.h" #include "common-utils.h" #include "defaults.h" +#include "statedump.h" int32_t quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, @@ -450,6 +451,11 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, UNLOCK (&ctx->lock); if (need_validate) { + LOCK (&priv->lock); + { + priv->validation_count++; + } + UNLOCK (&priv->lock); goto validate; } @@ -3481,6 +3487,37 @@ out: return ret; } +int32_t +quota_priv_dump (xlator_t *this) +{ + quota_priv_t *priv = NULL; + int32_t ret = -1; + + + GF_ASSERT (this); + + priv = this->private; + + gf_proc_dump_add_section ("xlators.features.quota.priv", this->name); + + ret = TRY_LOCK (&priv->lock); + if (ret) + goto out; + else { + gf_proc_dump_write("soft-timeout", "%d", priv->soft_timeout); + gf_proc_dump_write("hard-timeout", "%d", priv->hard_timeout); + gf_proc_dump_write("log-timeout", "%d", priv->log_timeout); + gf_proc_dump_write("quota-on", "%d", priv->is_quota_on); + gf_proc_dump_write("statfs", "%d", priv->consider_statfs); + gf_proc_dump_write("volume-uuid", "%s", priv->volume_uuid); + gf_proc_dump_write("validation-count", "%ld", + priv->validation_count); + } + UNLOCK (&priv->lock); + +out: + return 0; +} void fini (xlator_t *this) @@ -3523,6 +3560,9 @@ struct xlator_cbks cbks = { .forget = quota_forget }; +struct xlator_dumpops dumpops = { + .priv = quota_priv_dump, +}; struct volume_options options[] = { {.key = {"limit-set"}}, {.key = {"deem-statfs"}, diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h index 3a7a47f2..11022895 100644 --- a/xlators/features/quota/src/quota.h +++ b/xlators/features/quota/src/quota.h @@ -181,6 +181,7 @@ struct quota_priv { rpcsvc_t *rpcsvc; inode_table_t *itable; char *volume_uuid; + uint64_t validation_count; }; typedef struct quota_priv quota_priv_t; -- cgit