summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2012-12-03 10:41:49 -0500
committerVijay Bellur <vbellur@redhat.com>2012-12-17 02:10:54 -0500
commite2b15d14e550e99653c1bb3abd072fc487fd0497 (patch)
tree943541701e178097e564ec940c75a8a10cd5467e
parentae4970422efcbb168072c4db0ee82bbf2d2824f7 (diff)
afr: support self-heal data trylock mechanism
Introduce a block flag to support an optional blocking or non-blocking mode in the self-heal data locking mechanism. All callers are modified to use blocking mode, which is the current default behavior (no change in behavior is introduced by this commit). BUG: 874045 Change-Id: I89bd2e698bd3db898c3ad57b55cf5c38e822e136 Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-on: https://code.engineering.redhat.com/gerrit/1910 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-algorithm.c2
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.h2
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c16
-rw-r--r--xlators/cluster/afr/src/afr.h1
4 files changed, 14 insertions, 7 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.c b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
index 30e117b652d..448178bc753 100644
--- a/xlators/cluster/afr/src/afr-self-heal-algorithm.c
+++ b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
@@ -274,7 +274,7 @@ sh_loop_start (call_frame_t *sh_frame, xlator_t *this, off_t offset,
new_loop_sh->offset = offset;
new_loop_sh->block_size = sh->block_size;
afr_sh_data_lock (new_loop_frame, this, offset, new_loop_sh->block_size,
- sh_loop_lock_success, sh_loop_lock_failure);
+ _gf_true, sh_loop_lock_success, sh_loop_lock_failure);
return 0;
out:
sh->op_failed = 1;
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.h b/xlators/cluster/afr/src/afr-self-heal-common.h
index d104593ac70..0ef5edc9226 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.h
+++ b/xlators/cluster/afr/src/afr-self-heal-common.h
@@ -100,7 +100,7 @@ afr_local_t *
afr_local_copy (afr_local_t *l, xlator_t *this);
int
afr_sh_data_lock (call_frame_t *frame, xlator_t *this,
- off_t start, off_t len,
+ off_t start, off_t len, gf_boolean_t block,
afr_lock_cbk_t success_handler,
afr_lock_cbk_t failure_handler);
void
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 423e1c8049c..d2a205ee4ab 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -384,7 +384,7 @@ afr_sh_data_erase_pending_cbk (call_frame_t *frame, void *cookie,
goto out;
}
GF_ASSERT (sh->old_loop_frame);
- afr_sh_data_lock (frame, this, 0, 0,
+ afr_sh_data_lock (frame, this, 0, 0, _gf_true,
afr_post_sh_big_lock_success,
afr_post_sh_big_lock_failure);
}
@@ -1192,8 +1192,13 @@ afr_sh_data_post_nonblocking_inodelk_cbk (call_frame_t *frame, xlator_t *this)
"failed for %s. by %s",
local->loc.path, lkowner_utoa (&frame->root->lk_owner));
- int_lock->lock_cbk = afr_sh_data_post_blocking_inodelk_cbk;
- afr_blocking_lock (frame, this);
+ if (!sh->data_lock_block) {
+ sh->data_lock_failure_handler(frame, this);
+ } else {
+ int_lock->lock_cbk =
+ afr_sh_data_post_blocking_inodelk_cbk;
+ afr_blocking_lock (frame, this);
+ }
} else {
gf_log (this->name, GF_LOG_DEBUG, "Non Blocking data inodelks "
@@ -1266,7 +1271,7 @@ afr_post_sh_big_lock_failure (call_frame_t *frame, xlator_t *this)
int
afr_sh_data_lock (call_frame_t *frame, xlator_t *this,
- off_t start, off_t len,
+ off_t start, off_t len, gf_boolean_t block,
afr_lock_cbk_t success_handler,
afr_lock_cbk_t failure_handler)
{
@@ -1278,6 +1283,7 @@ afr_sh_data_lock (call_frame_t *frame, xlator_t *this,
sh->data_lock_success_handler = success_handler;
sh->data_lock_failure_handler = failure_handler;
+ sh->data_lock_block = block;
return afr_sh_data_lock_rec (frame, this, start, len);
}
@@ -1331,7 +1337,7 @@ afr_sh_data_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
"fd for %s opened, commencing sync",
local->loc.path);
- afr_sh_data_lock (frame, this, 0, 0,
+ afr_sh_data_lock (frame, this, 0, 0, _gf_true,
afr_sh_data_big_lock_success,
afr_sh_data_fail);
}
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 78d108db6d8..72953416024 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -257,6 +257,7 @@ typedef struct {
struct afr_sh_algorithm *algo;
afr_lock_cbk_t data_lock_success_handler;
afr_lock_cbk_t data_lock_failure_handler;
+ gf_boolean_t data_lock_block;
int (*completion_cbk) (call_frame_t *frame, xlator_t *this);
int (*sh_data_algo_start) (call_frame_t *frame, xlator_t *this);
int (*algo_completion_cbk) (call_frame_t *frame, xlator_t *this);