summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/fd.c4
-rw-r--r--libglusterfs/src/fd.h5
-rw-r--r--xlators/storage/posix/src/posix-helpers.c18
3 files changed, 19 insertions, 8 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 7377b1e30bd..688357327c0 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -309,8 +309,7 @@ gf_fd_put (fdtable_t *fdtable, int32_t fd)
fd_t *fdptr = NULL;
fdentry_t *fde = NULL;
- if (fd == -2)
- /* anonymous fd */
+ if (fd == GF_ANON_FD_NO)
return;
if (fdtable == NULL || fd < 0) {
@@ -774,6 +773,7 @@ __fd_anonymous (inode_t *inode)
return NULL;
fd->anonymous = _gf_true;
+ fd->flags = GF_ANON_FD_FLAGS;
__fd_bind (fd);
diff --git a/libglusterfs/src/fd.h b/libglusterfs/src/fd.h
index 5a98ec38ca7..53ec93dec6c 100644
--- a/libglusterfs/src/fd.h
+++ b/libglusterfs/src/fd.h
@@ -20,6 +20,7 @@
#include "common-utils.h"
#define GF_ANON_FD_NO -2
+#define GF_ANON_FD_FLAGS (O_RDWR|O_LARGEFILE)
struct _inode;
struct _dict;
@@ -47,7 +48,9 @@ struct _fd {
struct _fd_ctx *_ctx;
int xl_count; /* Number of xl referred in this fd */
struct fd_lk_ctx *lk_ctx;
- gf_boolean_t anonymous; /* geo-rep anonymous fd */
+ gf_boolean_t anonymous; /* fd which does not have counterpart open
+ fd on backend (server for client, posix
+ for server). */
};
typedef struct _fd fd_t;
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;