diff options
author | Vijay Bellur <vbellur@redhat.com> | 2013-08-04 23:20:49 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2013-08-12 00:48:15 +0530 |
commit | 6fa17855dbcf2388164ebe6e7d1e0ef4618d47b6 (patch) | |
tree | cb63f849d88ffe1007e427de3c86f9847ff34568 | |
parent | f8d618eab1bb98fd598bb13f0802b380db0e57ee (diff) |
features/marker: refactor marker quota for better readability (part 1).
Change-Id: I1133c5ca24f2b395103d470bde77be966d17d938
Signed-off-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r-- | xlators/features/marker/src/marker-quota.c | 59 | ||||
-rw-r--r-- | xlators/features/marker/src/marker-quota.h | 2 |
2 files changed, 38 insertions, 23 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index d1e59509..6b5f7f86 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -1757,7 +1757,8 @@ mq_fetch_child_size_and_contri (call_frame_t *frame, void *cookie, VALIDATE_OR_GOTO (local->ctx, err); VALIDATE_OR_GOTO (local->contri, err); - gf_log (this->name, GF_LOG_DEBUG, "%s marked dirty", local->parent_loc.path); + gf_log (this->name, GF_LOG_DEBUG, "%s marked dirty", + local->parent_loc.path); //update parent ctx ret = mq_inode_ctx_get (local->parent_loc.inode, this, &ctx); @@ -1928,15 +1929,18 @@ fr_destroy: return -1; } - -int -mq_start_quota_txn (xlator_t *this, loc_t *loc, - quota_inode_ctx_t *ctx, - inode_contribution_t *contri) +static int +mq_prepare_txn_frame (xlator_t *this, loc_t *loc, + quota_inode_ctx_t *ctx, + inode_contribution_t *contri, + call_frame_t **new_frame) { - int32_t ret = -1; - call_frame_t *frame = NULL; - quota_local_t *local = NULL; + call_frame_t *frame = NULL; + int ret = -1; + quota_local_t *local = NULL; + + if (!this || !loc || new_frame) + goto err; frame = create_frame (this, this->ctx->pool); if (frame == NULL) @@ -1962,14 +1966,35 @@ mq_start_quota_txn (xlator_t *this, loc_t *loc, local->ctx = ctx; local->contri = contri; + ret = 0; + *new_frame = frame; + +fr_destroy: + QUOTA_STACK_DESTROY (frame, this); + +err: + return ret; +} + +int +mq_start_quota_txn (xlator_t *this, loc_t *loc, + quota_inode_ctx_t *ctx, + inode_contribution_t *contri) +{ + int32_t ret = -1; + call_frame_t *frame = NULL; + + ret = mq_prepare_txn_frame (this, loc, ctx, + contri, &frame); + if (ret) + goto err; + ret = mq_get_lock_on_parent (frame, this); if (ret == -1) goto err; return 0; -fr_destroy: - QUOTA_STACK_DESTROY (frame, this); err: mq_set_ctx_updation_status (ctx, _gf_false); @@ -2017,6 +2042,7 @@ mq_initiate_quota_txn (xlator_t *this, loc_t *loc) loc->parent? uuid_utoa (loc->parent->gfid): NULL); + contribution = mq_add_new_contribution_node (this, ctx, loc); if (!contribution) { if(strcmp (loc->path, "/")) @@ -2031,7 +2057,7 @@ mq_initiate_quota_txn (xlator_t *this, loc_t *loc) } } - /* To improve performance, donot start another transaction + /* To improve performance, do not start another transaction * if one is already in progress for same inode */ status = _gf_true; @@ -2050,16 +2076,7 @@ out: } -/* int32_t */ -/* validate_inode_size_contribution (xlator_t *this, loc_t *loc, int64_t size, */ -/* int64_t contribution) */ -/* { */ -/* if (size != contribution) { */ -/* mq_initiate_quota_txn (this, loc); */ -/* } */ -/* return 0; */ -/* } */ int32_t diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h index 385760ac..ae30d1a3 100644 --- a/xlators/features/marker/src/marker-quota.h +++ b/xlators/features/marker/src/marker-quota.h @@ -42,8 +42,6 @@ var = GF_CALLOC (sizeof (type), 1, \ gf_marker_mt_##type); \ if (!var) { \ - gf_log ("", GF_LOG_ERROR, \ - "out of memory"); \ ret = -1; \ } \ } while (0); |