diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2015-11-23 13:06:25 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-11-23 22:20:03 -0800 |
commit | c93e436527e9d2ceed46b939e18edc40b7018cee (patch) | |
tree | 1d53c1ad5af72eeb11260e907d90947f99c4da01 /xlators/features/shard | |
parent | 5a06a9eef3f767c850e879ff87c72301e02fe137 (diff) |
features/shard: Eliminate extra update to postbuf in writev
After an extending write is complete, shard translator updates postbuf
at two places:
1. shard_update_file_size_cbk(), and
2. shard_post_update_size_writev_handler().
This can lead to unexpected behavior if md-cache is part of the client
stack and caches and serves values returned by shard translator in
postbuf. This patch eliminates the update to postbuf in
shard_post_update_size_writev_handler().
Change-Id: I9d107bf57baad66886eebec14aa369b6a3c88c49
BUG: 1284365
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/12717
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/features/shard')
-rw-r--r-- | xlators/features/shard/src/shard.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 35c9d1d9d45..ed02f6a8c60 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -3360,14 +3360,11 @@ shard_post_update_size_writev_handler (call_frame_t *frame, xlator_t *this) if (local->op_ret < 0) { SHARD_STACK_UNWIND (writev, frame, local->op_ret, local->op_errno, NULL, NULL, NULL); - return 0; + } else { + SHARD_STACK_UNWIND (writev, frame, local->written_size, + local->op_errno, &local->prebuf, + &local->postbuf, local->xattr_rsp); } - - local->postbuf.ia_size += (local->delta_size + local->hole_size); - local->postbuf.ia_blocks += local->delta_blocks; - - SHARD_STACK_UNWIND (writev, frame, local->written_size, local->op_errno, - &local->prebuf, &local->postbuf, local->xattr_rsp); return 0; } @@ -3423,16 +3420,20 @@ shard_writev_do_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; - if (op_ret < 0) { - local->op_ret = op_ret; - local->op_errno = op_errno; - } else { - local->written_size += op_ret; - local->delta_blocks += (postbuf->ia_blocks - prebuf->ia_blocks); - local->delta_size += (postbuf->ia_size - prebuf->ia_size); - shard_inode_ctx_set (local->fd->inode, this, postbuf, 0, - SHARD_MASK_TIMES); + LOCK (&frame->lock); + { + if (op_ret < 0) { + local->op_ret = op_ret; + local->op_errno = op_errno; + } else { + local->written_size += op_ret; + local->delta_blocks += (postbuf->ia_blocks - prebuf->ia_blocks); + local->delta_size += (postbuf->ia_size - prebuf->ia_size); + shard_inode_ctx_set (local->fd->inode, this, postbuf, 0, + SHARD_MASK_TIMES); + } } + UNLOCK (&frame->lock); if (anon_fd) fd_unref (anon_fd); |