12a457
From cda89700fc54c391bfca23cbb0c68224ae3f576f Mon Sep 17 00:00:00 2001
12a457
From: Krutika Dhananjay <kdhananj@redhat.com>
12a457
Date: Tue, 29 Mar 2016 18:36:08 +0530
12a457
Subject: [PATCH 76/80] features/shard: Make o-direct writes work with sharding
12a457
12a457
        Backport of: http://review.gluster.org/#/c/13846/
12a457
        release-3.7 patch: http://review.gluster.org/#/c/13966/
12a457
12a457
With files opened with o-direct, the expectation is that
12a457
the IO performed on the fds is byte aligned wrt the sector size
12a457
of the underlying device. With files getting sharded, a single
12a457
write from the application could be broken into more than one write
12a457
falling on different shards which _might_ cause the original byte alignment
12a457
property to be lost. To get around this, shard translator will send fsync
12a457
on odirect writes to emulate o-direct-like behavior in the backend.
12a457
12a457
Change-Id: Ic0291cfca16902b9c35a123eb5f4f46924a09395
12a457
BUG: 1314421
12a457
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/71872
12a457
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
12a457
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
12a457
---
12a457
 xlators/features/shard/src/shard.c |    6 ++++++
12a457
 1 files changed, 6 insertions(+), 0 deletions(-)
12a457
12a457
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
12a457
index c7a57e0..78bb82d 100644
12a457
--- a/xlators/features/shard/src/shard.c
12a457
+++ b/xlators/features/shard/src/shard.c
12a457
@@ -3591,6 +3591,7 @@ shard_common_inode_write_do (call_frame_t *frame, xlator_t *this)
12a457
         shard_local_t  *local             = NULL;
12a457
         struct iovec   *vec               = NULL;
12a457
         gf_boolean_t    wind_failed       = _gf_false;
12a457
+        gf_boolean_t    odirect           = _gf_false;
12a457
         off_t           orig_offset       = 0;
12a457
         off_t           shard_offset      = 0;
12a457
         off_t           vec_offset        = 0;
12a457
@@ -3621,6 +3622,9 @@ shard_common_inode_write_do (call_frame_t *frame, xlator_t *this)
12a457
                 return 0;
12a457
         }
12a457
 
12a457
+        if ((fd->flags & O_DIRECT) && (local->fop == GF_FOP_WRITE))
12a457
+                odirect = _gf_true;
12a457
+
12a457
         while (cur_block <= last_block) {
12a457
                 if (wind_failed) {
12a457
                         shard_common_inode_write_do_cbk (frame,
12a457
@@ -3678,6 +3682,8 @@ shard_common_inode_write_do (call_frame_t *frame, xlator_t *this)
12a457
                                                                  NULL, NULL);
12a457
                                 goto next;
12a457
                         }
12a457
+                        if (odirect)
12a457
+                                local->flags |= O_SYNC;
12a457
                 }
12a457
 
12a457
                 shard_common_inode_write_wind (frame, this, anon_fd,
12a457
-- 
12a457
1.7.1
12a457