From e89f2a1f5daf1513c533a47b90aec8f90702d09f Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 18 Apr 2011 08:30:54 +0000 Subject: features/marker-quota: reduce contributions to parents during unlink only if it is the last link. - since we are not having different contributions for different (parent, name) pairs, but only for different parents, links present in the same directory will have only one contribution representing all of them. Hence parents will not be updated for each link call and parents account for just file-size instead of (numlinks * filesize). However this patch will cause issues for links present accross directories, as only one of their contributions is subtracted when all of them removed (Here all the links are accounted in their parents, thereby total size accounted is [numlinks * filesize]). Signed-off-by: Raghavendra G Signed-off-by: Anand Avati BUG: 2689 (Quota: xattrs getting corrupted) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2689 --- xlators/features/marker/src/marker.c | 35 ++++++++++++++++++++++++++++++++--- xlators/features/marker/src/marker.h | 2 +- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index e7021647ca1..dcda5c70d04 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -743,7 +743,7 @@ marker_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, priv = this->private; - if (priv->feature_enabled & GF_QUOTA) + if ((priv->feature_enabled & GF_QUOTA) && (local->ia_nlink == 1)) reduce_parent_size (this, &local->loc); if (priv->feature_enabled & GF_XTIME) @@ -754,6 +754,34 @@ out: return 0; } + +int32_t +marker_unlink_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *buf) +{ + marker_local_t *local = NULL; + + if (op_ret < 0) { + goto err; + } + + local = frame->local; + if (local == NULL) { + goto err; + } + + local->ia_nlink = buf->ia_nlink; + + STACK_WIND (frame, marker_unlink_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->unlink, &local->loc); + return 0; +err: + STACK_UNWIND_STRICT (unlink, frame, -1, ENOMEM, NULL, NULL); + + return 0; +} + + int32_t marker_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) { @@ -775,8 +803,9 @@ marker_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) if (ret == -1) goto err; wind: - STACK_WIND (frame, marker_unlink_cbk, FIRST_CHILD(this), - FIRST_CHILD(this)->fops->unlink, loc); + STACK_WIND (frame, marker_unlink_stat_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->stat, loc); + return 0; err: STACK_UNWIND_STRICT (unlink, frame, -1, ENOMEM, NULL, NULL); diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h index 090e2621040..b2a64cf9908 100644 --- a/xlators/features/marker/src/marker.h +++ b/xlators/features/marker/src/marker.h @@ -66,7 +66,7 @@ struct marker_local{ pid_t pid; loc_t loc; int32_t ref; - + int32_t ia_nlink; gf_lock_t lock; struct marker_local *oplocal; }; -- cgit