summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2013-12-17 16:04:46 +0530
committerVijay Bellur <vbellur@redhat.com>2014-01-16 21:23:21 -0800
commita20e79ab3d0827936b679689055ea453c1d01abb (patch)
tree91fa427839349daea66d49b3d7515b2ed56a7620 /xlators/features
parent39968c09626074b34b62541af5940f44ba70cc06 (diff)
quota: fix recording of last alert log message
PROBLEM: Alert log messages, corresponding to disk usage crossing soft-limit on a directory, weren't being logged as often as expected. CAUSE: The mechanism in place to log alert messages, once every alert-time seconds, set the previous logged time incorrectly. FIX: Update previous logged time only if we logged an alert message, ie. when the "time was right" to alert. Change-Id: Iafcb7be11e3240e2d04b0bb29ddb88e4f4a1bd25 BUG: 969461 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/6532 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/quota/src/quota.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index a531ab123..c42b23027 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -3935,7 +3935,7 @@ wind:
/* Logs if
* i. Usage crossed soft limit
-* ii. Usage above soft limit and alert-time timed out
+* ii. Usage above soft limit and alert-time elapsed
*/
void
quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode,
@@ -3943,39 +3943,45 @@ quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode,
{
struct timeval cur_time = {0,};
char *usage_str = NULL;
+ char size_str[32] = {0};
char *path = NULL;
int64_t cur_size = 0;
quota_priv_t *priv = NULL;
priv = this->private;
- cur_size = ctx->size + delta;
if ((ctx->soft_lim <= 0) || (timerisset (&ctx->prev_log) &&
!quota_timeout (&ctx->prev_log,
priv->log_timeout))) {
return;
}
- gettimeofday (&cur_time, NULL);
- ctx->prev_log = cur_time;
+ cur_size = ctx->size + delta;
usage_str = gf_uint64_2human_readable (cur_size);
+ if (!usage_str) {
+ snprintf (size_str, sizeof (size_str), "%"PRId64, cur_size);
+ usage_str = (char*) size_str;
+ }
inode_path (inode, NULL, &path);
if (!path)
path = uuid_utoa (inode->gfid);
+ gettimeofday (&cur_time, NULL);
/* Usage crossed/reached soft limit */
if (DID_REACH_LIMIT (ctx->soft_lim, ctx->size, cur_size)) {
gf_log (this->name, GF_LOG_ALERT, "Usage crossed "
"soft limit: %s used by %s", usage_str, path);
+ ctx->prev_log = cur_time;
}
/* Usage is above soft limit */
else if (cur_size > ctx->soft_lim){
gf_log (this->name, GF_LOG_ALERT, "Usage is above "
"soft limit: %s used by %s", usage_str, path);
+ ctx->prev_log = cur_time;
}
- if (usage_str)
- GF_FREE (usage_str);
+
+ GF_FREE (usage_str);
}
int32_t