summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2016-06-07 17:15:56 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-06-27 22:57:11 -0700
commit37fa947743d5e56baa617fc2e72485a1907b39d2 (patch)
treeb636fcf020b8bf922d9895590a6fb6451d2c1f0e /libglusterfs
parentcac16a0e5713f85a65f03b3eb5b62abfa894ac94 (diff)
libglusterfs: Negate all but O_DIRECT flag if present on anon fds
Backport of: http://review.gluster.org/14665 This is to prevent any unforeseen problems that might arise due to writevs and readvs being wound with @flag parameter containing O_TRUNC or O_APPEND especially wrt translators like sharding and ec where O_TRUNC write or O_APPEND write on individual shards/fragments is not the same as O_TRUNC write or O_APPEND write as expected by the application. >Change-Id: Ib0110731d6099bc888b7ada552a2abbea8e76051 >BUG: 1342903 >Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> >Reviewed-on: http://review.gluster.org/14735 >Smoke: Gluster Build System <jenkins@build.gluster.org> >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> >Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> >CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Change-Id: I7ffa4fa366f727f7e345ab0bf4c8eb009710074b BUG: 1347553 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/14755 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/fd.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 7177fa275db..118f876c396 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -812,17 +812,11 @@ fd_anonymous_with_flags (inode_t *inode, int32_t flags)
LOCK (&inode->lock);
{
- if (flags == 0)
+ if (flags & O_DIRECT)
+ flags = GF_ANON_FD_FLAGS | O_DIRECT;
+ else
flags = GF_ANON_FD_FLAGS;
- /* If this API is ever called with O_SYNC or O_DSYNC in @flags,
- * reset the bits associated with these flags before calling
- * __fd_anonymous(). That way, posix will do the open() without
- * these flags. And subsequently, posix_writev() (mostly) will
- * do the write within inode->lock on an fd without O_SYNC or
- * O_DSYNC and in its place to an fsync() outside of the locks
- * to simulate the effect of using these flags.
- */
- flags &= (~(O_SYNC|O_DSYNC));
+
fd = __fd_anonymous (inode, flags);
}
UNLOCK (&inode->lock);