summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-inode-write.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-09-14 09:02:01 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-19 23:49:10 -0700
commitcb2c6982bd6d588a91fa2827f95f0d9cf3ff2560 (patch)
treed82ac0af25d70e5bc4dbf464e0f742c08ab9f543 /xlators/cluster/dht/src/dht-inode-write.c
parentb5b0bb056391659802099908f4bccde5afdb9e34 (diff)
cluster/distribute: minor fixes in open file migration
* incorporated Avati's comments on the first patch. * send proper stat information while unwinding Change-Id: I36982cec610753c241c372272620ab2bd581fd9f BUG: 3071 Reviewed-on: http://review.gluster.com/408 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-inode-write.c')
-rw-r--r--xlators/cluster/dht/src/dht-inode-write.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c
index 21eca611740..f9dea75aa21 100644
--- a/xlators/cluster/dht/src/dht-inode-write.c
+++ b/xlators/cluster/dht/src/dht-inode-write.c
@@ -48,23 +48,29 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- if (local->call_cnt != 1)
+ if (local->call_cnt != 1) {
+ /* preserve the modes of source */
+ if (local->stbuf.ia_blocks) {
+ dht_iatt_merge (this, postbuf, &local->stbuf, NULL);
+ dht_iatt_merge (this, prebuf, &local->prebuf, NULL);
+ }
goto out;
+ }
local->rebalance.target_op_fn = dht_writev2;
/* Phase 2 of migration */
- if (IA_ISREG (postbuf->ia_type) &&
- ((st_mode_from_ia (postbuf->ia_prot, postbuf->ia_type) &
- ~S_IFMT) == DHT_LINKFILE_MODE)) {
+ if (IS_DHT_MIGRATION_PHASE2 (postbuf)) {
ret = dht_rebalance_complete_check (this, frame);
if (!ret)
return 0;
}
/* Check if the rebalance phase1 is true */
- if (IA_ISREG (postbuf->ia_type) && (postbuf->ia_prot.sticky == 1) &&
- (postbuf->ia_prot.sgid == 1)) {
+ if (IS_DHT_MIGRATION_PHASE1 (postbuf)) {
+ dht_iatt_merge (this, &local->stbuf, postbuf, NULL);
+ dht_iatt_merge (this, &local->prebuf, prebuf, NULL);
+
ret = fd_ctx_get (local->fd, this, NULL);
if (!ret) {
dht_writev2 (this, frame, 0);
@@ -76,6 +82,9 @@ dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
out:
+ DHT_STRIP_PHASE1_FLAGS (postbuf);
+ DHT_STRIP_PHASE1_FLAGS (prebuf);
+
DHT_STACK_UNWIND (writev, frame, op_ret, op_errno, prebuf, postbuf);
return 0;
@@ -185,34 +194,40 @@ dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- if (local->call_cnt != 1)
+ if (local->call_cnt != 1) {
+ if (local->stbuf.ia_blocks) {
+ dht_iatt_merge (this, postbuf, &local->stbuf, NULL);
+ dht_iatt_merge (this, prebuf, &local->prebuf, NULL);
+ }
goto out;
+ }
local->rebalance.target_op_fn = dht_truncate2;
/* Phase 2 of migration */
- if ((op_ret == -1) || (IA_ISREG (postbuf->ia_type) &&
- ((st_mode_from_ia (postbuf->ia_prot, postbuf->ia_type) &
- ~S_IFMT) == DHT_LINKFILE_MODE))) {
+ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) {
ret = dht_rebalance_complete_check (this, frame);
if (!ret)
- goto err;
+ return 0;
}
/* Check if the rebalance phase1 is true */
- if (IA_ISREG (postbuf->ia_type) && (postbuf->ia_prot.sticky == 1) &&
- (postbuf->ia_prot.sgid == 1)) {
+ if (IS_DHT_MIGRATION_PHASE1 (postbuf)) {
+ dht_iatt_merge (this, &local->stbuf, postbuf, NULL);
+ dht_iatt_merge (this, &local->prebuf, prebuf, NULL);
ret = fd_ctx_get (local->fd, this, NULL);
if (!ret) {
dht_truncate2 (this, frame, 0);
- goto err;
+ return 0;
}
ret = dht_rebalance_in_progress_check (this, frame);
if (!ret)
- goto err;
+ return 0;
}
out:
+ DHT_STRIP_PHASE1_FLAGS (postbuf);
+ DHT_STRIP_PHASE1_FLAGS (prebuf);
DHT_STACK_UNWIND (truncate, frame, op_ret, op_errno,
prebuf, postbuf);
err:
@@ -362,19 +377,19 @@ dht_file_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local->rebalance.target_op_fn = dht_setattr2;
/* Phase 2 of migration */
- if ((op_ret == -1) || (IA_ISREG (postbuf->ia_type) &&
- ((st_mode_from_ia (postbuf->ia_prot, postbuf->ia_type) &
- ~S_IFMT) == DHT_LINKFILE_MODE))) {
+ if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) {
ret = dht_rebalance_complete_check (this, frame);
if (!ret)
- goto out;
+ return 0;
}
/* At the end of the migration process, whatever 'attr' we
have on source file will be migrated to destination file
in one shot, hence we don't need to check for in progress
- state here */
+ state here (ie, PHASE1) */
out:
+ DHT_STRIP_PHASE1_FLAGS (postbuf);
+ DHT_STRIP_PHASE1_FLAGS (prebuf);
DHT_STACK_UNWIND (setattr, frame, op_ret, op_errno,
prebuf, postbuf);