summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/src/marker-quota.c
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-11-02 15:39:46 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-11-09 03:12:26 -0800
commit2794cb71b96c44033dcd01102039c038956cf7b5 (patch)
tree0dc5459474f4e07ba0e75a81b79b0ae99db850bb /xlators/features/marker/src/marker-quota.c
parentc8c9308134ae4ce24c630a1b0ccfcf4e8f9b0fe7 (diff)
marker: do remove xattr only for last link
With unlink, rename, rmdir, contribution xattrs are removed. If the file is a last link then remove_xattr will fail with ENOENT. So it better to perform remove_xattr only if there are more links to the file Change-Id: Ifc1e7fda4d310fd87f6f28a635c9ea78b8f3929d BUG: 1257694 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/12033 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Manikandan Selvaganesh <mselvaga@redhat.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/features/marker/src/marker-quota.c')
-rw-r--r--xlators/features/marker/src/marker-quota.c24
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 39f199bb849..e12cfab2527 100644
--- a/xlators/features/marker/src/marker-quota.c
+++ b/xlators/features/marker/src/marker-quota.c
@@ -755,11 +755,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 "
@@ -786,6 +793,7 @@ mq_remove_contri (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx,
}
}
+done:
LOCK (&contri->lock);
{
contri->contribution += delta->size;
@@ -943,7 +951,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;
@@ -959,6 +967,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;
@@ -988,7 +997,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
@@ -1196,12 +1205,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;
@@ -1261,7 +1272,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;
}
@@ -1307,7 +1319,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, };
@@ -1325,7 +1337,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;