summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2011-04-21 04:16:44 +0000
committerAnand Avati <avati@gluster.com>2011-04-21 03:35:56 -0700
commit58465cdca9386fe2fa15049911223f7282e1b412 (patch)
tree1359cd599a4e9b153c7240ebc548caba1ff75163 /xlators/features
parent1f074563ecdaf92b2ecf12d7ea79b2b5d8f50c2d (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
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/marker/src/marker-quota.c47
-rw-r--r--xlators/features/marker/src/marker-quota.h2
-rw-r--r--xlators/features/marker/src/marker.c4
-rw-r--r--xlators/features/marker/src/marker.h2
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 8a56dcbbc..68a8a26c6 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 0011a28b6..ea54bb631 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 7b339748b..862c0a464 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 b2a64cf99..70b5e8567 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;