diff options
author | N Balachandran <nbalacha@redhat.com> | 2015-09-01 15:31:02 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-09-22 20:56:40 -0700 |
commit | 470869a954c17f32a3ba43ccda7442f82c0da6b2 (patch) | |
tree | 750a45685eff044b43fc739c8d3913e8ceeef8b9 /xlators/cluster/dht/src/dht-inode-write.c | |
parent | bdbd092e2caf79a2cfd6cda507af624e9861ae30 (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-write.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-inode-write.c | 162 |
1 files changed, 145 insertions, 17 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c index ce5006a80df..a1bf2aa5e8d 100644 --- a/xlators/cluster/dht/src/dht-inode-write.c +++ b/xlators/cluster/dht/src/dht-inode-write.c @@ -11,12 +11,18 @@ #include "dht-common.h" -int dht_writev2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); -int dht_truncate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); -int dht_setattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); -int dht_fallocate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); -int dht_discard2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); -int dht_zerofill2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame); +int dht_writev2 (xlator_t *this, xlator_t *subvol, + call_frame_t *frame, int ret); +int dht_truncate2 (xlator_t *this, xlator_t *subvol, + call_frame_t *frame, int ret); +int dht_setattr2 (xlator_t *this, xlator_t *subvol, + call_frame_t *frame, int ret); +int dht_fallocate2 (xlator_t *this, xlator_t *subvol, + call_frame_t *frame, int ret); +int dht_discard2 (xlator_t *this, xlator_t *subvol, + call_frame_t *frame, int ret); +int dht_zerofill2 (xlator_t *this, xlator_t *subvol, + call_frame_t *frame, int ret); int dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -58,7 +64,15 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->rebalance.target_op_fn = dht_writev2; + local->op_ret = op_ret; local->op_errno = op_errno; + + /* We might need to pass the stbuf information to the higher DHT + * layer for appropriate handling. + */ + + dht_set_local_rebalance (this, local, NULL, prebuf, postbuf, xdata); + /* Phase 2 of migration */ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) { ret = dht_rebalance_complete_check (this, frame); @@ -75,7 +89,7 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, &subvol1, &subvol2); if (!dht_mig_info_is_invalid (local->cached_subvol, subvol1, subvol2)) { - dht_writev2 (this, subvol2, frame); + dht_writev2 (this, subvol2, frame, 0); return 0; } ret = dht_rebalance_in_progress_check (this, frame); @@ -94,7 +108,7 @@ out: } int -dht_writev2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) +dht_writev2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; int32_t op_errno = EINVAL; @@ -105,6 +119,19 @@ dht_writev2 (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 (writev, frame, local->op_ret, + local->op_errno, &local->rebalance.prebuf, + &local->rebalance.postbuf, + local->rebalance.xdata); + return 0; + } + + if (subvol == NULL) goto out; @@ -215,7 +242,15 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->rebalance.target_op_fn = dht_truncate2; + local->op_ret = op_ret; local->op_errno = op_errno; + + /* We might need to pass the stbuf information to the higher DHT + * layer for appropriate handling. + */ + + dht_set_local_rebalance (this, local, NULL, prebuf, postbuf, xdata); + /* Phase 2 of migration */ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) { ret = dht_rebalance_complete_check (this, frame); @@ -233,7 +268,7 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, &dst_subvol); if (!dht_mig_info_is_invalid (local->cached_subvol, src_subvol, dst_subvol)) { - dht_truncate2 (this, dst_subvol, frame); + dht_truncate2 (this, dst_subvol, frame, 0); return 0; } ret = dht_rebalance_in_progress_check (this, frame); @@ -244,6 +279,7 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, out: DHT_STRIP_PHASE1_FLAGS (postbuf); DHT_STRIP_PHASE1_FLAGS (prebuf); + DHT_STACK_UNWIND (truncate, frame, op_ret, op_errno, prebuf, postbuf, xdata); err: @@ -252,7 +288,7 @@ err: int -dht_truncate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) +dht_truncate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; int32_t op_errno = EINVAL; @@ -263,6 +299,16 @@ dht_truncate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) local = frame->local; op_errno = local->op_errno; + /* This dht xlator is not migrating the file */ + if (we_are_not_migrating (ret)) { + + DHT_STACK_UNWIND (truncate, frame, local->op_ret, + local->op_errno, &local->rebalance.prebuf, + &local->rebalance.postbuf, + local->rebalance.xdata); + return 0; + } + if (subvol == NULL) goto out; @@ -406,8 +452,13 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, } goto out; } + + local->op_ret = op_ret; + local->op_errno = op_errno; local->rebalance.target_op_fn = dht_fallocate2; + dht_set_local_rebalance (this, local, NULL, prebuf, postbuf, xdata); + /* Phase 2 of migration */ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) { ret = dht_rebalance_complete_check (this, frame); @@ -424,7 +475,7 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, &dst_subvol); if (!dht_mig_info_is_invalid (local->cached_subvol, src_subvol, dst_subvol)) { - dht_fallocate2 (this, dst_subvol, frame); + dht_fallocate2 (this, dst_subvol, frame, 0); return 0; } ret = dht_rebalance_in_progress_check (this, frame); @@ -435,6 +486,7 @@ dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, out: DHT_STRIP_PHASE1_FLAGS (postbuf); DHT_STRIP_PHASE1_FLAGS (prebuf); + DHT_STACK_UNWIND (fallocate, frame, op_ret, op_errno, prebuf, postbuf, xdata); err: @@ -442,7 +494,7 @@ err: } int -dht_fallocate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) +dht_fallocate2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; int32_t op_errno = EINVAL; @@ -453,6 +505,19 @@ dht_fallocate2 (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 (fallocate, frame, local->op_ret, + local->op_errno, + &local->rebalance.prebuf, + &local->rebalance.postbuf, + local->rebalance.xdata); + return 0; + } + if (subvol == NULL) goto out; @@ -550,7 +615,12 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, } goto out; } + local->rebalance.target_op_fn = dht_discard2; + local->op_ret = op_ret; + local->op_errno = op_errno; + + dht_set_local_rebalance (this, local, NULL, prebuf, postbuf, xdata); /* Phase 2 of migration */ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) { @@ -568,7 +638,7 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, &dst_subvol); if (!dht_mig_info_is_invalid(local->cached_subvol, src_subvol, dst_subvol)) { - dht_discard2 (this, dst_subvol, frame); + dht_discard2 (this, dst_subvol, frame, 0); return 0; } ret = dht_rebalance_in_progress_check (this, frame); @@ -579,6 +649,7 @@ dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, out: DHT_STRIP_PHASE1_FLAGS (postbuf); DHT_STRIP_PHASE1_FLAGS (prebuf); + DHT_STACK_UNWIND (discard, frame, op_ret, op_errno, prebuf, postbuf, xdata); err: @@ -586,7 +657,7 @@ err: } int -dht_discard2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) +dht_discard2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; int32_t op_errno = EINVAL; @@ -597,6 +668,19 @@ dht_discard2 (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 (discard, frame, local->op_ret, + local->op_errno, + &local->rebalance.prebuf, + &local->rebalance.postbuf, + local->rebalance.xdata); + return 0; + } + if (subvol == NULL) goto out; @@ -689,7 +773,13 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, } goto out; } + local->rebalance.target_op_fn = dht_zerofill2; + local->op_ret = op_ret; + local->op_errno = op_errno; + + dht_set_local_rebalance (this, local, NULL, prebuf, postbuf, xdata); + /* Phase 2 of migration */ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) { ret = dht_rebalance_complete_check (this, frame); @@ -706,7 +796,7 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, &subvol1, &subvol2); if (!dht_mig_info_is_invalid (local->cached_subvol, subvol1, subvol2)) { - dht_zerofill2 (this, subvol2, frame); + dht_zerofill2 (this, subvol2, frame, 0); return 0; } @@ -718,6 +808,7 @@ dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, out: DHT_STRIP_PHASE1_FLAGS (postbuf); DHT_STRIP_PHASE1_FLAGS (prebuf); + DHT_STACK_UNWIND (zerofill, frame, op_ret, op_errno, prebuf, postbuf, xdata); err: @@ -725,7 +816,7 @@ err: } int -dht_zerofill2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) +dht_zerofill2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; int32_t op_errno = EINVAL; @@ -737,6 +828,20 @@ dht_zerofill2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) 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 (zerofill, frame, local->op_ret, + local->op_errno, + &local->rebalance.prebuf, + &local->rebalance.postbuf, + local->rebalance.xdata); + + return 0; + } + if (subvol == NULL) goto out; @@ -749,6 +854,7 @@ dht_zerofill2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) return 0; out: + DHT_STACK_UNWIND (zerofill, frame, -1, op_errno, NULL, NULL, NULL); return 0; } @@ -821,10 +927,18 @@ dht_file_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (local->call_cnt != 1) goto out; + local->op_ret = op_ret; + local->op_errno = op_errno; + local->rebalance.target_op_fn = dht_setattr2; + /* Phase 2 of migration */ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) { + + dht_set_local_rebalance (this, local, NULL, prebuf, + postbuf, xdata); + ret = dht_rebalance_complete_check (this, frame); if (!ret) return 0; @@ -837,6 +951,7 @@ dht_file_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, out: DHT_STRIP_PHASE1_FLAGS (postbuf); DHT_STRIP_PHASE1_FLAGS (prebuf); + DHT_STACK_UNWIND (setattr, frame, op_ret, op_errno, prebuf, postbuf, xdata); @@ -844,7 +959,7 @@ out: } int -dht_setattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame) +dht_setattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; int32_t op_errno = EINVAL; @@ -855,6 +970,19 @@ dht_setattr2 (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 (setattr, frame, local->op_ret, + local->op_errno, + &local->rebalance.prebuf, + &local->rebalance.postbuf, + local->rebalance.xdata); + return 0; + } + if (subvol == NULL) goto out; |