summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heal-data.c
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2012-12-03 10:41:49 -0500
committerAnand Avati <avati@redhat.com>2012-12-04 14:45:06 -0800
commite19bf891d5373e1660e666fecf6740062a375617 (patch)
tree16747fe36ff82dd18a15ec7bbf2ef93feb4b07ca /xlators/cluster/afr/src/afr-self-heal-data.c
parent7b5a21707edbbee1940f7cd3d05043bec998e51a (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: Ib7ff9984578fa11de4e3b6981508100cdddd37cd Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-on: http://review.gluster.org/4257 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-data.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 5e1e6fe9f6d..bf20d8652bc 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -389,7 +389,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);
}
@@ -1131,8 +1131,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 "
@@ -1205,7 +1210,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)
{
@@ -1217,6 +1222,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);
}
@@ -1270,7 +1276,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);
}
@@ -1395,7 +1401,7 @@ afr_self_heal_data (call_frame_t *frame, xlator_t *this)
if (IA_ISREG (sh->type)) {
afr_sh_data_open (frame, this);
} else {
- afr_sh_data_lock (frame, this, 0, 0,
+ afr_sh_data_lock (frame, this, 0, 0, _gf_true,
afr_sh_non_reg_lock_success,
afr_sh_data_fail);
}