summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix.h
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/storage/posix/src/posix.h')
-rw-r--r--xlators/storage/posix/src/posix.h181
1 files changed, 97 insertions, 84 deletions
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index a61758ef8f6..b8db146eef2 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -16,12 +16,8 @@
#include <dirent.h>
#include <time.h>
-#ifdef linux
-#ifdef __GLIBC__
+#ifdef HAVE_SET_FSID
#include <sys/fsuid.h>
-#else
-#include <unistd.h>
-#endif
#endif
#ifdef HAVE_SYS_XATTR_H
@@ -32,12 +28,10 @@
#include <sys/extattr.h>
#endif
-#include "xlator.h"
-#include "compat.h"
-#include "timer.h"
+#include <glusterfs/compat.h>
+#include <glusterfs/timer.h>
#include "posix-mem-types.h"
-#include "posix-handle.h"
-#include "call-stub.h"
+#include <glusterfs/call-stub.h>
#ifdef HAVE_LIBAIO
#include <libaio.h>
@@ -53,21 +47,21 @@
#define ACL_BUFFER_MAX 4096 /* size of character buffer */
#define DHT_LINKTO "trusted.glusterfs.dht.linkto"
-/*
- * TIER_MODE need to be changed when we stack tiers
- */
-#define TIER_LINKTO "trusted.tier.tier-dht.linkto"
#define POSIX_GFID_HANDLE_SIZE(base_path_len) \
(base_path_len + SLEN("/") + SLEN(GF_HIDDEN_PATH) + SLEN("/") + \
SLEN("00/") + SLEN("00/") + SLEN(UUID0_STR) + 1) /* '\0' */;
+
+#define POSIX_GFID_HANDLE_RELSIZE \
+ SLEN("../") + SLEN("../") + SLEN("00/") + SLEN("00/") + SLEN(UUID0_STR) + 1;
+
#define GF_UNLINK_TRUE 0x0000000000000001
#define GF_UNLINK_FALSE 0x0000000000000000
#define DISK_SPACE_CHECK_AND_GOTO(frame, priv, xdata, op_ret, op_errno, out) \
do { \
if (frame->root->pid >= 0 && priv->disk_space_full && \
- !dict_get(xdata, GLUSTERFS_INTERNAL_FOP_KEY)) { \
+ !dict_get_sizen(xdata, GLUSTERFS_INTERNAL_FOP_KEY)) { \
op_ret = -1; \
op_errno = ENOSPC; \
gf_msg_debug("posix", ENOSPC, \
@@ -95,9 +89,8 @@
#endif
#define GFID_NULL_CHECK_AND_GOTO(frame, this, loc, xattr_req, op_ret, \
- op_errno, out) \
+ op_errno, _uuid_req, out) \
do { \
- uuid_t _uuid_req; \
int _ret = 0; \
/* TODO: Remove pid check once trash implements client side \
* logic to assign gfid for entry creations inside .trashcan \
@@ -107,9 +100,7 @@
_ret = dict_get_gfuuid(xattr_req, "gfid-req", &_uuid_req); \
if (_ret) { \
gf_msg(this->name, GF_LOG_ERROR, EINVAL, P_MSG_NULL_GFID, \
- "failed to get the gfid from" \
- " dict for %s", \
- loc->path); \
+ "failed to get the gfid from dict for %s", loc->path); \
op_ret = -1; \
op_errno = EINVAL; \
goto out; \
@@ -128,12 +119,14 @@
*/
struct posix_fd {
- int fd; /* fd returned by the kernel */
- int32_t flags; /* flags for open/creat */
- DIR *dir; /* handle returned by the kernel */
- off_t dir_eof; /* offset at dir EOF */
- int odirect;
+ int fd; /* fd returned by the kernel */
+ int32_t flags; /* flags for open/creat */
+ DIR *dir; /* handle returned by the kernel */
+ off_t dir_eof; /* offset at dir EOF */
struct list_head list; /* to add to the janitor list */
+ int odirect;
+ xlator_t *xl;
+ char _pad[4]; /* manual padding */
};
struct posix_private {
@@ -144,69 +137,38 @@ struct posix_private {
gf_lock_t lock;
char *hostname;
- /* Statistics, provides activity of the server */
-
- struct timeval prev_fetch_time;
- struct timeval init_time;
time_t last_landfill_check;
- int32_t janitor_sleep_duration;
- struct list_head janitor_fds;
- pthread_cond_t janitor_cond;
- pthread_mutex_t janitor_lock;
-
- int64_t read_value; /* Total read, from init */
- int64_t write_value; /* Total write, from init */
- int64_t nr_files;
- /*
- In some cases, two exported volumes may reside on the same
- partition on the server. Sending statvfs info for both
- the volumes will lead to erroneous df output at the client,
- since free space on the partition will be counted twice.
- In such cases, user can disable exporting statvfs info
- on one of the volumes by setting this option.
- */
- gf_boolean_t export_statfs;
+ gf_atomic_t read_value; /* Total read, from init */
+ gf_atomic_t write_value; /* Total write, from init */
- gf_boolean_t o_direct; /* always open files in O_DIRECT mode */
+ /* janitor task which cleans up /.trash (created by replicate) */
+ struct gf_tw_timer_list *janitor;
- /*
- decide whether posix_unlink does open (file), unlink (file), close (fd)
- instead of just unlink (file). with the former approach there is no
- lockout of access to parent directory during removal of very large files
- for the entire duration of freeing of data blocks.
- */
- gf_boolean_t background_unlink;
-
- /* janitor thread which cleans up /.trash (created by replicate) */
- pthread_t janitor;
- gf_boolean_t janitor_present;
char *trash_path;
/* lock for brick dir */
- DIR *mount_lock;
+ int mount_lock;
struct stat handledir;
/* uuid of glusterd that swapned the brick process */
uuid_t glusterd_uuid;
- gf_boolean_t aio_configured;
- gf_boolean_t aio_init_done;
- gf_boolean_t aio_capable;
#ifdef HAVE_LIBAIO
io_context_t ctxp;
pthread_t aiothread;
#endif
- /* node-uuid in pathinfo xattr */
- gf_boolean_t node_uuid_pathinfo;
-
pthread_t fsyncer;
struct list_head fsyncs;
pthread_mutex_t fsync_mutex;
pthread_cond_t fsync_cond;
+ pthread_mutex_t janitor_mutex;
+ pthread_cond_t janitor_cond;
+ pthread_cond_t fd_cond;
int fsync_queue_count;
+ int32_t janitor_sleep_duration;
enum {
BATCH_NONE = 0,
@@ -217,8 +179,6 @@ struct posix_private {
} batch_fsync_mode;
uint32_t batch_fsync_delay_usec;
- gf_boolean_t update_pgfid_nlinks;
- gf_boolean_t gfid2path;
char gfid2path_sep[8];
/* seconds to sleep between health checks */
@@ -226,12 +186,10 @@ struct posix_private {
/* seconds to sleep to wait for aio write finish for health checks */
uint32_t health_check_timeout;
pthread_t health_check;
- gf_boolean_t health_check_active;
- uint32_t disk_reserve;
- uint32_t disk_space_full;
+ double disk_reserve;
pthread_t disk_space_check;
- gf_boolean_t disk_space_check_active;
+ uint32_t disk_space_full;
#ifdef GF_DARWIN_HOST_OS
enum {
@@ -246,9 +204,6 @@ struct posix_private {
same backend. Very much usable in brick-splitting feature. */
int32_t shared_brick_count;
- /* This option is used for either to call a landfill_purge or not */
- gf_boolean_t disable_landfill_purge;
-
/*Option to set mode bit permission that will always be set on
file/directory. */
mode_t force_create_mode;
@@ -256,9 +211,47 @@ struct posix_private {
mode_t create_mask;
mode_t create_directory_mask;
uint32_t max_hardlinks;
+ int32_t arrdfd[256];
+ int dirfd;
+
+ /* This option is used for either to call a landfill_purge or not */
+ gf_boolean_t disable_landfill_purge;
gf_boolean_t fips_mode_rchecksum;
gf_boolean_t ctime;
+ gf_boolean_t janitor_task_stop;
+
+ gf_boolean_t disk_space_check_active;
+ char disk_unit;
+ gf_boolean_t health_check_active;
+ gf_boolean_t update_pgfid_nlinks;
+ gf_boolean_t gfid2path;
+ /* node-uuid in pathinfo xattr */
+ gf_boolean_t node_uuid_pathinfo;
+ /*
+ In some cases, two exported volumes may reside on the same
+ partition on the server. Sending statvfs info for both
+ the volumes will lead to erroneous df output at the client,
+ since free space on the partition will be counted twice.
+
+ In such cases, user can disable exporting statvfs info
+ on one of the volumes by setting this option.
+ */
+ gf_boolean_t export_statfs;
+
+ gf_boolean_t o_direct; /* always open files in O_DIRECT mode */
+
+ /*
+ decide whether posix_unlink does open (file), unlink (file), close (fd)
+ instead of just unlink (file). with the former approach there is no
+ lockout of access to parent directory during removal of very large files
+ for the entire duration of freeing of data blocks.
+ */
+ gf_boolean_t background_unlink;
+ gf_boolean_t aio_configured;
+ gf_boolean_t aio_init_done;
+ gf_boolean_t aio_capable;
+ uint32_t rel_fdcount;
};
typedef struct {
@@ -272,9 +265,11 @@ typedef struct {
fd_t *fd;
int fdnum;
int flags;
- int32_t op_errno;
char *list;
size_t list_size;
+ int32_t op_errno;
+
+ char _pad[4]; /* manual padding */
} posix_xattr_filler_t;
typedef struct {
@@ -298,7 +293,7 @@ typedef struct {
char gfid_str[64] = {0}; \
uuid_utoa_r(gfid, gfid_str); \
path_len = strlen(base_path) + 1 + SLEN(GF_UNLINK_PATH) + 1 + \
- strlen(gfid_str) + 1; \
+ UUID_CANONICAL_FORM_LEN + 1; \
unlink_path = alloca(path_len); \
if (!unlink_path) { \
gf_msg("posix", GF_LOG_ERROR, ENOMEM, P_MSG_UNLINK_FAILED, \
@@ -334,24 +329,26 @@ posix_istat(xlator_t *this, inode_t *inode, uuid_t gfid, const char *basename,
int
posix_pstat(xlator_t *this, inode_t *inode, uuid_t gfid, const char *real_path,
struct iatt *iatt, gf_boolean_t inode_locked);
+
dict_t *
posix_xattr_fill(xlator_t *this, const char *path, loc_t *loc, fd_t *fd,
int fdnum, dict_t *xattr, struct iatt *buf);
int
-posix_handle_pair(xlator_t *this, const char *real_path, char *key,
+posix_handle_pair(xlator_t *this, loc_t *loc, const char *real_path, char *key,
data_t *value, int flags, struct iatt *stbuf);
int
posix_fhandle_pair(call_frame_t *frame, xlator_t *this, int fd, char *key,
data_t *value, int flags, struct iatt *stbuf, fd_t *_fd);
void
-posix_spawn_janitor_thread(xlator_t *this);
+posix_janitor_timer_start(xlator_t *this);
int
posix_acl_xattr_set(xlator_t *this, const char *path, dict_t *xattr_req);
int
posix_gfid_heal(xlator_t *this, const char *path, loc_t *loc,
dict_t *xattr_req);
int
-posix_entry_create_xattr_set(xlator_t *this, const char *path, dict_t *dict);
+posix_entry_create_xattr_set(xlator_t *this, loc_t *loc, const char *path,
+ dict_t *dict);
int
posix_fd_ctx_get(fd_t *fd, xlator_t *this, struct posix_fd **pfd,
@@ -365,10 +362,10 @@ posix_special_xattr(char **pattern, char *key);
void
__posix_fd_set_odirect(fd_t *fd, struct posix_fd *pfd, int opflags,
off_t offset, size_t size);
-void
+int
posix_spawn_health_check_thread(xlator_t *this);
-void
+int
posix_spawn_disk_space_check_thread(xlator_t *this);
void *
@@ -387,9 +384,6 @@ void
posix_gfid_unset(xlator_t *this, dict_t *xdata);
int
-posix_pacl_set(const char *path, int fdnum, const char *key, const char *acl_s);
-
-int
posix_pacl_get(const char *path, int fdnum, const char *key, char **acl_s);
int32_t
@@ -638,6 +632,11 @@ posix_put(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
off_t offset, struct iobref *iobref, dict_t *xattr, dict_t *xdata);
int32_t
+posix_copy_file_range(call_frame_t *frame, xlator_t *this, fd_t *fd_in,
+ off64_t off_in, fd_t *fd_out, off64_t off_out, size_t len,
+ uint32_t flags, dict_t *xdata);
+
+int32_t
posix_set_mode_in_dict(dict_t *in_dict, dict_t *out_dict,
struct iatt *in_stbuf);
@@ -656,5 +655,19 @@ int
posix_cs_maintenance(xlator_t *this, fd_t *fd, loc_t *loc, int *pfd,
struct iatt *buf, const char *realpath, dict_t *xattr_req,
dict_t **xattr_rsp, gf_boolean_t ignore_failure);
+int
+posix_check_dev_file(xlator_t *this, inode_t *inode, char *fop, int *op_errno);
+
+int
+posix_spawn_ctx_janitor_thread(xlator_t *this);
+
+void
+posix_update_iatt_buf(struct iatt *buf, int fd, char *loc, dict_t *xdata);
+
+gf_boolean_t
+posix_is_layout_stale(dict_t *xdata, char *par_path, xlator_t *this);
+
+int
+posix_delete_user_xattr(dict_t *dict, char *k, data_t *v, void *data);
#endif /* _POSIX_H */