summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-04-04 19:35:11 -0700
committerAnand Avati <avati@redhat.com>2013-04-05 17:47:16 -0700
commit6f6744730e34fa8a161b5f7f2a8ad3f8a7fc30fa (patch)
treea0de6ae7d951a09f4f888e5ed8abe130cb6730f9
parent862b1164525b8a6d4f8d49b3049093847533f819 (diff)
afr: let eager-locking do its own overlap checks
Today there is a non-obvious dependence of eager-locking on write-behind. The reason is that eager-locking works as long as the inheriting transaction has no overlaps with any of the transactions already in progress. While write-behind provides non-overlapping writes as a side-effect most of times (and only guarantees it when strict-write-ordering option is enabled, which is not on by default) eager-lock needs the behavior as a guarantee. This is leading to complex and unwanted checks for the presence of write-behind in the graph, for the simple task of checking for overlaps. This patch removes the interdependence between eager-locking and write-behind by making eager-locking do its own overlap checks with in-progress writes. Change-Id: Iccba1185aeb5f1e7f060089c895a62840787133f BUG: 912581 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/4782 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
-rw-r--r--xlators/cluster/afr/src/afr-common.c7
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c78
-rw-r--r--xlators/cluster/afr/src/afr.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c54
4 files changed, 87 insertions, 56 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 89d964056a0..a9acb409490 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -2520,6 +2520,8 @@ __afr_fd_ctx_set (xlator_t *this, fd_t *fd)
INIT_LIST_HEAD (&fd_ctx->entries);
fd_ctx->call_child = -1;
+ INIT_LIST_HEAD (&fd_ctx->eager_locked);
+
ret = __fd_ctx_set (fd, this, (uint64_t)(long) fd_ctx);
if (ret)
gf_log (this->name, GF_LOG_DEBUG,
@@ -4086,8 +4088,9 @@ afr_transaction_local_init (afr_local_t *local, xlator_t *this)
AFR_NUM_CHANGE_LOGS);
if (!local->transaction.txn_changelog)
goto out;
- if (local->fd && (local->transaction.type == AFR_DATA_TRANSACTION))
- local->transaction.eager_lock_on = priv->eager_lock;
+
+ INIT_LIST_HEAD (&local->transaction.eager_locked);
+
ret = 0;
out:
return ret;
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 502e1ed496f..644544abcc7 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -1647,6 +1647,17 @@ afr_transaction_resume (call_frame_t *frame, xlator_t *this)
int_lock = &local->internal_lock;
priv = this->private;
+ if (local->transaction.eager_lock_on) {
+ /* We don't need to retain "local" in the
+ fd list anymore, writes to all subvols
+ are finished by now */
+ LOCK (&local->fd->lock);
+ {
+ list_del_init (&local->transaction.eager_locked);
+ }
+ UNLOCK (&local->fd->lock);
+ }
+
afr_restore_lk_owner (frame);
if (__fop_changelog_needed (frame, this)) {
@@ -1681,6 +1692,71 @@ afr_transaction_fop_failed (call_frame_t *frame, xlator_t *this, int child_index
child_index, local->transaction.type);
}
+
+
+static gf_boolean_t
+afr_locals_overlap (afr_local_t *local1, afr_local_t *local2)
+{
+ uint64_t start1 = local1->transaction.start;
+ uint64_t start2 = local2->transaction.start;
+ uint64_t end1 = 0;
+ uint64_t end2 = 0;
+
+ if (local1->transaction.len)
+ end1 = start1 + local1->transaction.len - 1;
+ else
+ end1 = ULLONG_MAX;
+
+ if (local2->transaction.len)
+ end2 = start2 + local2->transaction.len - 1;
+ else
+ end2 = ULLONG_MAX;
+
+ return ((end1 >= start2) && (end2 >= start1));
+}
+
+
+void
+afr_transaction_eager_lock_init (afr_local_t *local, xlator_t *this)
+{
+ afr_private_t *priv = NULL;
+ afr_fd_ctx_t *fdctx = NULL;
+ afr_local_t *each = NULL;
+
+ priv = this->private;
+
+ if (!local->fd)
+ return;
+
+ if (local->transaction.type != AFR_DATA_TRANSACTION)
+ return;
+
+ if (!priv->eager_lock)
+ return;
+
+ fdctx = afr_fd_ctx_get (local->fd, this);
+ if (!fdctx)
+ return;
+
+ LOCK (&local->fd->lock);
+ {
+ list_for_each_entry (each, &fdctx->eager_locked,
+ transaction.eager_locked) {
+ if (afr_locals_overlap (each, local)) {
+ local->transaction.eager_lock_on = _gf_false;
+ goto unlock;
+ }
+ }
+
+ local->transaction.eager_lock_on = _gf_true;
+ list_add_tail (&local->transaction.eager_locked,
+ &fdctx->eager_locked);
+ }
+unlock:
+ UNLOCK (&local->fd->lock);
+}
+
+
int
afr_transaction (call_frame_t *frame, xlator_t *this, afr_transaction_type type)
{
@@ -1700,6 +1776,8 @@ afr_transaction (call_frame_t *frame, xlator_t *this, afr_transaction_type type)
goto out;
}
+ afr_transaction_eager_lock_init (local, this);
+
if (local->fd && local->transaction.eager_lock_on)
afr_set_lk_owner (frame, this, local->fd);
else
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 24bd20f136b..387ed12ec2f 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -677,6 +677,7 @@ typedef struct _afr_local {
of the transaction frame */
call_stub_t *resume_stub;
+ struct list_head eager_locked;
int32_t **txn_changelog;//changelog after pre+post ops
unsigned char *pre_op;
@@ -744,6 +745,9 @@ typedef struct {
(i.e, without O_SYNC or O_DSYNC)
*/
gf_boolean_t witnessed_unstable_write;
+
+ /* list of frames currently in progress */
+ struct list_head eager_locked;
} afr_fd_ctx_t;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 53963989a90..03bcb44ab54 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -3440,56 +3440,6 @@ out:
return ret;
}
-int
-validate_wb_eagerlock (glusterd_volinfo_t *volinfo, dict_t *val_dict,
- char **op_errstr)
-{
- int ret = -1;
- gf_boolean_t wb_val = _gf_false;
- gf_boolean_t el_val = _gf_false;
- char msg[2048] = {0};
- char *wb_key = NULL;
- char *el_key = NULL;
-
- wb_key = "performance.write-behind";
- el_key = "cluster.eager-lock";
- ret = dict_get_str_boolean (val_dict, wb_key, -1);
- if (ret < 0)
- goto check_eager_lock;
- wb_val = ret;
- ret = glusterd_volinfo_get_boolean (volinfo, el_key);
- if (ret < 0)
- goto out;
- el_val = ret;
- goto done;
-
-check_eager_lock:
- ret = dict_get_str_boolean (val_dict, el_key, -1);
- if (ret < 0) {
- ret = 0; //Keys of intereset to this fn are not present.
- goto out;
- }
- el_val = ret;
- ret = glusterd_volinfo_get_boolean (volinfo, wb_key);
- if (ret < 0)
- goto out;
- wb_val = ret;
- goto done;
-
-done:
- ret = 0;
- if (!wb_val && el_val) {
- ret = -1;
- snprintf (msg, sizeof (msg), "%s off and %s on is not "
- "valid configuration", wb_key, el_key);
- gf_log ("glusterd", GF_LOG_ERROR, "%s", msg);
- if (op_errstr)
- *op_errstr = gf_strdup (msg);
- goto out;
- }
-out:
- return ret;
-}
int
validate_clientopts (glusterd_volinfo_t *volinfo,
@@ -3650,10 +3600,6 @@ glusterd_validate_reconfopts (glusterd_volinfo_t *volinfo, dict_t *val_dict,
goto out;
}
- ret = validate_wb_eagerlock (volinfo, val_dict, op_errstr);
- if (ret)
- goto out;
-
ret = validate_clientopts (volinfo, val_dict, op_errstr);
if (ret) {
gf_log ("", GF_LOG_DEBUG,