summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/src/marker-quota-helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/features/marker/src/marker-quota-helper.c')
-rw-r--r--xlators/features/marker/src/marker-quota-helper.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c
index fba2cdd3f5d..a559da808f8 100644
--- a/xlators/features/marker/src/marker-quota-helper.c
+++ b/xlators/features/marker/src/marker-quota-helper.c
@@ -178,6 +178,8 @@ __add_new_contribution_node (xlator_t *this, quota_inode_ctx_t *ctx, loc_t *loc)
uuid_copy (contribution->gfid, loc->parent->gfid);
+ LOCK_INIT (&contribution->lock);
+
list_add_tail (&contribution->contri_list, &ctx->contribution_head);
out:
@@ -354,12 +356,13 @@ quota_local_ref (quota_local_t *local)
int32_t
quota_local_unref (xlator_t *this, quota_local_t *local)
{
+ int32_t ref = 0;
if (local == NULL)
goto out;
- QUOTA_SAFE_DECREMENT (&local->lock, local->ref);
+ QUOTA_SAFE_DECREMENT (&local->lock, local->ref, ref);
- if (local->ref > 0)
+ if (ref > 0)
goto out;
if (local->fd != NULL)
@@ -373,3 +376,38 @@ quota_local_unref (xlator_t *this, quota_local_t *local)
out:
return 0;
}
+
+
+inode_contribution_t *
+get_contribution_from_loc (xlator_t *this, loc_t *loc)
+{
+ int32_t ret = 0;
+ quota_inode_ctx_t *ctx = NULL;
+ inode_contribution_t *contribution = NULL;
+
+ ret = quota_inode_ctx_get (loc->inode, this, &ctx);
+ if (ret < 0) {
+ gf_log_callingfn (this->name, GF_LOG_WARNING,
+ "cannot get marker-quota context from inode "
+ "(ino: %"PRId64", gfid:%s, path:%s)",
+ loc->inode->ino,
+ uuid_utoa (loc->inode->gfid),
+ loc->path);
+ goto err;
+ }
+
+ contribution = get_contribution_node (loc->parent, ctx);
+ if (contribution == NULL) {
+ gf_log_callingfn (this->name, GF_LOG_WARNING,
+ "inode (ino:%"PRId64", gfid:%s, path:%s ) has"
+ " no contribution towards parent (ino:%"PRId64
+ ", gfid:%s)", loc->inode->ino,
+ uuid_utoa (loc->inode->gfid),
+ loc->path, loc->parent->ino,
+ uuid_utoa (loc->parent->gfid));
+ goto err;
+ }
+
+err:
+ return contribution;
+}