summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-inode-write.c
diff options
context:
space:
mode:
authorNithya Balachandran <nbalacha@redhat.com>2015-05-19 23:27:35 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-06-02 22:36:17 -0700
commit9684b90526d03a15d451e341521d7df44adae73e (patch)
tree4a4f342391a111d3c3fe1782bdc8ecd8dea1a903 /xlators/cluster/dht/src/dht-inode-write.c
parentb6eda067d2e2a0b56718ea71522f6c7b06a09f13 (diff)
cluster/dht: fix incorrect dst subvol info in inode_ctx
Stashing additional information in the inode_ctx to help decide whether the migration information is stale, which could happen if a file was migrated several times but FOPs only detected the P1 migration phase. If no FOP detects the P2 phase, the inode ctx1 is never reset. We now save the src subvol as well as the dst subvol in the inode ctx. The src subvol is the subvol on which the FOP was sent when the mig info was set in the inode ctx. This information is considered stale if: 1. The subvol on which the current FOP is sent is the same as the dst subvol in the ctx 2. The subvol on which the current FOP is sent is not the same as the src subvol in the ctx This does not handle the case where the same file might have been renamed such that the src subvol is the same but the dst subvol is different. However, that is unlikely to happen very often. Change-Id: I05a2e9b107ee64750c7ca629aee03b03a02ef75f BUG: 1142423 Signed-off-by: Nithya Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/10834 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-inode-write.c')
-rw-r--r--xlators/cluster/dht/src/dht-inode-write.c64
1 files changed, 41 insertions, 23 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c
index 259baa9e263..ec4029e5bd5 100644
--- a/xlators/cluster/dht/src/dht-inode-write.c
+++ b/xlators/cluster/dht/src/dht-inode-write.c
@@ -25,7 +25,8 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
{
dht_local_t *local = NULL;
int ret = -1;
- xlator_t *subvol = NULL;
+ xlator_t *subvol1 = NULL;
+ xlator_t *subvol2 = NULL;
if (op_ret == -1 && !dht_inode_missing(op_errno)) {
goto out;
@@ -62,9 +63,11 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
dht_iatt_merge (this, &local->stbuf, postbuf, NULL);
dht_iatt_merge (this, &local->prebuf, prebuf, NULL);
- ret = dht_inode_ctx_get1 (this, local->fd->inode, &subvol);
- if (subvol) {
- dht_writev2 (this, subvol, frame);
+ ret = dht_inode_ctx_get_mig_info (this, local->fd->inode,
+ &subvol1, &subvol2);
+ if (!dht_mig_info_is_invalid (local->cached_subvol,
+ subvol1, subvol2)) {
+ dht_writev2 (this, subvol2, frame);
return 0;
}
ret = dht_rebalance_in_progress_check (this, frame);
@@ -172,7 +175,8 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
dht_local_t *local = NULL;
call_frame_t *prev = NULL;
int ret = -1;
- xlator_t *subvol = NULL;
+ xlator_t *src_subvol = NULL;
+ xlator_t *dst_subvol = NULL;
inode_t *inode = NULL;
GF_VALIDATE_OR_GOTO ("dht", frame, err);
@@ -216,9 +220,12 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
dht_iatt_merge (this, &local->stbuf, postbuf, NULL);
dht_iatt_merge (this, &local->prebuf, prebuf, NULL);
inode = (local->fd) ? local->fd->inode : local->loc.inode;
- dht_inode_ctx_get1 (this, inode, &subvol);
- if (subvol) {
- dht_truncate2 (this, subvol, frame);
+
+ 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)) {
+ dht_truncate2 (this, dst_subvol, frame);
return 0;
}
ret = dht_rebalance_in_progress_check (this, frame);
@@ -363,7 +370,8 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
dht_local_t *local = NULL;
call_frame_t *prev = NULL;
int ret = -1;
- xlator_t *subvol = NULL;
+ xlator_t *src_subvol = NULL;
+ xlator_t *dst_subvol = NULL;
GF_VALIDATE_OR_GOTO ("dht", frame, err);
GF_VALIDATE_OR_GOTO ("dht", this, out);
@@ -403,9 +411,12 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
if (IS_DHT_MIGRATION_PHASE1 (postbuf)) {
dht_iatt_merge (this, &local->stbuf, postbuf, NULL);
dht_iatt_merge (this, &local->prebuf, prebuf, NULL);
- dht_inode_ctx_get1 (this, local->fd->inode, &subvol);
- if (subvol) {
- dht_fallocate2 (this, subvol, frame);
+
+ 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)) {
+ dht_fallocate2 (this, dst_subvol, frame);
return 0;
}
ret = dht_rebalance_in_progress_check (this, frame);
@@ -503,7 +514,8 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
dht_local_t *local = NULL;
call_frame_t *prev = NULL;
int ret = -1;
- xlator_t *subvol = NULL;
+ xlator_t *src_subvol = NULL;
+ xlator_t *dst_subvol = NULL;
GF_VALIDATE_OR_GOTO ("dht", frame, err);
GF_VALIDATE_OR_GOTO ("dht", this, out);
@@ -543,9 +555,12 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
if (IS_DHT_MIGRATION_PHASE1 (postbuf)) {
dht_iatt_merge (this, &local->stbuf, postbuf, NULL);
dht_iatt_merge (this, &local->prebuf, prebuf, NULL);
- dht_inode_ctx_get1 (this, local->fd->inode, &subvol);
- if (subvol) {
- dht_discard2 (this, subvol, frame);
+
+ 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)) {
+ dht_discard2 (this, dst_subvol, frame);
return 0;
}
ret = dht_rebalance_in_progress_check (this, frame);
@@ -637,10 +652,10 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno, struct iatt *prebuf,
struct iatt *postbuf, dict_t *xdata)
{
- dht_local_t *local = NULL;
- call_frame_t *prev = NULL;
- int ret = -1;
- xlator_t *subvol = NULL;
+ dht_local_t *local = NULL;
+ call_frame_t *prev = NULL;
+ int ret = -1;
+ xlator_t *subvol1 = NULL, *subvol2 = NULL;
GF_VALIDATE_OR_GOTO ("dht", frame, err);
GF_VALIDATE_OR_GOTO ("dht", this, out);
@@ -678,9 +693,12 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
if (IS_DHT_MIGRATION_PHASE1 (postbuf)) {
dht_iatt_merge (this, &local->stbuf, postbuf, NULL);
dht_iatt_merge (this, &local->prebuf, prebuf, NULL);
- dht_inode_ctx_get1 (this, local->fd->inode, &subvol);
- if (subvol) {
- dht_zerofill2 (this, subvol, frame);
+
+ ret = dht_inode_ctx_get_mig_info (this, local->fd->inode,
+ &subvol1, &subvol2);
+ if (!dht_mig_info_is_invalid (local->cached_subvol,
+ subvol1, subvol2)) {
+ dht_zerofill2 (this, subvol2, frame);
return 0;
}