diff options
author | Raghavendra G <raghavendra@gluster.com> | 2011-06-14 23:54:16 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-06-16 22:00:51 -0700 |
commit | a87555181d47522e985325c67b7d17c49dbd38de (patch) | |
tree | 16e7848551e64c1aa8b2038fabe2da4c3bd98dd7 /xlators/features/marker/src/marker-quota.c | |
parent | 01d67311c83ae272f3ee3632c1e8f13ccebaca81 (diff) |
features/marker-quota: fixes in rename path.
- remove xattrs from newpath after rename is complete.
- hold inodelk on both parents (if they are different) before doing rename and
gather contribution values of oldpath and newpath to their parents while still
holding the locks. Use these contribution values to reduce parent sizes.
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2697 (Quota: add-brick creates the size go awkward, though it was perfect earlier)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2697
Diffstat (limited to 'xlators/features/marker/src/marker-quota.c')
-rw-r--r-- | xlators/features/marker/src/marker-quota.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index 4662c989d91..0a82cb5fe2a 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -1762,10 +1762,13 @@ mq_inode_remove_done (call_frame_t *frame, void *cookie, xlator_t *this, local->err = -1; ret = quota_inode_ctx_get (local->parent_loc.inode, this, &ctx); - if (ret == 0) - ctx->size -= local->contri->contribution; - local->contri->contribution = 0; + if (local->contri->contribution == local->size) { + if (ret == 0) + ctx->size -= local->contri->contribution; + + local->contri->contribution = 0; + } lock.l_type = F_UNLCK; lock.l_whence = SEEK_SET; @@ -1813,10 +1816,13 @@ mq_reduce_parent_size_xattr (call_frame_t *frame, void *cookie, goto err; } - QUOTA_ALLOC_OR_GOTO (size, int64_t, ret, err); + if (local->size < 0) { + local->size = contribution->contribution; + } - *size = hton64 (-contribution->contribution); + QUOTA_ALLOC_OR_GOTO (size, int64_t, ret, err); + *size = hton64 (-local->size); ret = dict_set_bin (dict, QUOTA_SIZE_KEY, size, 8); if (ret < 0) @@ -1838,7 +1844,7 @@ err: } int32_t -reduce_parent_size (xlator_t *this, loc_t *loc) +reduce_parent_size (xlator_t *this, loc_t *loc, int64_t contri) { int32_t ret = -1; struct gf_flock lock = {0,}; @@ -1867,6 +1873,17 @@ reduce_parent_size (xlator_t *this, loc_t *loc) goto out; } + if (contri >= 0) { + local->size = contri; + } else { + local->size = -1; + } + + if (local->size == 0) { + ret = 0; + goto out; + } + ret = loc_copy (&local->loc, loc); if (ret < 0) goto out; @@ -1898,13 +1915,15 @@ reduce_parent_size (xlator_t *this, loc_t *loc) FIRST_CHILD(this), FIRST_CHILD(this)->fops->inodelk, this->name, &local->parent_loc, F_SETLKW, &lock); + local = NULL; ret = 0; out: - if (ret < 0) { + if (local != NULL) { quota_local_unref (this, local); GF_FREE (local); } + return ret; } |