From 1992dc12443f376f9b2974f4e830b4b17e3574c0 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Sun, 10 Apr 2011 10:53:36 +0000 Subject: features/quota: use signed type to store delta. Signed-off-by: Raghavendra G Signed-off-by: Anand Avati BUG: 2604 (Quota: crossing the set limit) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2604 --- xlators/features/quota/src/quota.c | 16 ++++++++-------- xlators/features/quota/src/quota.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'xlators/features/quota') diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 1911d63e364..80b3a2885eb 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -835,7 +835,8 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, { int32_t ret = -1, op_errno = EINVAL; int32_t parents = 0; - uint64_t size = 0, delta = 0; + uint64_t size = 0; + int64_t delta = 0; quota_local_t *local = NULL; quota_inode_ctx_t *ctx = NULL; quota_priv_t *priv = NULL; @@ -876,17 +877,14 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, size = iov_length (vector, count); LOCK (&ctx->lock); { - delta = (off + size - ctx->buf.ia_size); + delta = off + size - ctx->buf.ia_size; + list_for_each_entry (dentry, &ctx->parents, next) { parents++; } } UNLOCK (&ctx->lock); - if (delta < 0) { - delta = 0; - } - local->delta = delta; local->stub = stub; local->link_count = parents; @@ -1610,8 +1608,10 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, if (ctx == NULL) { gf_log (this->name, GF_LOG_WARNING, "quota context not set in inode (ino:%"PRId64 - ", gfid:%s)", oldloc->inode?oldloc->inode->ino:0, - oldloc->inode?uuid_utoa (oldloc->inode->gfid):"0"); + ", gfid:%s)", + oldloc->inode ? oldloc->inode->ino:0, + oldloc->inode ? uuid_utoa (oldloc->inode->gfid) + :"0"); op_errno = EINVAL; goto err; } diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h index fce2e54bd60..7250a5dc9d3 100644 --- a/xlators/features/quota/src/quota.h +++ b/xlators/features/quota/src/quota.h @@ -148,7 +148,7 @@ struct quota_local { loc_t oldloc; loc_t newloc; loc_t validate_loc; - uint32_t delta; + int64_t delta; int32_t op_ret; int32_t op_errno; int64_t size; -- cgit