summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/fd.h
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/fd.h')
-rw-r--r--libglusterfs/src/fd.h78
1 files changed, 53 insertions, 25 deletions
diff --git a/libglusterfs/src/fd.h b/libglusterfs/src/fd.h
index c2181d8af..c1b9157d8 100644
--- a/libglusterfs/src/fd.h
+++ b/libglusterfs/src/fd.h
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2007-2009 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
#ifndef _FD_H
@@ -30,29 +21,38 @@
#include <unistd.h>
#include "glusterfs.h"
#include "locking.h"
+#include "fd-lk.h"
+#include "common-utils.h"
+
+#define GF_ANON_FD_NO -2
struct _inode;
struct _dict;
+struct fd_lk_ctx;
struct _fd_ctx {
- uint64_t key;
- uint64_t value;
+ union {
+ uint64_t key;
+ void *xl_key;
+ };
+ union {
+ uint64_t value1;
+ void *ptr1;
+ };
};
-/* If this structure changes, please have mercy on the booster maintainer
- * and update the fd_t struct in booster/src/booster-fd.h.
- * See the comment there to know why.
- */
struct _fd {
- pid_t pid;
+ uint64_t pid;
int32_t flags;
int32_t refcount;
- uint64_t flush_unique;
struct list_head inode_list;
struct _inode *inode;
gf_lock_t lock; /* used ONLY for manipulating
'struct _fd_ctx' array (_ctx).*/
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 */
};
typedef struct _fd fd_t;
@@ -86,7 +86,7 @@ typedef struct _fdtable fdtable_t;
#include "xlator.h"
-inline void
+void
gf_fd_put (fdtable_t *fdtable, int32_t fd);
@@ -111,6 +111,10 @@ gf_fd_fdtable_destroy (fdtable_t *fdtable);
fd_t *
+__fd_ref (fd_t *fd);
+
+
+fd_t *
fd_ref (fd_t *fd);
@@ -121,10 +125,25 @@ fd_unref (fd_t *fd);
fd_t *
fd_create (struct _inode *inode, pid_t pid);
+fd_t *
+fd_create_uint64 (struct _inode *inode, uint64_t pid);
fd_t *
fd_lookup (struct _inode *inode, pid_t pid);
+fd_t *
+fd_lookup_uint64 (struct _inode *inode, uint64_t pid);
+
+fd_t*
+fd_lookup_anonymous (inode_t *inode);
+
+fd_t *
+fd_anonymous (inode_t *inode);
+
+
+gf_boolean_t
+fd_is_anonymous (fd_t *fd);
+
uint8_t
fd_list_empty (struct _inode *inode);
@@ -145,6 +164,9 @@ fd_ctx_get (fd_t *fd, xlator_t *xlator, uint64_t *value);
int
fd_ctx_del (fd_t *fd, xlator_t *xlator, uint64_t *value);
+int
+__fd_ctx_del (fd_t *fd, xlator_t *xlator, uint64_t *value);
+
int
__fd_ctx_set (fd_t *fd, xlator_t *xlator, uint64_t value);
@@ -154,8 +176,14 @@ int
__fd_ctx_get (fd_t *fd, xlator_t *xlator, uint64_t *value);
-int
-__fd_ctx_del (fd_t *fd, xlator_t *xlator, uint64_t *value);
+void
+fd_ctx_dump (fd_t *fd, char *prefix);
+
+fdentry_t *
+gf_fd_fdtable_copy_all_fds (fdtable_t *fdtable, uint32_t *count);
+
+void
+gf_fdptr_put (fdtable_t *fdtable, fd_t *fd);
#endif /* _FD_H */
t gfs3_readdirp_rsp *rsp, gf_dirent_t *entries)
+unserialize_rsp_direntp (xlator_t *this, fd_t *fd,
+ struct gfs3_readdirp_rsp *rsp, gf_dirent_t *entries)
{
struct gfs3_dirplist *trav = NULL;
+ char *buf = NULL;
gf_dirent_t *entry = NULL;
+ inode_table_t *itable = NULL;
int entry_len = 0;
int ret = -1;
trav = rsp->reply;
+ if (fd)
+ itable = fd->inode->table;
+
while (trav) {
entry_len = gf_dirent_size (trav->name);
entry = GF_CALLOC (1, entry_len, gf_common_mt_gf_dirent_t);
@@ -164,6 +203,30 @@ unserialize_rsp_direntp (struct gfs3_readdirp_rsp *rsp, gf_dirent_t *entries)
strcpy (entry->d_name, trav->name);
+ if (trav->dict.dict_val) {
+ /* Dictionary is sent along with response */
+ buf = memdup (trav->dict.dict_val, trav->dict.dict_len);
+ if (!buf)
+ goto out;
+
+ entry->dict = dict_new ();
+
+ ret = dict_unserialize (buf, trav->dict.dict_len,
+ &entry->dict);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_WARNING,
+ "failed to unserialize xattr dict");
+ errno = EINVAL;
+ goto out;
+ }
+ entry->dict->extra_free = buf;
+ buf = NULL;
+ }
+
+ entry->inode = inode_find (itable, entry->d_stat.ia_gfid);
+ if (!entry->inode)
+ entry->inode = inode_new (itable);
+
list_add_tail (&entry->list, &entries->list);
trav = trav->nextentry;
@@ -185,6 +248,7 @@ clnt_readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp)
while (tr