diff options
author | Raghavendra G <raghavendra@gluster.com> | 2011-04-21 04:16:44 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-21 03:35:56 -0700 |
commit | 58465cdca9386fe2fa15049911223f7282e1b412 (patch) | |
tree | 1359cd599a4e9b153c7240ebc548caba1ff75163 | |
parent | 1f074563ecdaf92b2ecf12d7ea79b2b5d8f50c2d (diff) |
features/marker-quota: handle overflow of counter used to set frame->root->lk_owner.
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2804 (Occasional log messages seen indicating failure of inodelk)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2804
-rw-r--r-- | xlators/features/marker/src/marker-quota.c | 47 | ||||
-rw-r--r-- | xlators/features/marker/src/marker-quota.h | 2 | ||||
-rw-r--r-- | xlators/features/marker/src/marker.c | 4 | ||||
-rw-r--r-- | xlators/features/marker/src/marker.h | 2 |
4 files changed, 42 insertions, 13 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index 8a56dcbbc5a..68a8a26c6fb 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -30,6 +30,30 @@ #include "marker-quota.h" #include "marker-quota-helper.h" +void +mq_assign_lk_owner (xlator_t *this, call_frame_t *frame) +{ + marker_conf_t *conf = NULL; + uint64_t lk_owner = 0; + + conf = this->private; + + LOCK (&conf->lock); + { + if (++conf->quota_lk_owner == 0) { + ++conf->quota_lk_owner; + } + + lk_owner = conf->quota_lk_owner; + } + UNLOCK (&conf->lock); + + frame->root->lk_owner = lk_owner; + + return; +} + + int32_t loc_fill_from_name (xlator_t *this, loc_t *newloc, loc_t *oldloc, uint64_t ino, char *name) @@ -652,10 +676,10 @@ update_dirty_inode (xlator_t *this, quota_inode_ctx_t *ctx, inode_contribution_t *contribution) { - int32_t ret = -1; - quota_local_t *local = NULL; - struct gf_flock lock; - call_frame_t *frame = NULL; + int32_t ret = -1; + quota_local_t *local = NULL; + struct gf_flock lock = {0, }; + call_frame_t *frame = NULL; frame = create_frame (this, this->ctx->pool); if (frame == NULL) { @@ -663,6 +687,8 @@ update_dirty_inode (xlator_t *this, goto out; } + mq_assign_lk_owner (this, frame); + local = quota_local_new (); if (local == NULL) goto fr_destroy; @@ -677,8 +703,6 @@ update_dirty_inode (xlator_t *this, local->contri = contribution; - frame->root->lk_owner = cn++; - lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; lock.l_start = 0; @@ -1400,15 +1424,15 @@ 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; - quota_local_t *local = NULL; + int32_t ret = -1; + call_frame_t *frame = NULL; + quota_local_t *local = NULL; frame = create_frame (this, this->ctx->pool); if (frame == NULL) goto err; - frame->root->lk_owner = cn++; + mq_assign_lk_owner (this, frame); local = quota_local_new (); if (local == NULL) @@ -1860,7 +1884,8 @@ reduce_parent_size (xlator_t *this, loc_t *loc) goto out; } - frame->root->lk_owner = cn++; + mq_assign_lk_owner (this, frame); + frame->local = local; lock.l_len = 0; diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h index 0011a28b677..ea54bb6315c 100644 --- a/xlators/features/marker/src/marker-quota.h +++ b/xlators/features/marker/src/marker-quota.h @@ -134,8 +134,6 @@ struct quota_local { }; typedef struct quota_local quota_local_t; -int32_t cn; - int32_t get_lock_on_parent (call_frame_t *, xlator_t *); diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index 7b339748bf4..862c0a464aa 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -1889,6 +1889,8 @@ marker_priv_cleanup (xlator_t *this) marker_xtime_priv_cleanup (this); + LOCK_DESTROY (&priv->lock); + GF_FREE (priv); out: return; @@ -1975,6 +1977,8 @@ init (xlator_t *this) priv->feature_enabled = 0; + LOCK_INIT (&priv->lock); + data = dict_get (options, "quota"); if (data) { ret = gf_string2boolean (data->data, &flag); diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h index b2a64cf9908..70b5e8567d3 100644 --- a/xlators/features/marker/src/marker.h +++ b/xlators/features/marker/src/marker.h @@ -85,6 +85,8 @@ struct marker_conf{ uuid_t volume_uuid_bin; char *timestamp_file; char *marker_xattr; + uint64_t quota_lk_owner; + gf_lock_t lock; }; typedef struct marker_conf marker_conf_t; |