diff options
author | N Balachandran <nbalacha@redhat.com> | 2015-12-16 21:09:22 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-01-29 00:42:30 -0800 |
commit | c2fbcb6140585d9fc82367a9101857bf5d05d732 (patch) | |
tree | 646e4126271defbe34447f161f3323b932c159ef /xlators/cluster/dht/src/dht-inode-write.c | |
parent | b43aa481712dab5df813050119ba6c08f50dbfd9 (diff) |
cluster/dht : Ftruncate on migrating file fails with EINVAL
What:
If dht_open is called on a migrating file after the inode_ctx is set,
subsequent FOPs on that fd do not open the fd on the dst subvol.
This is seen when the open-ftruncate-close sequence is repeatedly
called on a migrating file.
A second call to the sequence described above causes dht_truncate_cbk
to call dht_truncate2 as the dht_inode_ctx was already set by the first
call. As dht_rebalance_in_progress_check is not called, the fd is not
opened on the dst subvol.
On a distributed-replicate volume, this causes AFR to
open the fd using afr_fix_open, but with the wrong flags, causing
posix_ftruncate to fail with EINVAL.
The fix: We require fd specific information to make a decision while
handling migrating files.
Set the fd_ctx to indicate the fd has been opened on the dst subvol
and check if it has been set while processing Phase1/Phase2 checks
in the FOP callback functions.
> Change-Id: I43cdcd8017b4a11e18afdd210469de7cd9a5ef14
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
> Reviewed-on: http://review.gluster.org/12985
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Dan Lambright <dlambrig@redhat.com>
> Tested-by: Dan Lambright <dlambrig@redhat.com>
Change-Id: I99f8aceec105f16631def06a263f0561954d14b3
BUG: 1293827
Signed-off-by: N Balachandran <nbalacha@redhat.com>
Reviewed-on: http://review.gluster.org/13071
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-inode-write.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-inode-write.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c index e57056b4f77..e54b3fba584 100644 --- a/xlators/cluster/dht/src/dht-inode-write.c +++ b/xlators/cluster/dht/src/dht-inode-write.c @@ -94,8 +94,10 @@ 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, 0); - return 0; + if (dht_fd_open_on_dst (this, local->fd, subvol2)) { + dht_writev2 (this, subvol2, frame, 0); + return 0; + } } ret = dht_rebalance_in_progress_check (this, frame); if (!ret) @@ -212,12 +214,12 @@ dht_truncate_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 *src_subvol = NULL; - xlator_t *dst_subvol = NULL; - inode_t *inode = NULL; + dht_local_t *local = NULL; + call_frame_t *prev = NULL; + int ret = -1; + xlator_t *src_subvol = NULL; + xlator_t *dst_subvol = NULL; + inode_t *inode = NULL; GF_VALIDATE_OR_GOTO ("dht", frame, err); GF_VALIDATE_OR_GOTO ("dht", this, out); @@ -267,14 +269,18 @@ dht_truncate_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); + inode = (local->fd) ? local->fd->inode : local->loc.inode; 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, 0); - return 0; + if ((!local->fd) || ((local->fd) && + dht_fd_open_on_dst (this, local->fd, dst_subvol))) { + dht_truncate2 (this, dst_subvol, frame, 0); + return 0; + } } ret = dht_rebalance_in_progress_check (this, frame); if (!ret) @@ -480,8 +486,10 @@ 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, 0); - return 0; + if (dht_fd_open_on_dst (this, local->fd, dst_subvol)) { + dht_fallocate2 (this, dst_subvol, frame, 0); + return 0; + } } ret = dht_rebalance_in_progress_check (this, frame); if (!ret) @@ -643,8 +651,10 @@ 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, 0); - return 0; + if (dht_fd_open_on_dst (this, local->fd, dst_subvol)) { + dht_discard2 (this, dst_subvol, frame, 0); + return 0; + } } ret = dht_rebalance_in_progress_check (this, frame); if (!ret) @@ -801,8 +811,10 @@ 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, 0); - return 0; + if (dht_fd_open_on_dst (this, local->fd, subvol2)) { + dht_zerofill2 (this, subvol2, frame, 0); + return 0; + } } ret = dht_rebalance_in_progress_check (this, frame); |