summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2015-04-29 12:09:26 +0530
committerVijay Bellur <vbellur@redhat.com>2015-05-03 11:15:09 -0700
commitc9e6cd4ad931e9d63f8b3c95121a59071bb6e5b2 (patch)
tree52795b27b12733f110fd6930f69528f31ab88ec1
parent827119f277c15701a72c6b05199fb6854fe4f4d1 (diff)
features/shard: Take hole size into account while computing ia_size
Backport of: http://review.gluster.org/10446 Change-Id: Ic05e07801605c0d610545368a513b56d8df21bf4 BUG: 1214247 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/10493 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/features/shard/src/shard.c11
-rw-r--r--xlators/features/shard/src/shard.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
index aba54a491ed..4e78b49ee56 100644
--- a/xlators/features/shard/src/shard.c
+++ b/xlators/features/shard/src/shard.c
@@ -1626,7 +1626,7 @@ shard_update_file_size (call_frame_t *frame, xlator_t *this)
if (!xattr_req)
goto err;
- ret = shard_set_size_attrs (local->postbuf.ia_size,
+ ret = shard_set_size_attrs (local->postbuf.ia_size + local->hole_size,
local->postbuf.ia_blocks, &size_attr);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to set size attrs for"
@@ -1685,7 +1685,7 @@ shard_writev_do_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
call_count = shard_call_count_return (frame);
if (call_count == 0) {
if (local->op_ret < 0) {
- SHARD_STACK_UNWIND (writev, frame, local->op_ret,
+ SHARD_STACK_UNWIND (writev, frame, local->written_size,
local->op_errno, NULL, NULL, NULL);
} else {
if (xdata)
@@ -1805,6 +1805,13 @@ shard_post_lookup_writev_handler (call_frame_t *frame, xlator_t *this)
}
local->postbuf = local->prebuf;
+
+ /* At this point, calculate the size of the hole if it is going to be
+ * created as part of this write.
+ */
+ if (local->offset > local->prebuf.ia_size)
+ local->hole_size = local->offset - local->prebuf.ia_size;
+
shard_writev_do (frame, this);
return 0;
diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h
index ed452b50190..365616c108c 100644
--- a/xlators/features/shard/src/shard.h
+++ b/xlators/features/shard/src/shard.h
@@ -151,6 +151,7 @@ typedef struct shard_local {
off_t offset;
size_t total_size;
size_t written_size;
+ size_t hole_size;
loc_t loc;
loc_t dot_shard_loc;
loc_t loc2;