From 175f1737fb6fe9450702556b24bf395bac97cef1 Mon Sep 17 00:00:00 2001 From: Raghavendra Talur Date: Mon, 13 Apr 2015 17:05:44 +0530 Subject: libglusterfs: Even anonymous fds must have fd->flags set We do not set the same flags to anonymous fd that posix uses to open an anonymous fd in the backend. If there are any xlators which rely on these flags for their operation they may not work well. Add proper flags to anonymous fds at the time of their creation and refer to them for subsequent operations. Change-Id: Ia99b7ea7d38839f099c7b4aae3c7ead123bc8c67 BUG: 1211221 Signed-off-by: Raghavendra Talur Reviewed-on: http://review.gluster.org/10219 Tested-by: NetBSD Build System Reviewed-by: soumya k Reviewed-by: Poornima G Tested-by: Gluster Build System Reviewed-by: Rajesh Joseph Reviewed-by: Niels de Vos Reviewed-by: Raghavendra Bhat Reviewed-by: Raghavendra G --- xlators/storage/posix/src/posix-helpers.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'xlators/storage/posix') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index e0cb6b8a755..a89da58ef7c 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -1566,10 +1566,6 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p) goto out; } - if (!fd_is_anonymous(fd)) - /* anonymous fd */ - goto out; - MAKE_HANDLE_PATH (real_path, this, fd->inode->gfid, NULL); if (!real_path) { gf_msg (this->name, GF_LOG_ERROR, 0, @@ -1580,6 +1576,14 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p) goto out; } + if (!fd_is_anonymous(fd)) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to get fd context for a non-anonymous fd, " + "file: %s, gfid: %s", real_path, + uuid_utoa (fd->inode->gfid)); + goto out; + } + pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd); if (!pfd) { goto out; @@ -1596,8 +1600,12 @@ __posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd_p) _fd = dirfd (dir); } + /* Using fd->flags in case we choose to have anonymous + * fds with different flags some day. As of today it + * would be GF_ANON_FD_FLAGS and nothing else. + */ if (fd->inode->ia_type == IA_IFREG) { - _fd = open (real_path, O_RDWR|O_LARGEFILE); + _fd = open (real_path, fd->flags); if (_fd == -1) { GF_FREE (pfd); pfd = NULL; -- cgit