From 79dfe7d197ced45bd3b84f71d5c889e95f4dec1a Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Tue, 7 Jun 2016 17:15:56 +0530 Subject: libglusterfs: Negate all but O_DIRECT flag if present on anon fds 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: I9e5206a6ce2b1b70df61ff23b1c961cf25bf7ff9 BUG: 1342171 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/14665 Reviewed-by: Pranith Kumar Karampuri CentOS-regression: Gluster Build System Smoke: Gluster Build System Tested-by: Gluster Build System NetBSD-regression: NetBSD Build System --- libglusterfs/src/fd.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'libglusterfs/src/fd.c') 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); -- cgit