diff options
Diffstat (limited to 'xlators/features/marker/src/marker-quota.c')
-rw-r--r-- | xlators/features/marker/src/marker-quota.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index bb65c8787b2..65973edcd00 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -760,11 +760,18 @@ out: int32_t mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, - inode_contribution_t *contri, quota_meta_t *delta) + inode_contribution_t *contri, quota_meta_t *delta, + uint32_t nlink) { int32_t ret = -1; char contri_key[QUOTA_KEY_MAX] = {0, }; + if (nlink == 1) { + /*File was a last link and has been deleted */ + ret = 0; + goto done; + } + GET_CONTRI_KEY (this, contri_key, contri->gfid, ret); if (ret < 0) { gf_log (this->name, GF_LOG_ERROR, "get contri_key " @@ -791,6 +798,7 @@ mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx, } } +done: LOCK (&contri->lock); { contri->contribution += delta->size; @@ -948,7 +956,7 @@ mq_synctask_cleanup (int ret, call_frame_t *frame, void *opaque) int mq_synctask1 (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, - loc_t *loc, quota_meta_t *contri) + loc_t *loc, quota_meta_t *contri, uint32_t nlink) { int32_t ret = -1; quota_synctask_t *args = NULL; @@ -964,6 +972,7 @@ mq_synctask1 (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, args->this = this; loc_copy (&args->loc, loc); + args->ia_nlink = nlink; if (contri) { args->contri = *contri; @@ -993,7 +1002,7 @@ out: int mq_synctask (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, loc_t *loc) { - return mq_synctask1 (this, task, spawn, loc, NULL); + return mq_synctask1 (this, task, spawn, loc, NULL, -1); } int32_t @@ -1201,12 +1210,14 @@ mq_reduce_parent_size_task (void *opaque) xlator_t *this = NULL; loc_t *loc = NULL; gf_boolean_t remove_xattr = _gf_true; + uint32_t nlink = 0; GF_ASSERT (opaque); args = (quota_synctask_t *) opaque; loc = &args->loc; contri = args->contri; + nlink = args->ia_nlink; this = args->this; THIS = this; @@ -1266,7 +1277,8 @@ mq_reduce_parent_size_task (void *opaque) mq_sub_meta (&delta, NULL); if (remove_xattr) { - ret = mq_remove_contri (this, loc, ctx, contribution, &delta); + ret = mq_remove_contri (this, loc, ctx, contribution, &delta, + nlink); if (ret < 0) goto out; } @@ -1312,7 +1324,7 @@ out: int32_t mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc, - quota_meta_t *contri) + quota_meta_t *contri, uint32_t nlink) { int32_t ret = -1; loc_t loc = {0, }; @@ -1330,7 +1342,7 @@ mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc, } ret = mq_synctask1 (this, mq_reduce_parent_size_task, _gf_true, &loc, - contri); + contri, nlink); out: loc_wipe (&loc); return ret; |