summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-helper.c
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2015-05-28 16:03:12 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-06-02 22:33:00 -0700
commitb6eda067d2e2a0b56718ea71522f6c7b06a09f13 (patch)
tree82f5909c06abb4fdbb99d11d3fbe3eefea7b8f2c /xlators/cluster/dht/src/dht-helper.c
parentb7842d178a6019bc2c14ecaf18ae5438a46bda29 (diff)
cluster/dht: pass a destination subvol to fop2 variants to avoid races.
The destination subvol used in the fop2 variants is either stored in inode-ctx1 or local->cached_subvol. However, it is not guaranteed that a value stored in these locations before invocation of fop2 is still present after the invocation as these locations are shared among different concurrent operations. So, to preserve the atomicity of "check dst-subvol and invoke fop2 variant if dst-subvol found", we pass down the dst-subvol to fop2 variant. This patch also fixes error handling in some fop2 variants. Change-Id: Icc226228a246d3f223e3463519736c4495b364d2 BUG: 1142423 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-on: http://review.gluster.org/10943 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: N Balachandran <nbalacha@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-helper.c')
-rw-r--r--xlators/cluster/dht/src/dht-helper.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 19bea0a0ae2..7aa307da6b8 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -815,11 +815,23 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf)
static int
dht_migration_complete_check_done (int op_ret, call_frame_t *frame, void *data)
{
- dht_local_t *local = NULL;
+ dht_local_t *local = NULL;
+ xlator_t *subvol = NULL;
local = frame->local;
- local->rebalance.target_op_fn (THIS, frame, op_ret);
+ if (op_ret == -1)
+ goto out;
+
+ if (local->cached_subvol == NULL) {
+ local->op_errno = EINVAL;
+ goto out;
+ }
+
+ subvol = local->cached_subvol;
+
+out:
+ local->rebalance.target_op_fn (THIS, subvol, frame);
return 0;
}
@@ -998,13 +1010,30 @@ dht_rebalance_complete_check (xlator_t *this, call_frame_t *frame)
/* During 'in-progress' state, both nodes should have the file */
static int
-dht_inprogress_check_done (int op_ret, call_frame_t *sync_frame, void *data)
+dht_inprogress_check_done (int op_ret, call_frame_t *frame, void *data)
{
- dht_local_t *local = NULL;
+ dht_local_t *local = NULL;
+ xlator_t *subvol = NULL;
+ inode_t *inode = NULL;
- local = sync_frame->local;
+ local = frame->local;
+
+ if (op_ret == -1)
+ goto out;
+
+ inode = local->loc.inode ? local->loc.inode : local->fd->inode;
+
+ dht_inode_ctx_get1 (THIS, inode, &subvol);
+ if (!subvol) {
+ subvol = dht_subvol_get_cached (THIS, inode);
+ if (!subvol) {
+ local->op_errno = EINVAL;
+ goto out;
+ }
+ }
- local->rebalance.target_op_fn (THIS, sync_frame, op_ret);
+out:
+ local->rebalance.target_op_fn (THIS, subvol, frame);
return 0;
}