summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-inode-handle.h
diff options
context:
space:
mode:
authorShyamsundarR <srangana@redhat.com>2017-11-28 18:51:00 -0500
committerShyamsundarR <srangana@redhat.com>2017-12-02 13:56:19 -0500
commit8a0b115b20cfa2dd3c5a9e22a8244c9c2f03e17b (patch)
treee0dc5088e9931d4d2cff442e8a780da0ff7caa15 /xlators/storage/posix/src/posix-inode-handle.h
parent09cb795587772b60ba102f4369ab3f4501cdc01a (diff)
posix: Reorganize posix xlator to prepare for reuse with rio
1. Split out entry and inode/fd based FOPs into separate files from posix.c 2. Split out common routines (init, fini, reconf, and such) into its own file, from posix.c 3. Retain just the method assignments in posix.c (such that posix2 for RIO can assign its own methods in the future for entry operations and such) 4. Based on the split in (1) and (2) split out posix-handle.h into 2 files, such that macros that are needed for inode ops are in one and rest are in the other If the split is done as above, posix2 can compile with its own entry ops, and hence not compile, the entry ops as split in (1) above. The split described in (4) can again help posix2 to define its own macros to make entry and inode handles, thus not impact existing POSIX xlator code. Noted problems - There are path references in certain cases where quota is used (in the xattr FOPs), and thus will fail on reuse in posix2, this needs to be handled when we get there. - posix_init does set root GFID on the brick root, and this is incorrect for posix2, again will need handling later when posix2 evolves based on this code (other init checks seem fine on current inspection) Merge of experimental branch patches with the following gerrit change-IDs > Change-Id: I965ce6dffe70a62c697f790f3438559520e0af20 > Change-Id: I089a4d9cf470c2f9c121611e8ef18dea92b2be70 > Change-Id: I2cec103f6ba8f3084443f3066bcc70b2f5ecb49a Fixes gluster/glusterfs#327 Change-Id: I0ccfa78559a7c5a68f5e861e144cf856f5c9e19c Signed-off-by: ShyamsundarR <srangana@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-inode-handle.h')
-rw-r--r--xlators/storage/posix/src/posix-inode-handle.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-inode-handle.h b/xlators/storage/posix/src/posix-inode-handle.h
new file mode 100644
index 0000000..6849276
--- /dev/null
+++ b/xlators/storage/posix/src/posix-inode-handle.h
@@ -0,0 +1,106 @@
+/*
+ Copyright (c) 2011-2017 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ 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 _POSIX_INODE_HANDLE_H
+#define _POSIX_INODE_HANDLE_H
+
+#include <limits.h>
+#include <sys/types.h>
+#include "xlator.h"
+#include "gf-dirent.h"
+#include "posix.h"
+
+/* From Open Group Base Specifications Issue 6 */
+#ifndef _XOPEN_PATH_MAX
+#define _XOPEN_PATH_MAX 1024
+#endif
+
+#define TRASH_DIR "landfill"
+
+#define UUID0_STR "00000000-0000-0000-0000-000000000000"
+#define SLEN(str) (sizeof(str) - 1)
+
+#define LOC_HAS_ABSPATH(loc) (loc && (loc->path) && (loc->path[0] == '/'))
+#define LOC_IS_DIR(loc) (loc && (loc->inode) && \
+ (loc->inode->ia_type == IA_IFDIR))
+#define MAKE_REAL_PATH(var, this, path) do { \
+ size_t path_len = strlen(path); \
+ size_t var_len = path_len + POSIX_BASE_PATH_LEN(this) + 1; \
+ if (POSIX_PATH_MAX(this) != -1 && \
+ var_len >= POSIX_PATH_MAX(this)) { \
+ var = alloca (path_len + 1); \
+ strcpy (var, (path[0] == '/') ? path + 1 : path); \
+ } else { \
+ var = alloca (var_len); \
+ strcpy (var, POSIX_BASE_PATH(this)); \
+ strcpy (&var[POSIX_BASE_PATH_LEN(this)], path); \
+ } \
+ } while (0)
+
+#define MAKE_HANDLE_PATH(var, this, gfid, base) do { \
+ int __len; \
+ __len = posix_handle_path (this, gfid, base, NULL, 0); \
+ if (__len <= 0) \
+ break; \
+ var = alloca (__len); \
+ __len = posix_handle_path (this, gfid, base, var, __len); \
+ if (__len <= 0) \
+ var = NULL; \
+ } while (0)
+
+#define MAKE_INODE_HANDLE(rpath, this, loc, iatt_p) do { \
+ if (gf_uuid_is_null (loc->gfid)) { \
+ gf_msg (this->name, GF_LOG_ERROR, 0, \
+ P_MSG_INODE_HANDLE_CREATE, \
+ "null gfid for path %s", (loc)->path); \
+ break; \
+ } \
+ if (LOC_IS_DIR (loc) && LOC_HAS_ABSPATH (loc)) { \
+ MAKE_REAL_PATH (rpath, this, (loc)->path); \
+ op_ret = posix_pstat (this, (loc)->gfid, rpath, iatt_p); \
+ break; \
+ } \
+ errno = 0; \
+ op_ret = posix_istat (this, loc->gfid, NULL, iatt_p); \
+ if (errno != ELOOP) { \
+ MAKE_HANDLE_PATH (rpath, this, (loc)->gfid, NULL); \
+ if (!rpath) { \
+ op_ret = -1; \
+ gf_msg (this->name, GF_LOG_ERROR, errno, \
+ P_MSG_INODE_HANDLE_CREATE, \
+ "Failed to create inode handle " \
+ "for path %s", (loc)->path); \
+ } \
+ break; \
+ } \
+ /* __ret == -1 && errno == ELOOP */ \
+ } while (0)
+
+#define POSIX_ANCESTRY_PATH (1 << 0)
+#define POSIX_ANCESTRY_DENTRY (1 << 1)
+
+int
+posix_handle_path (xlator_t *this, uuid_t gfid, const char *basename, char *buf,
+ size_t len);
+
+int
+posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
+ gf_dirent_t *head, int type, uuid_t gfid,
+ const size_t handle_size,
+ const char *priv_base_path,
+ inode_table_t *table, inode_t **parent,
+ dict_t *xdata, int32_t *op_errno);
+
+int
+posix_handle_init (xlator_t *this);
+
+int
+posix_handle_trash_init (xlator_t *this);
+
+#endif /* !_POSIX_INODE_HANDLE_H */