summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2011-04-18 08:30:54 +0000
committerAnand Avati <avati@gluster.com>2011-04-18 07:42:23 -0700
commite89f2a1f5daf1513c533a47b90aec8f90702d09f (patch)
tree15baf7b9d31510de99f41cd8d2870577444739f2 /xlators
parentbb4c33f65f3e7eaeb03f3ac249d6eedd123c5ba6 (diff)
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 <raghavendra@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2689 (Quota: xattrs getting corrupted) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2689
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/marker/src/marker.c35
-rw-r--r--xlators/features/marker/src/marker.h2
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;
};