summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-inode-write.c
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-07-24 03:53:16 -0700
committerAnand Avati <avati@redhat.com>2013-08-13 23:45:03 -0700
commit8360037701788d49471cc0228fa873aa18382023 (patch)
tree6c0aff80595683322507102ddb04986915511729 /xlators/cluster/afr/src/afr-inode-write.c
parent0d756dc618c1a4b659a3531aec449506ce577f50 (diff)
afr: treat appending writes as stable writes.
Durability of appending writes is implicit in the file size. Therefore performing an explicit fsync() is unnecessary in such cases as self-heal can check for the size of file when pending changelog is not unambiguous. Change-Id: I05446180a91d20e0dbee5de5a7085b87d57f178a BUG: 927146 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/5501 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-inode-write.c')
-rw-r--r--xlators/cluster/afr/src/afr-inode-write.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c
index 68570f15afe..a7441676881 100644
--- a/xlators/cluster/afr/src/afr-inode-write.c
+++ b/xlators/cluster/afr/src/afr-inode-write.c
@@ -139,6 +139,7 @@ afr_writev_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int read_child = 0;
int ret = 0;
uint32_t open_fd_count = 0;
+ uint32_t write_is_append = 0;
local = frame->local;
@@ -173,6 +174,13 @@ afr_writev_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local->open_fd_count = open_fd_count;
local->update_open_fd_count = _gf_true;
}
+
+ write_is_append = 0;
+ ret = dict_get_uint32 (xdata,
+ GLUSTERFS_WRITE_IS_APPEND,
+ &write_is_append);
+ if (ret || !write_is_append)
+ local->append_write = _gf_false;
}
if ((local->success_count == 0) ||
@@ -192,7 +200,13 @@ afr_writev_wind_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (local->update_open_fd_count)
afr_handle_open_fd_count (frame, this);
- if (!local->stable_write)
+ if (!local->stable_write && !local->append_write)
+ /* An appended write removes the necessity to
+ fsync() the file. This is because self-heal
+ has the logic to check for larger file when
+ the xattrs are not reliably pointing at
+ a stale file.
+ */
afr_fd_report_unstable_write (this, local->fd);
afr_writev_handle_short_writes (frame, this);
@@ -251,6 +265,13 @@ afr_writev_wind (call_frame_t *frame, xlator_t *this)
if (xdata) {
ret = dict_set_uint32 (xdata, GLUSTERFS_OPEN_FD_COUNT,
sizeof (uint32_t));
+ ret = dict_set_uint32 (xdata, GLUSTERFS_WRITE_IS_APPEND,
+ 0);
+ /* Set append_write to be true speculatively. If on any
+ server it turns not be true, we unset it in the
+ callback.
+ */
+ local->append_write = _gf_true;
}
for (i = 0; i < priv->child_count; i++) {