From 9df83b504a01e86d3b73af6c40df0c94cd2cd97a Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Fri, 5 May 2017 14:30:49 +0530 Subject: features/shard: Set size in inode ctx before size update for truncate too Change-Id: I7e984bb0f50c7d42764c0648e697d94d6c768dc7 BUG: 1448299 Signed-off-by: Krutika Dhananjay Reviewed-on: https://review.gluster.org/17184 CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Pranith Kumar Karampuri Smoke: Gluster Build System --- xlators/features/shard/src/shard.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'xlators/features/shard/src') diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index a48806c6a8b..eaeb840e86d 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -697,11 +697,6 @@ shard_update_file_size_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->op_errno = ENOMEM; goto err; } - - if (local->fop == GF_FOP_FTRUNCATE || local->fop == GF_FOP_TRUNCATE) - shard_inode_ctx_set (inode, this, &local->postbuf, 0, - SHARD_INODE_WRITE_MASK); - err: local->post_update_size_handler (frame, this); return 0; @@ -2010,6 +2005,7 @@ int shard_post_lookup_truncate_handler (call_frame_t *frame, xlator_t *this) { shard_local_t *local = NULL; + struct iatt tmp_stbuf = {0,}; local = frame->local; @@ -2024,7 +2020,7 @@ shard_post_lookup_truncate_handler (call_frame_t *frame, xlator_t *this) return 0; } - local->postbuf = local->prebuf; + local->postbuf = tmp_stbuf = local->prebuf; if (local->prebuf.ia_size == local->offset) { /* If the file size is same as requested size, unwind the call @@ -2046,6 +2042,9 @@ shard_post_lookup_truncate_handler (call_frame_t *frame, xlator_t *this) local->delta_size = 0; local->delta_blocks = 0; local->postbuf.ia_size = local->offset; + tmp_stbuf.ia_size = local->offset; + shard_inode_ctx_set (local->loc.inode, this, &tmp_stbuf, 0, + SHARD_INODE_WRITE_MASK); shard_update_file_size (frame, this, NULL, &local->loc, shard_post_update_size_truncate_handler); } else { @@ -2058,6 +2057,9 @@ shard_post_lookup_truncate_handler (call_frame_t *frame, xlator_t *this) local->hole_size = 0; local->delta_size = (local->offset - local->prebuf.ia_size); local->delta_blocks = 0; + tmp_stbuf.ia_size = local->offset; + shard_inode_ctx_set (local->loc.inode, this, &tmp_stbuf, 0, + SHARD_INODE_WRITE_MASK); shard_truncate_begin (frame, this); } return 0; -- cgit