summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-inode-read.c
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2015-09-01 15:31:02 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-09-22 20:56:40 -0700
commit470869a954c17f32a3ba43ccda7442f82c0da6b2 (patch)
tree750a45685eff044b43fc739c8d3913e8ceeef8b9 /xlators/cluster/dht/src/dht-inode-read.c
parentbdbd092e2caf79a2cfd6cda507af624e9861ae30 (diff)
cluster/tier: Handle FOPs on files being migrated
Determine which DHT level is responsible for handling fops on a file undergoing migration based on the name of the the linkto xattr set on the file being migrated and process accordingly. Change-Id: I82772e39314d4fe7f2ba0dcf22de0c6a374ee139 BUG: 1254428 Signed-off-by: N Balachandran <nbalacha@redhat.com> Signed-off-by: Nithya Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/12090 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-inode-read.c')
-rw-r--r--xlators/cluster/dht/src/dht-inode-read.c139
1 files changed, 113 insertions, 26 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c
index a5eda4e1270..02265fd2e85 100644
--- a/xlators/cluster/dht/src/dht-inode-read.c
+++ b/xlators/cluster/dht/src/dht-inode-read.c
@@ -10,13 +10,22 @@
#include "dht-common.h"
-int dht_access2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame);
-int dht_readv2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame);
-int dht_attr2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame);
-int dht_open2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame);
-int dht_flush2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame);
-int dht_lk2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame);
-int dht_fsync2 (xlator_t *this, xlator_t *dst_node, call_frame_t *frame);
+int dht_access2 (xlator_t *this, xlator_t *dst_node,
+ call_frame_t *frame, int ret);
+int dht_readv2 (xlator_t *this, xlator_t *dst_node,
+ call_frame_t *frame, int ret);
+int dht_attr2 (xlator_t *this, xlator_t *dst_node,
+ call_frame_t *frame, int ret);
+int dht_open2 (xlator_t *this, xlator_t *dst_node,
+ call_frame_t *frame, int ret);
+int dht_flush2 (xlator_t *this, xlator_t *dst_node,
+ call_frame_t *frame, int ret);
+int dht_lk2 (xlator_t *this, xlator_t *dst_node,
+ call_frame_t *frame, int ret);
+int dht_fsync2 (xlator_t *this, xlator_t *dst_node,
+ call_frame_t *frame, int ret);
+
+
int
dht_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
@@ -53,7 +62,7 @@ out:
}
int
-dht_open2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
+dht_open2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
{
dht_local_t *local = NULL;
int op_errno = EINVAL;
@@ -64,6 +73,14 @@ dht_open2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
local = frame->local;
op_errno = ENOENT;
+ if (we_are_not_migrating (ret)) {
+ /* This DHT layer is not migrating the file */
+ DHT_STACK_UNWIND (open, frame, -1, local->op_errno,
+ NULL, NULL);
+ return 0;
+
+ }
+
if (subvol == NULL)
goto out;
@@ -75,10 +92,11 @@ dht_open2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
return 0;
out:
- DHT_STACK_UNWIND (stat, frame, -1, op_errno, NULL, NULL);
+ DHT_STACK_UNWIND (open, frame, -1, op_errno, NULL, NULL);
return 0;
}
+
int
dht_open (call_frame_t *frame, xlator_t *this,
loc_t *loc, int flags, fd_t *fd, dict_t *xdata)
@@ -150,6 +168,8 @@ dht_file_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
local->op_errno = op_errno;
+ local->op_ret = op_ret;
+
/* Check if the rebalance phase2 is true */
if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (stbuf)) {
inode = (local->fd) ? local->fd->inode : local->loc.inode;
@@ -157,13 +177,15 @@ dht_file_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (!subvol) {
/* Phase 2 of migration */
local->rebalance.target_op_fn = dht_attr2;
+ dht_set_local_rebalance (this, local, NULL, NULL,
+ stbuf, xdata);
ret = dht_rebalance_complete_check (this, frame);
if (!ret)
return 0;
} else {
/* value is already set in fd_ctx, that means no need
to check for whether its complete or not. */
- dht_attr2 (this, subvol, frame);
+ dht_attr2 (this, subvol, frame, 0);
return 0;
}
}
@@ -176,7 +198,7 @@ err:
}
int
-dht_attr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
+dht_attr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
{
dht_local_t *local = NULL;
int op_errno = EINVAL;
@@ -186,6 +208,19 @@ dht_attr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
goto out;
op_errno = local->op_errno;
+
+ if (we_are_not_migrating (ret)) {
+ /* This dht xlator is not migrating the file. Unwind and
+ * pass on the original mode bits so the higher DHT layer
+ * can handle this.
+ */
+ DHT_STACK_UNWIND (stat, frame, local->op_ret, op_errno,
+ &local->rebalance.postbuf,
+ local->rebalance.xdata);
+ return 0;
+ }
+
+
if (subvol == NULL)
goto out;
@@ -377,7 +412,8 @@ dht_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
{
dht_local_t *local = NULL;
int ret = 0;
- xlator_t *subvol = 0;
+ xlator_t *src_subvol = 0;
+ xlator_t *dst_subvol = 0;
local = frame->local;
if (!local) {
@@ -396,23 +432,31 @@ dht_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local->op_errno = op_errno;
if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (stbuf)) {
/* File would be migrated to other node */
- ret = dht_inode_ctx_get_mig_info (this, local->fd->inode, NULL,
- &subvol);
- if (!subvol) {
+ ret = dht_inode_ctx_get_mig_info (this, local->fd->inode,
+ &src_subvol,
+ &dst_subvol);
+
+ if (dht_mig_info_is_invalid (local->cached_subvol,
+ src_subvol, dst_subvol)) {
+ local->op_ret = op_ret;
local->rebalance.target_op_fn = dht_readv2;
+ dht_set_local_rebalance (this, local, NULL, NULL,
+ stbuf, xdata);
+
ret = dht_rebalance_complete_check (this, frame);
if (!ret)
return 0;
} else {
/* value is already set in fd_ctx, that means no need
to check for whether its complete or not. */
- dht_readv2 (this, subvol, frame);
+ dht_readv2 (this, dst_subvol, frame, 0);
return 0;
}
}
out:
DHT_STRIP_PHASE1_FLAGS (stbuf);
+
DHT_STACK_UNWIND (readv, frame, op_ret, op_errno, vector, count, stbuf,
iobref, xdata);
@@ -420,7 +464,7 @@ out:
}
int
-dht_readv2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
+dht_readv2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
{
dht_local_t *local = NULL;
int op_errno = EINVAL;
@@ -430,6 +474,18 @@ dht_readv2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
goto out;
op_errno = local->op_errno;
+
+ if (we_are_not_migrating (ret)) {
+ /* This dht xlator is not migrating the file. Unwind and
+ * pass on the original mode bits so the higher DHT layer
+ * can handle this.
+ */
+ DHT_STACK_UNWIND (readv, frame, local->op_ret, op_errno,
+ NULL, 0, &local->rebalance.postbuf,
+ NULL, local->rebalance.xdata);
+ return 0;
+ }
+
if (subvol == NULL)
goto out;
@@ -446,6 +502,7 @@ out:
return 0;
}
+
int
dht_readv (call_frame_t *frame, xlator_t *this,
fd_t *fd, size_t size, off_t off, uint32_t flags, dict_t *xdata)
@@ -538,7 +595,7 @@ out:
}
int
-dht_access2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
+dht_access2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
{
dht_local_t *local = NULL;
int op_errno = EINVAL;
@@ -548,6 +605,17 @@ dht_access2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
goto out;
op_errno = local->op_errno;
+
+ if (we_are_not_migrating (ret)) {
+ /* This dht xlator is not migrating the file. Unwind and
+ * pass on the original mode bits so the higher DHT layer
+ * can handle this.
+ */
+
+ DHT_STACK_UNWIND (access, frame, -1, op_errno, NULL);
+ return 0;
+ }
+
if (subvol == NULL)
goto out;
@@ -624,7 +692,7 @@ dht_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* If context is set, then send flush() it to the destination */
dht_inode_ctx_get_mig_info (this, local->fd->inode, NULL, &subvol);
if (subvol) {
- dht_flush2 (this, subvol, frame);
+ dht_flush2 (this, subvol, frame, 0);
return 0;
}
@@ -635,7 +703,7 @@ out:
}
int
-dht_flush2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
+dht_flush2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
{
dht_local_t *local = NULL;
int32_t op_errno = EINVAL;
@@ -647,7 +715,6 @@ dht_flush2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
op_errno = local->op_errno;
- dht_inode_ctx_get_mig_info (this, local->fd->inode, NULL, &subvol);
if (subvol == NULL)
goto out;
@@ -713,7 +780,8 @@ dht_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
call_frame_t *prev = NULL;
int ret = -1;
inode_t *inode = NULL;
- xlator_t *subvol = 0;
+ xlator_t *src_subvol = 0;
+ xlator_t *dst_subvol = 0;
local = frame->local;
prev = cookie;
@@ -736,9 +804,15 @@ dht_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
local->op_errno = op_errno;
inode = local->fd->inode;
- dht_inode_ctx_get_mig_info (this, inode, NULL, &subvol);
- if (!subvol) {
+
+ dht_inode_ctx_get_mig_info (this, inode, &src_subvol, &dst_subvol);
+
+ if (dht_mig_info_is_invalid (local->cached_subvol,
+ src_subvol, dst_subvol)) {
+
local->rebalance.target_op_fn = dht_fsync2;
+ dht_set_local_rebalance (this, local, NULL, prebuf,
+ postbuf, xdata);
/* Check if the rebalance phase1 is true */
if (IS_DHT_MIGRATION_PHASE1 (postbuf)) {
@@ -755,13 +829,14 @@ dht_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
if (!ret)
return 0;
} else {
- dht_fsync2 (this, subvol, frame);
+ dht_fsync2 (this, dst_subvol, frame, 0);
return 0;
}
out:
DHT_STRIP_PHASE1_FLAGS (postbuf);
DHT_STRIP_PHASE1_FLAGS (prebuf);
+
DHT_STACK_UNWIND (fsync, frame, op_ret, op_errno,
prebuf, postbuf, xdata);
@@ -769,7 +844,7 @@ out:
}
int
-dht_fsync2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
+dht_fsync2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
{
dht_local_t *local = NULL;
int32_t op_errno = EINVAL;
@@ -780,6 +855,18 @@ dht_fsync2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame)
local = frame->local;
op_errno = local->op_errno;
+ if (we_are_not_migrating (ret)) {
+ /* This dht xlator is not migrating the file. Unwind and
+ * pass on the original mode bits so the higher DHT layer
+ * can handle this.
+ */
+ DHT_STACK_UNWIND (fsync, frame, local->op_ret,
+ op_errno, &local->rebalance.prebuf,
+ &local->rebalance.postbuf,
+ local->rebalance.xdata);
+ return 0;
+ }
+
if (subvol == NULL)
goto out;