diff options
author | Gluster Ant <bugzilla-bot@gluster.org> | 2018-09-12 17:22:48 +0530 |
---|---|---|
committer | Nigel Babu <nigelb@redhat.com> | 2018-09-12 17:22:48 +0530 |
commit | 45a71c0548b6fd2c757aa2e7b7671a1411948894 (patch) | |
tree | 2a5a9b73bae47ab53a41166fd041a06612587f48 /xlators | |
parent | be77dbbda692792335a8e9e7c02e0c281f003c40 (diff) |
Land clang-format changes
Change-Id: I6f5d8140a06f3c1b2d196849299f8d483028d33b
Diffstat (limited to 'xlators')
257 files changed, 16171 insertions, 17145 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-read.h b/xlators/cluster/afr/src/afr-dir-read.h index 09456d15949..773e925ec6c 100644 --- a/xlators/cluster/afr/src/afr-dir-read.h +++ b/xlators/cluster/afr/src/afr-dir-read.h @@ -11,26 +11,23 @@ #ifndef __DIR_READ_H__ #define __DIR_READ_H__ - int32_t -afr_opendir (call_frame_t *frame, xlator_t *this, - loc_t *loc, fd_t *fd, dict_t *xdata); +afr_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + dict_t *xdata); int32_t -afr_releasedir (xlator_t *this, fd_t *fd); +afr_releasedir(xlator_t *this, fd_t *fd); int32_t -afr_readdir (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset, dict_t *xdata); - +afr_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t offset, dict_t *xdata); int32_t -afr_readdirp (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset, dict_t *dict); +afr_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t offset, dict_t *dict); int32_t -afr_checksum (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t flags, dict_t *xdata); - +afr_checksum(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + dict_t *xdata); #endif /* __DIR_READ_H__ */ diff --git a/xlators/cluster/afr/src/afr-dir-write.h b/xlators/cluster/afr/src/afr-dir-write.h index 02f0a3682d9..1d88c3b9b26 100644 --- a/xlators/cluster/afr/src/afr-dir-write.h +++ b/xlators/cluster/afr/src/afr-dir-write.h @@ -12,36 +12,35 @@ #define __DIR_WRITE_H__ int32_t -afr_create (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t flags, mode_t mode, - mode_t umask, fd_t *fd, dict_t *xdata); +afr_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata); int32_t -afr_mknod (call_frame_t *frame, xlator_t *this, - loc_t *loc, mode_t mode, dev_t dev, mode_t umask, dict_t *xdata); +afr_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dev_t dev, mode_t umask, dict_t *xdata); int32_t -afr_mkdir (call_frame_t *frame, xlator_t *this, - loc_t *loc, mode_t mode, mode_t umask, dict_t *xdata); +afr_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + mode_t umask, dict_t *xdata); int32_t -afr_unlink (call_frame_t *frame, xlator_t *this, - loc_t *loc, int xflag, dict_t *xdata); +afr_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, + dict_t *xdata); int32_t -afr_rmdir (call_frame_t *frame, xlator_t *this, - loc_t *loc, int flags, dict_t *xdata); +afr_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata); int32_t -afr_link (call_frame_t *frame, xlator_t *this, - loc_t *oldloc, loc_t *newloc, dict_t *xdata); +afr_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); int32_t -afr_rename (call_frame_t *frame, xlator_t *this, - loc_t *oldloc, loc_t *newloc, dict_t *xdata); +afr_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); int -afr_symlink (call_frame_t *frame, xlator_t *this, - const char *linkpath, loc_t *oldloc, mode_t umask, dict_t *params); +afr_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, + loc_t *oldloc, mode_t umask, dict_t *params); #endif /* __DIR_WRITE_H__ */ diff --git a/xlators/cluster/afr/src/afr-inode-read.h b/xlators/cluster/afr/src/afr-inode-read.h index d128134ef2a..1627ee2c426 100644 --- a/xlators/cluster/afr/src/afr-inode-read.h +++ b/xlators/cluster/afr/src/afr-inode-read.h @@ -12,34 +12,31 @@ #define __INODE_READ_H__ int32_t -afr_access (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t mask, dict_t *xdata); +afr_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, + dict_t *xdata); int32_t -afr_stat (call_frame_t *frame, xlator_t *this, - loc_t *loc, dict_t *xdata); +afr_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); int32_t -afr_fstat (call_frame_t *frame, xlator_t *this, - fd_t *fd, dict_t *xdata); +afr_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata); int32_t -afr_readlink (call_frame_t *frame, xlator_t *this, - loc_t *loc, size_t size, dict_t *xdata); +afr_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, + dict_t *xdata); int32_t -afr_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset, uint32_t flags, dict_t *xdata); +afr_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t offset, uint32_t flags, dict_t *xdata); int32_t -afr_getxattr (call_frame_t *frame, xlator_t *this, - loc_t *loc, const char *name, dict_t *xdata); +afr_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, + dict_t *xdata); int32_t -afr_fgetxattr (call_frame_t *frame, xlator_t *this, - fd_t *fd, const char *name, dict_t *xdata); - +afr_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, + dict_t *xdata); int -afr_handle_quota_size (call_frame_t *frame, xlator_t *this); +afr_handle_quota_size(call_frame_t *frame, xlator_t *this); #endif /* __INODE_READ_H__ */ diff --git a/xlators/cluster/afr/src/afr-inode-write.h b/xlators/cluster/afr/src/afr-inode-write.h index 1e8bb5c12b3..a787069b7a1 100644 --- a/xlators/cluster/afr/src/afr-inode-write.h +++ b/xlators/cluster/afr/src/afr-inode-write.h @@ -12,83 +12,83 @@ #define __INODE_WRITE_H__ int32_t -afr_chmod (call_frame_t *frame, xlator_t *this, - loc_t *loc, mode_t mode, dict_t *xdata); +afr_chmod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dict_t *xdata); int32_t -afr_chown (call_frame_t *frame, xlator_t *this, - loc_t *loc, uid_t uid, gid_t gid, dict_t *xdata); +afr_chown(call_frame_t *frame, xlator_t *this, loc_t *loc, uid_t uid, gid_t gid, + dict_t *xdata); int -afr_fchown (call_frame_t *frame, xlator_t *this, - fd_t *fd, uid_t uid, gid_t gid, dict_t *xdata); +afr_fchown(call_frame_t *frame, xlator_t *this, fd_t *fd, uid_t uid, gid_t gid, + dict_t *xdata); int32_t -afr_fchmod (call_frame_t *frame, xlator_t *this, - fd_t *fd, mode_t mode, dict_t *xdata); +afr_fchmod(call_frame_t *frame, xlator_t *this, fd_t *fd, mode_t mode, + dict_t *xdata); int32_t -afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, - struct iovec *vector, int32_t count, off_t offset, - uint32_t flags, struct iobref *iobref, dict_t *xdata); +afr_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, + int32_t count, off_t offset, uint32_t flags, struct iobref *iobref, + dict_t *xdata); int32_t -afr_truncate (call_frame_t *frame, xlator_t *this, - loc_t *loc, off_t offset, dict_t *xdata); +afr_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, + dict_t *xdata); int32_t -afr_ftruncate (call_frame_t *frame, xlator_t *this, - fd_t *fd, off_t offset, dict_t *xdata); +afr_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + dict_t *xdata); int32_t -afr_utimens (call_frame_t *frame, xlator_t *this, - loc_t *loc, struct timespec tv[2], dict_t *xdata); +afr_utimens(call_frame_t *frame, xlator_t *this, loc_t *loc, + struct timespec tv[2], dict_t *xdata); int -afr_setattr (call_frame_t *frame, xlator_t *this, - loc_t *loc, struct iatt *buf, int32_t valid, dict_t *xdata); +afr_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *buf, + int32_t valid, dict_t *xdata); int -afr_fsetattr (call_frame_t *frame, xlator_t *this, - fd_t *fd, struct iatt *buf, int32_t valid, dict_t *xdata); +afr_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *buf, + int32_t valid, dict_t *xdata); int32_t -afr_setxattr (call_frame_t *frame, xlator_t *this, - loc_t *loc, dict_t *dict, int32_t flags, dict_t *xdata); +afr_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + int32_t flags, dict_t *xdata); int32_t -afr_fsetxattr (call_frame_t *frame, xlator_t *this, - fd_t *fd, dict_t *dict, int32_t flags, dict_t *xdata); +afr_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, + int32_t flags, dict_t *xdata); int32_t -afr_removexattr (call_frame_t *frame, xlator_t *this, - loc_t *loc, const char *name, dict_t *xdata); +afr_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata); int32_t -afr_fremovexattr (call_frame_t *frame, xlator_t *this, - fd_t *fd, const char *name, dict_t *xdata); +afr_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name, dict_t *xdata); int -afr_discard (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, - size_t len, dict_t *xdata); +afr_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, dict_t *xdata); int -afr_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, - off_t offset, size_t len, dict_t *xdata); +afr_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata); int afr_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, off_t len, dict_t *xdata); int32_t -afr_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, - gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata); +afr_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, + gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata); int32_t -afr_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, - gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata); +afr_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, + gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata); int -afr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync, - dict_t *xdata); +afr_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync, + dict_t *xdata); #endif /* __INODE_WRITE_H__ */ diff --git a/xlators/cluster/afr/src/afr-mem-types.h b/xlators/cluster/afr/src/afr-mem-types.h index 2e1117fc18c..d62f7876bcd 100644 --- a/xlators/cluster/afr/src/afr-mem-types.h +++ b/xlators/cluster/afr/src/afr-mem-types.h @@ -8,47 +8,45 @@ cases as published by the Free Software Foundation. */ - #ifndef __AFR_MEM_TYPES_H__ #define __AFR_MEM_TYPES_H__ #include "mem-types.h" enum gf_afr_mem_types_ { - gf_afr_mt_iovec = gf_common_mt_end + 1, - gf_afr_mt_afr_fd_ctx_t, - gf_afr_mt_afr_private_t, - gf_afr_mt_int32_t, - gf_afr_mt_char, - gf_afr_mt_xattr_key, - gf_afr_mt_dict_t, - gf_afr_mt_xlator_t, - gf_afr_mt_iatt, - gf_afr_mt_int, - gf_afr_mt_afr_node_character, - gf_afr_mt_sh_diff_loop_state, - gf_afr_mt_uint8_t, - gf_afr_mt_loc_t, - gf_afr_mt_entry_name, - gf_afr_mt_pump_priv, - gf_afr_mt_locked_fd, - gf_afr_mt_inode_ctx_t, - gf_afr_fd_paused_call_t, - gf_afr_mt_crawl_data_t, - gf_afr_mt_brick_pos_t, - gf_afr_mt_shd_bool_t, - gf_afr_mt_shd_timer_t, - gf_afr_mt_shd_event_t, - gf_afr_mt_time_t, - gf_afr_mt_pos_data_t, - gf_afr_mt_reply_t, - gf_afr_mt_subvol_healer_t, - gf_afr_mt_spbc_timeout_t, - gf_afr_mt_spb_status_t, - gf_afr_mt_empty_brick_t, - gf_afr_mt_child_latency_t, - gf_afr_mt_atomic_t, + gf_afr_mt_iovec = gf_common_mt_end + 1, + gf_afr_mt_afr_fd_ctx_t, + gf_afr_mt_afr_private_t, + gf_afr_mt_int32_t, + gf_afr_mt_char, + gf_afr_mt_xattr_key, + gf_afr_mt_dict_t, + gf_afr_mt_xlator_t, + gf_afr_mt_iatt, + gf_afr_mt_int, + gf_afr_mt_afr_node_character, + gf_afr_mt_sh_diff_loop_state, + gf_afr_mt_uint8_t, + gf_afr_mt_loc_t, + gf_afr_mt_entry_name, + gf_afr_mt_pump_priv, + gf_afr_mt_locked_fd, + gf_afr_mt_inode_ctx_t, + gf_afr_fd_paused_call_t, + gf_afr_mt_crawl_data_t, + gf_afr_mt_brick_pos_t, + gf_afr_mt_shd_bool_t, + gf_afr_mt_shd_timer_t, + gf_afr_mt_shd_event_t, + gf_afr_mt_time_t, + gf_afr_mt_pos_data_t, + gf_afr_mt_reply_t, + gf_afr_mt_subvol_healer_t, + gf_afr_mt_spbc_timeout_t, + gf_afr_mt_spb_status_t, + gf_afr_mt_empty_brick_t, + gf_afr_mt_child_latency_t, + gf_afr_mt_atomic_t, gf_afr_mt_end }; #endif - diff --git a/xlators/cluster/afr/src/afr-messages.h b/xlators/cluster/afr/src/afr-messages.h index 8aa94730158..696336889d3 100644 --- a/xlators/cluster/afr/src/afr-messages.h +++ b/xlators/cluster/afr/src/afr-messages.h @@ -23,51 +23,25 @@ * glfs-message-id.h. */ -GLFS_MSGID(AFR, - AFR_MSG_QUORUM_FAIL, - AFR_MSG_QUORUM_MET, - AFR_MSG_QUORUM_OVERRIDE, - AFR_MSG_INVALID_CHILD_UP, - AFR_MSG_SUBVOL_UP, - AFR_MSG_SUBVOLS_DOWN, - AFR_MSG_ENTRY_UNLOCK_FAIL, - AFR_MSG_SPLIT_BRAIN, - AFR_MSG_OPEN_FAIL, - AFR_MSG_UNLOCK_FAIL, - AFR_MSG_REPLACE_BRICK_STATUS, - AFR_MSG_GFID_NULL, - AFR_MSG_FD_CREATE_FAILED, - AFR_MSG_DICT_SET_FAILED, - AFR_MSG_EXPUNGING_FILE_OR_DIR, - AFR_MSG_MIGRATION_IN_PROGRESS, - AFR_MSG_CHILD_MISCONFIGURED, - AFR_MSG_VOL_MISCONFIGURED, - AFR_MSG_BLOCKING_LKS_FAILED, - AFR_MSG_INVALID_FD, - AFR_MSG_LOCK_INFO, - AFR_MSG_LOCK_XLATOR_NOT_LOADED, - AFR_MSG_FD_CTX_GET_FAILED, - AFR_MSG_INVALID_SUBVOL, - AFR_MSG_PUMP_XLATOR_ERROR, - AFR_MSG_SELF_HEAL_INFO, - AFR_MSG_READ_SUBVOL_ERROR, - AFR_MSG_DICT_GET_FAILED, - AFR_MSG_INFO_COMMON, - AFR_MSG_SPLIT_BRAIN_CHOICE_ERROR, - AFR_MSG_LOCAL_CHILD, - AFR_MSG_INVALID_DATA, - AFR_MSG_INVALID_ARG, - AFR_MSG_INDEX_DIR_GET_FAILED, - AFR_MSG_FSYNC_FAILED, - AFR_MSG_FAVORITE_CHILD, - AFR_MSG_SELF_HEAL_FAILED, - AFR_MSG_SPLIT_BRAIN_STATUS, - AFR_MSG_ADD_BRICK_STATUS, - AFR_MSG_NO_CHANGELOG, - AFR_MSG_TIMER_CREATE_FAIL, - AFR_MSG_SBRAIN_FAV_CHILD_POLICY, - AFR_MSG_INODE_CTX_GET_FAILED, - AFR_MSG_THIN_ARB -); +GLFS_MSGID(AFR, AFR_MSG_QUORUM_FAIL, AFR_MSG_QUORUM_MET, + AFR_MSG_QUORUM_OVERRIDE, AFR_MSG_INVALID_CHILD_UP, AFR_MSG_SUBVOL_UP, + AFR_MSG_SUBVOLS_DOWN, AFR_MSG_ENTRY_UNLOCK_FAIL, AFR_MSG_SPLIT_BRAIN, + AFR_MSG_OPEN_FAIL, AFR_MSG_UNLOCK_FAIL, AFR_MSG_REPLACE_BRICK_STATUS, + AFR_MSG_GFID_NULL, AFR_MSG_FD_CREATE_FAILED, AFR_MSG_DICT_SET_FAILED, + AFR_MSG_EXPUNGING_FILE_OR_DIR, AFR_MSG_MIGRATION_IN_PROGRESS, + AFR_MSG_CHILD_MISCONFIGURED, AFR_MSG_VOL_MISCONFIGURED, + AFR_MSG_BLOCKING_LKS_FAILED, AFR_MSG_INVALID_FD, AFR_MSG_LOCK_INFO, + AFR_MSG_LOCK_XLATOR_NOT_LOADED, AFR_MSG_FD_CTX_GET_FAILED, + AFR_MSG_INVALID_SUBVOL, AFR_MSG_PUMP_XLATOR_ERROR, + AFR_MSG_SELF_HEAL_INFO, AFR_MSG_READ_SUBVOL_ERROR, + AFR_MSG_DICT_GET_FAILED, AFR_MSG_INFO_COMMON, + AFR_MSG_SPLIT_BRAIN_CHOICE_ERROR, AFR_MSG_LOCAL_CHILD, + AFR_MSG_INVALID_DATA, AFR_MSG_INVALID_ARG, + AFR_MSG_INDEX_DIR_GET_FAILED, AFR_MSG_FSYNC_FAILED, + AFR_MSG_FAVORITE_CHILD, AFR_MSG_SELF_HEAL_FAILED, + AFR_MSG_SPLIT_BRAIN_STATUS, AFR_MSG_ADD_BRICK_STATUS, + AFR_MSG_NO_CHANGELOG, AFR_MSG_TIMER_CREATE_FAIL, + AFR_MSG_SBRAIN_FAV_CHILD_POLICY, AFR_MSG_INODE_CTX_GET_FAILED, + AFR_MSG_THIN_ARB); #endif /* !_AFR_MESSAGES_H_ */ diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h index 9836e2fbc03..545e67f774d 100644 --- a/xlators/cluster/afr/src/afr-self-heal.h +++ b/xlators/cluster/afr/src/afr-self-heal.h @@ -8,7 +8,6 @@ cases as published by the Free Software Foundation. */ - #ifndef _AFR_SELFHEAL_H #define _AFR_SELFHEAL_H @@ -16,257 +15,257 @@ /* Perform fop on all UP subvolumes and wait for all callbacks to return */ -#define AFR_ONALL(frame, rfn, fop, args ...) do { \ - afr_local_t *__local = frame->local; \ - afr_private_t *__priv = frame->this->private; \ - int __i = 0, __count = 0; \ - unsigned char *__child_up = NULL; \ - \ - __child_up = alloca0 (__priv->child_count); \ - memcpy (__child_up, __priv->child_up, \ - sizeof (*__child_up) * __priv->child_count); \ - __count = AFR_COUNT (__child_up, __priv->child_count); \ - \ - __local->barrier.waitfor = __count; \ - afr_local_replies_wipe (__local, __priv); \ - \ - for (__i = 0; __i < __priv->child_count; __i++) { \ - if (!__child_up[__i]) \ - continue; \ - STACK_WIND_COOKIE (frame, rfn, (void *)(long) __i, \ - __priv->children[__i], \ - __priv->children[__i]->fops->fop, args); \ - } \ - syncbarrier_wait (&__local->barrier, __count); \ - } while (0) - +#define AFR_ONALL(frame, rfn, fop, args...) \ + do { \ + afr_local_t *__local = frame->local; \ + afr_private_t *__priv = frame->this->private; \ + int __i = 0, __count = 0; \ + unsigned char *__child_up = NULL; \ + \ + __child_up = alloca0(__priv->child_count); \ + memcpy(__child_up, __priv->child_up, \ + sizeof(*__child_up) * __priv->child_count); \ + __count = AFR_COUNT(__child_up, __priv->child_count); \ + \ + __local->barrier.waitfor = __count; \ + afr_local_replies_wipe(__local, __priv); \ + \ + for (__i = 0; __i < __priv->child_count; __i++) { \ + if (!__child_up[__i]) \ + continue; \ + STACK_WIND_COOKIE(frame, rfn, (void *)(long)__i, \ + __priv->children[__i], \ + __priv->children[__i]->fops->fop, args); \ + } \ + syncbarrier_wait(&__local->barrier, __count); \ + } while (0) /* Perform fop on all subvolumes represented by list[] array and wait for all callbacks to return */ -#define AFR_ONLIST(list, frame, rfn, fop, args ...) do { \ - afr_local_t *__local = frame->local; \ - afr_private_t *__priv = frame->this->private; \ - int __i = 0; \ - int __count = AFR_COUNT (list, __priv->child_count); \ - \ - __local->barrier.waitfor = __count; \ - afr_local_replies_wipe (__local, __priv); \ - \ - for (__i = 0; __i < __priv->child_count; __i++) { \ - if (!list[__i]) continue; \ - STACK_WIND_COOKIE (frame, rfn, (void *)(long) __i, \ - __priv->children[__i], \ - __priv->children[__i]->fops->fop, args); \ - } \ - syncbarrier_wait (&__local->barrier, __count); \ - } while (0) - - -#define AFR_SEQ(frame, rfn, fop, args ...) do { \ - afr_local_t *__local = frame->local; \ - afr_private_t *__priv = frame->this->private; \ - int __i = 0; \ - \ - afr_local_replies_wipe (__local, __priv); \ - \ - for (__i = 0; __i < __priv->child_count; __i++) { \ - if (!__priv->child_up[__i]) continue; \ - STACK_WIND_COOKIE (frame, rfn, (void *)(long) __i, \ - __priv->children[__i], \ - __priv->children[__i]->fops->fop, args); \ - syncbarrier_wait (&__local->barrier, 1); \ - } \ - } while (0) - - -#define ALLOC_MATRIX(n, type) ({type **__ptr = NULL; \ - int __i; \ - __ptr = alloca0 (n * sizeof(type *)); \ - for (__i = 0; __i < n; __i++) __ptr[__i] = alloca0 (n * sizeof(type)); \ - __ptr;}) - - -#define IA_EQUAL(f,s,field) (memcmp (&(f.ia_##field), &(s.ia_##field), sizeof (s.ia_##field)) == 0) - -#define SBRAIN_HEAL_NO_GO_MSG "Failed to obtain replies from all bricks of "\ - "the replica (are they up?). Cannot resolve split-brain." -int -afr_selfheal (xlator_t *this, uuid_t gfid); +#define AFR_ONLIST(list, frame, rfn, fop, args...) \ + do { \ + afr_local_t *__local = frame->local; \ + afr_private_t *__priv = frame->this->private; \ + int __i = 0; \ + int __count = AFR_COUNT(list, __priv->child_count); \ + \ + __local->barrier.waitfor = __count; \ + afr_local_replies_wipe(__local, __priv); \ + \ + for (__i = 0; __i < __priv->child_count; __i++) { \ + if (!list[__i]) \ + continue; \ + STACK_WIND_COOKIE(frame, rfn, (void *)(long)__i, \ + __priv->children[__i], \ + __priv->children[__i]->fops->fop, args); \ + } \ + syncbarrier_wait(&__local->barrier, __count); \ + } while (0) + +#define AFR_SEQ(frame, rfn, fop, args...) \ + do { \ + afr_local_t *__local = frame->local; \ + afr_private_t *__priv = frame->this->private; \ + int __i = 0; \ + \ + afr_local_replies_wipe(__local, __priv); \ + \ + for (__i = 0; __i < __priv->child_count; __i++) { \ + if (!__priv->child_up[__i]) \ + continue; \ + STACK_WIND_COOKIE(frame, rfn, (void *)(long)__i, \ + __priv->children[__i], \ + __priv->children[__i]->fops->fop, args); \ + syncbarrier_wait(&__local->barrier, 1); \ + } \ + } while (0) + +#define ALLOC_MATRIX(n, type) \ + ({ \ + type **__ptr = NULL; \ + int __i; \ + __ptr = alloca0(n * sizeof(type *)); \ + for (__i = 0; __i < n; __i++) \ + __ptr[__i] = alloca0(n * sizeof(type)); \ + __ptr; \ + }) + +#define IA_EQUAL(f, s, field) \ + (memcmp(&(f.ia_##field), &(s.ia_##field), sizeof(s.ia_##field)) == 0) + +#define SBRAIN_HEAL_NO_GO_MSG \ + "Failed to obtain replies from all bricks of " \ + "the replica (are they up?). Cannot resolve split-brain." +int +afr_selfheal(xlator_t *this, uuid_t gfid); gf_boolean_t -afr_throttled_selfheal (call_frame_t *frame, xlator_t *this); +afr_throttled_selfheal(call_frame_t *frame, xlator_t *this); int -afr_selfheal_name (xlator_t *this, uuid_t gfid, const char *name, - void *gfid_req, dict_t *xdata); +afr_selfheal_name(xlator_t *this, uuid_t gfid, const char *name, void *gfid_req, + dict_t *xdata); int -afr_selfheal_data (call_frame_t *frame, xlator_t *this, fd_t *fd); +afr_selfheal_data(call_frame_t *frame, xlator_t *this, fd_t *fd); int -afr_selfheal_metadata (call_frame_t *frame, xlator_t *this, inode_t *inode); +afr_selfheal_metadata(call_frame_t *frame, xlator_t *this, inode_t *inode); int -afr_selfheal_entry (call_frame_t *frame, xlator_t *this, inode_t *inode); +afr_selfheal_entry(call_frame_t *frame, xlator_t *this, inode_t *inode); int -afr_lookup_and_heal_gfid (xlator_t *this, inode_t *parent, const char *name, - inode_t *inode, struct afr_reply *replies, int source, - unsigned char *sources, void *gfid); +afr_lookup_and_heal_gfid(xlator_t *this, inode_t *parent, const char *name, + inode_t *inode, struct afr_reply *replies, int source, + unsigned char *sources, void *gfid); int -afr_selfheal_inodelk (call_frame_t *frame, xlator_t *this, inode_t *inode, - char *dom, off_t off, size_t size, - unsigned char *locked_on); +afr_selfheal_inodelk(call_frame_t *frame, xlator_t *this, inode_t *inode, + char *dom, off_t off, size_t size, + unsigned char *locked_on); int -afr_selfheal_tryinodelk (call_frame_t *frame, xlator_t *this, inode_t *inode, - char *dom, off_t off, size_t size, - unsigned char *locked_on); +afr_selfheal_tryinodelk(call_frame_t *frame, xlator_t *this, inode_t *inode, + char *dom, off_t off, size_t size, + unsigned char *locked_on); int -afr_selfheal_tie_breaker_inodelk (call_frame_t *frame, xlator_t *this, - inode_t *inode, char *dom, off_t off, - size_t size, unsigned char *locked_on); +afr_selfheal_tie_breaker_inodelk(call_frame_t *frame, xlator_t *this, + inode_t *inode, char *dom, off_t off, + size_t size, unsigned char *locked_on); int -afr_selfheal_uninodelk (call_frame_t *frame, xlator_t *this, inode_t *inode, - char *dom, off_t off, size_t size, - const unsigned char *locked_on); +afr_selfheal_uninodelk(call_frame_t *frame, xlator_t *this, inode_t *inode, + char *dom, off_t off, size_t size, + const unsigned char *locked_on); int -afr_selfheal_entrylk (call_frame_t *frame, xlator_t *this, inode_t *inode, - char *dom, const char *name, unsigned char *locked_on); +afr_selfheal_entrylk(call_frame_t *frame, xlator_t *this, inode_t *inode, + char *dom, const char *name, unsigned char *locked_on); int -afr_selfheal_tryentrylk (call_frame_t *frame, xlator_t *this, inode_t *inode, - char *dom, const char *name, unsigned char *locked_on); +afr_selfheal_tryentrylk(call_frame_t *frame, xlator_t *this, inode_t *inode, + char *dom, const char *name, unsigned char *locked_on); int -afr_selfheal_tie_breaker_entrylk (call_frame_t *frame, xlator_t *this, - inode_t *inode, char *dom, const char *name, - unsigned char *locked_on); +afr_selfheal_tie_breaker_entrylk(call_frame_t *frame, xlator_t *this, + inode_t *inode, char *dom, const char *name, + unsigned char *locked_on); int -afr_selfheal_unentrylk (call_frame_t *frame, xlator_t *this, inode_t *inode, - char *dom, const char *name, unsigned char *locked_on, - dict_t *xdata); +afr_selfheal_unentrylk(call_frame_t *frame, xlator_t *this, inode_t *inode, + char *dom, const char *name, unsigned char *locked_on, + dict_t *xdata); int -afr_selfheal_unlocked_discover (call_frame_t *frame, inode_t *inode, - uuid_t gfid, struct afr_reply *replies); +afr_selfheal_unlocked_discover(call_frame_t *frame, inode_t *inode, uuid_t gfid, + struct afr_reply *replies); int -afr_selfheal_unlocked_discover_on (call_frame_t *frame, inode_t *inode, +afr_selfheal_unlocked_discover_on(call_frame_t *frame, inode_t *inode, uuid_t gfid, struct afr_reply *replies, - unsigned char *discover_on); + unsigned char *discover_on); inode_t * -afr_selfheal_unlocked_lookup_on (call_frame_t *frame, inode_t *parent, - const char *name, struct afr_reply *replies, - unsigned char *lookup_on, dict_t *xattr); +afr_selfheal_unlocked_lookup_on(call_frame_t *frame, inode_t *parent, + const char *name, struct afr_reply *replies, + unsigned char *lookup_on, dict_t *xattr); int -afr_selfheal_find_direction (call_frame_t *frame, xlator_t *this, - struct afr_reply *replies, - afr_transaction_type type, - unsigned char *locked_on, unsigned char *sources, - unsigned char *sinks, uint64_t *witness, - gf_boolean_t *flag); +afr_selfheal_find_direction(call_frame_t *frame, xlator_t *this, + struct afr_reply *replies, + afr_transaction_type type, unsigned char *locked_on, + unsigned char *sources, unsigned char *sinks, + uint64_t *witness, gf_boolean_t *flag); int -afr_selfheal_fill_matrix (xlator_t *this, int **matrix, int subvol, int idx, - dict_t *xdata); +afr_selfheal_fill_matrix(xlator_t *this, int **matrix, int subvol, int idx, + dict_t *xdata); int -afr_selfheal_extract_xattr (xlator_t *this, struct afr_reply *replies, - afr_transaction_type type, int *dirty, int **matrix); +afr_selfheal_extract_xattr(xlator_t *this, struct afr_reply *replies, + afr_transaction_type type, int *dirty, int **matrix); int -afr_sh_generic_fop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *pre, - struct iatt *post, dict_t *xdata); +afr_sh_generic_fop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, struct iatt *pre, + struct iatt *post, dict_t *xdata); int -afr_selfheal_restore_time (call_frame_t *frame, xlator_t *this, inode_t *inode, - int source, unsigned char *healed_sinks, - struct afr_reply *replies); +afr_selfheal_restore_time(call_frame_t *frame, xlator_t *this, inode_t *inode, + int source, unsigned char *healed_sinks, + struct afr_reply *replies); int -afr_selfheal_undo_pending (call_frame_t *frame, xlator_t *this, inode_t *inode, - unsigned char *sources, unsigned char *sinks, - unsigned char *healed_sinks, - unsigned char *undid_pending, - afr_transaction_type type, struct afr_reply *replies, - unsigned char *locked_on); +afr_selfheal_undo_pending(call_frame_t *frame, xlator_t *this, inode_t *inode, + unsigned char *sources, unsigned char *sinks, + unsigned char *healed_sinks, + unsigned char *undid_pending, + afr_transaction_type type, struct afr_reply *replies, + unsigned char *locked_on); int -afr_selfheal_recreate_entry (call_frame_t *frame, int dst, int source, - unsigned char *sources, - inode_t *dir, const char *name, inode_t *inode, - struct afr_reply *replies); +afr_selfheal_recreate_entry(call_frame_t *frame, int dst, int source, + unsigned char *sources, inode_t *dir, + const char *name, inode_t *inode, + struct afr_reply *replies); int -afr_selfheal_post_op (call_frame_t *frame, xlator_t *this, inode_t *inode, - int subvol, dict_t *xattr, dict_t *xdata); +afr_selfheal_post_op(call_frame_t *frame, xlator_t *this, inode_t *inode, + int subvol, dict_t *xattr, dict_t *xdata); call_frame_t * -afr_frame_create (xlator_t *this, int32_t *op_errno); +afr_frame_create(xlator_t *this, int32_t *op_errno); inode_t * -afr_inode_find (xlator_t *this, uuid_t gfid); +afr_inode_find(xlator_t *this, uuid_t gfid); int -afr_selfheal_discover_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, inode_t *inode, - struct iatt *buf, dict_t *xdata, - struct iatt *parbuf); +afr_selfheal_discover_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, inode_t *inode, + struct iatt *buf, dict_t *xdata, struct iatt *parbuf); void -afr_reply_copy (struct afr_reply *dst, struct afr_reply *src); +afr_reply_copy(struct afr_reply *dst, struct afr_reply *src); void -afr_replies_copy (struct afr_reply *dst, struct afr_reply *src, int count); +afr_replies_copy(struct afr_reply *dst, struct afr_reply *src, int count); int -afr_selfheal_newentry_mark (call_frame_t *frame, xlator_t *this, inode_t *inode, - int source, struct afr_reply *replies, - unsigned char *sources, unsigned char *newentry); +afr_selfheal_newentry_mark(call_frame_t *frame, xlator_t *this, inode_t *inode, + int source, struct afr_reply *replies, + unsigned char *sources, unsigned char *newentry); unsigned int -afr_success_count (struct afr_reply *replies, unsigned int count); +afr_success_count(struct afr_reply *replies, unsigned int count); void -afr_log_selfheal (uuid_t gfid, xlator_t *this, int ret, char *type, - int source, unsigned char *sources, - unsigned char *healed_sinks); +afr_log_selfheal(uuid_t gfid, xlator_t *this, int ret, char *type, int source, + unsigned char *sources, unsigned char *healed_sinks); void -afr_mark_largest_file_as_source (xlator_t *this, unsigned char *sources, - struct afr_reply *replies); +afr_mark_largest_file_as_source(xlator_t *this, unsigned char *sources, + struct afr_reply *replies); void -afr_mark_active_sinks (xlator_t *this, unsigned char *sources, - unsigned char *locked_on, unsigned char *sinks); +afr_mark_active_sinks(xlator_t *this, unsigned char *sources, + unsigned char *locked_on, unsigned char *sinks); gf_boolean_t -afr_dict_contains_heal_op (call_frame_t *frame); +afr_dict_contains_heal_op(call_frame_t *frame); gf_boolean_t -afr_can_decide_split_brain_source_sinks (struct afr_reply *replies, - int child_count); +afr_can_decide_split_brain_source_sinks(struct afr_reply *replies, + int child_count); int -afr_mark_split_brain_source_sinks (call_frame_t *frame, xlator_t *this, - inode_t *inode, - unsigned char *sources, - unsigned char *sinks, - unsigned char *healed_sinks, - unsigned char *locked_on, - struct afr_reply *replies, - afr_transaction_type type); +afr_mark_split_brain_source_sinks( + call_frame_t *frame, xlator_t *this, inode_t *inode, unsigned char *sources, + unsigned char *sinks, unsigned char *healed_sinks, unsigned char *locked_on, + struct afr_reply *replies, afr_transaction_type type); int -afr_sh_get_fav_by_policy (xlator_t *this, struct afr_reply *replies, - inode_t *inode, char **policy_str); +afr_sh_get_fav_by_policy(xlator_t *this, struct afr_reply *replies, + inode_t *inode, char **policy_str); int -_afr_fav_child_reset_sink_xattrs (call_frame_t *frame, xlator_t *this, +_afr_fav_child_reset_sink_xattrs(call_frame_t *frame, xlator_t *this, inode_t *inode, int source, unsigned char *healed_sinks, unsigned char *undid_pending, @@ -275,86 +274,77 @@ _afr_fav_child_reset_sink_xattrs (call_frame_t *frame, xlator_t *this, struct afr_reply *replies); int -afr_get_child_index_from_name (xlator_t *this, char *name); +afr_get_child_index_from_name(xlator_t *this, char *name); gf_boolean_t -afr_does_witness_exist (xlator_t *this, uint64_t *witness); +afr_does_witness_exist(xlator_t *this, uint64_t *witness); int -__afr_selfheal_data_prepare (call_frame_t *frame, xlator_t *this, - inode_t *inode, unsigned char *locked_on, - unsigned char *sources, - unsigned char *sinks, unsigned char *healed_sinks, - unsigned char *undid_pending, - struct afr_reply *replies, gf_boolean_t *flag); +__afr_selfheal_data_prepare(call_frame_t *frame, xlator_t *this, inode_t *inode, + unsigned char *locked_on, unsigned char *sources, + unsigned char *sinks, unsigned char *healed_sinks, + unsigned char *undid_pending, + struct afr_reply *replies, gf_boolean_t *flag); int -__afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, - inode_t *inode, unsigned char *locked_on, - unsigned char *sources, - unsigned char *sinks, - unsigned char *healed_sinks, - unsigned char *undid_pending, - struct afr_reply *replies, - gf_boolean_t *flag); +__afr_selfheal_metadata_prepare(call_frame_t *frame, xlator_t *this, + inode_t *inode, unsigned char *locked_on, + unsigned char *sources, unsigned char *sinks, + unsigned char *healed_sinks, + unsigned char *undid_pending, + struct afr_reply *replies, gf_boolean_t *flag); int -__afr_selfheal_entry_prepare (call_frame_t *frame, xlator_t *this, - inode_t *inode, unsigned char *locked_on, - unsigned char *sources, - unsigned char *sinks, - unsigned char *healed_sinks, - struct afr_reply *replies, int *source_p, - gf_boolean_t *flag); +__afr_selfheal_entry_prepare(call_frame_t *frame, xlator_t *this, + inode_t *inode, unsigned char *locked_on, + unsigned char *sources, unsigned char *sinks, + unsigned char *healed_sinks, + struct afr_reply *replies, int *source_p, + gf_boolean_t *flag); int -afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this, - uuid_t gfid, inode_t **link_inode, - gf_boolean_t *data_selfheal, - gf_boolean_t *metadata_selfheal, - gf_boolean_t *entry_selfheal); +afr_selfheal_unlocked_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid, + inode_t **link_inode, gf_boolean_t *data_selfheal, + gf_boolean_t *metadata_selfheal, + gf_boolean_t *entry_selfheal); int -afr_selfheal_do (call_frame_t *frame, xlator_t *this, uuid_t gfid); +afr_selfheal_do(call_frame_t *frame, xlator_t *this, uuid_t gfid); int -afr_selfheal_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, dict_t *xdata); +afr_selfheal_lock_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata); int -afr_locked_fill (call_frame_t *frame, xlator_t *this, - unsigned char *locked_on); +afr_locked_fill(call_frame_t *frame, xlator_t *this, unsigned char *locked_on); int -afr_choose_source_by_policy (afr_private_t *priv, unsigned char *sources, - afr_transaction_type type); +afr_choose_source_by_policy(afr_private_t *priv, unsigned char *sources, + afr_transaction_type type); int -afr_selfheal_metadata_by_stbuf (xlator_t *this, struct iatt *stbuf); +afr_selfheal_metadata_by_stbuf(xlator_t *this, struct iatt *stbuf); int -afr_sh_fav_by_size (xlator_t *this, struct afr_reply *replies, - inode_t *inode); +afr_sh_fav_by_size(xlator_t *this, struct afr_reply *replies, inode_t *inode); int -afr_sh_fav_by_mtime (xlator_t *this, struct afr_reply *replies, - inode_t *inode); +afr_sh_fav_by_mtime(xlator_t *this, struct afr_reply *replies, inode_t *inode); int -afr_sh_fav_by_ctime (xlator_t *this, struct afr_reply *replies, - inode_t *inode); +afr_sh_fav_by_ctime(xlator_t *this, struct afr_reply *replies, inode_t *inode); int -afr_gfid_split_brain_source (xlator_t *this, struct afr_reply *replies, - inode_t *inode, uuid_t pargfid, const char *bname, - int src_idx, int child_idx, - unsigned char *locked_on, int *src, dict_t *xdata); +afr_gfid_split_brain_source(xlator_t *this, struct afr_reply *replies, + inode_t *inode, uuid_t pargfid, const char *bname, + int src_idx, int child_idx, + unsigned char *locked_on, int *src, dict_t *xdata); int -afr_mark_source_sinks_if_file_empty (xlator_t *this, unsigned char *sources, - unsigned char *sinks, - unsigned char *healed_sinks, - unsigned char *locked_on, - struct afr_reply *replies, - afr_transaction_type type); +afr_mark_source_sinks_if_file_empty(xlator_t *this, unsigned char *sources, + unsigned char *sinks, + unsigned char *healed_sinks, + unsigned char *locked_on, + struct afr_reply *replies, + afr_transaction_type type); gf_boolean_t -afr_is_file_empty_on_all_children (afr_private_t *priv, - struct afr_reply *replies); +afr_is_file_empty_on_all_children(afr_private_t *priv, + struct afr_reply *replies); #endif /* !_AFR_SELFHEAL_H */ diff --git a/xlators/cluster/afr/src/afr-self-heald.h b/xlators/cluster/afr/src/afr-self-heald.h index 4ac1d32f58a..7de7c431460 100644 --- a/xlators/cluster/afr/src/afr-self-heald.h +++ b/xlators/cluster/afr/src/afr-self-heald.h @@ -8,74 +8,71 @@ cases as published by the Free Software Foundation. */ - #ifndef _AFR_SELF_HEALD_H #define _AFR_SELF_HEALD_H #include <pthread.h> - typedef struct { - int child; - char *path; + int child; + char *path; } shd_event_t; typedef struct { - int child; - uint64_t healed_count; - uint64_t split_brain_count; - uint64_t heal_failed_count; - - /* If start_time is 0, it means crawler is not in progress - and stats are not valid */ - time_t start_time; - /* If start_time is NOT 0 and end_time is 0, it means - cralwer is in progress */ - time_t end_time; - char *crawl_type; + int child; + uint64_t healed_count; + uint64_t split_brain_count; + uint64_t heal_failed_count; + + /* If start_time is 0, it means crawler is not in progress + and stats are not valid */ + time_t start_time; + /* If start_time is NOT 0 and end_time is 0, it means + cralwer is in progress */ + time_t end_time; + char *crawl_type; } crawl_event_t; struct subvol_healer { - xlator_t *this; - int subvol; - gf_boolean_t local; - gf_boolean_t running; - gf_boolean_t rerun; - crawl_event_t crawl_event; - pthread_mutex_t mutex; - pthread_cond_t cond; - pthread_t thread; + xlator_t *this; + int subvol; + gf_boolean_t local; + gf_boolean_t running; + gf_boolean_t rerun; + crawl_event_t crawl_event; + pthread_mutex_t mutex; + pthread_cond_t cond; + pthread_t thread; }; typedef struct { - gf_boolean_t iamshd; - gf_boolean_t enabled; - int timeout; - struct subvol_healer *index_healers; - struct subvol_healer *full_healers; - - eh_t *split_brain; - eh_t **statistics; - uint32_t max_threads; - uint32_t wait_qlength; - uint32_t halo_max_latency_msec; + gf_boolean_t iamshd; + gf_boolean_t enabled; + int timeout; + struct subvol_healer *index_healers; + struct subvol_healer *full_healers; + + eh_t *split_brain; + eh_t **statistics; + uint32_t max_threads; + uint32_t wait_qlength; + uint32_t halo_max_latency_msec; } afr_self_heald_t; - int -afr_selfheal_childup (xlator_t *this, int subvol); +afr_selfheal_childup(xlator_t *this, int subvol); int -afr_selfheal_daemon_init (xlator_t *this); +afr_selfheal_daemon_init(xlator_t *this); int -afr_xl_op (xlator_t *this, dict_t *input, dict_t *output); +afr_xl_op(xlator_t *this, dict_t *input, dict_t *output); int -afr_shd_gfid_to_path (xlator_t *this, xlator_t *subvol, uuid_t gfid, - char **path_p); +afr_shd_gfid_to_path(xlator_t *this, xlator_t *subvol, uuid_t gfid, + char **path_p); int -afr_shd_index_purge (xlator_t *subvol, inode_t *inode, char *name, - ia_type_t type); +afr_shd_index_purge(xlator_t *subvol, inode_t *inode, char *name, + ia_type_t type); #endif /* !_AFR_SELF_HEALD_H */ diff --git a/xlators/cluster/afr/src/afr-transaction.h b/xlators/cluster/afr/src/afr-transaction.h index fe0f45f2f93..fff8c65e976 100644 --- a/xlators/cluster/afr/src/afr-transaction.h +++ b/xlators/cluster/afr/src/afr-transaction.h @@ -14,51 +14,57 @@ #include "afr.h" void -afr_transaction_fop_failed (call_frame_t *frame, xlator_t *this, - int child_index); +afr_transaction_fop_failed(call_frame_t *frame, xlator_t *this, + int child_index); int32_t -afr_transaction (call_frame_t *frame, xlator_t *this, afr_transaction_type type); +afr_transaction(call_frame_t *frame, xlator_t *this, afr_transaction_type type); int -afr_set_pending_dict (afr_private_t *priv, dict_t *xattr, int32_t **pending); +afr_set_pending_dict(afr_private_t *priv, dict_t *xattr, int32_t **pending); void -afr_delayed_changelog_wake_up (xlator_t *this, fd_t *fd); +afr_delayed_changelog_wake_up(xlator_t *this, fd_t *fd); void -__mark_all_success (call_frame_t *frame, xlator_t *this); +__mark_all_success(call_frame_t *frame, xlator_t *this); gf_boolean_t -afr_txn_nothing_failed (call_frame_t *frame, xlator_t *this); +afr_txn_nothing_failed(call_frame_t *frame, xlator_t *this); -int afr_read_txn (call_frame_t *frame, xlator_t *this, inode_t *inode, - afr_read_txn_wind_t readfn, afr_transaction_type type); +int +afr_read_txn(call_frame_t *frame, xlator_t *this, inode_t *inode, + afr_read_txn_wind_t readfn, afr_transaction_type type); -int afr_read_txn_continue (call_frame_t *frame, xlator_t *this, int subvol); +int +afr_read_txn_continue(call_frame_t *frame, xlator_t *this, int subvol); void -afr_pending_read_increment (afr_private_t *priv, int child_index); +afr_pending_read_increment(afr_private_t *priv, int child_index); void -afr_pending_read_decrement (afr_private_t *priv, int child_index); +afr_pending_read_decrement(afr_private_t *priv, int child_index); -call_frame_t *afr_transaction_detach_fop_frame (call_frame_t *frame); -gf_boolean_t afr_has_quorum (unsigned char *subvols, xlator_t *this); -gf_boolean_t afr_needs_changelog_update (afr_local_t *local); -void afr_zero_fill_stat (afr_local_t *local); +call_frame_t * +afr_transaction_detach_fop_frame(call_frame_t *frame); +gf_boolean_t +afr_has_quorum(unsigned char *subvols, xlator_t *this); +gf_boolean_t +afr_needs_changelog_update(afr_local_t *local); +void +afr_zero_fill_stat(afr_local_t *local); void -afr_pick_error_xdata (afr_local_t *local, afr_private_t *priv, - inode_t *inode1, unsigned char *readable1, - inode_t *inode2, unsigned char *readable2); +afr_pick_error_xdata(afr_local_t *local, afr_private_t *priv, inode_t *inode1, + unsigned char *readable1, inode_t *inode2, + unsigned char *readable2); int -afr_transaction_resume (call_frame_t *frame, xlator_t *this); +afr_transaction_resume(call_frame_t *frame, xlator_t *this); int -afr_lock (call_frame_t *frame, xlator_t *this); +afr_lock(call_frame_t *frame, xlator_t *this); void -afr_delayed_changelog_wake_up_cbk (void *data); +afr_delayed_changelog_wake_up_cbk(void *data); #endif /* __TRANSACTION_H__ */ diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index f7b636cb3d9..3395507ab90 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -8,7 +8,6 @@ cases as published by the Free Software Foundation. */ - #ifndef __AFR_H__ #define __AFR_H__ @@ -27,11 +26,11 @@ #define AFR_SH_READDIR_SIZE_KEY "self-heal-readdir-size" #define AFR_SH_DATA_DOMAIN_FMT "%s:self-heal" #define AFR_DIRTY_DEFAULT AFR_XATTR_PREFIX ".dirty" -#define AFR_DIRTY (((afr_private_t *) (THIS->private))->afr_dirty) +#define AFR_DIRTY (((afr_private_t *)(THIS->private))->afr_dirty) -#define AFR_LOCKEE_COUNT_MAX 3 -#define AFR_DOM_COUNT_MAX 3 -#define AFR_NUM_CHANGE_LOGS 3 /*data + metadata + entry*/ +#define AFR_LOCKEE_COUNT_MAX 3 +#define AFR_DOM_COUNT_MAX 3 +#define AFR_NUM_CHANGE_LOGS 3 /*data + metadata + entry*/ #define AFR_DEFAULT_SPB_CHOICE_TIMEOUT 300 /*in seconds*/ #define ARBITER_BRICK_INDEX 2 @@ -40,160 +39,185 @@ #define AFR_TA_DOM_MODIFY "afr.ta.dom-modify" #define AFR_HALO_MAX_LATENCY 99999 -typedef int (*afr_lock_cbk_t) (call_frame_t *frame, xlator_t *this); - -typedef int (*afr_read_txn_wind_t) (call_frame_t *frame, xlator_t *this, int subvol); - -typedef int (*afr_inode_refresh_cbk_t) (call_frame_t *frame, xlator_t *this, int err); - -typedef int (*afr_changelog_resume_t) (call_frame_t *frame, xlator_t *this); - -#define AFR_COUNT(array,max) ({int __i; int __res = 0; for (__i = 0; __i < max; __i++) if (array[__i]) __res++; __res;}) -#define AFR_INTERSECT(dst,src1,src2,max) ({int __i; for (__i = 0; __i < max; __i++) dst[__i] = src1[__i] && src2[__i];}) -#define AFR_CMP(a1,a2,len) ({int __cmp = 0; int __i; for (__i = 0; __i < len; __i++) if (a1[__i] != a2[__i]) { __cmp = 1; break;} __cmp;}) -#define AFR_IS_ARBITER_BRICK(priv, index) ((priv->arbiter_count == 1) && (index == ARBITER_BRICK_INDEX)) +typedef int (*afr_lock_cbk_t)(call_frame_t *frame, xlator_t *this); + +typedef int (*afr_read_txn_wind_t)(call_frame_t *frame, xlator_t *this, + int subvol); + +typedef int (*afr_inode_refresh_cbk_t)(call_frame_t *frame, xlator_t *this, + int err); + +typedef int (*afr_changelog_resume_t)(call_frame_t *frame, xlator_t *this); + +#define AFR_COUNT(array, max) \ + ({ \ + int __i; \ + int __res = 0; \ + for (__i = 0; __i < max; __i++) \ + if (array[__i]) \ + __res++; \ + __res; \ + }) +#define AFR_INTERSECT(dst, src1, src2, max) \ + ({ \ + int __i; \ + for (__i = 0; __i < max; __i++) \ + dst[__i] = src1[__i] && src2[__i]; \ + }) +#define AFR_CMP(a1, a2, len) \ + ({ \ + int __cmp = 0; \ + int __i; \ + for (__i = 0; __i < len; __i++) \ + if (a1[__i] != a2[__i]) { \ + __cmp = 1; \ + break; \ + } \ + __cmp; \ + }) +#define AFR_IS_ARBITER_BRICK(priv, index) \ + ((priv->arbiter_count == 1) && (index == ARBITER_BRICK_INDEX)) #define AFR_SET_ERROR_AND_CHECK_SPLIT_BRAIN(ret, errnum) \ - do { \ - local->op_ret = ret; \ - local->op_errno = errnum; \ - if (local->op_errno == EIO) \ - gf_msg (this->name, GF_LOG_ERROR, local->op_errno, \ - AFR_MSG_SPLIT_BRAIN, "Failing %s on gfid %s: " \ - "split-brain observed.", \ - gf_fop_list[local->op], \ - uuid_utoa (local->inode->gfid)); \ - } while (0) + do { \ + local->op_ret = ret; \ + local->op_errno = errnum; \ + if (local->op_errno == EIO) \ + gf_msg(this->name, GF_LOG_ERROR, local->op_errno, \ + AFR_MSG_SPLIT_BRAIN, \ + "Failing %s on gfid %s: " \ + "split-brain observed.", \ + gf_fop_list[local->op], uuid_utoa(local->inode->gfid)); \ + } while (0) typedef enum { - AFR_FAV_CHILD_NONE, - AFR_FAV_CHILD_BY_SIZE, - AFR_FAV_CHILD_BY_CTIME, - AFR_FAV_CHILD_BY_MTIME, - AFR_FAV_CHILD_BY_MAJORITY, - AFR_FAV_CHILD_POLICY_MAX, + AFR_FAV_CHILD_NONE, + AFR_FAV_CHILD_BY_SIZE, + AFR_FAV_CHILD_BY_CTIME, + AFR_FAV_CHILD_BY_MTIME, + AFR_FAV_CHILD_BY_MAJORITY, + AFR_FAV_CHILD_POLICY_MAX, } afr_favorite_child_policy; typedef enum { - AFR_CHILD_UNKNOWN = -1, - AFR_CHILD_ZERO, - AFR_CHILD_ONE, + AFR_CHILD_UNKNOWN = -1, + AFR_CHILD_ZERO, + AFR_CHILD_ONE, } afr_child_index; struct afr_nfsd { - gf_boolean_t iamnfsd; - uint32_t halo_max_latency_msec; + gf_boolean_t iamnfsd; + uint32_t halo_max_latency_msec; }; typedef struct _afr_private { - gf_lock_t lock; /* to guard access to child_count, etc */ - unsigned int child_count; /* total number of children */ - unsigned int arbiter_count; /*subset of child_count. - Has to be 0 or 1.*/ - - xlator_t **children; - - inode_t *root_inode; - - /* For thin-arbiter. */ - unsigned int thin_arbiter_count; /* 0 or 1 at the moment.*/ - uuid_t ta_gfid; - int ta_bad_child_index; - off_t ta_notify_dom_lock_offset; - - unsigned char *child_up; - int64_t *child_latency; - unsigned char *local; - - char **pending_key; - - char *data_self_heal; /* on/off/open */ - char * data_self_heal_algorithm; /* name of algorithm */ - unsigned int data_self_heal_window_size; /* max number of pipelined - read/writes */ - - struct list_head heal_waiting; /*queue for files that need heal*/ - uint32_t heal_wait_qlen; /*configurable queue length for heal_waiting*/ - int32_t heal_waiters; /* No. of elements currently in wait queue.*/ - - struct list_head healing;/* queue for files that are undergoing - background heal*/ - uint32_t background_self_heal_count;/*configurable queue length for - healing queue*/ - int32_t healers;/* No. of elements currently undergoing background - heal*/ - - gf_boolean_t metadata_self_heal; /* on/off */ - gf_boolean_t entry_self_heal; /* on/off */ - - gf_boolean_t metadata_splitbrain_forced_heal; /* on/off */ - int read_child; /* read-subvolume */ - unsigned int hash_mode; /* for when read_child is not set */ - gf_atomic_t *pending_reads; /*No. of pending read cbks per child.*/ - int favorite_child; /* subvolume to be preferred in resolving - split-brain cases */ - - afr_favorite_child_policy fav_child_policy;/*Policy to use for automatic - resolution of split-brains.*/ - - unsigned int wait_count; /* # of servers to wait for success */ - - gf_timer_t *timer; /* launched when parent up is received */ - - gf_boolean_t optimistic_change_log; - gf_boolean_t eager_lock; - gf_boolean_t pre_op_compat; /* on/off */ - uint32_t post_op_delay_secs; - unsigned int quorum_count; - - char vol_uuid[UUID_SIZE + 1]; - int32_t *last_event; - - /* @event_generation: Keeps count of number of events received which can - potentially impact consistency decisions. The events are CHILD_UP - and CHILD_DOWN, when we have to recalculate the freshness/staleness - of copies to detect if changes had happened while the other server - was down. CHILD_DOWN and CHILD_UP can also be received on network - disconnect/reconnects and not necessarily server going down/up. - Recalculating freshness/staleness on network events is equally - important as we might have had a network split brain. - */ - uint32_t event_generation; - - gf_boolean_t choose_local; - gf_boolean_t did_discovery; - uint64_t sh_readdir_size; - gf_boolean_t ensure_durability; - char *sh_domain; - char *afr_dirty; - gf_boolean_t halo_enabled; - - uint32_t halo_max_latency_msec; - uint32_t halo_max_replicas; - uint32_t halo_min_replicas; - - afr_self_heald_t shd; - struct afr_nfsd nfsd; - - gf_boolean_t consistent_metadata; - uint64_t spb_choice_timeout; - gf_boolean_t need_heal; - - /* pump dependencies */ - void *pump_private; - gf_boolean_t use_afr_in_pump; - char *locking_scheme; - gf_boolean_t full_lock; - gf_boolean_t esh_granular; - gf_boolean_t consistent_io; + gf_lock_t lock; /* to guard access to child_count, etc */ + unsigned int child_count; /* total number of children */ + unsigned int arbiter_count; /*subset of child_count. + Has to be 0 or 1.*/ + + xlator_t **children; + + inode_t *root_inode; + + /* For thin-arbiter. */ + unsigned int thin_arbiter_count; /* 0 or 1 at the moment.*/ + uuid_t ta_gfid; + int ta_bad_child_index; + off_t ta_notify_dom_lock_offset; + + unsigned char *child_up; + int64_t *child_latency; + unsigned char *local; + + char **pending_key; + + char *data_self_heal; /* on/off/open */ + char *data_self_heal_algorithm; /* name of algorithm */ + unsigned int data_self_heal_window_size; /* max number of pipelined + read/writes */ + + struct list_head heal_waiting; /*queue for files that need heal*/ + uint32_t heal_wait_qlen; /*configurable queue length for heal_waiting*/ + int32_t heal_waiters; /* No. of elements currently in wait queue.*/ + + struct list_head healing; /* queue for files that are undergoing + background heal*/ + uint32_t background_self_heal_count; /*configurable queue length for + healing queue*/ + int32_t healers; /* No. of elements currently undergoing background + heal*/ + + gf_boolean_t metadata_self_heal; /* on/off */ + gf_boolean_t entry_self_heal; /* on/off */ + + gf_boolean_t metadata_splitbrain_forced_heal; /* on/off */ + int read_child; /* read-subvolume */ + unsigned int hash_mode; /* for when read_child is not set */ + gf_atomic_t *pending_reads; /*No. of pending read cbks per child.*/ + int favorite_child; /* subvolume to be preferred in resolving + split-brain cases */ + + afr_favorite_child_policy fav_child_policy; /*Policy to use for automatic + resolution of split-brains.*/ + + unsigned int wait_count; /* # of servers to wait for success */ + + gf_timer_t *timer; /* launched when parent up is received */ + + gf_boolean_t optimistic_change_log; + gf_boolean_t eager_lock; + gf_boolean_t pre_op_compat; /* on/off */ + uint32_t post_op_delay_secs; + unsigned int quorum_count; + + char vol_uuid[UUID_SIZE + 1]; + int32_t *last_event; + + /* @event_generation: Keeps count of number of events received which can + potentially impact consistency decisions. The events are CHILD_UP + and CHILD_DOWN, when we have to recalculate the freshness/staleness + of copies to detect if changes had happened while the other server + was down. CHILD_DOWN and CHILD_UP can also be received on network + disconnect/reconnects and not necessarily server going down/up. + Recalculating freshness/staleness on network events is equally + important as we might have had a network split brain. + */ + uint32_t event_generation; + + gf_boolean_t choose_local; + gf_boolean_t did_discovery; + uint64_t sh_readdir_size; + gf_boolean_t ensure_durability; + char *sh_domain; + char *afr_dirty; + gf_boolean_t halo_enabled; + + uint32_t halo_max_latency_msec; + uint32_t halo_max_replicas; + uint32_t halo_min_replicas; + + afr_self_heald_t shd; + struct afr_nfsd nfsd; + + gf_boolean_t consistent_metadata; + uint64_t spb_choice_timeout; + gf_boolean_t need_heal; + + /* pump dependencies */ + void *pump_private; + gf_boolean_t use_afr_in_pump; + char *locking_scheme; + gf_boolean_t full_lock; + gf_boolean_t esh_granular; + gf_boolean_t consistent_io; } afr_private_t; - typedef enum { - AFR_DATA_TRANSACTION, /* truncate, write, ... */ - AFR_METADATA_TRANSACTION, /* chmod, chown, ... */ - AFR_ENTRY_TRANSACTION, /* create, rmdir, ... */ - AFR_ENTRY_RENAME_TRANSACTION, /* rename */ + AFR_DATA_TRANSACTION, /* truncate, write, ... */ + AFR_METADATA_TRANSACTION, /* chmod, chown, ... */ + AFR_ENTRY_TRANSACTION, /* create, rmdir, ... */ + AFR_ENTRY_RENAME_TRANSACTION, /* rename */ } afr_transaction_type; /* @@ -204,914 +228,909 @@ typedef enum { */ static inline int -afr_index_for_transaction_type (afr_transaction_type type) +afr_index_for_transaction_type(afr_transaction_type type) { - switch (type) { - + switch (type) { case AFR_DATA_TRANSACTION: - return 0; + return 0; case AFR_METADATA_TRANSACTION: - return 1; + return 1; case AFR_ENTRY_TRANSACTION: case AFR_ENTRY_RENAME_TRANSACTION: - return 2; - } + return 2; + } - return -1; /* make gcc happy */ + return -1; /* make gcc happy */ } static inline int -afr_index_from_ia_type (ia_type_t type) +afr_index_from_ia_type(ia_type_t type) { - switch (type) { + switch (type) { case IA_IFDIR: - return afr_index_for_transaction_type (AFR_ENTRY_TRANSACTION); + return afr_index_for_transaction_type(AFR_ENTRY_TRANSACTION); case IA_IFREG: - return afr_index_for_transaction_type (AFR_DATA_TRANSACTION); - default: return -1; - } + return afr_index_for_transaction_type(AFR_DATA_TRANSACTION); + default: + return -1; + } } typedef struct { - loc_t loc; - char *basename; - unsigned char *locked_nodes; - int locked_count; + loc_t loc; + char *basename; + unsigned char *locked_nodes; + int locked_count; } afr_entry_lockee_t; int -afr_entry_lockee_cmp (const void *l1, const void *l2); +afr_entry_lockee_cmp(const void *l1, const void *l2); typedef struct { - loc_t *lk_loc; + loc_t *lk_loc; - int lockee_count; - afr_entry_lockee_t lockee[AFR_LOCKEE_COUNT_MAX]; + int lockee_count; + afr_entry_lockee_t lockee[AFR_LOCKEE_COUNT_MAX]; - struct gf_flock flock; - const char *lk_basename; - const char *lower_basename; - const char *higher_basename; - char lower_locked; - char higher_locked; + struct gf_flock flock; + const char *lk_basename; + const char *lower_basename; + const char *higher_basename; + char lower_locked; + char higher_locked; - unsigned char *locked_nodes; - unsigned char *lower_locked_nodes; + unsigned char *locked_nodes; + unsigned char *lower_locked_nodes; - int32_t lock_count; - int32_t entrylk_lock_count; + int32_t lock_count; + int32_t entrylk_lock_count; - int32_t lk_call_count; - int32_t lk_expected_count; - int32_t lk_attempted_count; + int32_t lk_call_count; + int32_t lk_expected_count; + int32_t lk_attempted_count; - int32_t lock_op_ret; - int32_t lock_op_errno; - afr_lock_cbk_t lock_cbk; - char *domain; /* Domain on which inode/entry lock/unlock in progress.*/ + int32_t lock_op_ret; + int32_t lock_op_errno; + afr_lock_cbk_t lock_cbk; + char *domain; /* Domain on which inode/entry lock/unlock in progress.*/ } afr_internal_lock_t; struct afr_reply { - int valid; - int32_t op_ret; - int32_t op_errno; - dict_t *xattr;/*For xattrop*/ - dict_t *xdata; - struct iatt poststat; - struct iatt postparent; - struct iatt prestat; - struct iatt preparent; - struct iatt preparent2; - struct iatt postparent2; - /* For rchecksum */ - uint8_t checksum[SHA256_DIGEST_LENGTH]; - gf_boolean_t buf_has_zeroes; - gf_boolean_t fips_mode_rchecksum; - /* For lookup */ - int8_t need_heal; + int valid; + int32_t op_ret; + int32_t op_errno; + dict_t *xattr; /*For xattrop*/ + dict_t *xdata; + struct iatt poststat; + struct iatt postparent; + struct iatt prestat; + struct iatt preparent; + struct iatt preparent2; + struct iatt postparent2; + /* For rchecksum */ + uint8_t checksum[SHA256_DIGEST_LENGTH]; + gf_boolean_t buf_has_zeroes; + gf_boolean_t fips_mode_rchecksum; + /* For lookup */ + int8_t need_heal; }; typedef enum { - AFR_FD_NOT_OPENED, - AFR_FD_OPENED, - AFR_FD_OPENING + AFR_FD_NOT_OPENED, + AFR_FD_OPENED, + AFR_FD_OPENING } afr_fd_open_status_t; typedef struct { - afr_fd_open_status_t *opened_on; /* which subvolumes the fd is open on */ - int flags; - - /* the subvolume on which the latest sequence of readdirs (starting - at offset 0) has begun. Till the next readdir request with 0 offset - arrives, we continue to read off this subvol. - */ - int readdir_subvol; + afr_fd_open_status_t *opened_on; /* which subvolumes the fd is open on */ + int flags; + + /* the subvolume on which the latest sequence of readdirs (starting + at offset 0) has begun. Till the next readdir request with 0 offset + arrives, we continue to read off this subvol. + */ + int readdir_subvol; } afr_fd_ctx_t; typedef enum { - AFR_FOP_LOCK_PARALLEL, - AFR_FOP_LOCK_SERIAL, - AFR_FOP_LOCK_QUORUM_FAILED, + AFR_FOP_LOCK_PARALLEL, + AFR_FOP_LOCK_SERIAL, + AFR_FOP_LOCK_QUORUM_FAILED, } afr_fop_lock_state_t; typedef struct _afr_inode_lock_t { - unsigned int event_generation; - gf_boolean_t release; - gf_boolean_t acquired; - gf_timer_t *delay_timer; - struct list_head owners; /*Transactions that are performing fop*/ - struct list_head post_op;/*Transactions that are done with the fop - *So can not conflict with the fops*/ - struct list_head waiting;/*Transaction that are waiting for - *conflicting transactions to complete*/ - struct list_head frozen;/*Transactions that need to go as part of - * next batch of eager-lock*/ + unsigned int event_generation; + gf_boolean_t release; + gf_boolean_t acquired; + gf_timer_t *delay_timer; + struct list_head owners; /*Transactions that are performing fop*/ + struct list_head post_op; /*Transactions that are done with the fop + *So can not conflict with the fops*/ + struct list_head waiting; /*Transaction that are waiting for + *conflicting transactions to complete*/ + struct list_head frozen; /*Transactions that need to go as part of + * next batch of eager-lock*/ } afr_lock_t; typedef struct _afr_inode_ctx { - uint64_t read_subvol; - uint64_t write_subvol; - int lock_count; - int spb_choice; - gf_timer_t *timer; - gf_boolean_t need_refresh; - unsigned int *pre_op_done[AFR_NUM_CHANGE_LOGS]; - int inherited[AFR_NUM_CHANGE_LOGS]; - int on_disk[AFR_NUM_CHANGE_LOGS]; - - /* set if any write on this fd was a non stable write - (i.e, without O_SYNC or O_DSYNC) - */ - gf_boolean_t witnessed_unstable_write; - - /* @open_fd_count: - Number of open FDs queried from the server, as queried through - xdata in FOPs. Currently, used to decide if eager-locking must be - temporarily disabled. - */ - uint32_t open_fd_count; - /*Only 2 types of transactions support eager-locks now. DATA/METADATA*/ - afr_lock_t lock[2]; + uint64_t read_subvol; + uint64_t write_subvol; + int lock_count; + int spb_choice; + gf_timer_t *timer; + gf_boolean_t need_refresh; + unsigned int *pre_op_done[AFR_NUM_CHANGE_LOGS]; + int inherited[AFR_NUM_CHANGE_LOGS]; + int on_disk[AFR_NUM_CHANGE_LOGS]; + + /* set if any write on this fd was a non stable write + (i.e, without O_SYNC or O_DSYNC) + */ + gf_boolean_t witnessed_unstable_write; + + /* @open_fd_count: + Number of open FDs queried from the server, as queried through + xdata in FOPs. Currently, used to decide if eager-locking must be + temporarily disabled. + */ + uint32_t open_fd_count; + /*Only 2 types of transactions support eager-locks now. DATA/METADATA*/ + afr_lock_t lock[2]; } afr_inode_ctx_t; - typedef struct _afr_local { - glusterfs_fop_t op; - unsigned int call_count; + glusterfs_fop_t op; + unsigned int call_count; - /* @event_generation: copy of priv->event_generation taken at the - time of starting the transaction. The copy is made so that we - have a stable value through the various phases of the transaction. - */ - unsigned int event_generation; + /* @event_generation: copy of priv->event_generation taken at the + time of starting the transaction. The copy is made so that we + have a stable value through the various phases of the transaction. + */ + unsigned int event_generation; - uint32_t open_fd_count; - gf_boolean_t update_open_fd_count; + uint32_t open_fd_count; + gf_boolean_t update_open_fd_count; - gf_lkowner_t saved_lk_owner; + gf_lkowner_t saved_lk_owner; - int32_t op_ret; - int32_t op_errno; + int32_t op_ret; + int32_t op_errno; - int32_t **pending; + int32_t **pending; - int dirty[AFR_NUM_CHANGE_LOGS]; + int dirty[AFR_NUM_CHANGE_LOGS]; - loc_t loc; - loc_t newloc; + loc_t loc; + loc_t newloc; - fd_t *fd; - afr_fd_ctx_t *fd_ctx; + fd_t *fd; + afr_fd_ctx_t *fd_ctx; - /* @child_up: copy of priv->child_up taken at the time of transaction - start. The copy is taken so that we have a stable child_up array - through the phases of the transaction as priv->child_up[i] can keep - changing through time. - */ - unsigned char *child_up; + /* @child_up: copy of priv->child_up taken at the time of transaction + start. The copy is taken so that we have a stable child_up array + through the phases of the transaction as priv->child_up[i] can keep + changing through time. + */ + unsigned char *child_up; - /* @read_attempted: - array of flags representing subvolumes where read operations of - the read transaction have already been attempted. The array is - first pre-filled with down subvolumes, and as reads are performed - on other subvolumes, those are set as well. This way if the read - operation fails we do not retry on that subvolume again. - */ - unsigned char *read_attempted; + /* @read_attempted: + array of flags representing subvolumes where read operations of + the read transaction have already been attempted. The array is + first pre-filled with down subvolumes, and as reads are performed + on other subvolumes, those are set as well. This way if the read + operation fails we do not retry on that subvolume again. + */ + unsigned char *read_attempted; - /* @readfn: + /* @readfn: - pointer to function which will perform the read operation on a given - subvolume. Used in read transactions. - */ + pointer to function which will perform the read operation on a given + subvolume. Used in read transactions. + */ - afr_read_txn_wind_t readfn; + afr_read_txn_wind_t readfn; - /* @refreshed: + /* @refreshed: - the inode was "refreshed" (i.e, pending xattrs from all subvols - freshly inspected and inode ctx updated accordingly) as part of - this transaction already. - */ - gf_boolean_t refreshed; + the inode was "refreshed" (i.e, pending xattrs from all subvols + freshly inspected and inode ctx updated accordingly) as part of + this transaction already. + */ + gf_boolean_t refreshed; - /* @inode: + /* @inode: - the inode on which the read txn is performed on. ref'ed and copied - from either fd->inode or loc.inode - */ + the inode on which the read txn is performed on. ref'ed and copied + from either fd->inode or loc.inode + */ - inode_t *inode; + inode_t *inode; - /* @parent[2]: + /* @parent[2]: - parent inode[s] on which directory transactions are performed. - */ + parent inode[s] on which directory transactions are performed. + */ - inode_t *parent; - inode_t *parent2; + inode_t *parent; + inode_t *parent2; - /* @readable: + /* @readable: - array of flags representing servers from which a read can be - performed. This is the output of afr_inode_refresh() - */ - unsigned char *readable; - unsigned char *readable2; /*For rename transaction*/ + array of flags representing servers from which a read can be + performed. This is the output of afr_inode_refresh() + */ + unsigned char *readable; + unsigned char *readable2; /*For rename transaction*/ - int read_subvol; /* Current read subvolume */ + int read_subvol; /* Current read subvolume */ - afr_inode_refresh_cbk_t refreshfn; + afr_inode_refresh_cbk_t refreshfn; - /* @refreshinode: + /* @refreshinode: - Inode currently getting refreshed. - */ - inode_t *refreshinode; + Inode currently getting refreshed. + */ + inode_t *refreshinode; - /*To handle setattr/setxattr on yet to be linked inode from dht*/ - uuid_t refreshgfid; + /*To handle setattr/setxattr on yet to be linked inode from dht*/ + uuid_t refreshgfid; - /* - @pre_op_compat: + /* + @pre_op_compat: - compatibility mode of pre-op. send a separate pre-op and - op operations as part of transaction, rather than combining - */ + compatibility mode of pre-op. send a separate pre-op and + op operations as part of transaction, rather than combining + */ - gf_boolean_t pre_op_compat; + gf_boolean_t pre_op_compat; - dict_t *xattr_req; + dict_t *xattr_req; - afr_internal_lock_t internal_lock; + afr_internal_lock_t internal_lock; - dict_t *dict; + dict_t *dict; - int optimistic_change_log; + int optimistic_change_log; - /* Is the current writev() going to perform a stable write? - i.e, is fd->flags or @flags writev param have O_SYNC or - O_DSYNC? - */ - gf_boolean_t stable_write; + /* Is the current writev() going to perform a stable write? + i.e, is fd->flags or @flags writev param have O_SYNC or + O_DSYNC? + */ + gf_boolean_t stable_write; - /* This write appended to the file. Nnot necessarily O_APPEND, - just means the offset of write was at the end of file. - */ - gf_boolean_t append_write; + /* This write appended to the file. Nnot necessarily O_APPEND, + just means the offset of write was at the end of file. + */ + gf_boolean_t append_write; - /* - This struct contains the arguments for the "continuation" - (scheme-like) of fops - */ + /* + This struct contains the arguments for the "continuation" + (scheme-like) of fops + */ + struct { struct { - struct { - gf_boolean_t needs_fresh_lookup; - uuid_t gfid_req; - } lookup; - - struct { - unsigned char buf_set; - struct statvfs buf; - } statfs; - - struct { - int32_t flags; - fd_t *fd; - } open; - - struct { - int32_t cmd; - struct gf_flock user_flock; - struct gf_flock ret_flock; - unsigned char *locked_nodes; - } lk; - - /* inode read */ - - struct { - int32_t mask; - int last_index; /* index of the child we tried previously */ - } access; - - struct { - int last_index; - } stat; - - struct { - int last_index; - } fstat; - - struct { - size_t size; - int last_index; - } readlink; - - struct { - char *name; - int last_index; - long xattr_len; - } getxattr; - - struct { - size_t size; - off_t offset; - int last_index; - uint32_t flags; - } readv; - - /* dir read */ - - struct { - int success_count; - int32_t op_ret; - int32_t op_errno; - - uint32_t *checksum; - } opendir; - - struct { - int32_t op_ret; - int32_t op_errno; - size_t size; - off_t offset; - dict_t *dict; - gf_boolean_t failed; - int last_index; - } readdir; - /* inode write */ - - struct { - struct iatt prebuf; - struct iatt postbuf; - } inode_wfop; //common structure for all inode-write-fops - - struct { - int32_t op_ret; - - struct iovec *vector; - struct iobref *iobref; - int32_t count; - off_t offset; - uint32_t flags; - } writev; - - struct { - off_t offset; - } truncate; - - struct { - off_t offset; - } ftruncate; - - struct { - struct iatt in_buf; - int32_t valid; - } setattr; - - struct { - struct iatt in_buf; - int32_t valid; - } fsetattr; - - struct { - dict_t *dict; - int32_t flags; - } setxattr; - - struct { - dict_t *dict; - int32_t flags; - } fsetxattr; - - struct { - char *name; - } removexattr; - - struct { - dict_t *xattr; - gf_xattrop_flags_t optype; - } xattrop; - - /* dir write */ - - struct { - inode_t *inode; - struct iatt buf; - struct iatt preparent; - struct iatt postparent; - struct iatt prenewparent; - struct iatt postnewparent; - } dir_fop; //common structure for all dir fops - - struct { - fd_t *fd; - dict_t *params; - int32_t flags; - mode_t mode; - } create; - - struct { - dev_t dev; - mode_t mode; - dict_t *params; - } mknod; - - struct { - int32_t mode; - dict_t *params; - } mkdir; - - struct { - int flags; - } rmdir; - - struct { - dict_t *params; - char *linkpath; - } symlink; - - struct { - int32_t mode; - off_t offset; - size_t len; - } fallocate; - - struct { - off_t offset; - size_t len; - } discard; - - struct { - off_t offset; - off_t len; - struct iatt prebuf; - struct iatt postbuf; - } zerofill; - - struct { - char *volume; - int32_t cmd; - int32_t in_cmd; - struct gf_flock in_flock; - struct gf_flock flock; - void *xdata; - } inodelk; - - struct { - char *volume; - char *basename; - entrylk_cmd in_cmd; - entrylk_cmd cmd; - entrylk_type type; - void *xdata; - } entrylk; - - struct { - off_t offset; - gf_seek_what_t what; - } seek; - - struct { - int32_t datasync; - } fsync; - - struct { - struct gf_lease user_lease; - struct gf_lease ret_lease; - unsigned char *locked_nodes; - } lease; - - - } cont; + gf_boolean_t needs_fresh_lookup; + uuid_t gfid_req; + } lookup; struct { - off_t start, len; + unsigned char buf_set; + struct statvfs buf; + } statfs; - gf_boolean_t eager_lock_on; - gf_boolean_t do_eager_unlock; + struct { + int32_t flags; + fd_t *fd; + } open; - char *basename; - char *new_basename; + struct { + int32_t cmd; + struct gf_flock user_flock; + struct gf_flock ret_flock; + unsigned char *locked_nodes; + } lk; - loc_t parent_loc; - loc_t new_parent_loc; + /* inode read */ - afr_transaction_type type; + struct { + int32_t mask; + int last_index; /* index of the child we tried previously */ + } access; - /* stub to resume on destruction - of the transaction frame */ - call_stub_t *resume_stub; + struct { + int last_index; + } stat; - struct list_head owner_list; - struct list_head wait_list; + struct { + int last_index; + } fstat; - unsigned char *pre_op; + struct { + size_t size; + int last_index; + } readlink; - /* Changelog xattr dict for [f]xattrop*/ - dict_t **changelog_xdata; - unsigned char *pre_op_sources; + struct { + char *name; + int last_index; + long xattr_len; + } getxattr; - /* @failed_subvols: subvolumes on which a pre-op or a - FOP failed. */ - unsigned char *failed_subvols; + struct { + size_t size; + off_t offset; + int last_index; + uint32_t flags; + } readv; - /* @dirtied: flag which indicates whether we set dirty flag - in the OP. Typically true when we are performing operation - on more than one subvol and optimistic changelog is disabled + /* dir read */ - A 'true' value set in @dirtied flag means an 'undirtying' - has to be done in POST-OP phase. - */ - gf_boolean_t dirtied; + struct { + int success_count; + int32_t op_ret; + int32_t op_errno; - /* @inherited: flag which indicates that the dirty flags - of the previous transaction were inherited - */ - gf_boolean_t inherited; + uint32_t *checksum; + } opendir; - /* - @no_uninherit: flag which indicates that a pre_op_uninherit() - must _not_ be attempted (and returned as failure) always. This - flag is set when a hard pre-op is performed, but not accounted - for it in fd_ctx->on_disk[]. Such transactions are "isolated" - from the pre-op piggybacking entirely and therefore uninherit - must not be attempted. - */ - gf_boolean_t no_uninherit; + struct { + int32_t op_ret; + int32_t op_errno; + size_t size; + off_t offset; + dict_t *dict; + gf_boolean_t failed; + int last_index; + } readdir; + /* inode write */ - /* @uninherit_done: - @uninherit_value: + struct { + struct iatt prebuf; + struct iatt postbuf; + } inode_wfop; // common structure for all inode-write-fops - The above pair variables make pre_op_uninherit() idempotent. - Both are FALSE initially. The first call to pre_op_uninherit - sets @uninherit_done to TRUE and the return value to - @uninherit_value. Further calls will check for @uninherit_done - to be TRUE and if so will simply return @uninherit_value. - */ - gf_boolean_t uninherit_done; - gf_boolean_t uninherit_value; + struct { + int32_t op_ret; - gf_boolean_t in_flight_sb; /* Indicator for occurrence of - split-brain while in the middle of - a txn. */ - int32_t in_flight_sb_errno; /* This is where the cause of the - failure on the last good copy of - the file is stored. - */ + struct iovec *vector; + struct iobref *iobref; + int32_t count; + off_t offset; + uint32_t flags; + } writev; - /* @changelog_resume: function to be called after changlogging - (either pre-op or post-op) is done - */ - afr_changelog_resume_t changelog_resume; + struct { + off_t offset; + } truncate; - call_frame_t *main_frame; /*Fop frame*/ - call_frame_t *frame; /*Transaction frame*/ + struct { + off_t offset; + } ftruncate; - int (*wind) (call_frame_t *frame, xlator_t *this, int subvol); + struct { + struct iatt in_buf; + int32_t valid; + } setattr; - int (*unwind) (call_frame_t *frame, xlator_t *this); + struct { + struct iatt in_buf; + int32_t valid; + } fsetattr; - /* post-op hook */ - } transaction; + struct { + dict_t *dict; + int32_t flags; + } setxattr; - syncbarrier_t barrier; + struct { + dict_t *dict; + int32_t flags; + } fsetxattr; - /* extra data for fops */ - dict_t *xdata_req; - dict_t *xdata_rsp; + struct { + char *name; + } removexattr; - dict_t *xattr_rsp; /*for [f]xattrop*/ + struct { + dict_t *xattr; + gf_xattrop_flags_t optype; + } xattrop; - mode_t umask; - int xflag; - gf_boolean_t do_discovery; - struct afr_reply *replies; + /* dir write */ - /* For client side background heals. */ - struct list_head healer; - call_frame_t *heal_frame; + struct { + inode_t *inode; + struct iatt buf; + struct iatt preparent; + struct iatt postparent; + struct iatt prenewparent; + struct iatt postnewparent; + } dir_fop; // common structure for all dir fops - gf_boolean_t need_full_crawl; - afr_fop_lock_state_t fop_lock_state; + struct { + fd_t *fd; + dict_t *params; + int32_t flags; + mode_t mode; + } create; - gf_boolean_t is_read_txn; - afr_inode_ctx_t *inode_ctx; -} afr_local_t; + struct { + dev_t dev; + mode_t mode; + dict_t *params; + } mknod; + + struct { + int32_t mode; + dict_t *params; + } mkdir; + + struct { + int flags; + } rmdir; + + struct { + dict_t *params; + char *linkpath; + } symlink; + + struct { + int32_t mode; + off_t offset; + size_t len; + } fallocate; + + struct { + off_t offset; + size_t len; + } discard; + struct { + off_t offset; + off_t len; + struct iatt prebuf; + struct iatt postbuf; + } zerofill; + + struct { + char *volume; + int32_t cmd; + int32_t in_cmd; + struct gf_flock in_flock; + struct gf_flock flock; + void *xdata; + } inodelk; + + struct { + char *volume; + char *basename; + entrylk_cmd in_cmd; + entrylk_cmd cmd; + entrylk_type type; + void *xdata; + } entrylk; + + struct { + off_t offset; + gf_seek_what_t what; + } seek; + + struct { + int32_t datasync; + } fsync; + + struct { + struct gf_lease user_lease; + struct gf_lease ret_lease; + unsigned char *locked_nodes; + } lease; + + } cont; + + struct { + off_t start, len; + + gf_boolean_t eager_lock_on; + gf_boolean_t do_eager_unlock; + + char *basename; + char *new_basename; + + loc_t parent_loc; + loc_t new_parent_loc; + + afr_transaction_type type; + + /* stub to resume on destruction + of the transaction frame */ + call_stub_t *resume_stub; + + struct list_head owner_list; + struct list_head wait_list; + + unsigned char *pre_op; + + /* Changelog xattr dict for [f]xattrop*/ + dict_t **changelog_xdata; + unsigned char *pre_op_sources; + + /* @failed_subvols: subvolumes on which a pre-op or a + FOP failed. */ + unsigned char *failed_subvols; + + /* @dirtied: flag which indicates whether we set dirty flag + in the OP. Typically true when we are performing operation + on more than one subvol and optimistic changelog is disabled + + A 'true' value set in @dirtied flag means an 'undirtying' + has to be done in POST-OP phase. + */ + gf_boolean_t dirtied; + + /* @inherited: flag which indicates that the dirty flags + of the previous transaction were inherited + */ + gf_boolean_t inherited; + + /* + @no_uninherit: flag which indicates that a pre_op_uninherit() + must _not_ be attempted (and returned as failure) always. This + flag is set when a hard pre-op is performed, but not accounted + for it in fd_ctx->on_disk[]. Such transactions are "isolated" + from the pre-op piggybacking entirely and therefore uninherit + must not be attempted. + */ + gf_boolean_t no_uninherit; + + /* @uninherit_done: + @uninherit_value: + + The above pair variables make pre_op_uninherit() idempotent. + Both are FALSE initially. The first call to pre_op_uninherit + sets @uninherit_done to TRUE and the return value to + @uninherit_value. Further calls will check for @uninherit_done + to be TRUE and if so will simply return @uninherit_value. + */ + gf_boolean_t uninherit_done; + gf_boolean_t uninherit_value; + + gf_boolean_t in_flight_sb; /* Indicator for occurrence of + split-brain while in the middle of + a txn. */ + int32_t in_flight_sb_errno; /* This is where the cause of the + failure on the last good copy of + the file is stored. + */ + + /* @changelog_resume: function to be called after changlogging + (either pre-op or post-op) is done + */ + afr_changelog_resume_t changelog_resume; + + call_frame_t *main_frame; /*Fop frame*/ + call_frame_t *frame; /*Transaction frame*/ + + int (*wind)(call_frame_t *frame, xlator_t *this, int subvol); + + int (*unwind)(call_frame_t *frame, xlator_t *this); + + /* post-op hook */ + } transaction; + + syncbarrier_t barrier; + + /* extra data for fops */ + dict_t *xdata_req; + dict_t *xdata_rsp; + + dict_t *xattr_rsp; /*for [f]xattrop*/ + + mode_t umask; + int xflag; + gf_boolean_t do_discovery; + struct afr_reply *replies; + + /* For client side background heals. */ + struct list_head healer; + call_frame_t *heal_frame; + + gf_boolean_t need_full_crawl; + afr_fop_lock_state_t fop_lock_state; + + gf_boolean_t is_read_txn; + afr_inode_ctx_t *inode_ctx; +} afr_local_t; typedef struct afr_spbc_timeout { - call_frame_t *frame; - gf_boolean_t d_spb; - gf_boolean_t m_spb; - loc_t *loc; - int spb_child_index; + call_frame_t *frame; + gf_boolean_t d_spb; + gf_boolean_t m_spb; + loc_t *loc; + int spb_child_index; } afr_spbc_timeout_t; typedef struct afr_spb_status { - call_frame_t *frame; - loc_t *loc; + call_frame_t *frame; + loc_t *loc; } afr_spb_status_t; typedef struct afr_empty_brick_args { - call_frame_t *frame; - loc_t loc; - int empty_index; - char *op_type; + call_frame_t *frame; + loc_t loc; + int empty_index; + char *op_type; } afr_empty_brick_args_t; typedef struct afr_read_subvol_args { - ia_type_t ia_type; - uuid_t gfid; + ia_type_t ia_type; + uuid_t gfid; } afr_read_subvol_args_t; typedef struct afr_granular_esh_args { - fd_t *heal_fd; - xlator_t *xl; - call_frame_t *frame; - gf_boolean_t mismatch; /* flag to represent occurrence of type/gfid - mismatch */ + fd_t *heal_fd; + xlator_t *xl; + call_frame_t *frame; + gf_boolean_t mismatch; /* flag to represent occurrence of type/gfid + mismatch */ } afr_granular_esh_args_t; int -afr_inode_get_readable (call_frame_t *frame, inode_t *inode, xlator_t *this, - unsigned char *readable, int *event_p, int type); +afr_inode_get_readable(call_frame_t *frame, inode_t *inode, xlator_t *this, + unsigned char *readable, int *event_p, int type); int -afr_inode_read_subvol_get (inode_t *inode, xlator_t *this, - unsigned char *data_subvols, - unsigned char *metadata_subvols, - int *event_generation); +afr_inode_read_subvol_get(inode_t *inode, xlator_t *this, + unsigned char *data_subvols, + unsigned char *metadata_subvols, + int *event_generation); int -__afr_inode_read_subvol_get (inode_t *inode, xlator_t *this, - unsigned char *data_subvols, - unsigned char *metadata_subvols, - int *event_generation); +__afr_inode_read_subvol_get(inode_t *inode, xlator_t *this, + unsigned char *data_subvols, + unsigned char *metadata_subvols, + int *event_generation); int -__afr_inode_read_subvol_set (inode_t *inode, xlator_t *this, - unsigned char *data_subvols, - unsigned char *metadata_subvol, - int event_generation); +__afr_inode_read_subvol_set(inode_t *inode, xlator_t *this, + unsigned char *data_subvols, + unsigned char *metadata_subvol, + int event_generation); int -afr_inode_read_subvol_set (inode_t *inode, xlator_t *this, - unsigned char *data_subvols, - unsigned char *metadata_subvols, - int event_generation); +afr_inode_read_subvol_set(inode_t *inode, xlator_t *this, + unsigned char *data_subvols, + unsigned char *metadata_subvols, + int event_generation); int -afr_inode_event_gen_reset (inode_t *inode, xlator_t *this); +afr_inode_event_gen_reset(inode_t *inode, xlator_t *this); int -afr_read_subvol_select_by_policy (inode_t *inode, xlator_t *this, - unsigned char *readable, - afr_read_subvol_args_t *args); +afr_read_subvol_select_by_policy(inode_t *inode, xlator_t *this, + unsigned char *readable, + afr_read_subvol_args_t *args); int -afr_inode_read_subvol_type_get (inode_t *inode, xlator_t *this, - unsigned char *readable, int *event_p, - int type); +afr_inode_read_subvol_type_get(inode_t *inode, xlator_t *this, + unsigned char *readable, int *event_p, int type); int -afr_read_subvol_get (inode_t *inode, xlator_t *this, int *subvol_p, - unsigned char *readables, - int *event_p, afr_transaction_type type, - afr_read_subvol_args_t *args); +afr_read_subvol_get(inode_t *inode, xlator_t *this, int *subvol_p, + unsigned char *readables, int *event_p, + afr_transaction_type type, afr_read_subvol_args_t *args); -#define afr_data_subvol_get(i, t, s, r, e, a) \ - afr_read_subvol_get(i, t, s, r, e, AFR_DATA_TRANSACTION, a) +#define afr_data_subvol_get(i, t, s, r, e, a) \ + afr_read_subvol_get(i, t, s, r, e, AFR_DATA_TRANSACTION, a) -#define afr_metadata_subvol_get(i, t, s, r, e, a) \ - afr_read_subvol_get(i, t, s, r, e, AFR_METADATA_TRANSACTION, a) +#define afr_metadata_subvol_get(i, t, s, r, e, a) \ + afr_read_subvol_get(i, t, s, r, e, AFR_METADATA_TRANSACTION, a) int -afr_inode_refresh (call_frame_t *frame, xlator_t *this, inode_t *inode, - uuid_t gfid, afr_inode_refresh_cbk_t cbk); +afr_inode_refresh(call_frame_t *frame, xlator_t *this, inode_t *inode, + uuid_t gfid, afr_inode_refresh_cbk_t cbk); int32_t -afr_notify (xlator_t *this, int32_t event, void *data, void *data2); +afr_notify(xlator_t *this, int32_t event, void *data, void *data2); int -xattr_is_equal (dict_t *this, char *key1, data_t *value1, void *data); +xattr_is_equal(dict_t *this, char *key1, data_t *value1, void *data); int -afr_init_entry_lockee (afr_entry_lockee_t *lockee, afr_local_t *local, - loc_t *loc, char *basename, int child_count); +afr_init_entry_lockee(afr_entry_lockee_t *lockee, afr_local_t *local, + loc_t *loc, char *basename, int child_count); void -afr_entry_lockee_cleanup (afr_internal_lock_t *int_lock); +afr_entry_lockee_cleanup(afr_internal_lock_t *int_lock); int -afr_attempt_lock_recovery (xlator_t *this, int32_t child_index); +afr_attempt_lock_recovery(xlator_t *this, int32_t child_index); int -afr_mark_locked_nodes (xlator_t *this, fd_t *fd, - unsigned char *locked_nodes); +afr_mark_locked_nodes(xlator_t *this, fd_t *fd, unsigned char *locked_nodes); void -afr_set_lk_owner (call_frame_t *frame, xlator_t *this, void *lk_owner); +afr_set_lk_owner(call_frame_t *frame, xlator_t *this, void *lk_owner); int -afr_set_lock_number (call_frame_t *frame, xlator_t *this); +afr_set_lock_number(call_frame_t *frame, xlator_t *this); int32_t -afr_unlock (call_frame_t *frame, xlator_t *this); +afr_unlock(call_frame_t *frame, xlator_t *this); int -afr_nonblocking_entrylk (call_frame_t *frame, xlator_t *this); +afr_nonblocking_entrylk(call_frame_t *frame, xlator_t *this); int -afr_nonblocking_inodelk (call_frame_t *frame, xlator_t *this); +afr_nonblocking_inodelk(call_frame_t *frame, xlator_t *this); int -afr_blocking_lock (call_frame_t *frame, xlator_t *this); +afr_blocking_lock(call_frame_t *frame, xlator_t *this); int -afr_internal_lock_finish (call_frame_t *frame, xlator_t *this); +afr_internal_lock_finish(call_frame_t *frame, xlator_t *this); int -__afr_fd_ctx_set (xlator_t *this, fd_t *fd); +__afr_fd_ctx_set(xlator_t *this, fd_t *fd); afr_fd_ctx_t * -afr_fd_ctx_get (fd_t *fd, xlator_t *this); +afr_fd_ctx_get(fd_t *fd, xlator_t *this); int -afr_build_parent_loc (loc_t *parent, loc_t *child, int32_t *op_errno); +afr_build_parent_loc(loc_t *parent, loc_t *child, int32_t *op_errno); int -afr_locked_nodes_count (unsigned char *locked_nodes, int child_count); +afr_locked_nodes_count(unsigned char *locked_nodes, int child_count); int -afr_replies_interpret (call_frame_t *frame, xlator_t *this, inode_t *inode, - gf_boolean_t *start_heal); +afr_replies_interpret(call_frame_t *frame, xlator_t *this, inode_t *inode, + gf_boolean_t *start_heal); void -afr_local_replies_wipe (afr_local_t *local, afr_private_t *priv); +afr_local_replies_wipe(afr_local_t *local, afr_private_t *priv); void -afr_local_cleanup (afr_local_t *local, xlator_t *this); +afr_local_cleanup(afr_local_t *local, xlator_t *this); int -afr_frame_return (call_frame_t *frame); +afr_frame_return(call_frame_t *frame); int -afr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, - fd_t *fd, dict_t *xdata); +afr_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + fd_t *fd, dict_t *xdata); void -afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this); +afr_local_transaction_cleanup(afr_local_t *local, xlator_t *this); int -afr_cleanup_fd_ctx (xlator_t *this, fd_t *fd); - -#define AFR_STACK_UNWIND(fop, frame, op_ret, op_errno, params ...)\ - do { \ - afr_local_t *__local = NULL; \ - xlator_t *__this = NULL; \ - int32_t __op_ret = 0; \ - int32_t __op_errno = 0; \ - \ - __op_ret = op_ret; \ - __op_errno = op_errno; \ - if (frame) { \ - __local = frame->local; \ - __this = frame->this; \ - afr_handle_inconsistent_fop (frame, &__op_ret,\ - &__op_errno);\ - if (__local && __local->is_read_txn) \ - afr_pending_read_decrement (__this->private, __local->read_subvol); \ - frame->local = NULL; \ - } \ - \ - STACK_UNWIND_STRICT (fop, frame, __op_ret, \ - __op_errno, params); \ - if (__local) { \ - afr_local_cleanup (__local, __this); \ - mem_put (__local); \ - } \ - } while (0) - -#define AFR_STACK_DESTROY(frame) \ - do { \ - afr_local_t *__local = NULL; \ - xlator_t *__this = NULL; \ - __local = frame->local; \ - __this = frame->this; \ - frame->local = NULL; \ - STACK_DESTROY (frame->root); \ - if (__local) { \ - afr_local_cleanup (__local, __this); \ - mem_put (__local); \ - } \ - } while (0); - -#define AFR_FRAME_INIT(frame, op_errno) \ - ({frame->local = mem_get0 (THIS->local_pool); \ - if (afr_local_init (frame->local, THIS->private, &op_errno)) { \ - afr_local_cleanup (frame->local, THIS); \ - mem_put (frame->local); \ - frame->local = NULL; }; \ - frame->local; }) - -#define AFR_STACK_RESET(frame) \ - do { \ - afr_local_t *__local = NULL; \ - xlator_t *__this = NULL; \ - __local = frame->local; \ - __this = frame->this; \ - frame->local = NULL; \ - int __opr; \ - STACK_RESET (frame->root); \ - if (__local) { \ - afr_local_cleanup (__local, __this); \ - mem_put (__local); \ - } \ - AFR_FRAME_INIT (frame, __opr); \ - } while (0) +afr_cleanup_fd_ctx(xlator_t *this, fd_t *fd); + +#define AFR_STACK_UNWIND(fop, frame, op_ret, op_errno, params...) \ + do { \ + afr_local_t *__local = NULL; \ + xlator_t *__this = NULL; \ + int32_t __op_ret = 0; \ + int32_t __op_errno = 0; \ + \ + __op_ret = op_ret; \ + __op_errno = op_errno; \ + if (frame) { \ + __local = frame->local; \ + __this = frame->this; \ + afr_handle_inconsistent_fop(frame, &__op_ret, &__op_errno); \ + if (__local && __local->is_read_txn) \ + afr_pending_read_decrement(__this->private, \ + __local->read_subvol); \ + frame->local = NULL; \ + } \ + \ + STACK_UNWIND_STRICT(fop, frame, __op_ret, __op_errno, params); \ + if (__local) { \ + afr_local_cleanup(__local, __this); \ + mem_put(__local); \ + } \ + } while (0) + +#define AFR_STACK_DESTROY(frame) \ + do { \ + afr_local_t *__local = NULL; \ + xlator_t *__this = NULL; \ + __local = frame->local; \ + __this = frame->this; \ + frame->local = NULL; \ + STACK_DESTROY(frame->root); \ + if (__local) { \ + afr_local_cleanup(__local, __this); \ + mem_put(__local); \ + } \ + } while (0); + +#define AFR_FRAME_INIT(frame, op_errno) \ + ({ \ + frame->local = mem_get0(THIS->local_pool); \ + if (afr_local_init(frame->local, THIS->private, &op_errno)) { \ + afr_local_cleanup(frame->local, THIS); \ + mem_put(frame->local); \ + frame->local = NULL; \ + }; \ + frame->local; \ + }) + +#define AFR_STACK_RESET(frame) \ + do { \ + afr_local_t *__local = NULL; \ + xlator_t *__this = NULL; \ + __local = frame->local; \ + __this = frame->this; \ + frame->local = NULL; \ + int __opr; \ + STACK_RESET(frame->root); \ + if (__local) { \ + afr_local_cleanup(__local, __this); \ + mem_put(__local); \ + } \ + AFR_FRAME_INIT(frame, __opr); \ + } while (0) /* allocate and return a string that is the basename of argument */ static inline char * -AFR_BASENAME (const char *str) +AFR_BASENAME(const char *str) { - char *__tmp_str = NULL; - char *__basename_str = NULL; - __tmp_str = gf_strdup (str); - __basename_str = gf_strdup (basename (__tmp_str)); - GF_FREE (__tmp_str); - return __basename_str; + char *__tmp_str = NULL; + char *__basename_str = NULL; + __tmp_str = gf_strdup(str); + __basename_str = gf_strdup(basename(__tmp_str)); + GF_FREE(__tmp_str); + return __basename_str; } call_frame_t * -afr_copy_frame (call_frame_t *base); +afr_copy_frame(call_frame_t *base); int -afr_transaction_local_init (afr_local_t *local, xlator_t *this); +afr_transaction_local_init(afr_local_t *local, xlator_t *this); int32_t -afr_marker_getxattr (call_frame_t *frame, xlator_t *this, - loc_t *loc, const char *name,afr_local_t *local, afr_private_t *priv ); +afr_marker_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, afr_local_t *local, afr_private_t *priv); int -afr_local_init (afr_local_t *local, afr_private_t *priv, int32_t *op_errno); +afr_local_init(afr_local_t *local, afr_private_t *priv, int32_t *op_errno); int -afr_internal_lock_init (afr_internal_lock_t *lk, size_t child_count); +afr_internal_lock_init(afr_internal_lock_t *lk, size_t child_count); int -afr_higher_errno (int32_t old_errno, int32_t new_errno); +afr_higher_errno(int32_t old_errno, int32_t new_errno); int -afr_final_errno (afr_local_t *local, afr_private_t *priv); +afr_final_errno(afr_local_t *local, afr_private_t *priv); int -afr_xattr_req_prepare (xlator_t *this, dict_t *xattr_req); +afr_xattr_req_prepare(xlator_t *this, dict_t *xattr_req); void -afr_fix_open (fd_t *fd, xlator_t *this); +afr_fix_open(fd_t *fd, xlator_t *this); afr_fd_ctx_t * -afr_fd_ctx_get (fd_t *fd, xlator_t *this); +afr_fd_ctx_get(fd_t *fd, xlator_t *this); void -afr_set_low_priority (call_frame_t *frame); +afr_set_low_priority(call_frame_t *frame); int -afr_child_fd_ctx_set (xlator_t *this, fd_t *fd, int32_t child, - int flags); +afr_child_fd_ctx_set(xlator_t *this, fd_t *fd, int32_t child, int flags); void -afr_matrix_cleanup (int32_t **pending, unsigned int m); +afr_matrix_cleanup(int32_t **pending, unsigned int m); -int32_t** -afr_matrix_create (unsigned int m, unsigned int n); +int32_t ** +afr_matrix_create(unsigned int m, unsigned int n); -int** -afr_mark_pending_changelog (afr_private_t *priv, unsigned char *pending, - dict_t *xattr, ia_type_t iat); +int ** +afr_mark_pending_changelog(afr_private_t *priv, unsigned char *pending, + dict_t *xattr, ia_type_t iat); void -afr_filter_xattrs (dict_t *xattr); +afr_filter_xattrs(dict_t *xattr); /* * Special value indicating we should use the "auto" quorum method instead of @@ -1120,139 +1139,139 @@ afr_filter_xattrs (dict_t *xattr); #define AFR_QUORUM_AUTO INT_MAX int -afr_fd_report_unstable_write (xlator_t *this, afr_local_t *local); +afr_fd_report_unstable_write(xlator_t *this, afr_local_t *local); gf_boolean_t -afr_fd_has_witnessed_unstable_write (xlator_t *this, inode_t *inode); +afr_fd_has_witnessed_unstable_write(xlator_t *this, inode_t *inode); void -afr_reply_wipe (struct afr_reply *reply); +afr_reply_wipe(struct afr_reply *reply); void -afr_replies_wipe (struct afr_reply *replies, int count); +afr_replies_wipe(struct afr_reply *replies, int count); gf_boolean_t -afr_xattrs_are_equal (dict_t *dict1, dict_t *dict2); +afr_xattrs_are_equal(dict_t *dict1, dict_t *dict2); gf_boolean_t -afr_is_xattr_ignorable (char *key); +afr_is_xattr_ignorable(char *key); int -afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc); +afr_get_heal_info(call_frame_t *frame, xlator_t *this, loc_t *loc); int afr_heal_splitbrain_file(call_frame_t *frame, xlator_t *this, loc_t *loc); int -afr_get_split_brain_status (void *opaque); +afr_get_split_brain_status(void *opaque); int -afr_get_split_brain_status_cbk (int ret, call_frame_t *frame, void *opaque); +afr_get_split_brain_status_cbk(int ret, call_frame_t *frame, void *opaque); int -afr_inode_split_brain_choice_set (inode_t *inode, xlator_t *this, - int spb_choice); +afr_inode_split_brain_choice_set(inode_t *inode, xlator_t *this, + int spb_choice); int -afr_inode_split_brain_choice_get (inode_t *inode, xlator_t *this, - int *spb_choice); +afr_inode_split_brain_choice_get(inode_t *inode, xlator_t *this, + int *spb_choice); int -afr_get_child_index_from_name (xlator_t *this, char *name); +afr_get_child_index_from_name(xlator_t *this, char *name); int -afr_is_split_brain (call_frame_t *frame, xlator_t *this, inode_t *inode, - uuid_t gfid, gf_boolean_t *d_spb, gf_boolean_t *m_spb); +afr_is_split_brain(call_frame_t *frame, xlator_t *this, inode_t *inode, + uuid_t gfid, gf_boolean_t *d_spb, gf_boolean_t *m_spb); int -afr_spb_choice_timeout_cancel (xlator_t *this, inode_t *inode); +afr_spb_choice_timeout_cancel(xlator_t *this, inode_t *inode); int -afr_set_split_brain_choice (int ret, call_frame_t *frame, void *opaque); +afr_set_split_brain_choice(int ret, call_frame_t *frame, void *opaque); gf_boolean_t -afr_get_need_heal (xlator_t *this); +afr_get_need_heal(xlator_t *this); void -afr_set_need_heal (xlator_t *this, afr_local_t *local); +afr_set_need_heal(xlator_t *this, afr_local_t *local); int -afr_selfheal_data_open (xlator_t *this, inode_t *inode, fd_t **fd); +afr_selfheal_data_open(xlator_t *this, inode_t *inode, fd_t **fd); int -afr_get_msg_id (char *op_type); +afr_get_msg_id(char *op_type); int -afr_set_in_flight_sb_status (xlator_t *this, call_frame_t *frame, - inode_t *inode); +afr_set_in_flight_sb_status(xlator_t *this, call_frame_t *frame, + inode_t *inode); int32_t -afr_quorum_errno (afr_private_t *priv); +afr_quorum_errno(afr_private_t *priv); gf_boolean_t -afr_is_consistent_io_possible (afr_local_t *local, afr_private_t *priv, - int32_t *op_errno); +afr_is_consistent_io_possible(afr_local_t *local, afr_private_t *priv, + int32_t *op_errno); void -afr_handle_inconsistent_fop (call_frame_t *frame, int32_t *op_ret, - int32_t *op_errno); +afr_handle_inconsistent_fop(call_frame_t *frame, int32_t *op_ret, + int32_t *op_errno); void -afr_inode_write_fill (call_frame_t *frame, xlator_t *this, int child_index, +afr_inode_write_fill(call_frame_t *frame, xlator_t *this, int child_index, int32_t op_ret, int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata); void -afr_process_post_writev (call_frame_t *frame, xlator_t *this); +afr_process_post_writev(call_frame_t *frame, xlator_t *this); void -afr_writev_unwind (call_frame_t *frame, xlator_t *this); +afr_writev_unwind(call_frame_t *frame, xlator_t *this); void -afr_writev_copy_outvars (call_frame_t *src_frame, call_frame_t *dst_frame); +afr_writev_copy_outvars(call_frame_t *src_frame, call_frame_t *dst_frame); void -afr_update_uninodelk (afr_local_t *local, afr_internal_lock_t *int_lock, - int32_t child_index); +afr_update_uninodelk(afr_local_t *local, afr_internal_lock_t *int_lock, + int32_t child_index); int afr_is_inodelk_transaction(afr_transaction_type type); afr_fd_ctx_t * -__afr_fd_ctx_get (fd_t *fd, xlator_t *this); +__afr_fd_ctx_get(fd_t *fd, xlator_t *this); gf_boolean_t -afr_is_inode_refresh_reqd (inode_t *inode, xlator_t *this, - int event_gen1, int event_gen2); +afr_is_inode_refresh_reqd(inode_t *inode, xlator_t *this, int event_gen1, + int event_gen2); int -afr_serialize_xattrs_with_delimiter (call_frame_t *frame, xlator_t *this, - char *buf, const char *default_str, - int32_t *serz_len, char delimiter); +afr_serialize_xattrs_with_delimiter(call_frame_t *frame, xlator_t *this, + char *buf, const char *default_str, + int32_t *serz_len, char delimiter); gf_boolean_t -afr_is_symmetric_error (call_frame_t *frame, xlator_t *this); +afr_is_symmetric_error(call_frame_t *frame, xlator_t *this); int -__afr_inode_ctx_get (xlator_t *this, inode_t *inode, afr_inode_ctx_t **ctx); +__afr_inode_ctx_get(xlator_t *this, inode_t *inode, afr_inode_ctx_t **ctx); uint64_t -afr_write_subvol_get (call_frame_t *frame, xlator_t *this); +afr_write_subvol_get(call_frame_t *frame, xlator_t *this); int -afr_write_subvol_set (call_frame_t *frame, xlator_t *this); +afr_write_subvol_set(call_frame_t *frame, xlator_t *this); int -afr_write_subvol_reset (call_frame_t *frame, xlator_t *this); +afr_write_subvol_reset(call_frame_t *frame, xlator_t *this); int -afr_set_inode_local (xlator_t *this, afr_local_t *local, inode_t *inode); +afr_set_inode_local(xlator_t *this, afr_local_t *local, inode_t *inode); int -afr_fill_ta_loc (xlator_t *this, loc_t *loc); +afr_fill_ta_loc(xlator_t *this, loc_t *loc); int -afr_ta_post_op_lock (xlator_t *this, loc_t *loc); +afr_ta_post_op_lock(xlator_t *this, loc_t *loc); int -afr_ta_post_op_unlock (xlator_t *this, loc_t *loc); +afr_ta_post_op_unlock(xlator_t *this, loc_t *loc); gf_boolean_t -afr_is_pending_set (xlator_t *this, dict_t *xdata, int type); +afr_is_pending_set(xlator_t *this, dict_t *xdata, int type); -call_frame_t* -afr_ta_frame_create (xlator_t *this); +call_frame_t * +afr_ta_frame_create(xlator_t *this); #endif /* __AFR_H__ */ diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 86b3eb3cbd2..bd30fd84b88 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -25,141 +25,136 @@ #ifndef _DHT_H #define _DHT_H -#define GF_XATTR_FIX_LAYOUT_KEY "distribute.fix.layout" -#define GF_XATTR_TIER_LAYOUT_FIXED_KEY "trusted.tier.fix.layout.complete" -#define GF_XATTR_FILE_MIGRATE_KEY "trusted.distribute.migrate-data" -#define DHT_MDS_STR "mds" -#define GF_DHT_LOOKUP_UNHASHED_OFF 0 -#define GF_DHT_LOOKUP_UNHASHED_ON 1 -#define GF_DHT_LOOKUP_UNHASHED_AUTO 2 -#define DHT_PATHINFO_HEADER "DISTRIBUTE:" -#define DHT_FILE_MIGRATE_DOMAIN "dht.file.migrate" +#define GF_XATTR_FIX_LAYOUT_KEY "distribute.fix.layout" +#define GF_XATTR_TIER_LAYOUT_FIXED_KEY "trusted.tier.fix.layout.complete" +#define GF_XATTR_FILE_MIGRATE_KEY "trusted.distribute.migrate-data" +#define DHT_MDS_STR "mds" +#define GF_DHT_LOOKUP_UNHASHED_OFF 0 +#define GF_DHT_LOOKUP_UNHASHED_ON 1 +#define GF_DHT_LOOKUP_UNHASHED_AUTO 2 +#define DHT_PATHINFO_HEADER "DISTRIBUTE:" +#define DHT_FILE_MIGRATE_DOMAIN "dht.file.migrate" /* Layout synchronization */ -#define DHT_LAYOUT_HEAL_DOMAIN "dht.layout.heal" +#define DHT_LAYOUT_HEAL_DOMAIN "dht.layout.heal" /* Namespace synchronization */ -#define DHT_ENTRY_SYNC_DOMAIN "dht.entry.sync" -#define TIERING_MIGRATION_KEY "tiering.migration" -#define DHT_LAYOUT_HASH_INVALID 1 -#define MAX_REBAL_THREADS sysconf(_SC_NPROCESSORS_ONLN) - -#define DHT_DIR_STAT_BLOCKS 8 -#define DHT_DIR_STAT_SIZE 4096 +#define DHT_ENTRY_SYNC_DOMAIN "dht.entry.sync" +#define TIERING_MIGRATION_KEY "tiering.migration" +#define DHT_LAYOUT_HASH_INVALID 1 +#define MAX_REBAL_THREADS sysconf(_SC_NPROCESSORS_ONLN) +#define DHT_DIR_STAT_BLOCKS 8 +#define DHT_DIR_STAT_SIZE 4096 /* Virtual xattrs for debugging */ -#define DHT_DBG_HASHED_SUBVOL_PATTERN "dht.file.hashed-subvol.*" -#define DHT_DBG_HASHED_SUBVOL_KEY "dht.file.hashed-subvol." - +#define DHT_DBG_HASHED_SUBVOL_PATTERN "dht.file.hashed-subvol.*" +#define DHT_DBG_HASHED_SUBVOL_KEY "dht.file.hashed-subvol." /* Array to hold custom xattr keys -*/ + */ extern char *xattrs_to_heal[]; /* Rebalance nodeuuid flags */ -#define REBAL_NODEUUID_MINE 0x01 +#define REBAL_NODEUUID_MINE 0x01 +typedef int (*dht_selfheal_dir_cbk_t)(call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, + int32_t op_errno, dict_t *xdata); +typedef int (*dht_defrag_cbk_fn_t)(xlator_t *this, xlator_t *dst_node, + call_frame_t *frame, int ret); -typedef int (*dht_selfheal_dir_cbk_t) (call_frame_t *frame, void *cookie, - xlator_t *this, - int32_t op_ret, int32_t op_errno, - dict_t *xdata); -typedef int (*dht_defrag_cbk_fn_t) (xlator_t *this, xlator_t *dst_node, - call_frame_t *frame, int ret); - -typedef int (*dht_refresh_layout_unlock) (call_frame_t *frame, xlator_t *this, +typedef int (*dht_refresh_layout_unlock)(call_frame_t *frame, xlator_t *this, int op_ret, int invoke_cbk); -typedef int (*dht_refresh_layout_done_handle) (call_frame_t *frame); +typedef int (*dht_refresh_layout_done_handle)(call_frame_t *frame); struct dht_layout { - int spread_cnt; /* layout spread count per directory, - is controlled by 'setxattr()' with - special key */ - int cnt; - int preset; - /* - * The last *configuration* state for which this directory was known - * to be in balance. The corresponding vol_commit_hash changes - * whenever bricks are added or removed. This value changes when a - * (full) rebalance is complete. If they match, it's safe to assume - * that every file is where it should be and there's no need to do - * lookups for files elsewhere. If they don't, then we have to do a - * global lookup to be sure. - */ - uint32_t commit_hash; - /* - * The *runtime* state of the volume, changes when connections to - * bricks are made or lost. - */ - int gen; - int type; - gf_atomic_t ref; /* use with dht_conf_t->layout_lock */ - uint32_t search_unhashed; - struct { - int err; /* 0 = normal - -1 = dir exists and no xattr - >0 = dir lookup failed with errno - */ - uint32_t start; - uint32_t stop; - uint32_t commit_hash; - xlator_t *xlator; - } list[]; + int spread_cnt; /* layout spread count per directory, + is controlled by 'setxattr()' with + special key */ + int cnt; + int preset; + /* + * The last *configuration* state for which this directory was known + * to be in balance. The corresponding vol_commit_hash changes + * whenever bricks are added or removed. This value changes when a + * (full) rebalance is complete. If they match, it's safe to assume + * that every file is where it should be and there's no need to do + * lookups for files elsewhere. If they don't, then we have to do a + * global lookup to be sure. + */ + uint32_t commit_hash; + /* + * The *runtime* state of the volume, changes when connections to + * bricks are made or lost. + */ + int gen; + int type; + gf_atomic_t ref; /* use with dht_conf_t->layout_lock */ + uint32_t search_unhashed; + struct { + int err; /* 0 = normal + -1 = dir exists and no xattr + >0 = dir lookup failed with errno + */ + uint32_t start; + uint32_t stop; + uint32_t commit_hash; + xlator_t *xlator; + } list[]; }; -typedef struct dht_layout dht_layout_t; +typedef struct dht_layout dht_layout_t; struct dht_stat_time { - uint32_t atime; - uint32_t atime_nsec; - uint32_t ctime; - uint32_t ctime_nsec; - uint32_t mtime; - uint32_t mtime_nsec; + uint32_t atime; + uint32_t atime_nsec; + uint32_t ctime; + uint32_t ctime_nsec; + uint32_t mtime; + uint32_t mtime_nsec; }; typedef struct dht_stat_time dht_stat_time_t; struct dht_inode_ctx { - dht_layout_t *layout; - dht_stat_time_t time; - xlator_t *lock_subvol; - xlator_t *mds_subvol; /* This is only used for directories */ + dht_layout_t *layout; + dht_stat_time_t time; + xlator_t *lock_subvol; + xlator_t *mds_subvol; /* This is only used for directories */ }; typedef struct dht_inode_ctx dht_inode_ctx_t; - typedef enum { - DHT_HASH_TYPE_DM, - DHT_HASH_TYPE_DM_USER, + DHT_HASH_TYPE_DM, + DHT_HASH_TYPE_DM_USER, } dht_hashfn_type_t; typedef enum { - DHT_INODELK, - DHT_ENTRYLK, + DHT_INODELK, + DHT_ENTRYLK, } dht_lock_type_t; /* rebalance related */ struct dht_rebalance_ { - xlator_t *from_subvol; - xlator_t *target_node; - off_t offset; - size_t size; - int32_t flags; - int count; - struct iobref *iobref; - struct iovec *vector; - struct iatt stbuf; - struct iatt prebuf; - struct iatt postbuf; - dht_defrag_cbk_fn_t target_op_fn; - dict_t *xdata; - dict_t *xattr; - dict_t *dict; - int32_t set; - struct gf_flock flock; - int lock_cmd; + xlator_t *from_subvol; + xlator_t *target_node; + off_t offset; + size_t size; + int32_t flags; + int count; + struct iobref *iobref; + struct iovec *vector; + struct iatt stbuf; + struct iatt prebuf; + struct iatt postbuf; + dht_defrag_cbk_fn_t target_op_fn; + dict_t *xdata; + dict_t *xattr; + dict_t *dict; + int32_t set; + struct gf_flock flock; + int lock_cmd; }; /** @@ -167,63 +162,62 @@ struct dht_rebalance_ { * events **/ typedef enum { - qdstatfs_action_OFF = 0, - qdstatfs_action_REPLACE, - qdstatfs_action_NEGLECT, - qdstatfs_action_COMPARE, + qdstatfs_action_OFF = 0, + qdstatfs_action_REPLACE, + qdstatfs_action_NEGLECT, + qdstatfs_action_COMPARE, } qdstatfs_action_t; typedef enum { - REACTION_INVALID, - FAIL_ON_ANY_ERROR, - IGNORE_ENOENT_ESTALE, - IGNORE_ENOENT_ESTALE_EIO, + REACTION_INVALID, + FAIL_ON_ANY_ERROR, + IGNORE_ENOENT_ESTALE, + IGNORE_ENOENT_ESTALE_EIO, } dht_reaction_type_t; struct dht_skip_linkto_unlink { - - gf_boolean_t handle_valid_link; - int opend_fd_count; - xlator_t *hash_links_to; - uuid_t cached_gfid; - uuid_t hashed_gfid; + gf_boolean_t handle_valid_link; + int opend_fd_count; + xlator_t *hash_links_to; + uuid_t cached_gfid; + uuid_t hashed_gfid; }; typedef struct { - xlator_t *xl; - loc_t loc; /* contains/points to inode to lock on. */ - short type; /* read/write lock. */ - char *domain; /* Only locks within a single domain - * contend with each other - */ - char *basename; /* Required for entrylk */ - gf_lkowner_t lk_owner; - gf_boolean_t locked; - dht_reaction_type_t do_on_failure; + xlator_t *xl; + loc_t loc; /* contains/points to inode to lock on. */ + short type; /* read/write lock. */ + char *domain; /* Only locks within a single domain + * contend with each other + */ + char *basename; /* Required for entrylk */ + gf_lkowner_t lk_owner; + gf_boolean_t locked; + dht_reaction_type_t do_on_failure; } dht_lock_t; /* The lock structure represents inodelk. */ typedef struct { - fop_inodelk_cbk_t inodelk_cbk; - dht_lock_t **locks; - int lk_count; - dht_reaction_type_t reaction; - - /* whether locking failed on _any_ of the "locks" above */ - int op_ret; - int op_errno; + fop_inodelk_cbk_t inodelk_cbk; + dht_lock_t **locks; + int lk_count; + dht_reaction_type_t reaction; + + /* whether locking failed on _any_ of the "locks" above */ + int op_ret; + int op_errno; } dht_ilock_wrap_t; /* The lock structure represents entrylk. */ typedef struct { - fop_entrylk_cbk_t entrylk_cbk; - dht_lock_t **locks; - int lk_count; - dht_reaction_type_t reaction; - - /* whether locking failed on _any_ of the "locks" above */ - int op_ret; - int op_errno; + fop_entrylk_cbk_t entrylk_cbk; + dht_lock_t **locks; + int lk_count; + dht_reaction_type_t reaction; + + /* whether locking failed on _any_ of the "locks" above */ + int op_ret; + int op_errno; } dht_elock_wrap_t; /* The first member of dht_dir_transaction_t should be of type dht_ilock_wrap_t. @@ -232,1263 +226,1280 @@ typedef struct { * lock[0].ns.parent_layout (like in dht_local_wipe). */ typedef union { - union { - dht_ilock_wrap_t my_layout; - dht_ilock_wrap_t parent_layout; - } layout; - struct dht_namespace { - dht_ilock_wrap_t parent_layout; - dht_elock_wrap_t directory_ns; - fop_entrylk_cbk_t ns_cbk; - } ns; + union { + dht_ilock_wrap_t my_layout; + dht_ilock_wrap_t parent_layout; + } layout; + struct dht_namespace { + dht_ilock_wrap_t parent_layout; + dht_elock_wrap_t directory_ns; + fop_entrylk_cbk_t ns_cbk; + } ns; } dht_dir_transaction_t; -typedef -int (*dht_selfheal_layout_t)(call_frame_t *frame, loc_t *loc, - dht_layout_t *layout); +typedef int (*dht_selfheal_layout_t)(call_frame_t *frame, loc_t *loc, + dht_layout_t *layout); -typedef -gf_boolean_t (*dht_need_heal_t)(call_frame_t *frame, dht_layout_t **inmem, - dht_layout_t **ondisk); +typedef gf_boolean_t (*dht_need_heal_t)(call_frame_t *frame, + dht_layout_t **inmem, + dht_layout_t **ondisk); typedef struct { - uint64_t blocks_used; - uint64_t pblocks_used; - uint64_t files_used; - uint64_t pfiles_used; - uint64_t unhashed_blocks_used; - uint64_t unhashed_pblocks_used; - uint64_t unhashed_files_used; - uint64_t unhashed_pfiles_used; - uint64_t unhashed_fsid; - uint64_t hashed_fsid; + uint64_t blocks_used; + uint64_t pblocks_used; + uint64_t files_used; + uint64_t pfiles_used; + uint64_t unhashed_blocks_used; + uint64_t unhashed_pblocks_used; + uint64_t unhashed_files_used; + uint64_t unhashed_pfiles_used; + uint64_t unhashed_fsid; + uint64_t hashed_fsid; } tier_statvfs_t; struct dht_local { - int call_cnt; - loc_t loc; - loc_t loc2; - int op_ret; - int op_errno; - int layout_mismatch; - /* Use stbuf as the postbuf, when we require both - * pre and post attrs */ - struct iatt stbuf; - struct iatt mds_stbuf; - struct iatt prebuf; - struct iatt preoldparent; - struct iatt postoldparent; - struct iatt preparent; - struct iatt postparent; - struct statvfs statvfs; - tier_statvfs_t tier_statvfs; - fd_t *fd; - inode_t *inode; - dict_t *params; - dict_t *xattr; - dict_t *mds_xattr; - dict_t *xdata; /* dict used to save xdata response by xattr fop */ - dict_t *xattr_req; - dht_layout_t *layout; - size_t size; - ino_t ia_ino; - xlator_t *src_hashed, *src_cached; - xlator_t *dst_hashed, *dst_cached; - xlator_t *cached_subvol; - xlator_t *hashed_subvol; - xlator_t *mds_subvol; /* This is use for dir only */ - char need_selfheal; - char need_xattr_heal; - char need_attrheal; - int file_count; - int dir_count; - call_frame_t *main_frame; - int fop_succeeded; - struct { - fop_mknod_cbk_t linkfile_cbk; - struct iatt stbuf; - loc_t loc; - inode_t *inode; - dict_t *xattr; - xlator_t *srcvol; - } linkfile; - struct { - uint32_t hole_cnt; - uint32_t overlaps_cnt; - uint32_t down; - uint32_t misc; - uint32_t missing_cnt; - dht_selfheal_dir_cbk_t dir_cbk; - dht_selfheal_layout_t healer; - dht_need_heal_t should_heal; - gf_boolean_t force_mkdir; - dht_layout_t *layout, *refreshed_layout; - } selfheal; - - dht_refresh_layout_unlock refresh_layout_unlock; - dht_refresh_layout_done_handle refresh_layout_done; - - uint32_t uid; - uint32_t gid; - - /* needed by nufa */ - int32_t flags; - mode_t mode; - dev_t rdev; - mode_t umask; - - /* need for file-info */ - char *xattr_val; - char *key; - - /* which xattr request? */ - char xsel[256]; - int32_t alloc_len; - - /* gfid related */ - uuid_t gfid; - - /* flag used to make sure we need to return estale in - {lookup,revalidate}_cbk */ - char return_estale; - char need_lookup_everywhere; - - glusterfs_fop_t fop; - - gf_boolean_t linked; - xlator_t *link_subvol; - - struct dht_rebalance_ rebalance; - xlator_t *first_up_subvol; - - gf_boolean_t quota_deem_statfs; - - gf_boolean_t added_link; - gf_boolean_t is_linkfile; - - struct dht_skip_linkto_unlink skip_unlink; - - dht_dir_transaction_t lock[2], *current; - - /* inodelks during filerename for backward compatibility */ - dht_lock_t **rename_inodelk_backward_compatible; - int rename_inodelk_bc_count; - - short lock_type; - - call_stub_t *stub; - int32_t parent_disk_layout[4]; - - /* rename rollback */ - int *ret_cache ; - - /* fd open check */ - gf_boolean_t fd_checked; - /* This is use only for directory operation */ - int32_t valid; - gf_boolean_t heal_layout; - int32_t mds_heal_fresh_lookup; - loc_t loc2_copy; - gf_boolean_t locked; - gf_boolean_t dont_create_linkto; + int call_cnt; + loc_t loc; + loc_t loc2; + int op_ret; + int op_errno; + int layout_mismatch; + /* Use stbuf as the postbuf, when we require both + * pre and post attrs */ + struct iatt stbuf; + struct iatt mds_stbuf; + struct iatt prebuf; + struct iatt preoldparent; + struct iatt postoldparent; + struct iatt preparent; + struct iatt postparent; + struct statvfs statvfs; + tier_statvfs_t tier_statvfs; + fd_t *fd; + inode_t *inode; + dict_t *params; + dict_t *xattr; + dict_t *mds_xattr; + dict_t *xdata; /* dict used to save xdata response by xattr fop */ + dict_t *xattr_req; + dht_layout_t *layout; + size_t size; + ino_t ia_ino; + xlator_t *src_hashed, *src_cached; + xlator_t *dst_hashed, *dst_cached; + xlator_t *cached_subvol; + xlator_t *hashed_subvol; + xlator_t *mds_subvol; /* This is use for dir only */ + char need_selfheal; + char need_xattr_heal; + char need_attrheal; + int file_count; + int dir_count; + call_frame_t *main_frame; + int fop_succeeded; + struct { + fop_mknod_cbk_t linkfile_cbk; + struct iatt stbuf; + loc_t loc; + inode_t *inode; + dict_t *xattr; + xlator_t *srcvol; + } linkfile; + struct { + uint32_t hole_cnt; + uint32_t overlaps_cnt; + uint32_t down; + uint32_t misc; + uint32_t missing_cnt; + dht_selfheal_dir_cbk_t dir_cbk; + dht_selfheal_layout_t healer; + dht_need_heal_t should_heal; + gf_boolean_t force_mkdir; + dht_layout_t *layout, *refreshed_layout; + } selfheal; + + dht_refresh_layout_unlock refresh_layout_unlock; + dht_refresh_layout_done_handle refresh_layout_done; + + uint32_t uid; + uint32_t gid; + + /* needed by nufa */ + int32_t flags; + mode_t mode; + dev_t rdev; + mode_t umask; + + /* need for file-info */ + char *xattr_val; + char *key; + + /* which xattr request? */ + char xsel[256]; + int32_t alloc_len; + + /* gfid related */ + uuid_t gfid; + + /* flag used to make sure we need to return estale in + {lookup,revalidate}_cbk */ + char return_estale; + char need_lookup_everywhere; + + glusterfs_fop_t fop; + + gf_boolean_t linked; + xlator_t *link_subvol; + + struct dht_rebalance_ rebalance; + xlator_t *first_up_subvol; + + gf_boolean_t quota_deem_statfs; + + gf_boolean_t added_link; + gf_boolean_t is_linkfile; + + struct dht_skip_linkto_unlink skip_unlink; + + dht_dir_transaction_t lock[2], *current; + + /* inodelks during filerename for backward compatibility */ + dht_lock_t **rename_inodelk_backward_compatible; + int rename_inodelk_bc_count; + + short lock_type; + + call_stub_t *stub; + int32_t parent_disk_layout[4]; + + /* rename rollback */ + int *ret_cache; + + /* fd open check */ + gf_boolean_t fd_checked; + /* This is use only for directory operation */ + int32_t valid; + gf_boolean_t heal_layout; + int32_t mds_heal_fresh_lookup; + loc_t loc2_copy; + gf_boolean_t locked; + gf_boolean_t dont_create_linkto; }; typedef struct dht_local dht_local_t; /* du - disk-usage */ struct dht_du { - double avail_percent; - double avail_inodes; - uint64_t avail_space; - uint32_t log; - uint32_t chunks; - uint32_t total_blocks; - uint32_t avail_blocks; - uint32_t frsize; /*fragment size*/ + double avail_percent; + double avail_inodes; + uint64_t avail_space; + uint32_t log; + uint32_t chunks; + uint32_t total_blocks; + uint32_t avail_blocks; + uint32_t frsize; /*fragment size*/ }; typedef struct dht_du dht_du_t; enum gf_defrag_type { - GF_DEFRAG_CMD_NONE = 0, - GF_DEFRAG_CMD_START = 1, - GF_DEFRAG_CMD_STOP = 1 + 1, - GF_DEFRAG_CMD_STATUS = 1 + 2, - GF_DEFRAG_CMD_START_LAYOUT_FIX = 1 + 3, - GF_DEFRAG_CMD_START_FORCE = 1 + 4, - GF_DEFRAG_CMD_START_TIER = 1 + 5, - GF_DEFRAG_CMD_STATUS_TIER = 1 + 6, - GF_DEFRAG_CMD_START_DETACH_TIER = 1 + 7, - GF_DEFRAG_CMD_STOP_DETACH_TIER = 1 + 8, - GF_DEFRAG_CMD_PAUSE_TIER = 1 + 9, - GF_DEFRAG_CMD_RESUME_TIER = 1 + 10, - GF_DEFRAG_CMD_DETACH_STATUS = 1 + 11, - GF_DEFRAG_CMD_STOP_TIER = 1 + 12, - GF_DEFRAG_CMD_DETACH_START = 1 + 13, - GF_DEFRAG_CMD_DETACH_COMMIT = 1 + 14, - GF_DEFRAG_CMD_DETACH_COMMIT_FORCE = 1 + 15, - GF_DEFRAG_CMD_DETACH_STOP = 1 + 16, - /* new labels are used so it will help - * while removing old labels by easily differentiating. - * A few labels are added so that the count remains same - * between this enum and the ones on the xdr file. - * different values for the same enum cause errors and - * confusion. - */ + GF_DEFRAG_CMD_NONE = 0, + GF_DEFRAG_CMD_START = 1, + GF_DEFRAG_CMD_STOP = 1 + 1, + GF_DEFRAG_CMD_STATUS = 1 + 2, + GF_DEFRAG_CMD_START_LAYOUT_FIX = 1 + 3, + GF_DEFRAG_CMD_START_FORCE = 1 + 4, + GF_DEFRAG_CMD_START_TIER = 1 + 5, + GF_DEFRAG_CMD_STATUS_TIER = 1 + 6, + GF_DEFRAG_CMD_START_DETACH_TIER = 1 + 7, + GF_DEFRAG_CMD_STOP_DETACH_TIER = 1 + 8, + GF_DEFRAG_CMD_PAUSE_TIER = 1 + 9, + GF_DEFRAG_CMD_RESUME_TIER = 1 + 10, + GF_DEFRAG_CMD_DETACH_STATUS = 1 + 11, + GF_DEFRAG_CMD_STOP_TIER = 1 + 12, + GF_DEFRAG_CMD_DETACH_START = 1 + 13, + GF_DEFRAG_CMD_DETACH_COMMIT = 1 + 14, + GF_DEFRAG_CMD_DETACH_COMMIT_FORCE = 1 + 15, + GF_DEFRAG_CMD_DETACH_STOP = 1 + 16, + /* new labels are used so it will help + * while removing old labels by easily differentiating. + * A few labels are added so that the count remains same + * between this enum and the ones on the xdr file. + * different values for the same enum cause errors and + * confusion. + */ }; typedef enum gf_defrag_type gf_defrag_type; enum gf_defrag_status_t { - GF_DEFRAG_STATUS_NOT_STARTED, - GF_DEFRAG_STATUS_STARTED, - GF_DEFRAG_STATUS_STOPPED, - GF_DEFRAG_STATUS_COMPLETE, - GF_DEFRAG_STATUS_FAILED, - GF_DEFRAG_STATUS_LAYOUT_FIX_STARTED, - GF_DEFRAG_STATUS_LAYOUT_FIX_STOPPED, - GF_DEFRAG_STATUS_LAYOUT_FIX_COMPLETE, - GF_DEFRAG_STATUS_LAYOUT_FIX_FAILED, + GF_DEFRAG_STATUS_NOT_STARTED, + GF_DEFRAG_STATUS_STARTED, + GF_DEFRAG_STATUS_STOPPED, + GF_DEFRAG_STATUS_COMPLETE, + GF_DEFRAG_STATUS_FAILED, + GF_DEFRAG_STATUS_LAYOUT_FIX_STARTED, + GF_DEFRAG_STATUS_LAYOUT_FIX_STOPPED, + GF_DEFRAG_STATUS_LAYOUT_FIX_COMPLETE, + GF_DEFRAG_STATUS_LAYOUT_FIX_FAILED, }; typedef enum gf_defrag_status_t gf_defrag_status_t; typedef struct gf_defrag_pattern_list gf_defrag_pattern_list_t; struct gf_defrag_pattern_list { - char path_pattern[256]; - uint64_t size; - gf_defrag_pattern_list_t *next; + char path_pattern[256]; + uint64_t size; + gf_defrag_pattern_list_t *next; }; struct dht_container { - union { - struct list_head list; - struct { - struct _gf_dirent_t *next; - struct _gf_dirent_t *prev; - }; + union { + struct list_head list; + struct { + struct _gf_dirent_t *next; + struct _gf_dirent_t *prev; }; - gf_dirent_t *df_entry; - xlator_t *this; - loc_t *parent_loc; - dict_t *migrate_data; - int local_subvol_index; + }; + gf_dirent_t *df_entry; + xlator_t *this; + loc_t *parent_loc; + dict_t *migrate_data; + int local_subvol_index; }; typedef enum tier_mode_ { - TIER_MODE_NONE = 0, - TIER_MODE_TEST, - TIER_MODE_WM + TIER_MODE_NONE = 0, + TIER_MODE_TEST, + TIER_MODE_WM } tier_mode_t; typedef enum tier_pause_state_ { - TIER_RUNNING = 0, - TIER_REQUEST_PAUSE, - TIER_PAUSED + TIER_RUNNING = 0, + TIER_REQUEST_PAUSE, + TIER_PAUSED } tier_pause_state_t; /* This Structure is only used in tiering fixlayout */ typedef struct gf_tier_fix_layout_arg { - xlator_t *this; - dict_t *fix_layout; - pthread_t thread_id; + xlator_t *this; + dict_t *fix_layout; + pthread_t thread_id; } gf_tier_fix_layout_arg_t; typedef struct gf_tier_conf { - int is_tier; - int watermark_hi; - int watermark_low; - int watermark_last; - unsigned long block_size; - fsblkcnt_t blocks_total; - fsblkcnt_t blocks_used; - int percent_full; - uint64_t max_migrate_bytes; - int max_migrate_files; - int query_limit; - tier_mode_t mode; - /* These flags are only used for tier-compact */ - gf_boolean_t compact_active; - /* These 3 flags are set to true when the client changes the */ - /* compaction mode on the command line. */ - /* When they are set, the daemon will trigger compaction as */ - /* soon as possible to activate or deactivate compaction. */ - /* If in the middle of a compaction, then the switches take */ - /* effect on the next compaction, not the current one. */ - /* If the user switches it off, we want to avoid needless */ - /* compactions. */ - /* If the user switches it on, they want to compact as soon */ - /* as possible. */ - gf_boolean_t compact_mode_switched; - gf_boolean_t compact_mode_switched_hot; - gf_boolean_t compact_mode_switched_cold; - int tier_max_promote_size; - int tier_promote_frequency; - int tier_demote_frequency; - int tier_compact_hot_frequency; - int tier_compact_cold_frequency; - uint64_t st_last_promoted_size; - uint64_t st_last_demoted_size; - tier_pause_state_t pause_state; - struct synctask *pause_synctask; - gf_timer_t *pause_timer; - pthread_mutex_t pause_mutex; - int promote_in_progress; - int demote_in_progress; - /* This Structure is only used in tiering fixlayout */ - gf_tier_fix_layout_arg_t tier_fix_layout_arg; - /* Indicates the index of the first queryfile picked - * in the last cycle of promote or demote */ - int32_t last_promote_qfile_index; - int32_t last_demote_qfile_index; - char volname[GD_VOLUME_NAME_MAX + 1]; + int is_tier; + int watermark_hi; + int watermark_low; + int watermark_last; + unsigned long block_size; + fsblkcnt_t blocks_total; + fsblkcnt_t blocks_used; + int percent_full; + uint64_t max_migrate_bytes; + int max_migrate_files; + int query_limit; + tier_mode_t mode; + /* These flags are only used for tier-compact */ + gf_boolean_t compact_active; + /* These 3 flags are set to true when the client changes the */ + /* compaction mode on the command line. */ + /* When they are set, the daemon will trigger compaction as */ + /* soon as possible to activate or deactivate compaction. */ + /* If in the middle of a compaction, then the switches take */ + /* effect on the next compaction, not the current one. */ + /* If the user switches it off, we want to avoid needless */ + /* compactions. */ + /* If the user switches it on, they want to compact as soon */ + /* as possible. */ + gf_boolean_t compact_mode_switched; + gf_boolean_t compact_mode_switched_hot; + gf_boolean_t compact_mode_switched_cold; + int tier_max_promote_size; + int tier_promote_frequency; + int tier_demote_frequency; + int tier_compact_hot_frequency; + int tier_compact_cold_frequency; + uint64_t st_last_promoted_size; + uint64_t st_last_demoted_size; + tier_pause_state_t pause_state; + struct synctask *pause_synctask; + gf_timer_t *pause_timer; + pthread_mutex_t pause_mutex; + int promote_in_progress; + int demote_in_progress; + /* This Structure is only used in tiering fixlayout */ + gf_tier_fix_layout_arg_t tier_fix_layout_arg; + /* Indicates the index of the first queryfile picked + * in the last cycle of promote or demote */ + int32_t last_promote_qfile_index; + int32_t last_demote_qfile_index; + char volname[GD_VOLUME_NAME_MAX + 1]; } gf_tier_conf_t; typedef struct nodeuuid_info { - char info; /* Set to 1 is this is my node's uuid*/ - uuid_t uuid; /* Store the nodeuuid as well for debugging*/ + char info; /* Set to 1 is this is my node's uuid*/ + uuid_t uuid; /* Store the nodeuuid as well for debugging*/ } nodeuuid_info_t; typedef struct subvol_nodeuuids_info { - nodeuuid_info_t *elements; - int count; + nodeuuid_info_t *elements; + int count; } subvol_nodeuuids_info_t; - struct gf_defrag_info_ { - uint64_t total_files; - uint64_t total_data; - uint64_t num_files_lookedup; - uint64_t total_failures; - uint64_t skipped; - uint64_t num_dirs_processed; - uint64_t size_processed; - gf_lock_t lock; - int cmd; - pthread_t th; - gf_defrag_status_t defrag_status; - struct rpc_clnt *rpc; - uint32_t connected; - uint32_t is_exiting; - pid_t pid; - inode_t *root_inode; - uuid_t node_uuid; - struct timeval start_time; - gf_boolean_t stats; - uint32_t new_commit_hash; - gf_defrag_pattern_list_t *defrag_pattern; - gf_tier_conf_t tier_conf; - - /*Data Tiering params for scanner*/ - uint64_t total_files_promoted; - uint64_t total_files_demoted; - int write_freq_threshold; - int read_freq_threshold; - - pthread_cond_t parallel_migration_cond; - pthread_mutex_t dfq_mutex; - pthread_cond_t rebalance_crawler_alarm; - int32_t q_entry_count; - int32_t global_error; - struct dht_container *queue; - int32_t crawl_done; - int32_t abort; - int32_t wakeup_crawler; - - /*Throttle params*/ - /*stands for reconfigured thread count*/ - int32_t recon_thread_count; - /*stands for current running thread count*/ - int32_t current_thread_count; - pthread_cond_t df_wakeup_thread; - - /* lock migration flag */ - gf_boolean_t lock_migration_enabled; - - /* backpointer to make it easier to write functions for rebalance */ - xlator_t *this; - - pthread_cond_t fc_wakeup_cond; - pthread_mutex_t fc_mutex; + uint64_t total_files; + uint64_t total_data; + uint64_t num_files_lookedup; + uint64_t total_failures; + uint64_t skipped; + uint64_t num_dirs_processed; + uint64_t size_processed; + gf_lock_t lock; + int cmd; + pthread_t th; + gf_defrag_status_t defrag_status; + struct rpc_clnt *rpc; + uint32_t connected; + uint32_t is_exiting; + pid_t pid; + inode_t *root_inode; + uuid_t node_uuid; + struct timeval start_time; + gf_boolean_t stats; + uint32_t new_commit_hash; + gf_defrag_pattern_list_t *defrag_pattern; + gf_tier_conf_t tier_conf; + + /*Data Tiering params for scanner*/ + uint64_t total_files_promoted; + uint64_t total_files_demoted; + int write_freq_threshold; + int read_freq_threshold; + + pthread_cond_t parallel_migration_cond; + pthread_mutex_t dfq_mutex; + pthread_cond_t rebalance_crawler_alarm; + int32_t q_entry_count; + int32_t global_error; + struct dht_container *queue; + int32_t crawl_done; + int32_t abort; + int32_t wakeup_crawler; + + /*Throttle params*/ + /*stands for reconfigured thread count*/ + int32_t recon_thread_count; + /*stands for current running thread count*/ + int32_t current_thread_count; + pthread_cond_t df_wakeup_thread; + + /* lock migration flag */ + gf_boolean_t lock_migration_enabled; + + /* backpointer to make it easier to write functions for rebalance */ + xlator_t *this; + + pthread_cond_t fc_wakeup_cond; + pthread_mutex_t fc_mutex; }; typedef struct gf_defrag_info_ gf_defrag_info_t; struct dht_methods_s { - int32_t (*migration_get_dst_subvol)(xlator_t *this, - dht_local_t *local); - int32_t (*migration_other)(xlator_t *this, - gf_defrag_info_t *defrag); - int32_t (*migration_needed)(xlator_t *this); - xlator_t* (*layout_search)(xlator_t *this, - dht_layout_t *layout, - const char *name); + int32_t (*migration_get_dst_subvol)(xlator_t *this, dht_local_t *local); + int32_t (*migration_other)(xlator_t *this, gf_defrag_info_t *defrag); + int32_t (*migration_needed)(xlator_t *this); + xlator_t *(*layout_search)(xlator_t *this, dht_layout_t *layout, + const char *name); }; typedef struct dht_methods_s dht_methods_t; struct dht_conf { - gf_lock_t subvolume_lock; - int subvolume_cnt; - xlator_t **subvolumes; - char *subvolume_status; - int *last_event; - dht_layout_t **file_layouts; - dht_layout_t **dir_layouts; - unsigned int search_unhashed; - gf_boolean_t lookup_optimize; - int gen; - dht_du_t *du_stats; - double min_free_disk; - double min_free_inodes; - char disk_unit; - int32_t refresh_interval; - gf_boolean_t unhashed_sticky_bit; - struct timeval last_stat_fetch; - gf_lock_t layout_lock; - dict_t *leaf_to_subvol; - void *private; /* Can be used by wrapper xlators over - dht */ - gf_boolean_t use_readdirp; - char vol_uuid[UUID_SIZE + 1]; - gf_boolean_t assert_no_child_down; - time_t *subvol_up_time; - - /* This is the count used as the distribute layout for a directory */ - /* Will be a global flag to control the layout spread count */ - uint32_t dir_spread_cnt; - - /* to keep track of nodes which are decommissioned */ - xlator_t **decommissioned_bricks; - int decommission_in_progress; - int decommission_subvols_cnt; - - /* defrag related */ - gf_defrag_info_t *defrag; - - /* Request to filter directory entries in readdir request */ - - gf_boolean_t readdir_optimize; - - /* Support regex-based name reinterpretation. */ - regex_t rsync_regex; - gf_boolean_t rsync_regex_valid; - regex_t extra_regex; - gf_boolean_t extra_regex_valid; - - /* Support variable xattr names. */ - char *xattr_name; - char *mds_xattr_key; - char *link_xattr_name; - char *commithash_xattr_name; - char *wild_xattr_name; - - /* Support size-weighted rebalancing (heterogeneous bricks). */ - gf_boolean_t do_weighting; - gf_boolean_t randomize_by_gfid; - int dthrottle; - - dht_methods_t methods; - - struct mem_pool *lock_pool; - - /*local subvol storage for rebalance*/ - xlator_t **local_subvols; - subvol_nodeuuids_info_t *local_nodeuuids; - int32_t local_subvols_cnt; - - /* - * "Commit hash" for this volume topology. Changed whenever bricks - * are added or removed. - */ - uint32_t vol_commit_hash; - gf_boolean_t vch_forced; - - /* lock migration */ - - gf_boolean_t lock_migration_enabled; - gf_lock_t lock; - - /* Hard link handle requirement for migration triggered from client*/ - synclock_t link_lock; - - gf_boolean_t use_fallocate; - - gf_boolean_t force_migration; + gf_lock_t subvolume_lock; + int subvolume_cnt; + xlator_t **subvolumes; + char *subvolume_status; + int *last_event; + dht_layout_t **file_layouts; + dht_layout_t **dir_layouts; + unsigned int search_unhashed; + gf_boolean_t lookup_optimize; + int gen; + dht_du_t *du_stats; + double min_free_disk; + double min_free_inodes; + char disk_unit; + int32_t refresh_interval; + gf_boolean_t unhashed_sticky_bit; + struct timeval last_stat_fetch; + gf_lock_t layout_lock; + dict_t *leaf_to_subvol; + void *private; /* Can be used by wrapper xlators over + dht */ + gf_boolean_t use_readdirp; + char vol_uuid[UUID_SIZE + 1]; + gf_boolean_t assert_no_child_down; + time_t *subvol_up_time; + + /* This is the count used as the distribute layout for a directory */ + /* Will be a global flag to control the layout spread count */ + uint32_t dir_spread_cnt; + + /* to keep track of nodes which are decommissioned */ + xlator_t **decommissioned_bricks; + int decommission_in_progress; + int decommission_subvols_cnt; + + /* defrag related */ + gf_defrag_info_t *defrag; + + /* Request to filter directory entries in readdir request */ + + gf_boolean_t readdir_optimize; + + /* Support regex-based name reinterpretation. */ + regex_t rsync_regex; + gf_boolean_t rsync_regex_valid; + regex_t extra_regex; + gf_boolean_t extra_regex_valid; + + /* Support variable xattr names. */ + char *xattr_name; + char *mds_xattr_key; + char *link_xattr_name; + char *commithash_xattr_name; + char *wild_xattr_name; + + /* Support size-weighted rebalancing (heterogeneous bricks). */ + gf_boolean_t do_weighting; + gf_boolean_t randomize_by_gfid; + int dthrottle; + + dht_methods_t methods; + + struct mem_pool *lock_pool; + + /*local subvol storage for rebalance*/ + xlator_t **local_subvols; + subvol_nodeuuids_info_t *local_nodeuuids; + int32_t local_subvols_cnt; + + /* + * "Commit hash" for this volume topology. Changed whenever bricks + * are added or removed. + */ + uint32_t vol_commit_hash; + gf_boolean_t vch_forced; + + /* lock migration */ + + gf_boolean_t lock_migration_enabled; + gf_lock_t lock; + + /* Hard link handle requirement for migration triggered from client*/ + synclock_t link_lock; + + gf_boolean_t use_fallocate; + + gf_boolean_t force_migration; }; typedef struct dht_conf dht_conf_t; struct dht_dfoffset_ctx { - xlator_t *this; - off_t offset; - int32_t readdir_done; + xlator_t *this; + off_t offset; + int32_t readdir_done; }; typedef struct dht_dfoffset_ctx dht_dfoffset_ctx_t; struct dht_disk_layout { - uint32_t cnt; - uint32_t type; - struct { - uint32_t start; - uint32_t stop; - } list[1]; + uint32_t cnt; + uint32_t type; + struct { + uint32_t start; + uint32_t stop; + } list[1]; }; typedef struct dht_disk_layout dht_disk_layout_t; typedef enum { - GF_DHT_MIGRATE_DATA, - GF_DHT_MIGRATE_DATA_EVEN_IF_LINK_EXISTS, - GF_DHT_MIGRATE_HARDLINK, - GF_DHT_MIGRATE_HARDLINK_IN_PROGRESS + GF_DHT_MIGRATE_DATA, + GF_DHT_MIGRATE_DATA_EVEN_IF_LINK_EXISTS, + GF_DHT_MIGRATE_HARDLINK, + GF_DHT_MIGRATE_HARDLINK_IN_PROGRESS } gf_dht_migrate_data_type_t; typedef enum { - GF_DHT_EQUAL_DISTRIBUTION, - GF_DHT_WEIGHTED_DISTRIBUTION + GF_DHT_EQUAL_DISTRIBUTION, + GF_DHT_WEIGHTED_DISTRIBUTION } dht_distribution_type_t; struct dir_dfmeta { - gf_dirent_t *equeue; - dht_dfoffset_ctx_t *offset_var; - struct list_head **head; - struct list_head **iterator; - int *fetch_entries; + gf_dirent_t *equeue; + dht_dfoffset_ctx_t *offset_var; + struct list_head **head; + struct list_head **iterator; + int *fetch_entries; }; typedef struct dht_migrate_info { - xlator_t *src_subvol; - xlator_t *dst_subvol; - GF_REF_DECL; + xlator_t *src_subvol; + xlator_t *dst_subvol; + GF_REF_DECL; } dht_migrate_info_t; - - typedef struct dht_fd_ctx { - uint64_t opened_on_dst; - GF_REF_DECL; + uint64_t opened_on_dst; + GF_REF_DECL; } dht_fd_ctx_t; - #define ENTRY_MISSING(op_ret, op_errno) (op_ret == -1 && op_errno == ENOENT) -#define is_revalidate(loc) (dht_inode_ctx_layout_get ((loc)->inode, this, NULL) == 0) +#define is_revalidate(loc) \ + (dht_inode_ctx_layout_get((loc)->inode, this, NULL) == 0) #define is_last_call(cnt) (cnt == 0) #define DHT_MIGRATION_IN_PROGRESS 1 -#define DHT_MIGRATION_COMPLETED 2 +#define DHT_MIGRATION_COMPLETED 2 -#define check_is_linkfile(i,s,x,n) (IS_DHT_LINKFILE_MODE (s) && dict_get (x, n)) +#define check_is_linkfile(i, s, x, n) \ + (IS_DHT_LINKFILE_MODE(s) && dict_get(x, n)) -#define IS_DHT_MIGRATION_PHASE2(buf) ( \ - IA_ISREG ((buf)->ia_type) && \ - ((st_mode_from_ia ((buf)->ia_prot, (buf)->ia_type) & \ - ~S_IFMT) == DHT_LINKFILE_MODE)) +#define IS_DHT_MIGRATION_PHASE2(buf) \ + (IA_ISREG((buf)->ia_type) && \ + ((st_mode_from_ia((buf)->ia_prot, (buf)->ia_type) & ~S_IFMT) == \ + DHT_LINKFILE_MODE)) -#define IS_DHT_MIGRATION_PHASE1(buf) ( \ - IA_ISREG ((buf)->ia_type) && \ - ((buf)->ia_prot.sticky == 1) && \ - ((buf)->ia_prot.sgid == 1)) +#define IS_DHT_MIGRATION_PHASE1(buf) \ + (IA_ISREG((buf)->ia_type) && ((buf)->ia_prot.sticky == 1) && \ + ((buf)->ia_prot.sgid == 1)) -#define DHT_STRIP_PHASE1_FLAGS(buf) do { \ - if ((buf) && IS_DHT_MIGRATION_PHASE1(buf)) { \ - (buf)->ia_prot.sticky = 0; \ - (buf)->ia_prot.sgid = 0; \ - } \ - } while (0) +#define DHT_STRIP_PHASE1_FLAGS(buf) \ + do { \ + if ((buf) && IS_DHT_MIGRATION_PHASE1(buf)) { \ + (buf)->ia_prot.sticky = 0; \ + (buf)->ia_prot.sgid = 0; \ + } \ + } while (0) #define dht_inode_missing(op_errno) (op_errno == ENOENT || op_errno == ESTALE) -#define check_is_dir(i,s,x) (IA_ISDIR(s->ia_type)) +#define check_is_dir(i, s, x) (IA_ISDIR(s->ia_type)) #define layout_is_sane(layout) ((layout) && (layout->cnt > 0)) -#define we_are_not_migrating(x) ((x) == 1) - -#define DHT_STACK_UNWIND(fop, frame, params ...) do { \ - dht_local_t *__local = NULL; \ - xlator_t *__xl = NULL; \ - if (frame) { \ - __xl = frame->this; \ - __local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - dht_local_wipe (__xl, __local); \ - } while (0) - -#define DHT_STACK_DESTROY(frame) do { \ - dht_local_t *__local = NULL; \ - xlator_t *__xl = NULL; \ - __xl = frame->this; \ - __local = frame->local; \ - frame->local = NULL; \ - STACK_DESTROY (frame->root); \ - dht_local_wipe (__xl, __local); \ - } while (0) - -#define DHT_UPDATE_TIME(ctx_sec, ctx_nsec, new_sec, new_nsec, inode, post) do {\ - LOCK (&inode->lock); \ - { \ - if (ctx_sec == new_sec) \ - new_nsec = max (new_nsec, ctx_nsec); \ - else if (ctx_sec > new_sec) { \ - new_sec = ctx_sec; \ - new_nsec = ctx_nsec; \ - } \ - if (post) { \ - ctx_sec = new_sec; \ - ctx_nsec = new_nsec; \ - } \ - } \ - UNLOCK (&inode->lock); \ - } while (0) - -#define is_greater_time(a, an, b, bn) (((a) < (b)) || (((a) == (b)) && ((an) < (bn)))) - -#define DHT_MARK_FOP_INTERNAL(xattr) do { \ - int tmp = -1; \ - if (!xattr) { \ - xattr = dict_new (); \ - if (!xattr) \ - break; \ - } \ - tmp = dict_set_str (xattr, GLUSTERFS_INTERNAL_FOP_KEY, "yes"); \ - if (tmp) { \ - gf_msg (this->name, GF_LOG_ERROR, 0, \ - DHT_MSG_DICT_SET_FAILED, \ - "Failed to set dictionary value: key = %s," \ - " path = %s", GLUSTERFS_INTERNAL_FOP_KEY, \ - local->loc.path); \ - } \ - } while (0) - -dht_layout_t *dht_layout_new (xlator_t *this, int cnt); -dht_layout_t *dht_layout_get (xlator_t *this, inode_t *inode); -dht_layout_t *dht_layout_for_subvol (xlator_t *this, xlator_t *subvol); -xlator_t *dht_layout_search (xlator_t *this, dht_layout_t *layout, - const char *name); +#define we_are_not_migrating(x) ((x) == 1) + +#define DHT_STACK_UNWIND(fop, frame, params...) \ + do { \ + dht_local_t *__local = NULL; \ + xlator_t *__xl = NULL; \ + if (frame) { \ + __xl = frame->this; \ + __local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + dht_local_wipe(__xl, __local); \ + } while (0) + +#define DHT_STACK_DESTROY(frame) \ + do { \ + dht_local_t *__local = NULL; \ + xlator_t *__xl = NULL; \ + __xl = frame->this; \ + __local = frame->local; \ + frame->local = NULL; \ + STACK_DESTROY(frame->root); \ + dht_local_wipe(__xl, __local); \ + } while (0) + +#define DHT_UPDATE_TIME(ctx_sec, ctx_nsec, new_sec, new_nsec, inode, post) \ + do { \ + LOCK(&inode->lock); \ + { \ + if (ctx_sec == new_sec) \ + new_nsec = max(new_nsec, ctx_nsec); \ + else if (ctx_sec > new_sec) { \ + new_sec = ctx_sec; \ + new_nsec = ctx_nsec; \ + } \ + if (post) { \ + ctx_sec = new_sec; \ + ctx_nsec = new_nsec; \ + } \ + } \ + UNLOCK(&inode->lock); \ + } while (0) + +#define is_greater_time(a, an, b, bn) \ + (((a) < (b)) || (((a) == (b)) && ((an) < (bn)))) + +#define DHT_MARK_FOP_INTERNAL(xattr) \ + do { \ + int tmp = -1; \ + if (!xattr) { \ + xattr = dict_new(); \ + if (!xattr) \ + break; \ + } \ + tmp = dict_set_str(xattr, GLUSTERFS_INTERNAL_FOP_KEY, "yes"); \ + if (tmp) { \ + gf_msg(this->name, GF_LOG_ERROR, 0, DHT_MSG_DICT_SET_FAILED, \ + "Failed to set dictionary value: key = %s," \ + " path = %s", \ + GLUSTERFS_INTERNAL_FOP_KEY, local->loc.path); \ + } \ + } while (0) + +dht_layout_t * +dht_layout_new(xlator_t *this, int cnt); +dht_layout_t * +dht_layout_get(xlator_t *this, inode_t *inode); +dht_layout_t * +dht_layout_for_subvol(xlator_t *this, xlator_t *subvol); +xlator_t * +dht_layout_search(xlator_t *this, dht_layout_t *layout, const char *name); int32_t -dht_migration_get_dst_subvol(xlator_t *this, dht_local_t *local); +dht_migration_get_dst_subvol(xlator_t *this, dht_local_t *local); int32_t dht_migration_needed(xlator_t *this); -int dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout); -int dht_layout_anomalies (xlator_t *this, loc_t *loc, dht_layout_t *layout, - uint32_t *holes_p, uint32_t *overlaps_p, - uint32_t *missing_p, uint32_t *down_p, - uint32_t *misc_p, uint32_t *no_space_p); -int dht_layout_dir_mismatch (xlator_t *this, dht_layout_t *layout, - xlator_t *subvol, loc_t *loc, dict_t *xattr); +int +dht_layout_normalize(xlator_t *this, loc_t *loc, dht_layout_t *layout); +int +dht_layout_anomalies(xlator_t *this, loc_t *loc, dht_layout_t *layout, + uint32_t *holes_p, uint32_t *overlaps_p, + uint32_t *missing_p, uint32_t *down_p, uint32_t *misc_p, + uint32_t *no_space_p); +int +dht_layout_dir_mismatch(xlator_t *this, dht_layout_t *layout, xlator_t *subvol, + loc_t *loc, dict_t *xattr); -xlator_t *dht_linkfile_subvol (xlator_t *this, inode_t *inode, - struct iatt *buf, dict_t *xattr); -int dht_linkfile_unlink (call_frame_t *frame, xlator_t *this, - xlator_t *subvol, loc_t *loc); +xlator_t * +dht_linkfile_subvol(xlator_t *this, inode_t *inode, struct iatt *buf, + dict_t *xattr); +int +dht_linkfile_unlink(call_frame_t *frame, xlator_t *this, xlator_t *subvol, + loc_t *loc); -int dht_layouts_init (xlator_t *this, dht_conf_t *conf); -int dht_layout_merge (xlator_t *this, dht_layout_t *layout, xlator_t *subvol, - int op_ret, int op_errno, dict_t *xattr); +int +dht_layouts_init(xlator_t *this, dht_conf_t *conf); +int +dht_layout_merge(xlator_t *this, dht_layout_t *layout, xlator_t *subvol, + int op_ret, int op_errno, dict_t *xattr); -int dht_disk_layout_extract (xlator_t *this, dht_layout_t *layout, - int pos, int32_t **disk_layout_p); -int dht_disk_layout_merge (xlator_t *this, dht_layout_t *layout, - int pos, void *disk_layout_raw, int disk_layout_len); int -dht_disk_layout_extract_for_subvol (xlator_t *this, dht_layout_t *layout, - xlator_t *subvol, int32_t **disk_layout_p); +dht_disk_layout_extract(xlator_t *this, dht_layout_t *layout, int pos, + int32_t **disk_layout_p); +int +dht_disk_layout_merge(xlator_t *this, dht_layout_t *layout, int pos, + void *disk_layout_raw, int disk_layout_len); +int +dht_disk_layout_extract_for_subvol(xlator_t *this, dht_layout_t *layout, + xlator_t *subvol, int32_t **disk_layout_p); -int dht_frame_return (call_frame_t *frame); +int +dht_frame_return(call_frame_t *frame); -int dht_deitransform (xlator_t *this, uint64_t y, xlator_t **subvol); +int +dht_deitransform(xlator_t *this, uint64_t y, xlator_t **subvol); -void dht_local_wipe (xlator_t *this, dht_local_t *local); -dht_local_t *dht_local_init (call_frame_t *frame, loc_t *loc, fd_t *fd, - glusterfs_fop_t fop); -int dht_iatt_merge (xlator_t *this, struct iatt *to, struct iatt *from); +void +dht_local_wipe(xlator_t *this, dht_local_t *local); +dht_local_t * +dht_local_init(call_frame_t *frame, loc_t *loc, fd_t *fd, glusterfs_fop_t fop); +int +dht_iatt_merge(xlator_t *this, struct iatt *to, struct iatt *from); -xlator_t *dht_subvol_get_hashed (xlator_t *this, loc_t *loc); -xlator_t *dht_subvol_get_cached (xlator_t *this, inode_t *inode); -xlator_t *dht_subvol_next (xlator_t *this, xlator_t *prev); -xlator_t *dht_subvol_next_available (xlator_t *this, xlator_t *prev); -int dht_subvol_cnt (xlator_t *this, xlator_t *subvol); +xlator_t * +dht_subvol_get_hashed(xlator_t *this, loc_t *loc); +xlator_t * +dht_subvol_get_cached(xlator_t *this, inode_t *inode); +xlator_t * +dht_subvol_next(xlator_t *this, xlator_t *prev); +xlator_t * +dht_subvol_next_available(xlator_t *this, xlator_t *prev); +int +dht_subvol_cnt(xlator_t *this, xlator_t *subvol); -int dht_hash_compute (xlator_t *this, int type, const char *name, uint32_t *hash_p); +int +dht_hash_compute(xlator_t *this, int type, const char *name, uint32_t *hash_p); -int dht_linkfile_create (call_frame_t *frame, fop_mknod_cbk_t linkfile_cbk, - xlator_t *this, xlator_t *tovol, - xlator_t *fromvol, loc_t *loc); -int dht_lookup_directory (call_frame_t *frame, xlator_t *this, loc_t *loc); -int dht_lookup_everywhere (call_frame_t *frame, xlator_t *this, loc_t *loc); int -dht_selfheal_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t cbk, - loc_t *loc, dht_layout_t *layout); +dht_linkfile_create(call_frame_t *frame, fop_mknod_cbk_t linkfile_cbk, + xlator_t *this, xlator_t *tovol, xlator_t *fromvol, + loc_t *loc); +int +dht_lookup_directory(call_frame_t *frame, xlator_t *this, loc_t *loc); +int +dht_lookup_everywhere(call_frame_t *frame, xlator_t *this, loc_t *loc); +int +dht_selfheal_directory(call_frame_t *frame, dht_selfheal_dir_cbk_t cbk, + loc_t *loc, dht_layout_t *layout); int -dht_selfheal_directory_for_nameless_lookup (call_frame_t *frame, - dht_selfheal_dir_cbk_t cbk, - loc_t *loc, dht_layout_t *layout); +dht_selfheal_directory_for_nameless_lookup(call_frame_t *frame, + dht_selfheal_dir_cbk_t cbk, + loc_t *loc, dht_layout_t *layout); int -dht_selfheal_new_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t cbk, - dht_layout_t *layout); +dht_selfheal_new_directory(call_frame_t *frame, dht_selfheal_dir_cbk_t cbk, + dht_layout_t *layout); int -dht_selfheal_restore (call_frame_t *frame, dht_selfheal_dir_cbk_t cbk, - loc_t *loc, dht_layout_t *layout); +dht_selfheal_restore(call_frame_t *frame, dht_selfheal_dir_cbk_t cbk, + loc_t *loc, dht_layout_t *layout); int -dht_layout_sort_volname (dht_layout_t *layout); +dht_layout_sort_volname(dht_layout_t *layout); -int dht_get_du_info (call_frame_t *frame, xlator_t *this, loc_t *loc); +int +dht_get_du_info(call_frame_t *frame, xlator_t *this, loc_t *loc); -gf_boolean_t dht_is_subvol_filled (xlator_t *this, xlator_t *subvol); -xlator_t *dht_free_disk_available_subvol (xlator_t *this, xlator_t *subvol, - dht_local_t *layout); -int dht_get_du_info_for_subvol (xlator_t *this, int subvol_idx); +gf_boolean_t +dht_is_subvol_filled(xlator_t *this, xlator_t *subvol); +xlator_t * +dht_free_disk_available_subvol(xlator_t *this, xlator_t *subvol, + dht_local_t *layout); +int +dht_get_du_info_for_subvol(xlator_t *this, int subvol_idx); -int dht_layout_preset (xlator_t *this, xlator_t *subvol, inode_t *inode); -int dht_layout_index_for_subvol (dht_layout_t *layout, xlator_t *subvol); -int dht_layout_set (xlator_t *this, inode_t *inode, dht_layout_t *layout);; -void dht_layout_unref (xlator_t *this, dht_layout_t *layout); -dht_layout_t *dht_layout_ref (xlator_t *this, dht_layout_t *layout); -xlator_t *dht_first_up_subvol (xlator_t *this); -xlator_t *dht_last_up_subvol (xlator_t *this); +int +dht_layout_preset(xlator_t *this, xlator_t *subvol, inode_t *inode); +int +dht_layout_index_for_subvol(dht_layout_t *layout, xlator_t *subvol); +int +dht_layout_set(xlator_t *this, inode_t *inode, dht_layout_t *layout); +; +void +dht_layout_unref(xlator_t *this, dht_layout_t *layout); +dht_layout_t * +dht_layout_ref(xlator_t *this, dht_layout_t *layout); +xlator_t * +dht_first_up_subvol(xlator_t *this); +xlator_t * +dht_last_up_subvol(xlator_t *this); -int dht_build_child_loc (xlator_t *this, loc_t *child, loc_t *parent, char *name); +int +dht_build_child_loc(xlator_t *this, loc_t *child, loc_t *parent, char *name); -int dht_filter_loc_subvol_key (xlator_t *this, loc_t *loc, loc_t *new_loc, - xlator_t **subvol); +int +dht_filter_loc_subvol_key(xlator_t *this, loc_t *loc, loc_t *new_loc, + xlator_t **subvol); -int dht_rename_cleanup (call_frame_t *frame); -int dht_rename_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, - inode_t *inode, struct iatt *stbuf, - struct iatt *preparent, struct iatt *postparent, - dict_t *xdata); +int +dht_rename_cleanup(call_frame_t *frame); +int +dht_rename_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, inode_t *inode, + struct iatt *stbuf, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata); -int dht_update_commit_hash_for_layout (call_frame_t *frame); -int dht_fix_directory_layout (call_frame_t *frame, - dht_selfheal_dir_cbk_t dir_cbk, - dht_layout_t *layout); +int +dht_update_commit_hash_for_layout(call_frame_t *frame); +int +dht_fix_directory_layout(call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk, + dht_layout_t *layout); -int dht_init_subvolumes (xlator_t *this, dht_conf_t *conf); +int +dht_init_subvolumes(xlator_t *this, dht_conf_t *conf); /* migration/rebalance */ -int dht_start_rebalance_task (xlator_t *this, call_frame_t *frame); +int +dht_start_rebalance_task(xlator_t *this, call_frame_t *frame); -int dht_rebalance_in_progress_check (xlator_t *this, call_frame_t *frame); -int dht_rebalance_complete_check (xlator_t *this, call_frame_t *frame); +int +dht_rebalance_in_progress_check(xlator_t *this, call_frame_t *frame); +int +dht_rebalance_complete_check(xlator_t *this, call_frame_t *frame); int -dht_init_local_subvolumes (xlator_t *this, dht_conf_t *conf); +dht_init_local_subvolumes(xlator_t *this, dht_conf_t *conf); /* FOPS */ -int32_t dht_lookup (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - dict_t *xattr_req); - -int32_t dht_stat (call_frame_t *frame, - xlator_t *this, - loc_t *loc, dict_t *xdata); - -int32_t dht_fstat (call_frame_t *frame, - xlator_t *this, - fd_t *fd, dict_t *xdata); - -int32_t dht_truncate (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - off_t offset, dict_t *xdata); - -int32_t dht_ftruncate (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - off_t offset, dict_t *xdata); - -int32_t dht_access (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - int32_t mask, dict_t *xdata); - -int32_t dht_readlink (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - size_t size, dict_t *xdata); - -int32_t dht_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, - mode_t mode, dev_t rdev, mode_t umask, dict_t *xdata); - -int32_t dht_mkdir (call_frame_t *frame, xlator_t *this, - loc_t *loc, mode_t mode, mode_t umask, dict_t *xdata); - -int32_t dht_unlink (call_frame_t *frame, - xlator_t *this, - loc_t *loc, int xflag, dict_t *xdata); - -int32_t dht_rmdir (call_frame_t *frame, xlator_t *this, - loc_t *loc, int flags, dict_t *xdata); - -int32_t dht_symlink (call_frame_t *frame, xlator_t *this, - const char *linkpath, loc_t *loc, mode_t umask, - dict_t *xdata); - -int32_t dht_rename (call_frame_t *frame, - xlator_t *this, - loc_t *oldloc, - loc_t *newloc, dict_t *xdata); - -int32_t dht_link (call_frame_t *frame, - xlator_t *this, - loc_t *oldloc, - loc_t *newloc, dict_t *xdata); - -int32_t dht_create (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t flags, mode_t mode, - mode_t umask, fd_t *fd, dict_t *params); - -int32_t dht_open (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - int32_t flags, fd_t *fd, dict_t *xdata); - -int32_t dht_readv (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - size_t size, - off_t offset, uint32_t flags, dict_t *xdata); - -int32_t dht_writev (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - struct iovec *vector, - int32_t count, - off_t offset, - uint32_t flags, - struct iobref *iobref, dict_t *xdata); - -int32_t dht_flush (call_frame_t *frame, - xlator_t *this, - fd_t *fd, dict_t *xdata); - -int32_t dht_fsync (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - int32_t datasync, dict_t *xdata); - -int32_t dht_opendir (call_frame_t *frame, - xlator_t *this, - loc_t *loc, fd_t *fd, dict_t *xdata); - -int32_t dht_fsyncdir (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - int32_t datasync, dict_t *xdata); - -int32_t dht_statfs (call_frame_t *frame, - xlator_t *this, - loc_t *loc, dict_t *xdata); - -int32_t dht_setxattr (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - dict_t *dict, - int32_t flags, dict_t *xdata); - -int32_t dht_getxattr (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - const char *name, dict_t *xdata); - -int32_t dht_fsetxattr (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - dict_t *dict, - int32_t flags, dict_t *xdata); - -int32_t dht_fgetxattr (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - const char *name, dict_t *xdata); - -int32_t dht_removexattr (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - const char *name, dict_t *xdata); -int32_t dht_fremovexattr (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - const char *name, dict_t *xdata); - -int32_t dht_lk (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - int32_t cmd, - struct gf_flock *flock, dict_t *xdata); - -int32_t dht_lease (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - struct gf_lease *lease, dict_t *xdata); - -int32_t dht_inodelk (call_frame_t *frame, xlator_t *this, - const char *volume, loc_t *loc, int32_t cmd, - struct gf_flock *flock, dict_t *xdata); - -int32_t dht_finodelk (call_frame_t *frame, xlator_t *this, - const char *volume, fd_t *fd, int32_t cmd, - struct gf_flock *flock, dict_t *xdata); - -int32_t dht_entrylk (call_frame_t *frame, xlator_t *this, - const char *volume, loc_t *loc, const char *basename, - entrylk_cmd cmd, entrylk_type type, dict_t *xdata); - -int32_t dht_fentrylk (call_frame_t *frame, xlator_t *this, - const char *volume, fd_t *fd, const char *basename, - entrylk_cmd cmd, entrylk_type type, dict_t *xdata); - -int32_t dht_readdir (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - size_t size, off_t off, dict_t *xdata); - -int32_t dht_readdirp (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - size_t size, off_t off, dict_t *dict); - -int32_t dht_xattrop (call_frame_t *frame, - xlator_t *this, - loc_t *loc, - gf_xattrop_flags_t flags, - dict_t *dict, dict_t *xdata); - -int32_t dht_fxattrop (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - gf_xattrop_flags_t flags, - dict_t *dict, dict_t *xdata); - -int32_t dht_forget (xlator_t *this, inode_t *inode); -int32_t dht_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - struct iatt *stbuf, int32_t valid, dict_t *xdata); -int32_t dht_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - struct iatt *stbuf, int32_t valid, dict_t *xdata); -int32_t dht_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, - int32_t mode, off_t offset, size_t len, dict_t *xdata); -int32_t dht_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, - off_t offset, size_t len, dict_t *xdata); -int32_t dht_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, - off_t offset, off_t len, dict_t *xdata); -int32_t dht_ipc (call_frame_t *frame, xlator_t *this, int32_t op, - dict_t *xdata); +int32_t +dht_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req); + +int32_t +dht_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); + +int32_t +dht_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata); + +int32_t +dht_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, + dict_t *xdata); + +int32_t +dht_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + dict_t *xdata); + +int32_t +dht_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, + dict_t *xdata); + +int32_t +dht_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, + dict_t *xdata); + +int32_t +dht_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dev_t rdev, mode_t umask, dict_t *xdata); + +int32_t +dht_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + mode_t umask, dict_t *xdata); + +int32_t +dht_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, + dict_t *xdata); + +int32_t +dht_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata); + +int32_t +dht_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, + loc_t *loc, mode_t umask, dict_t *xdata); + +int32_t +dht_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); + +int32_t +dht_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); + +int32_t +dht_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + mode_t mode, mode_t umask, fd_t *fd, dict_t *params); + +int32_t +dht_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + fd_t *fd, dict_t *xdata); + +int32_t +dht_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t offset, uint32_t flags, dict_t *xdata); + +int32_t +dht_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, + int32_t count, off_t offset, uint32_t flags, struct iobref *iobref, + dict_t *xdata); + +int32_t +dht_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata); + +int32_t +dht_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync, + dict_t *xdata); + +int32_t +dht_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + dict_t *xdata); + +int32_t +dht_fsyncdir(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync, + dict_t *xdata); + +int32_t +dht_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); + +int32_t +dht_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + int32_t flags, dict_t *xdata); + +int32_t +dht_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, + dict_t *xdata); + +int32_t +dht_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, + int32_t flags, dict_t *xdata); + +int32_t +dht_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, + dict_t *xdata); + +int32_t +dht_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata); +int32_t +dht_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name, dict_t *xdata); + +int32_t +dht_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, + struct gf_flock *flock, dict_t *xdata); + +int32_t +dht_lease(call_frame_t *frame, xlator_t *this, loc_t *loc, + struct gf_lease *lease, dict_t *xdata); + +int32_t +dht_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, + int32_t cmd, struct gf_flock *flock, dict_t *xdata); + +int32_t +dht_finodelk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, + int32_t cmd, struct gf_flock *flock, dict_t *xdata); + +int32_t +dht_entrylk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, + const char *basename, entrylk_cmd cmd, entrylk_type type, + dict_t *xdata); + +int32_t +dht_fentrylk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, + const char *basename, entrylk_cmd cmd, entrylk_type type, + dict_t *xdata); + +int32_t +dht_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t off, dict_t *xdata); + +int32_t +dht_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t off, dict_t *dict); + +int32_t +dht_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata); + +int32_t +dht_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata); + +int32_t +dht_forget(xlator_t *this, inode_t *inode); +int32_t +dht_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf, + int32_t valid, dict_t *xdata); +int32_t +dht_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf, + int32_t valid, dict_t *xdata); +int32_t +dht_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata); +int32_t +dht_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, dict_t *xdata); +int32_t +dht_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + off_t len, dict_t *xdata); +int32_t +dht_ipc(call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata); int dht_set_subvol_range(xlator_t *this); -int32_t dht_init (xlator_t *this); -void dht_fini (xlator_t *this); -int dht_reconfigure (xlator_t *this, dict_t *options); -int32_t dht_notify (xlator_t *this, int32_t event, void *data, ...); +int32_t +dht_init(xlator_t *this); +void +dht_fini(xlator_t *this); +int +dht_reconfigure(xlator_t *this, dict_t *options); +int32_t +dht_notify(xlator_t *this, int32_t event, void *data, ...); /* definitions for nufa/switch */ -int dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, inode_t *inode, - struct iatt *stbuf, dict_t *xattr, - struct iatt *postparent); -int dht_lookup_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +int +dht_revalidate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, inode_t *inode, struct iatt *stbuf, + dict_t *xattr, struct iatt *postparent); +int +dht_lookup_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, inode_t *inode, struct iatt *stbuf, + dict_t *xattr, struct iatt *postparent); +int +dht_lookup_linkfile_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, inode_t *inode, struct iatt *stbuf, dict_t *xattr, struct iatt *postparent); -int dht_lookup_linkfile_cbk (call_frame_t *frame, void *cookie, - xlator_t *this, int op_ret, int op_errno, - inode_t *inode, struct iatt *stbuf, dict_t *xattr, - struct iatt *postparent); -int dht_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - inode_t *inode, struct iatt *stbuf, dict_t *xattr, - struct iatt *postparent); -int dht_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - fd_t *fd, inode_t *inode, struct iatt *stbuf, - struct iatt *preparent, struct iatt *postparent, - dict_t *xdata); -int dht_newfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - inode_t *inode, struct iatt *stbuf, struct iatt *preparent, - struct iatt *postparent, dict_t *xdata); - -int -gf_defrag_status_get (dht_conf_t *conf, dict_t *dict); +int +dht_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, inode_t *inode, struct iatt *stbuf, dict_t *xattr, + struct iatt *postparent); +int +dht_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, fd_t *fd, inode_t *inode, struct iatt *stbuf, + struct iatt *preparent, struct iatt *postparent, dict_t *xdata); +int +dht_newfile_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, inode_t *inode, struct iatt *stbuf, + struct iatt *preparent, struct iatt *postparent, dict_t *xdata); + +int +gf_defrag_status_get(dht_conf_t *conf, dict_t *dict); void -gf_defrag_set_pause_state (gf_tier_conf_t *tier_conf, tier_pause_state_t state); +gf_defrag_set_pause_state(gf_tier_conf_t *tier_conf, tier_pause_state_t state); tier_pause_state_t -gf_defrag_get_pause_state (gf_tier_conf_t *tier_conf); +gf_defrag_get_pause_state(gf_tier_conf_t *tier_conf); int -gf_defrag_pause_tier (xlator_t *this, gf_defrag_info_t *defrag); +gf_defrag_pause_tier(xlator_t *this, gf_defrag_info_t *defrag); tier_pause_state_t -gf_defrag_check_pause_tier (gf_tier_conf_t *defrag); +gf_defrag_check_pause_tier(gf_tier_conf_t *defrag); int -gf_defrag_resume_tier (xlator_t *this, gf_defrag_info_t *defrag); +gf_defrag_resume_tier(xlator_t *this, gf_defrag_info_t *defrag); int -gf_defrag_start_detach_tier (gf_defrag_info_t *defrag); +gf_defrag_start_detach_tier(gf_defrag_info_t *defrag); int -gf_defrag_stop (dht_conf_t *conf, gf_defrag_status_t status, - dict_t *output); +gf_defrag_stop(dht_conf_t *conf, gf_defrag_status_t status, dict_t *output); -void* -gf_defrag_start (void *this); +void * +gf_defrag_start(void *this); int32_t -gf_defrag_handle_hardlink (xlator_t *this, loc_t *loc, int *fop_errno); +gf_defrag_handle_hardlink(xlator_t *this, loc_t *loc, int *fop_errno); int -dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to, +dht_migrate_file(xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to, int flag, int *fop_errno); int -dht_inode_ctx_layout_get (inode_t *inode, xlator_t *this, - dht_layout_t **layout_int); +dht_inode_ctx_layout_get(inode_t *inode, xlator_t *this, + dht_layout_t **layout_int); int -dht_inode_ctx_layout_set (inode_t *inode, xlator_t *this, - dht_layout_t* layout_int); +dht_inode_ctx_layout_set(inode_t *inode, xlator_t *this, + dht_layout_t *layout_int); int -dht_inode_ctx_time_update (inode_t *inode, xlator_t *this, struct iatt *stat, - int32_t update_ctx); -void dht_inode_ctx_time_set (inode_t *inode, xlator_t *this, struct iatt *stat); +dht_inode_ctx_time_update(inode_t *inode, xlator_t *this, struct iatt *stat, + int32_t update_ctx); +void +dht_inode_ctx_time_set(inode_t *inode, xlator_t *this, struct iatt *stat); -int dht_inode_ctx_get (inode_t *inode, xlator_t *this, dht_inode_ctx_t **ctx); -int dht_inode_ctx_set (inode_t *inode, xlator_t *this, dht_inode_ctx_t *ctx); int -dht_dir_attr_heal (void *data); +dht_inode_ctx_get(inode_t *inode, xlator_t *this, dht_inode_ctx_t **ctx); int -dht_dir_attr_heal_done (int ret, call_frame_t *sync_frame, void *data); +dht_inode_ctx_set(inode_t *inode, xlator_t *this, dht_inode_ctx_t *ctx); int -dht_dir_has_layout (dict_t *xattr, char *name); +dht_dir_attr_heal(void *data); +int +dht_dir_attr_heal_done(int ret, call_frame_t *sync_frame, void *data); +int +dht_dir_has_layout(dict_t *xattr, char *name); gf_boolean_t -dht_is_subvol_in_layout (dht_layout_t *layout, xlator_t *xlator); +dht_is_subvol_in_layout(dht_layout_t *layout, xlator_t *xlator); xlator_t * -dht_subvol_with_free_space_inodes (xlator_t *this, xlator_t *subvol, xlator_t *ignore, - dht_layout_t *layout, uint64_t filesize); +dht_subvol_with_free_space_inodes(xlator_t *this, xlator_t *subvol, + xlator_t *ignore, dht_layout_t *layout, + uint64_t filesize); xlator_t * -dht_subvol_maxspace_nonzeroinode (xlator_t *this, xlator_t *subvol, - dht_layout_t *layout); +dht_subvol_maxspace_nonzeroinode(xlator_t *this, xlator_t *subvol, + dht_layout_t *layout); int -dht_linkfile_attr_heal (call_frame_t *frame, xlator_t *this); +dht_linkfile_attr_heal(call_frame_t *frame, xlator_t *this); void -dht_layout_dump (dht_layout_t *layout, const char *prefix); +dht_layout_dump(dht_layout_t *layout, const char *prefix); int32_t -dht_priv_dump (xlator_t *this); +dht_priv_dump(xlator_t *this); int32_t -dht_inodectx_dump (xlator_t *this, inode_t *inode); +dht_inodectx_dump(xlator_t *this, inode_t *inode); int -dht_inode_ctx_get_mig_info (xlator_t *this, inode_t *inode, - xlator_t **src_subvol, xlator_t **dst_subvol); +dht_inode_ctx_get_mig_info(xlator_t *this, inode_t *inode, + xlator_t **src_subvol, xlator_t **dst_subvol); gf_boolean_t -dht_mig_info_is_invalid (xlator_t *current, xlator_t *src_subvol, - xlator_t *dst_subvol); +dht_mig_info_is_invalid(xlator_t *current, xlator_t *src_subvol, + xlator_t *dst_subvol); int -dht_subvol_status (dht_conf_t *conf, xlator_t *subvol); +dht_subvol_status(dht_conf_t *conf, xlator_t *subvol); void -dht_log_new_layout_for_dir_selfheal (xlator_t *this, loc_t *loc, - dht_layout_t *layout); +dht_log_new_layout_for_dir_selfheal(xlator_t *this, loc_t *loc, + dht_layout_t *layout); int -dht_lookup_everywhere_done (call_frame_t *frame, xlator_t *this); +dht_lookup_everywhere_done(call_frame_t *frame, xlator_t *this); int -dht_fill_dict_to_avoid_unlink_of_migrating_file (dict_t *dict); +dht_fill_dict_to_avoid_unlink_of_migrating_file(dict_t *dict); int -dht_layout_sort (dht_layout_t *layout); +dht_layout_sort(dht_layout_t *layout); int -dht_heal_full_path (void *data); +dht_heal_full_path(void *data); int -dht_heal_full_path_done (int op_ret, call_frame_t *frame, void *data); +dht_heal_full_path_done(int op_ret, call_frame_t *frame, void *data); int -dht_layout_missing_dirs (dht_layout_t *layout); +dht_layout_missing_dirs(dht_layout_t *layout); int -dht_refresh_layout (call_frame_t *frame); +dht_refresh_layout(call_frame_t *frame); gf_boolean_t -dht_is_tier_xlator (xlator_t *this); +dht_is_tier_xlator(xlator_t *this); int -dht_build_parent_loc (xlator_t *this, loc_t *parent, loc_t *child, - int32_t *op_errno); +dht_build_parent_loc(xlator_t *this, loc_t *parent, loc_t *child, + int32_t *op_errno); int32_t -dht_set_local_rebalance (xlator_t *this, dht_local_t *local, - struct iatt *stbuf, - struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +dht_set_local_rebalance(xlator_t *this, dht_local_t *local, struct iatt *stbuf, + struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata); void -dht_build_root_loc (inode_t *inode, loc_t *loc); +dht_build_root_loc(inode_t *inode, loc_t *loc); gf_boolean_t -dht_fd_open_on_dst (xlator_t *this, fd_t *fd, xlator_t *dst); +dht_fd_open_on_dst(xlator_t *this, fd_t *fd, xlator_t *dst); int32_t -dht_fd_ctx_destroy (xlator_t *this, fd_t *fd); +dht_fd_ctx_destroy(xlator_t *this, fd_t *fd); int32_t -dht_release (xlator_t *this, fd_t *fd); - +dht_release(xlator_t *this, fd_t *fd); int32_t -dht_set_fixed_dir_stat (struct iatt *stat); +dht_set_fixed_dir_stat(struct iatt *stat); -xlator_t* -dht_get_lock_subvolume (xlator_t *this, struct gf_flock *lock, - dht_local_t *local); +xlator_t * +dht_get_lock_subvolume(xlator_t *this, struct gf_flock *lock, + dht_local_t *local); int -dht_lk_inode_unref (call_frame_t *frame, int32_t op_ret); +dht_lk_inode_unref(call_frame_t *frame, int32_t op_ret); void -dht_normalize_stats (struct statvfs *buf, unsigned long bsize, - unsigned long frsize); +dht_normalize_stats(struct statvfs *buf, unsigned long bsize, + unsigned long frsize); int add_opt(char **optsp, const char *opt); int -dht_aggregate_split_brain_xattr (dict_t *dst, char *key, data_t *value); +dht_aggregate_split_brain_xattr(dict_t *dst, char *key, data_t *value); int -dht_remove_stale_linkto (void *data); +dht_remove_stale_linkto(void *data); int -dht_remove_stale_linkto_cbk (int ret, call_frame_t *sync_frame, void *data); +dht_remove_stale_linkto_cbk(int ret, call_frame_t *sync_frame, void *data); int -dht_fd_ctx_set (xlator_t *this, fd_t *fd, xlator_t *subvol); +dht_fd_ctx_set(xlator_t *this, fd_t *fd, xlator_t *subvol); int -dht_check_and_open_fd_on_subvol (xlator_t *this, call_frame_t *frame); +dht_check_and_open_fd_on_subvol(xlator_t *this, call_frame_t *frame); /* FD fop callbacks */ int -dht_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +dht_writev_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata); int -dht_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, dict_t *xdata); +dht_flush_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, dict_t *xdata); int -dht_file_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +dht_file_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata); int -dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +dht_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata); int -dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +dht_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata); int -dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +dht_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata); int -dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +dht_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata); int -dht_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, - int op_errno, struct iatt *prebuf, struct iatt *postbuf, - dict_t *xdata); - +dht_fsync_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata); int -dht_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - struct iovec *vector, int count, struct iatt *stbuf, - struct iobref *iobref, dict_t *xdata); +dht_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iovec *vector, int count, struct iatt *stbuf, + struct iobref *iobref, dict_t *xdata); int -dht_file_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *stbuf, dict_t *xdata); +dht_file_attr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *stbuf, dict_t *xdata); int -dht_file_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, dict_t *xdata); +dht_file_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata); int -dht_file_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, dict_t *xdata); +dht_file_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata); /* All custom xattr heal functions */ int -dht_dir_heal_xattrs (void *data); +dht_dir_heal_xattrs(void *data); int -dht_dir_heal_xattrs_done (int ret, call_frame_t *sync_frame, void *data); +dht_dir_heal_xattrs_done(int ret, call_frame_t *sync_frame, void *data); void -dht_aggregate_xattr (dict_t *dst, dict_t *src); +dht_aggregate_xattr(dict_t *dst, dict_t *src); int32_t dht_dict_set_array(dict_t *dict, char *key, int32_t value[], int32_t size); int -dht_set_user_xattr (dict_t *dict, char *k, data_t *v, void *data); +dht_set_user_xattr(dict_t *dict, char *k, data_t *v, void *data); void -dht_dir_set_heal_xattr (xlator_t *this, dht_local_t *local, dict_t *dst, - dict_t *src, int *uret, int *uflag); +dht_dir_set_heal_xattr(xlator_t *this, dht_local_t *local, dict_t *dst, + dict_t *src, int *uret, int *uflag); int -dht_dir_xattr_heal (xlator_t *this, dht_local_t *local); +dht_dir_xattr_heal(xlator_t *this, dht_local_t *local); int32_t -dht_dict_get_array (dict_t *dict, char *key, int32_t value[], int32_t size, int *errst); +dht_dict_get_array(dict_t *dict, char *key, int32_t value[], int32_t size, + int *errst); xlator_t * -dht_inode_get_hashed_subvol (inode_t *inode, xlator_t *this, loc_t *loc); +dht_inode_get_hashed_subvol(inode_t *inode, xlator_t *this, loc_t *loc); int -dht_common_mark_mdsxattr (call_frame_t *frame, int *errst, int flag); +dht_common_mark_mdsxattr(call_frame_t *frame, int *errst, int flag); int -dht_common_mark_mdsxattr_cbk (call_frame_t *frame, void *cookie, - xlator_t *this, int op_ret, int op_errno, - dict_t *xdata); +dht_common_mark_mdsxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *xdata); int -dht_inode_ctx_mdsvol_set (inode_t *inode, xlator_t *this, - xlator_t *mds_subvol); +dht_inode_ctx_mdsvol_set(inode_t *inode, xlator_t *this, xlator_t *mds_subvol); int -dht_inode_ctx_mdsvol_get (inode_t *inode, xlator_t *this, - xlator_t **mdsvol); +dht_inode_ctx_mdsvol_get(inode_t *inode, xlator_t *this, xlator_t **mdsvol); int -dht_selfheal_dir_setattr (call_frame_t *frame, loc_t *loc, struct iatt *stbuf, - int32_t valid, dht_layout_t *layout); +dht_selfheal_dir_setattr(call_frame_t *frame, loc_t *loc, struct iatt *stbuf, + int32_t valid, dht_layout_t *layout); /* Abstract out the DHT-IATT-IN-DICT */ +int +dht_request_iatt_in_xdata(xlator_t *this, dict_t *xattr_req); -int dht_request_iatt_in_xdata (xlator_t *this, dict_t *xattr_req); - -int dht_read_iatt_from_xdata (xlator_t *this, dict_t *xdata, - struct iatt *stbuf); +int +dht_read_iatt_from_xdata(xlator_t *this, dict_t *xdata, struct iatt *stbuf); int -is_permission_different (ia_prot_t *prot1, ia_prot_t *prot2); -#endif/* _DHT_H */ +is_permission_different(ia_prot_t *prot1, ia_prot_t *prot2); +#endif /* _DHT_H */ diff --git a/xlators/cluster/dht/src/dht-lock.h b/xlators/cluster/dht/src/dht-lock.h index f36bf3fd685..802970adb3b 100644 --- a/xlators/cluster/dht/src/dht-lock.h +++ b/xlators/cluster/dht/src/dht-lock.h @@ -15,32 +15,32 @@ #include "dht-common.h" void -dht_lock_array_free (dht_lock_t **lk_array, int count); +dht_lock_array_free(dht_lock_t **lk_array, int count); int32_t -dht_lock_count (dht_lock_t **lk_array, int lk_count); +dht_lock_count(dht_lock_t **lk_array, int lk_count); dht_lock_t * -dht_lock_new (xlator_t *this, xlator_t *xl, loc_t *loc, short type, - const char *domain, const char *basename, - dht_reaction_type_t do_on_failure); +dht_lock_new(xlator_t *this, xlator_t *xl, loc_t *loc, short type, + const char *domain, const char *basename, + dht_reaction_type_t do_on_failure); int32_t -dht_unlock_entrylk_wrapper (call_frame_t *, dht_elock_wrap_t *); +dht_unlock_entrylk_wrapper(call_frame_t *, dht_elock_wrap_t *); void -dht_blocking_entrylk_rec (call_frame_t *frame, int i); +dht_blocking_entrylk_rec(call_frame_t *frame, int i); int -dht_blocking_entrylk (call_frame_t *frame, dht_lock_t **lk_array, - int lk_count, fop_inodelk_cbk_t entrylk_cbk); +dht_blocking_entrylk(call_frame_t *frame, dht_lock_t **lk_array, int lk_count, + fop_inodelk_cbk_t entrylk_cbk); int32_t -dht_unlock_inodelk (call_frame_t *frame, dht_lock_t **lk_array, int lk_count, - fop_inodelk_cbk_t inodelk_cbk); +dht_unlock_inodelk(call_frame_t *frame, dht_lock_t **lk_array, int lk_count, + fop_inodelk_cbk_t inodelk_cbk); int32_t -dht_unlock_inodelk_wrapper (call_frame_t *, dht_ilock_wrap_t *); +dht_unlock_inodelk_wrapper(call_frame_t *, dht_ilock_wrap_t *); /* Acquire non-blocking inodelk on a list of xlators. * @@ -57,11 +57,11 @@ dht_unlock_inodelk_wrapper (call_frame_t *, dht_ilock_wrap_t *); */ int -dht_nonblocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, - int lk_count, fop_inodelk_cbk_t inodelk_cbk); +dht_nonblocking_inodelk(call_frame_t *frame, dht_lock_t **lk_array, + int lk_count, fop_inodelk_cbk_t inodelk_cbk); void -dht_blocking_inodelk_rec (call_frame_t *frame, int i); +dht_blocking_inodelk_rec(call_frame_t *frame, int i); /* same as dht_nonblocking_inodelk, but issues sequential blocking locks on * @lk_array directly. locks are issued on some order which remains same @@ -69,25 +69,24 @@ dht_blocking_inodelk_rec (call_frame_t *frame, int i); */ int -dht_blocking_inodelk (call_frame_t *frame, dht_lock_t **lk_array, - int lk_count, fop_inodelk_cbk_t inodelk_cbk); +dht_blocking_inodelk(call_frame_t *frame, dht_lock_t **lk_array, int lk_count, + fop_inodelk_cbk_t inodelk_cbk); int32_t -dht_blocking_entrylk_after_inodelk (call_frame_t *frame, void *cookie, - xlator_t *this, int32_t op_ret, - int32_t op_errno, dict_t *xdata); +dht_blocking_entrylk_after_inodelk(call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, + int32_t op_errno, dict_t *xdata); int32_t -dht_blocking_entrylk_after_inodelk_rename (call_frame_t *frame, void *cookie, - xlator_t *this, int32_t op_ret, - int32_t op_errno, dict_t *xdata); +dht_blocking_entrylk_after_inodelk_rename(call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, + int32_t op_errno, dict_t *xdata); void -dht_unlock_namespace (call_frame_t *, dht_dir_transaction_t *); +dht_unlock_namespace(call_frame_t *, dht_dir_transaction_t *); int -dht_protect_namespace (call_frame_t *frame, loc_t *loc, xlator_t *subvol, - struct dht_namespace *ns, - fop_entrylk_cbk_t ns_cbk); +dht_protect_namespace(call_frame_t *frame, loc_t *loc, xlator_t *subvol, + struct dht_namespace *ns, fop_entrylk_cbk_t ns_cbk); -#endif /* _DHT_LOCK_H */ +#endif /* _DHT_LOCK_H */ diff --git a/xlators/cluster/dht/src/dht-mem-types.h b/xlators/cluster/dht/src/dht-mem-types.h index 19cccef537b..5b728f86c95 100644 --- a/xlators/cluster/dht/src/dht-mem-types.h +++ b/xlators/cluster/dht/src/dht-mem-types.h @@ -8,38 +8,37 @@ cases as published by the Free Software Foundation. */ - #ifndef __DHT_MEM_TYPES_H__ #define __DHT_MEM_TYPES_H__ #include "mem-types.h" enum gf_dht_mem_types_ { - gf_dht_mt_dht_du_t = gf_common_mt_end + 1, - gf_dht_mt_dht_conf_t, - gf_dht_mt_char, - gf_dht_mt_int32_t, - gf_dht_mt_xlator_t, - gf_dht_mt_dht_layout_t, - gf_switch_mt_dht_conf_t, - gf_switch_mt_dht_du_t, - gf_switch_mt_switch_sched_array, - gf_switch_mt_switch_struct, - gf_dht_mt_subvol_time, - gf_dht_mt_loc_t, - gf_defrag_info_mt, - gf_dht_mt_inode_ctx_t, - gf_dht_mt_ctx_stat_time_t, - gf_dht_mt_dirent_t, - gf_dht_mt_container_t, - gf_dht_mt_octx_t, - gf_dht_mt_miginfo_t, - gf_tier_mt_bricklist_t, - gf_tier_mt_ipc_ctr_params_t, - gf_dht_mt_fd_ctx_t, - gf_tier_mt_qfile_array_t, - gf_dht_ret_cache_t, - gf_dht_nodeuuids_t, - gf_dht_mt_end + gf_dht_mt_dht_du_t = gf_common_mt_end + 1, + gf_dht_mt_dht_conf_t, + gf_dht_mt_char, + gf_dht_mt_int32_t, + gf_dht_mt_xlator_t, + gf_dht_mt_dht_layout_t, + gf_switch_mt_dht_conf_t, + gf_switch_mt_dht_du_t, + gf_switch_mt_switch_sched_array, + gf_switch_mt_switch_struct, + gf_dht_mt_subvol_time, + gf_dht_mt_loc_t, + gf_defrag_info_mt, + gf_dht_mt_inode_ctx_t, + gf_dht_mt_ctx_stat_time_t, + gf_dht_mt_dirent_t, + gf_dht_mt_container_t, + gf_dht_mt_octx_t, + gf_dht_mt_miginfo_t, + gf_tier_mt_bricklist_t, + gf_tier_mt_ipc_ctr_params_t, + gf_dht_mt_fd_ctx_t, + gf_tier_mt_qfile_array_t, + gf_dht_ret_cache_t, + gf_dht_nodeuuids_t, + gf_dht_mt_end }; #endif diff --git a/xlators/cluster/dht/src/dht-messages.h b/xlators/cluster/dht/src/dht-messages.h index bdea5a092b7..005ab57b505 100644 --- a/xlators/cluster/dht/src/dht-messages.h +++ b/xlators/cluster/dht/src/dht-messages.h @@ -22,136 +22,63 @@ * glfs-message-id.h. */ -GLFS_MSGID(DHT, - DHT_MSG_CACHED_SUBVOL_GET_FAILED, - DHT_MSG_CREATE_LINK_FAILED, - DHT_MSG_DICT_SET_FAILED, - DHT_MSG_DIR_ATTR_HEAL_FAILED, - DHT_MSG_DIR_SELFHEAL_FAILED, - DHT_MSG_DIR_SELFHEAL_XATTR_FAILED, - DHT_MSG_FILE_ON_MULT_SUBVOL, - DHT_MSG_FILE_TYPE_MISMATCH, - DHT_MSG_GFID_MISMATCH, - DHT_MSG_GFID_NULL, - DHT_MSG_HASHED_SUBVOL_GET_FAILED, - DHT_MSG_INIT_FAILED, - DHT_MSG_INVALID_CONFIGURATION, - DHT_MSG_INVALID_DISK_LAYOUT, - DHT_MSG_INVALID_OPTION, - DHT_MSG_LAYOUT_FIX_FAILED, - DHT_MSG_LAYOUT_MERGE_FAILED, - DHT_MSG_LAYOUT_MISMATCH, - DHT_MSG_LAYOUT_NULL, - DHT_MSG_MIGRATE_DATA_COMPLETE, - DHT_MSG_MIGRATE_DATA_FAILED, - DHT_MSG_MIGRATE_FILE_COMPLETE, - DHT_MSG_MIGRATE_FILE_FAILED, - DHT_MSG_NO_MEMORY, - DHT_MSG_OPENDIR_FAILED, - DHT_MSG_REBALANCE_FAILED, - DHT_MSG_REBALANCE_START_FAILED, - DHT_MSG_REBALANCE_STATUS, - DHT_MSG_REBALANCE_STOPPED, - DHT_MSG_RENAME_FAILED, - DHT_MSG_SETATTR_FAILED, - DHT_MSG_SUBVOL_INSUFF_INODES, - DHT_MSG_SUBVOL_INSUFF_SPACE, - DHT_MSG_UNLINK_FAILED, - DHT_MSG_LAYOUT_SET_FAILED, - DHT_MSG_LOG_FIXED_LAYOUT, - DHT_MSG_LOG_TIER_ERROR, - DHT_MSG_LOG_TIER_STATUS, - DHT_MSG_GET_XATTR_FAILED, - DHT_MSG_FILE_LOOKUP_FAILED, - DHT_MSG_OPEN_FD_FAILED, - DHT_MSG_SET_INODE_CTX_FAILED, - DHT_MSG_UNLOCKING_FAILED, - DHT_MSG_DISK_LAYOUT_NULL, - DHT_MSG_SUBVOL_INFO, - DHT_MSG_CHUNK_SIZE_INFO, - DHT_MSG_LAYOUT_FORM_FAILED, - DHT_MSG_SUBVOL_ERROR, - DHT_MSG_LAYOUT_SORT_FAILED, - DHT_MSG_REGEX_INFO, - DHT_MSG_FOPEN_FAILED, - DHT_MSG_SET_HOSTNAME_FAILED, - DHT_MSG_BRICK_ERROR, - DHT_MSG_SYNCOP_FAILED, - DHT_MSG_MIGRATE_INFO, - DHT_MSG_SOCKET_ERROR, - DHT_MSG_CREATE_FD_FAILED, - DHT_MSG_READDIR_ERROR, - DHT_MSG_CHILD_LOC_BUILD_FAILED, - DHT_MSG_SET_SWITCH_PATTERN_ERROR, - DHT_MSG_COMPUTE_HASH_FAILED, - DHT_MSG_FIND_LAYOUT_ANOMALIES_ERROR, - DHT_MSG_ANOMALIES_INFO, - DHT_MSG_LAYOUT_INFO, - DHT_MSG_INODE_LK_ERROR, - DHT_MSG_RENAME_INFO, - DHT_MSG_DATA_NULL, - DHT_MSG_AGGREGATE_QUOTA_XATTR_FAILED, - DHT_MSG_UNLINK_LOOKUP_INFO, - DHT_MSG_LINK_FILE_LOOKUP_INFO, - DHT_MSG_OPERATION_NOT_SUP, - DHT_MSG_NOT_LINK_FILE_ERROR, - DHT_MSG_CHILD_DOWN, - DHT_MSG_UUID_PARSE_ERROR, - DHT_MSG_GET_DISK_INFO_ERROR, - DHT_MSG_INVALID_VALUE, - DHT_MSG_SWITCH_PATTERN_INFO, - DHT_MSG_SUBVOL_OP_FAILED, - DHT_MSG_LAYOUT_PRESET_FAILED, - DHT_MSG_INVALID_LINKFILE, - DHT_MSG_FIX_LAYOUT_INFO, - DHT_MSG_GET_HOSTNAME_FAILED, - DHT_MSG_WRITE_FAILED, - DHT_MSG_MIGRATE_HARDLINK_FILE_FAILED, - DHT_MSG_FSYNC_FAILED, - DHT_MSG_SUBVOL_DECOMMISSION_INFO, - DHT_MSG_BRICK_QUERY_FAILED, - DHT_MSG_SUBVOL_NO_LAYOUT_INFO, - DHT_MSG_OPEN_FD_ON_DST_FAILED, - DHT_MSG_SUBVOL_NOT_FOUND, - DHT_MSG_FILE_LOOKUP_ON_DST_FAILED, - DHT_MSG_DISK_LAYOUT_MISSING, - DHT_MSG_DICT_GET_FAILED, - DHT_MSG_REVALIDATE_CBK_INFO, - DHT_MSG_UPGRADE_BRICKS, - DHT_MSG_LK_ARRAY_INFO, - DHT_MSG_RENAME_NOT_LOCAL, - DHT_MSG_RECONFIGURE_INFO, - DHT_MSG_INIT_LOCAL_SUBVOL_FAILED, - DHT_MSG_SYS_CALL_GET_TIME_FAILED, - DHT_MSG_NO_DISK_USAGE_STATUS, - DHT_MSG_SUBVOL_DOWN_ERROR, - DHT_MSG_REBAL_THROTTLE_INFO, - DHT_MSG_COMMIT_HASH_INFO, - DHT_MSG_REBAL_STRUCT_SET, - DHT_MSG_HAS_MIGINFO, - DHT_MSG_LOG_IPC_TIER_ERROR, - DHT_MSG_TIER_PAUSED, - DHT_MSG_TIER_RESUME, - DHT_MSG_SETTLE_HASH_FAILED, - DHT_MSG_DEFRAG_PROCESS_DIR_FAILED, - DHT_MSG_FD_CTX_SET_FAILED, - DHT_MSG_STALE_LOOKUP, - DHT_MSG_PARENT_LAYOUT_CHANGED, - DHT_MSG_LOCK_MIGRATION_FAILED, - DHT_MSG_LOCK_INODE_UNREF_FAILED, - DHT_MSG_ASPRINTF_FAILED, - DHT_MSG_DIR_LOOKUP_FAILED, - DHT_MSG_INODELK_FAILED, - DHT_MSG_LOCK_FRAME_FAILED, - DHT_MSG_LOCAL_LOCK_INIT_FAILED, - DHT_MSG_ENTRYLK_ERROR, - DHT_MSG_INODELK_ERROR, - DHT_MSG_LOC_FAILED, - DHT_MSG_UNKNOWN_FOP, - DHT_MSG_MIGRATE_FILE_SKIPPED, - DHT_MSG_DIR_XATTR_HEAL_FAILED, - DHT_MSG_HASHED_SUBVOL_DOWN, - DHT_MSG_NON_HASHED_SUBVOL_DOWN -); +GLFS_MSGID( + DHT, DHT_MSG_CACHED_SUBVOL_GET_FAILED, DHT_MSG_CREATE_LINK_FAILED, + DHT_MSG_DICT_SET_FAILED, DHT_MSG_DIR_ATTR_HEAL_FAILED, + DHT_MSG_DIR_SELFHEAL_FAILED, DHT_MSG_DIR_SELFHEAL_XATTR_FAILED, + DHT_MSG_FILE_ON_MULT_SUBVOL, DHT_MSG_FILE_TYPE_MISMATCH, + DHT_MSG_GFID_MISMATCH, DHT_MSG_GFID_NULL, DHT_MSG_HASHED_SUBVOL_GET_FAILED, + DHT_MSG_INIT_FAILED, DHT_MSG_INVALID_CONFIGURATION, + DHT_MSG_INVALID_DISK_LAYOUT, DHT_MSG_INVALID_OPTION, + DHT_MSG_LAYOUT_FIX_FAILED, DHT_MSG_LAYOUT_MERGE_FAILED, + DHT_MSG_LAYOUT_MISMATCH, DHT_MSG_LAYOUT_NULL, DHT_MSG_MIGRATE_DATA_COMPLETE, + DHT_MSG_MIGRATE_DATA_FAILED, DHT_MSG_MIGRATE_FILE_COMPLETE, + DHT_MSG_MIGRATE_FILE_FAILED, DHT_MSG_NO_MEMORY, DHT_MSG_OPENDIR_FAILED, + DHT_MSG_REBALANCE_FAILED, DHT_MSG_REBALANCE_START_FAILED, + DHT_MSG_REBALANCE_STATUS, DHT_MSG_REBALANCE_STOPPED, DHT_MSG_RENAME_FAILED, + DHT_MSG_SETATTR_FAILED, DHT_MSG_SUBVOL_INSUFF_INODES, + DHT_MSG_SUBVOL_INSUFF_SPACE, DHT_MSG_UNLINK_FAILED, + DHT_MSG_LAYOUT_SET_FAILED, DHT_MSG_LOG_FIXED_LAYOUT, DHT_MSG_LOG_TIER_ERROR, + DHT_MSG_LOG_TIER_STATUS, DHT_MSG_GET_XATTR_FAILED, + DHT_MSG_FILE_LOOKUP_FAILED, DHT_MSG_OPEN_FD_FAILED, + DHT_MSG_SET_INODE_CTX_FAILED, DHT_MSG_UNLOCKING_FAILED, + DHT_MSG_DISK_LAYOUT_NULL, DHT_MSG_SUBVOL_INFO, DHT_MSG_CHUNK_SIZE_INFO, + DHT_MSG_LAYOUT_FORM_FAILED, DHT_MSG_SUBVOL_ERROR, + DHT_MSG_LAYOUT_SORT_FAILED, DHT_MSG_REGEX_INFO, DHT_MSG_FOPEN_FAILED, + DHT_MSG_SET_HOSTNAME_FAILED, DHT_MSG_BRICK_ERROR, DHT_MSG_SYNCOP_FAILED, + DHT_MSG_MIGRATE_INFO, DHT_MSG_SOCKET_ERROR, DHT_MSG_CREATE_FD_FAILED, + DHT_MSG_READDIR_ERROR, DHT_MSG_CHILD_LOC_BUILD_FAILED, + DHT_MSG_SET_SWITCH_PATTERN_ERROR, DHT_MSG_COMPUTE_HASH_FAILED, + DHT_MSG_FIND_LAYOUT_ANOMALIES_ERROR, DHT_MSG_ANOMALIES_INFO, + DHT_MSG_LAYOUT_INFO, DHT_MSG_INODE_LK_ERROR, DHT_MSG_RENAME_INFO, + DHT_MSG_DATA_NULL, DHT_MSG_AGGREGATE_QUOTA_XATTR_FAILED, + DHT_MSG_UNLINK_LOOKUP_INFO, DHT_MSG_LINK_FILE_LOOKUP_INFO, + DHT_MSG_OPERATION_NOT_SUP, DHT_MSG_NOT_LINK_FILE_ERROR, DHT_MSG_CHILD_DOWN, + DHT_MSG_UUID_PARSE_ERROR, DHT_MSG_GET_DISK_INFO_ERROR, + DHT_MSG_INVALID_VALUE, DHT_MSG_SWITCH_PATTERN_INFO, + DHT_MSG_SUBVOL_OP_FAILED, DHT_MSG_LAYOUT_PRESET_FAILED, + DHT_MSG_INVALID_LINKFILE, DHT_MSG_FIX_LAYOUT_INFO, + DHT_MSG_GET_HOSTNAME_FAILED, DHT_MSG_WRITE_FAILED, + DHT_MSG_MIGRATE_HARDLINK_FILE_FAILED, DHT_MSG_FSYNC_FAILED, + DHT_MSG_SUBVOL_DECOMMISSION_INFO, DHT_MSG_BRICK_QUERY_FAILED, + DHT_MSG_SUBVOL_NO_LAYOUT_INFO, DHT_MSG_OPEN_FD_ON_DST_FAILED, + DHT_MSG_SUBVOL_NOT_FOUND, DHT_MSG_FILE_LOOKUP_ON_DST_FAILED, + DHT_MSG_DISK_LAYOUT_MISSING, DHT_MSG_DICT_GET_FAILED, + DHT_MSG_REVALIDATE_CBK_INFO, DHT_MSG_UPGRADE_BRICKS, DHT_MSG_LK_ARRAY_INFO, + DHT_MSG_RENAME_NOT_LOCAL, DHT_MSG_RECONFIGURE_INFO, + DHT_MSG_INIT_LOCAL_SUBVOL_FAILED, DHT_MSG_SYS_CALL_GET_TIME_FAILED, + DHT_MSG_NO_DISK_USAGE_STATUS, DHT_MSG_SUBVOL_DOWN_ERROR, + DHT_MSG_REBAL_THROTTLE_INFO, DHT_MSG_COMMIT_HASH_INFO, + DHT_MSG_REBAL_STRUCT_SET, DHT_MSG_HAS_MIGINFO, DHT_MSG_LOG_IPC_TIER_ERROR, + DHT_MSG_TIER_PAUSED, DHT_MSG_TIER_RESUME, DHT_MSG_SETTLE_HASH_FAILED, + DHT_MSG_DEFRAG_PROCESS_DIR_FAILED, DHT_MSG_FD_CTX_SET_FAILED, + DHT_MSG_STALE_LOOKUP, DHT_MSG_PARENT_LAYOUT_CHANGED, + DHT_MSG_LOCK_MIGRATION_FAILED, DHT_MSG_LOCK_INODE_UNREF_FAILED, + DHT_MSG_ASPRINTF_FAILED, DHT_MSG_DIR_LOOKUP_FAILED, DHT_MSG_INODELK_FAILED, + DHT_MSG_LOCK_FRAME_FAILED, DHT_MSG_LOCAL_LOCK_INIT_FAILED, + DHT_MSG_ENTRYLK_ERROR, DHT_MSG_INODELK_ERROR, DHT_MSG_LOC_FAILED, + DHT_MSG_UNKNOWN_FOP, DHT_MSG_MIGRATE_FILE_SKIPPED, + DHT_MSG_DIR_XATTR_HEAL_FAILED, DHT_MSG_HASHED_SUBVOL_DOWN, + DHT_MSG_NON_HASHED_SUBVOL_DOWN); #endif /* _DHT_MESSAGES_H_ */ diff --git a/xlators/cluster/dht/src/tier-common.h b/xlators/cluster/dht/src/tier-common.h index 26e01d7f141..b1ebaa8004d 100644 --- a/xlators/cluster/dht/src/tier-common.h +++ b/xlators/cluster/dht/src/tier-common.h @@ -12,57 +12,44 @@ #define _TIER_COMMON_H_ /* Function definitions */ int -tier_create_unlink_stale_linkto_cbk (call_frame_t *frame, void *cookie, - xlator_t *this, int op_ret, int op_errno, - struct iatt *preparent, - struct iatt *postparent, dict_t *xdata); +tier_create_unlink_stale_linkto_cbk(call_frame_t *frame, void *cookie, + xlator_t *this, int op_ret, int op_errno, + struct iatt *preparent, + struct iatt *postparent, dict_t *xdata); int -tier_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, - fd_t *fd, inode_t *inode, struct iatt *stbuf, - struct iatt *preparent, struct iatt *postparent, - dict_t *xdata); +tier_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, fd_t *fd, inode_t *inode, struct iatt *stbuf, + struct iatt *preparent, struct iatt *postparent, dict_t *xdata); int -tier_create_linkfile_create_cbk (call_frame_t *frame, void *cookie, - xlator_t *this, - int32_t op_ret, int32_t op_errno, - inode_t *inode, struct iatt *stbuf, - struct iatt *preparent, - struct iatt *postparent, - dict_t *xdata); +tier_create_linkfile_create_cbk(call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, + int32_t op_errno, inode_t *inode, + struct iatt *stbuf, struct iatt *preparent, + struct iatt *postparent, dict_t *xdata); int -tier_create (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t flags, mode_t mode, - mode_t umask, fd_t *fd, dict_t *params); +tier_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + mode_t mode, mode_t umask, fd_t *fd, dict_t *params); int32_t -tier_unlink (call_frame_t *frame, xlator_t *this, - loc_t *loc, int xflag, dict_t *xdata); +tier_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, + dict_t *xdata); int32_t -tier_readdirp (call_frame_t *frame, - xlator_t *this, - fd_t *fd, - size_t size, off_t off, dict_t *dict); +tier_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t off, dict_t *dict); int -tier_readdir (call_frame_t *frame, - xlator_t *this, fd_t *fd, size_t size, - off_t yoff, dict_t *xdata); - - +tier_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, + off_t yoff, dict_t *xdata); int -tier_link (call_frame_t *frame, xlator_t *this, - loc_t *oldloc, loc_t *newloc, dict_t *xdata); - +tier_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); int -tier_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); - +tier_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata); #endif - diff --git a/xlators/cluster/dht/src/tier.h b/xlators/cluster/dht/src/tier.h index ce08fb5a669..f0ffdfcd769 100644 --- a/xlators/cluster/dht/src/tier.h +++ b/xlators/cluster/dht/src/tier.h @@ -11,7 +11,6 @@ #ifndef _TIER_H_ #define _TIER_H_ - /******************************************************************************/ /* This is from dht-rebalancer.c as we don't have dht-rebalancer.h */ #include "dht-common.h" @@ -33,80 +32,79 @@ #define PROMOTION_QFILE "promotequeryfile" #define DEMOTION_QFILE "demotequeryfile" -#define TIER_HASHED_SUBVOL conf->subvolumes[0] -#define TIER_UNHASHED_SUBVOL conf->subvolumes[1] +#define TIER_HASHED_SUBVOL conf->subvolumes[0] +#define TIER_UNHASHED_SUBVOL conf->subvolumes[1] -#define GET_QFILE_PATH(is_promotion)\ - (is_promotion) ? promotion_qfile : demotion_qfile +#define GET_QFILE_PATH(is_promotion) \ + (is_promotion) ? promotion_qfile : demotion_qfile typedef struct tier_qfile_array { - int *fd_array; - ssize_t array_size; - ssize_t next_index; - /* Indicate the number of exhuasted FDs*/ - ssize_t exhausted_count; + int *fd_array; + ssize_t array_size; + ssize_t next_index; + /* Indicate the number of exhuasted FDs*/ + ssize_t exhausted_count; } tier_qfile_array_t; - typedef struct _query_cbk_args { - xlator_t *this; - gf_defrag_info_t *defrag; - /* This is write */ - int query_fd; - int is_promotion; - int is_compaction; - /* This is for read */ - tier_qfile_array_t *qfile_array; + xlator_t *this; + gf_defrag_info_t *defrag; + /* This is write */ + int query_fd; + int is_promotion; + int is_compaction; + /* This is for read */ + tier_qfile_array_t *qfile_array; } query_cbk_args_t; int gf_run_tier(xlator_t *this, gf_defrag_info_t *defrag); typedef struct gfdb_brick_info { - gfdb_time_t *time_stamp; - gf_boolean_t _gfdb_promote; - query_cbk_args_t *_query_cbk_args; + gfdb_time_t *time_stamp; + gf_boolean_t _gfdb_promote; + query_cbk_args_t *_query_cbk_args; } gfdb_brick_info_t; typedef struct brick_list { - xlator_t *xlator; - char *brick_db_path; - char brick_name[NAME_MAX]; - char qfile_path[PATH_MAX]; - struct list_head list; + xlator_t *xlator; + char *brick_db_path; + char brick_name[NAME_MAX]; + char qfile_path[PATH_MAX]; + struct list_head list; } tier_brick_list_t; typedef struct _dm_thread_args { - xlator_t *this; - gf_defrag_info_t *defrag; - struct list_head *brick_list; - int freq_time; - int return_value; - int is_promotion; - int is_compaction; - gf_boolean_t is_hot_tier; + xlator_t *this; + gf_defrag_info_t *defrag; + struct list_head *brick_list; + int freq_time; + int return_value; + int is_promotion; + int is_compaction; + gf_boolean_t is_hot_tier; } migration_args_t; typedef enum tier_watermark_op_ { - TIER_WM_NONE = 0, - TIER_WM_LOW, - TIER_WM_HI, - TIER_WM_MID + TIER_WM_NONE = 0, + TIER_WM_LOW, + TIER_WM_HI, + TIER_WM_MID } tier_watermark_op_t; -#define DEFAULT_PROMOTE_FREQ_SEC 120 -#define DEFAULT_DEMOTE_FREQ_SEC 120 -#define DEFAULT_HOT_COMPACT_FREQ_SEC 604800 -#define DEFAULT_COLD_COMPACT_FREQ_SEC 604800 -#define DEFAULT_DEMOTE_DEGRADED 1 -#define DEFAULT_WRITE_FREQ_SEC 0 -#define DEFAULT_READ_FREQ_SEC 0 -#define DEFAULT_WM_LOW 75 -#define DEFAULT_WM_HI 90 -#define DEFAULT_TIER_MODE TIER_MODE_TEST -#define DEFAULT_COMP_MODE _gf_true -#define DEFAULT_TIER_MAX_MIGRATE_MB 1000 +#define DEFAULT_PROMOTE_FREQ_SEC 120 +#define DEFAULT_DEMOTE_FREQ_SEC 120 +#define DEFAULT_HOT_COMPACT_FREQ_SEC 604800 +#define DEFAULT_COLD_COMPACT_FREQ_SEC 604800 +#define DEFAULT_DEMOTE_DEGRADED 1 +#define DEFAULT_WRITE_FREQ_SEC 0 +#define DEFAULT_READ_FREQ_SEC 0 +#define DEFAULT_WM_LOW 75 +#define DEFAULT_WM_HI 90 +#define DEFAULT_TIER_MODE TIER_MODE_TEST +#define DEFAULT_COMP_MODE _gf_true +#define DEFAULT_TIER_MAX_MIGRATE_MB 1000 #define DEFAULT_TIER_MAX_MIGRATE_FILES 5000 -#define DEFAULT_TIER_QUERY_LIMIT 100 +#define DEFAULT_TIER_QUERY_LIMIT 100 #endif diff --git a/xlators/cluster/ec/src/ec-code-c.h b/xlators/cluster/ec/src/ec-code-c.h index 92e8070e514..42b5a064eb8 100644 --- a/xlators/cluster/ec/src/ec-code-c.h +++ b/xlators/cluster/ec/src/ec-code-c.h @@ -13,12 +13,15 @@ #include "ec-types.h" -void ec_code_c_prepare(ec_gf_t *gf, uint32_t *values, uint32_t count); +void +ec_code_c_prepare(ec_gf_t *gf, uint32_t *values, uint32_t count); -void ec_code_c_linear(void *dst, void *src, uint64_t offset, uint32_t *values, - uint32_t count); +void +ec_code_c_linear(void *dst, void *src, uint64_t offset, uint32_t *values, + uint32_t count); -void ec_code_c_interleaved(void *dst, void **src, uint64_t offset, - uint32_t *values, uint32_t count); +void +ec_code_c_interleaved(void *dst, void **src, uint64_t offset, uint32_t *values, + uint32_t count); #endif /* __EC_CODE_C_H__ */ diff --git a/xlators/cluster/ec/src/ec-code-intel.h b/xlators/cluster/ec/src/ec-code-intel.h index 903d023f962..3fa4a174765 100644 --- a/xlators/cluster/ec/src/ec-code-intel.h +++ b/xlators/cluster/ec/src/ec-code-intel.h @@ -76,109 +76,116 @@ enum _ec_code_vex_opcode { struct _ec_code_intel_buffer { uint32_t bytes; union { - uint8_t data[4]; + uint8_t data[4]; uint32_t value; }; }; struct _ec_code_intel_sib { gf_boolean_t present; - uint32_t base; - uint32_t index; - uint32_t scale; + uint32_t base; + uint32_t index; + uint32_t scale; }; struct _ec_code_intel_modrm { gf_boolean_t present; - uint32_t mod; - uint32_t rm; - uint32_t reg; + uint32_t mod; + uint32_t rm; + uint32_t reg; }; struct _ec_code_intel_rex { gf_boolean_t present; - uint32_t w; - uint32_t r; - uint32_t x; - uint32_t b; + uint32_t w; + uint32_t r; + uint32_t x; + uint32_t b; }; struct _ec_code_intel { - gf_boolean_t invalid; + gf_boolean_t invalid; ec_code_intel_buffer_t prefix; ec_code_intel_buffer_t opcode; ec_code_intel_buffer_t offset; ec_code_intel_buffer_t immediate; ec_code_intel_buffer_t vex; - ec_code_intel_rex_t rex; - ec_code_intel_modrm_t modrm; - ec_code_intel_sib_t sib; - uint32_t reg; + ec_code_intel_rex_t rex; + ec_code_intel_modrm_t modrm; + ec_code_intel_sib_t sib; + uint32_t reg; }; -void ec_code_intel_op_push_r(ec_code_builder_t *builder, - ec_code_intel_reg_t reg); -void ec_code_intel_op_pop_r(ec_code_builder_t *builder, - ec_code_intel_reg_t reg); -void ec_code_intel_op_ret(ec_code_builder_t *builder, uint32_t size); - -void ec_code_intel_op_mov_r2r(ec_code_builder_t *builder, - ec_code_intel_reg_t src, - ec_code_intel_reg_t dst); -void ec_code_intel_op_mov_r2m(ec_code_builder_t *builder, - ec_code_intel_reg_t src, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset); -void ec_code_intel_op_mov_m2r(ec_code_builder_t *builder, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset, ec_code_intel_reg_t dst); -void ec_code_intel_op_xor_r2r(ec_code_builder_t *builder, - ec_code_intel_reg_t src, - ec_code_intel_reg_t dst); -void ec_code_intel_op_xor_m2r(ec_code_builder_t *builder, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset, ec_code_intel_reg_t dst); -void ec_code_intel_op_add_i2r(ec_code_builder_t *builder, int32_t value, - ec_code_intel_reg_t reg); -void ec_code_intel_op_test_i2r(ec_code_builder_t *builder, uint32_t value, - ec_code_intel_reg_t reg); -void ec_code_intel_op_jne(ec_code_builder_t *builder, uint32_t address); - -void ec_code_intel_op_mov_sse2sse(ec_code_builder_t *builder, uint32_t src, - uint32_t dst); -void ec_code_intel_op_mov_sse2m(ec_code_builder_t *builder, uint32_t src, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset); -void ec_code_intel_op_mov_m2sse(ec_code_builder_t *builder, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset, uint32_t dst); -void ec_code_intel_op_xor_sse2sse(ec_code_builder_t *builder, uint32_t src, - uint32_t dst); -void ec_code_intel_op_xor_m2sse(ec_code_builder_t *builder, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset, uint32_t dst); - -void ec_code_intel_op_mov_avx2avx(ec_code_builder_t *builder, uint32_t src, - uint32_t dst); -void ec_code_intel_op_mov_avx2m(ec_code_builder_t *builder, uint32_t src, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset); -void ec_code_intel_op_mov_m2avx(ec_code_builder_t *builder, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset, uint32_t dst); -void ec_code_intel_op_xor_avx2avx(ec_code_builder_t *builder, uint32_t src, - uint32_t dst); -void ec_code_intel_op_xor_m2avx(ec_code_builder_t *builder, - ec_code_intel_reg_t base, - ec_code_intel_reg_t index, uint32_t scale, - int32_t offset, uint32_t dst); +void +ec_code_intel_op_push_r(ec_code_builder_t *builder, ec_code_intel_reg_t reg); +void +ec_code_intel_op_pop_r(ec_code_builder_t *builder, ec_code_intel_reg_t reg); +void +ec_code_intel_op_ret(ec_code_builder_t *builder, uint32_t size); + +void +ec_code_intel_op_mov_r2r(ec_code_builder_t *builder, ec_code_intel_reg_t src, + ec_code_intel_reg_t dst); +void +ec_code_intel_op_mov_r2m(ec_code_builder_t *builder, ec_code_intel_reg_t src, + ec_code_intel_reg_t base, ec_code_intel_reg_t index, + uint32_t scale, int32_t offset); +void +ec_code_intel_op_mov_m2r(ec_code_builder_t *builder, ec_code_intel_reg_t base, + ec_code_intel_reg_t index, uint32_t scale, + int32_t offset, ec_code_intel_reg_t dst); +void +ec_code_intel_op_xor_r2r(ec_code_builder_t *builder, ec_code_intel_reg_t src, + ec_code_intel_reg_t dst); +void +ec_code_intel_op_xor_m2r(ec_code_builder_t *builder, ec_code_intel_reg_t base, + ec_code_intel_reg_t index, uint32_t scale, + int32_t offset, ec_code_intel_reg_t dst); +void +ec_code_intel_op_add_i2r(ec_code_builder_t *builder, int32_t value, + ec_code_intel_reg_t reg); +void +ec_code_intel_op_test_i2r(ec_code_builder_t *builder, uint32_t value, + ec_code_intel_reg_t reg); +void +ec_code_intel_op_jne(ec_code_builder_t *builder, uint32_t address); + +void +ec_code_intel_op_mov_sse2sse(ec_code_builder_t *builder, uint32_t src, + uint32_t dst); +void +ec_code_intel_op_mov_sse2m(ec_code_builder_t *builder, uint32_t src, + ec_code_intel_reg_t base, ec_code_intel_reg_t index, + uint32_t scale, int32_t offset); +void +ec_code_intel_op_mov_m2sse(ec_code_builder_t *builder, ec_code_intel_reg_t base, + ec_code_intel_reg_t index, uint32_t scale, + int32_t offset, uint32_t dst); +void +ec_code_intel_op_xor_sse2sse(ec_code_builder_t *builder, uint32_t src, + uint32_t dst); +void +ec_code_intel_op_xor_m2sse(ec_code_builder_t *builder, ec_code_intel_reg_t base, + ec_code_intel_reg_t index, uint32_t scale, + int32_t offset, uint32_t dst); + +void +ec_code_intel_op_mov_avx2avx(ec_code_builder_t *builder, uint32_t src, + uint32_t dst); +void +ec_code_intel_op_mov_avx2m(ec_code_builder_t *builder, uint32_t src, + ec_code_intel_reg_t base, ec_code_intel_reg_t index, + uint32_t scale, int32_t offset); +void +ec_code_intel_op_mov_m2avx(ec_code_builder_t *builder, ec_code_intel_reg_t base, + ec_code_intel_reg_t index, uint32_t scale, + int32_t offset, uint32_t dst); +void +ec_code_intel_op_xor_avx2avx(ec_code_builder_t *builder, uint32_t src, + uint32_t dst); +void +ec_code_intel_op_xor_m2avx(ec_code_builder_t *builder, ec_code_intel_reg_t base, + ec_code_intel_reg_t index, uint32_t scale, + int32_t offset, uint32_t dst); #endif /* __EC_CODE_INTEL_H__ */ diff --git a/xlators/cluster/ec/src/ec-combine.h b/xlators/cluster/ec/src/ec-combine.h index 19a42ded706..1010cc3be26 100644 --- a/xlators/cluster/ec/src/ec-combine.h +++ b/xlators/cluster/ec/src/ec-combine.h @@ -11,28 +11,34 @@ #ifndef __EC_COMBINE_H__ #define __EC_COMBINE_H__ -#define EC_COMBINE_DICT 0 +#define EC_COMBINE_DICT 0 #define EC_COMBINE_XDATA 1 -typedef int32_t (* ec_combine_f)(ec_fop_data_t * fop, ec_cbk_data_t * dst, - ec_cbk_data_t * src); +typedef int32_t (*ec_combine_f)(ec_fop_data_t *fop, ec_cbk_data_t *dst, + ec_cbk_data_t *src); -void ec_iatt_rebuild(ec_t * ec, struct iatt * iatt, int32_t count, - int32_t answers); +void +ec_iatt_rebuild(ec_t *ec, struct iatt *iatt, int32_t count, int32_t answers); -int32_t ec_iatt_combine(ec_fop_data_t *fop, struct iatt *dst, struct iatt *src, - int32_t count); -int32_t ec_dict_compare(dict_t * dict1, dict_t * dict2); -int32_t ec_vector_compare(struct iovec * dst_vector, int32_t dst_count, - struct iovec * src_vector, int32_t src_count); -int32_t ec_flock_compare(struct gf_flock * dst, struct gf_flock * src); -void ec_statvfs_combine(struct statvfs * dst, struct statvfs * src); +int32_t +ec_iatt_combine(ec_fop_data_t *fop, struct iatt *dst, struct iatt *src, + int32_t count); +int32_t +ec_dict_compare(dict_t *dict1, dict_t *dict2); +int32_t +ec_vector_compare(struct iovec *dst_vector, int32_t dst_count, + struct iovec *src_vector, int32_t src_count); +int32_t +ec_flock_compare(struct gf_flock *dst, struct gf_flock *src); +void +ec_statvfs_combine(struct statvfs *dst, struct statvfs *src); -int32_t ec_dict_combine(ec_cbk_data_t * cbk, int32_t which); +int32_t +ec_dict_combine(ec_cbk_data_t *cbk, int32_t which); -void ec_combine(ec_cbk_data_t * cbk, ec_combine_f combine); +void +ec_combine(ec_cbk_data_t *cbk, ec_combine_f combine); int32_t -ec_combine_write (ec_fop_data_t *fop, ec_cbk_data_t *dst, - ec_cbk_data_t *src); +ec_combine_write(ec_fop_data_t *fop, ec_cbk_data_t *dst, ec_cbk_data_t *src); #endif /* __EC_COMBINE_H__ */ diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h index a92752952ad..bea0c045a47 100644 --- a/xlators/cluster/ec/src/ec-common.h +++ b/xlators/cluster/ec/src/ec-common.h @@ -15,29 +15,26 @@ #include "ec-data.h" -typedef enum { - EC_DATA_TXN, - EC_METADATA_TXN -} ec_txn_t; +typedef enum { EC_DATA_TXN, EC_METADATA_TXN } ec_txn_t; -#define EC_FOP_HEAL -1 -#define EC_FOP_FHEAL -2 +#define EC_FOP_HEAL -1 +#define EC_FOP_FHEAL -2 #define EC_CONFIG_VERSION 0 #define EC_CONFIG_ALGORITHM 0 -#define EC_FLAG_LOCK_SHARED 0x0001 +#define EC_FLAG_LOCK_SHARED 0x0001 enum _ec_xattrop_flags { - EC_FLAG_XATTROP, - EC_FLAG_DATA_DIRTY, - EC_FLAG_METADATA_DIRTY, + EC_FLAG_XATTROP, + EC_FLAG_DATA_DIRTY, + EC_FLAG_METADATA_DIRTY, - /* Add any new flag here, before EC_FLAG_MAX. The maximum number of - * flags that can be defined is 16. */ + /* Add any new flag here, before EC_FLAG_MAX. The maximum number of + * flags that can be defined is 16. */ - EC_FLAG_MAX + EC_FLAG_MAX }; /* We keep two sets of flags. One to determine what's really providing the @@ -57,57 +54,63 @@ enum _ec_xattrop_flags { #define EC_SELFHEAL_BIT 62 -#define EC_MINIMUM_ONE -1 -#define EC_MINIMUM_MIN -2 -#define EC_MINIMUM_ALL -3 - -#define EC_UPDATE_DATA 1 -#define EC_UPDATE_META 2 -#define EC_QUERY_INFO 4 -#define EC_INODE_SIZE 8 - -#define EC_STATE_START 0 -#define EC_STATE_END 0 -#define EC_STATE_INIT 1 -#define EC_STATE_LOCK 2 -#define EC_STATE_DISPATCH 3 -#define EC_STATE_PREPARE_ANSWER 4 -#define EC_STATE_REPORT 5 -#define EC_STATE_LOCK_REUSE 6 -#define EC_STATE_UNLOCK 7 - -#define EC_STATE_DELAYED_START 100 - -#define EC_STATE_HEAL_ENTRY_LOOKUP 200 -#define EC_STATE_HEAL_ENTRY_PREPARE 201 -#define EC_STATE_HEAL_PRE_INODELK_LOCK 202 -#define EC_STATE_HEAL_PRE_INODE_LOOKUP 203 -#define EC_STATE_HEAL_XATTRIBUTES_REMOVE 204 -#define EC_STATE_HEAL_XATTRIBUTES_SET 205 -#define EC_STATE_HEAL_ATTRIBUTES 206 -#define EC_STATE_HEAL_OPEN 207 -#define EC_STATE_HEAL_REOPEN_FD 208 -#define EC_STATE_HEAL_UNLOCK 209 -#define EC_STATE_HEAL_UNLOCK_ENTRY 210 -#define EC_STATE_HEAL_DATA_LOCK 211 -#define EC_STATE_HEAL_DATA_COPY 212 -#define EC_STATE_HEAL_DATA_UNLOCK 213 -#define EC_STATE_HEAL_POST_INODELK_LOCK 214 -#define EC_STATE_HEAL_POST_INODE_LOOKUP 215 -#define EC_STATE_HEAL_SETATTR 216 -#define EC_STATE_HEAL_POST_INODELK_UNLOCK 217 -#define EC_STATE_HEAL_DISPATCH 218 - -gf_boolean_t ec_dispatch_one_retry (ec_fop_data_t *fop, ec_cbk_data_t **cbk); -void ec_dispatch_next(ec_fop_data_t * fop, uint32_t idx); - -void ec_complete(ec_fop_data_t *fop); - -void ec_update_good(ec_fop_data_t *fop, uintptr_t good); - -void ec_fop_set_error(ec_fop_data_t *fop, int32_t error); - -void __ec_fop_set_error(ec_fop_data_t *fop, int32_t error); +#define EC_MINIMUM_ONE -1 +#define EC_MINIMUM_MIN -2 +#define EC_MINIMUM_ALL -3 + +#define EC_UPDATE_DATA 1 +#define EC_UPDATE_META 2 +#define EC_QUERY_INFO 4 +#define EC_INODE_SIZE 8 + +#define EC_STATE_START 0 +#define EC_STATE_END 0 +#define EC_STATE_INIT 1 +#define EC_STATE_LOCK 2 +#define EC_STATE_DISPATCH 3 +#define EC_STATE_PREPARE_ANSWER 4 +#define EC_STATE_REPORT 5 +#define EC_STATE_LOCK_REUSE 6 +#define EC_STATE_UNLOCK 7 + +#define EC_STATE_DELAYED_START 100 + +#define EC_STATE_HEAL_ENTRY_LOOKUP 200 +#define EC_STATE_HEAL_ENTRY_PREPARE 201 +#define EC_STATE_HEAL_PRE_INODELK_LOCK 202 +#define EC_STATE_HEAL_PRE_INODE_LOOKUP 203 +#define EC_STATE_HEAL_XATTRIBUTES_REMOVE 204 +#define EC_STATE_HEAL_XATTRIBUTES_SET 205 +#define EC_STATE_HEAL_ATTRIBUTES 206 +#define EC_STATE_HEAL_OPEN 207 +#define EC_STATE_HEAL_REOPEN_FD 208 +#define EC_STATE_HEAL_UNLOCK 209 +#define EC_STATE_HEAL_UNLOCK_ENTRY 210 +#define EC_STATE_HEAL_DATA_LOCK 211 +#define EC_STATE_HEAL_DATA_COPY 212 +#define EC_STATE_HEAL_DATA_UNLOCK 213 +#define EC_STATE_HEAL_POST_INODELK_LOCK 214 +#define EC_STATE_HEAL_POST_INODE_LOOKUP 215 +#define EC_STATE_HEAL_SETATTR 216 +#define EC_STATE_HEAL_POST_INODELK_UNLOCK 217 +#define EC_STATE_HEAL_DISPATCH 218 + +gf_boolean_t +ec_dispatch_one_retry(ec_fop_data_t *fop, ec_cbk_data_t **cbk); +void +ec_dispatch_next(ec_fop_data_t *fop, uint32_t idx); + +void +ec_complete(ec_fop_data_t *fop); + +void +ec_update_good(ec_fop_data_t *fop, uintptr_t good); + +void +ec_fop_set_error(ec_fop_data_t *fop, int32_t error); + +void +__ec_fop_set_error(ec_fop_data_t *fop, int32_t error); ec_cbk_data_t * ec_fop_prepare_answer(ec_fop_data_t *fop, gf_boolean_t ro); @@ -115,55 +118,73 @@ ec_fop_prepare_answer(ec_fop_data_t *fop, gf_boolean_t ro); gf_boolean_t ec_cbk_set_error(ec_cbk_data_t *cbk, int32_t error, gf_boolean_t ro); -void ec_lock_prepare_inode(ec_fop_data_t *fop, loc_t *loc, uint32_t flags, - off_t fl_start, size_t fl_size); -void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc, loc_t *base, - uint32_t flags); -void ec_lock_prepare_fd(ec_fop_data_t *fop, fd_t *fd, uint32_t flags, - off_t fl_start, size_t fl_size); -void ec_lock(ec_fop_data_t * fop); -void ec_lock_reuse(ec_fop_data_t *fop); -void ec_unlock(ec_fop_data_t * fop); -void ec_lock_release(ec_t *ec, inode_t *inode); - -gf_boolean_t ec_get_inode_size(ec_fop_data_t *fop, inode_t *inode, - uint64_t *size); -gf_boolean_t __ec_get_inode_size(ec_fop_data_t *fop, inode_t *inode, - uint64_t *size); -gf_boolean_t ec_set_inode_size(ec_fop_data_t *fop, inode_t *inode, - uint64_t size); -gf_boolean_t __ec_set_inode_size(ec_fop_data_t *fop, inode_t *inode, - uint64_t size); -void ec_clear_inode_info(ec_fop_data_t *fop, inode_t *inode); - -void ec_flush_size_version(ec_fop_data_t * fop); - -void ec_dispatch_all(ec_fop_data_t * fop); -void ec_dispatch_inc(ec_fop_data_t * fop); -void ec_dispatch_min(ec_fop_data_t * fop); -void ec_dispatch_one(ec_fop_data_t * fop); - -void ec_sleep(ec_fop_data_t *fop); -void ec_resume(ec_fop_data_t * fop, int32_t error); -void ec_resume_parent(ec_fop_data_t * fop, int32_t error); - -void ec_manager(ec_fop_data_t * fop, int32_t error); -gf_boolean_t ec_is_recoverable_error (int32_t op_errno); -void ec_handle_healers_done (ec_fop_data_t *fop); +void +ec_lock_prepare_inode(ec_fop_data_t *fop, loc_t *loc, uint32_t flags, + off_t fl_start, size_t fl_size); +void +ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc, loc_t *base, + uint32_t flags); +void +ec_lock_prepare_fd(ec_fop_data_t *fop, fd_t *fd, uint32_t flags, off_t fl_start, + size_t fl_size); +void +ec_lock(ec_fop_data_t *fop); +void +ec_lock_reuse(ec_fop_data_t *fop); +void +ec_unlock(ec_fop_data_t *fop); +void +ec_lock_release(ec_t *ec, inode_t *inode); + +gf_boolean_t +ec_get_inode_size(ec_fop_data_t *fop, inode_t *inode, uint64_t *size); +gf_boolean_t +__ec_get_inode_size(ec_fop_data_t *fop, inode_t *inode, uint64_t *size); +gf_boolean_t +ec_set_inode_size(ec_fop_data_t *fop, inode_t *inode, uint64_t size); +gf_boolean_t +__ec_set_inode_size(ec_fop_data_t *fop, inode_t *inode, uint64_t size); +void +ec_clear_inode_info(ec_fop_data_t *fop, inode_t *inode); + +void +ec_flush_size_version(ec_fop_data_t *fop); + +void +ec_dispatch_all(ec_fop_data_t *fop); +void +ec_dispatch_inc(ec_fop_data_t *fop); +void +ec_dispatch_min(ec_fop_data_t *fop); +void +ec_dispatch_one(ec_fop_data_t *fop); + +void +ec_sleep(ec_fop_data_t *fop); +void +ec_resume(ec_fop_data_t *fop, int32_t error); +void +ec_resume_parent(ec_fop_data_t *fop, int32_t error); + +void +ec_manager(ec_fop_data_t *fop, int32_t error); +gf_boolean_t +ec_is_recoverable_error(int32_t op_errno); +void +ec_handle_healers_done(ec_fop_data_t *fop); int32_t -ec_heal_inspect (call_frame_t *frame, ec_t *ec, - inode_t *inode, unsigned char *locked_on, - gf_boolean_t self_locked, gf_boolean_t thorough, - ec_heal_need_t *need_heal); +ec_heal_inspect(call_frame_t *frame, ec_t *ec, inode_t *inode, + unsigned char *locked_on, gf_boolean_t self_locked, + gf_boolean_t thorough, ec_heal_need_t *need_heal); int32_t -ec_get_heal_info (xlator_t *this, loc_t *loc, dict_t **dict); +ec_get_heal_info(xlator_t *this, loc_t *loc, dict_t **dict); -int32_t ec_lock_unlocked(call_frame_t *frame, void *cookie, - xlator_t *this, int32_t op_ret, int32_t op_errno, - dict_t *xdata); +int32_t +ec_lock_unlocked(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata); void -ec_update_fd_status (fd_t *fd, xlator_t *xl, - int child_index, int32_t ret_status); +ec_update_fd_status(fd_t *fd, xlator_t *xl, int child_index, + int32_t ret_status); #endif /* __EC_COMMON_H__ */ diff --git a/xlators/cluster/ec/src/ec-data.h b/xlators/cluster/ec/src/ec-data.h index 965bc1e25ef..112536d554c 100644 --- a/xlators/cluster/ec/src/ec-data.h +++ b/xlators/cluster/ec/src/ec-data.h @@ -13,20 +13,23 @@ #include "ec-types.h" -ec_cbk_data_t * ec_cbk_data_allocate(call_frame_t * frame, xlator_t * this, - ec_fop_data_t * fop, int32_t id, - int32_t idx, int32_t op_ret, - int32_t op_errno); -ec_fop_data_t * ec_fop_data_allocate(call_frame_t * frame, xlator_t * this, - int32_t id, uint32_t flags, - uintptr_t target, int32_t minimum, - ec_wind_f wind, ec_handler_f handler, - ec_cbk_t cbks, void * data); -void ec_fop_data_acquire(ec_fop_data_t * fop); -void ec_fop_data_release(ec_fop_data_t * fop); +ec_cbk_data_t * +ec_cbk_data_allocate(call_frame_t *frame, xlator_t *this, ec_fop_data_t *fop, + int32_t id, int32_t idx, int32_t op_ret, int32_t op_errno); +ec_fop_data_t * +ec_fop_data_allocate(call_frame_t *frame, xlator_t *this, int32_t id, + uint32_t flags, uintptr_t target, int32_t minimum, + ec_wind_f wind, ec_handler_f handler, ec_cbk_t cbks, + void *data); +void +ec_fop_data_acquire(ec_fop_data_t *fop); +void +ec_fop_data_release(ec_fop_data_t *fop); -void ec_fop_cleanup(ec_fop_data_t *fop); +void +ec_fop_cleanup(ec_fop_data_t *fop); -void ec_pending_fops_completed(ec_t *ec); +void +ec_pending_fops_completed(ec_t *ec); #endif /* __EC_DATA_H__ */ diff --git a/xlators/cluster/ec/src/ec-fops.h b/xlators/cluster/ec/src/ec-fops.h index 4a926cf4802..2858d829c73 100644 --- a/xlators/cluster/ec/src/ec-fops.h +++ b/xlators/cluster/ec/src/ec-fops.h @@ -16,199 +16,235 @@ #include "ec-types.h" #include "ec-common.h" -void ec_access(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_access_cbk_t func, void *data, loc_t * loc, - int32_t mask, dict_t * xdata); - -void ec_create(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_create_cbk_t func, void *data, loc_t * loc, - int32_t flags, mode_t mode, mode_t umask, fd_t * fd, - dict_t * xdata); - -void ec_entrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_entrylk_cbk_t func, void *data, - const char * volume, loc_t * loc, const char * basename, - entrylk_cmd cmd, entrylk_type type, dict_t * xdata); - -void ec_fentrylk(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fentrylk_cbk_t func, void *data, - const char * volume, fd_t * fd, const char * basename, - entrylk_cmd cmd, entrylk_type type, dict_t * xdata); - -void ec_flush(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_flush_cbk_t func, void *data, fd_t * fd, - dict_t * xdata); - -void ec_fsync(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fsync_cbk_t func, void *data, fd_t * fd, - int32_t datasync, dict_t * xdata); - -void ec_fsyncdir(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fsyncdir_cbk_t func, void *data, - fd_t * fd, int32_t datasync, dict_t * xdata); - -void ec_getxattr(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_getxattr_cbk_t func, void *data, - loc_t * loc, const char * name, dict_t * xdata); - -void ec_fgetxattr(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fgetxattr_cbk_t func, void *data, - fd_t * fd, const char * name, dict_t * xdata); - -void ec_heal(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_heal_cbk_t func, void *data, loc_t * loc, - int32_t partial, dict_t *xdata); - -void ec_fheal(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fheal_cbk_t func, void *data, fd_t * fd, - int32_t partial, dict_t *xdata); - -void ec_inodelk (call_frame_t *frame, xlator_t *this, gf_lkowner_t *owner, - uintptr_t target, int32_t minimum, fop_inodelk_cbk_t func, - void *data, const char *volume, loc_t *loc, int32_t cmd, - struct gf_flock * flock, dict_t * xdata); - -void ec_finodelk(call_frame_t *frame, xlator_t *this, gf_lkowner_t *owner, - uintptr_t target, int32_t minimum, fop_finodelk_cbk_t func, - void *data, const char *volume, fd_t *fd, int32_t cmd, - struct gf_flock *flock, dict_t *xdata); - -void ec_link(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_link_cbk_t func, void *data, loc_t * oldloc, - loc_t * newloc, dict_t * xdata); - -void ec_lk(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_lk_cbk_t func, void *data, fd_t * fd, - int32_t cmd, struct gf_flock * flock, dict_t * xdata); - -void ec_lookup(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_lookup_cbk_t func, void *data, loc_t * loc, - dict_t * xdata); - -void ec_mkdir(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_mkdir_cbk_t func, void *data, loc_t * loc, - mode_t mode, mode_t umask, dict_t * xdata); - -void ec_mknod(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_mknod_cbk_t func, void *data, loc_t * loc, - mode_t mode, dev_t rdev, mode_t umask, dict_t * xdata); - -void ec_open(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_open_cbk_t func, void *data, loc_t * loc, - int32_t flags, fd_t * fd, dict_t * xdata); - -void ec_opendir(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_opendir_cbk_t func, void *data, - loc_t * loc, fd_t * fd, dict_t * xdata); - -void ec_readdir(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_readdir_cbk_t func, void *data, fd_t * fd, - size_t size, off_t offset, dict_t * xdata); - -void ec_readdirp(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_readdirp_cbk_t func, void *data, - fd_t * fd, size_t size, off_t offset, dict_t * xdata); - -void ec_readlink(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_readlink_cbk_t func, void *data, - loc_t * loc, size_t size, dict_t * xdata); - -void ec_readv(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_readv_cbk_t func, void *data, fd_t * fd, - size_t size, off_t offset, uint32_t flags, dict_t * xdata); - -void ec_removexattr(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_removexattr_cbk_t func, void *data, - loc_t * loc, const char * name, dict_t * xdata); - -void ec_fremovexattr(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fremovexattr_cbk_t func, void *data, - fd_t * fd, const char * name, dict_t * xdata); - -void ec_rename(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_rename_cbk_t func, void *data, - loc_t * oldloc, loc_t * newloc, dict_t * xdata); - -void ec_rmdir(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_rmdir_cbk_t func, void *data, loc_t * loc, - int xflags, dict_t * xdata); - -void ec_setattr(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_setattr_cbk_t func, void *data, - loc_t * loc, struct iatt * stbuf, int32_t valid, - dict_t * xdata); - -void ec_fsetattr(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fsetattr_cbk_t func, void *data, - fd_t * fd, struct iatt * stbuf, int32_t valid, - dict_t * xdata); - -void ec_setxattr(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_setxattr_cbk_t func, void *data, - loc_t * loc, dict_t * dict, int32_t flags, dict_t * xdata); - -void ec_fsetxattr(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fsetxattr_cbk_t func, void *data, - fd_t * fd, dict_t * dict, int32_t flags, dict_t * xdata); - -void ec_stat(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_stat_cbk_t func, void *data, loc_t * loc, - dict_t * xdata); - -void ec_fstat(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fstat_cbk_t func, void *data, fd_t * fd, - dict_t * xdata); - -void ec_statfs(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_statfs_cbk_t func, void *data, loc_t * loc, - dict_t * xdata); - -void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_symlink_cbk_t func, void *data, - const char * linkname, loc_t * loc, mode_t umask, - dict_t * xdata); - -void ec_fallocate(call_frame_t *frame, xlator_t *this, uintptr_t target, - int32_t minimum, fop_fallocate_cbk_t func, void *data, fd_t *fd, - int32_t mode, off_t offset, size_t len, dict_t *xdata); - -void ec_discard(call_frame_t *frame, xlator_t *this, uintptr_t target, - int32_t minimum, fop_discard_cbk_t func, void *data, fd_t *fd, - off_t offset, size_t len, dict_t *xdata); - -void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_truncate_cbk_t func, void *data, - loc_t * loc, off_t offset, dict_t * xdata); - -void ec_ftruncate(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_ftruncate_cbk_t func, void *data, - fd_t * fd, off_t offset, dict_t * xdata); - -void ec_unlink(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_unlink_cbk_t func, void *data, loc_t * loc, - int xflags, dict_t * xdata); - -void ec_writev(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_writev_cbk_t func, void *data, fd_t * fd, - struct iovec * vector, int32_t count, off_t offset, - uint32_t flags, struct iobref * iobref, dict_t * xdata); - -void ec_xattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_xattrop_cbk_t func, void *data, - loc_t * loc, gf_xattrop_flags_t optype, dict_t * xattr, - dict_t * xdata); - -void ec_fxattrop(call_frame_t * frame, xlator_t * this, uintptr_t target, - int32_t minimum, fop_fxattrop_cbk_t func, void *data, - fd_t * fd, gf_xattrop_flags_t optype, dict_t * xattr, - dict_t * xdata); - -void ec_seek(call_frame_t *frame, xlator_t *this, uintptr_t target, - int32_t minimum, fop_seek_cbk_t func, void *data, fd_t *fd, - off_t offset, gf_seek_what_t what, dict_t *xdata); - -void ec_ipc(call_frame_t *frame, xlator_t *this, uintptr_t target, - int32_t minimum, fop_ipc_cbk_t func, void *data, int32_t op, - dict_t *xdata); +void +ec_access(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_access_cbk_t func, void *data, loc_t *loc, + int32_t mask, dict_t *xdata); + +void +ec_create(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_create_cbk_t func, void *data, loc_t *loc, + int32_t flags, mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata); + +void +ec_entrylk(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_entrylk_cbk_t func, void *data, + const char *volume, loc_t *loc, const char *basename, + entrylk_cmd cmd, entrylk_type type, dict_t *xdata); + +void +ec_fentrylk(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_fentrylk_cbk_t func, void *data, + const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, + entrylk_type type, dict_t *xdata); + +void +ec_flush(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_flush_cbk_t func, void *data, fd_t *fd, dict_t *xdata); + +void +ec_fsync(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_fsync_cbk_t func, void *data, fd_t *fd, int32_t datasync, + dict_t *xdata); + +void +ec_fsyncdir(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_fsyncdir_cbk_t func, void *data, fd_t *fd, + int32_t datasync, dict_t *xdata); + +void +ec_getxattr(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_getxattr_cbk_t func, void *data, loc_t *loc, + const char *name, dict_t *xdata); + +void +ec_fgetxattr(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_fgetxattr_cbk_t func, void *data, fd_t *fd, + const char *name, dict_t *xdata); + +void +ec_heal(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_heal_cbk_t func, void *data, loc_t *loc, int32_t partial, + dict_t *xdata); + +void +ec_fheal(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_fheal_cbk_t func, void *data, fd_t *fd, int32_t partial, + dict_t *xdata); + +void +ec_inodelk(call_frame_t *frame, xlator_t *this, gf_lkowner_t *owner, + uintptr_t target, int32_t minimum, fop_inodelk_cbk_t func, + void *data, const char *volume, loc_t *loc, int32_t cmd, + struct gf_flock *flock, dict_t *xdata); + +void +ec_finodelk(call_frame_t *frame, xlator_t *this, gf_lkowner_t *owner, + uintptr_t target, int32_t minimum, fop_finodelk_cbk_t func, + void *data, const char *volume, fd_t *fd, int32_t cmd, + struct gf_flock *flock, dict_t *xdata); + +void +ec_link(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_link_cbk_t func, void *data, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); + +void +ec_lk(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_lk_cbk_t func, void *data, fd_t *fd, int32_t cmd, + struct gf_flock *flock, dict_t *xdata); + +void +ec_lookup(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_lookup_cbk_t func, void *data, loc_t *loc, + dict_t *xdata); + +void +ec_mkdir(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_mkdir_cbk_t func, void *data, loc_t *loc, mode_t mode, + mode_t umask, dict_t *xdata); + +void +ec_mknod(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_mknod_cbk_t func, void *data, loc_t *loc, mode_t mode, dev_t rdev, + mode_t umask, dict_t *xdata); + +void +ec_open(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_open_cbk_t func, void *data, loc_t *loc, int32_t flags, fd_t *fd, + dict_t *xdata); + +void +ec_opendir(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_opendir_cbk_t func, void *data, loc_t *loc, + fd_t *fd, dict_t *xdata); + +void +ec_readdir(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_readdir_cbk_t func, void *data, fd_t *fd, + size_t size, off_t offset, dict_t *xdata); + +void +ec_readdirp(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_readdirp_cbk_t func, void *data, fd_t *fd, + size_t size, off_t offset, dict_t *xdata); + +void +ec_readlink(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_readlink_cbk_t func, void *data, loc_t *loc, + size_t size, dict_t *xdata); + +void +ec_readv(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_readv_cbk_t func, void *data, fd_t *fd, size_t size, off_t offset, + uint32_t flags, dict_t *xdata); + +void +ec_removexattr(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_removexattr_cbk_t func, void *data, + loc_t *loc, const char *name, dict_t *xdata); + +void +ec_fremovexattr(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_fremovexattr_cbk_t func, void *data, + fd_t *fd, const char *name, dict_t *xdata); + +void +ec_rename(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_rename_cbk_t func, void *data, loc_t *oldloc, + loc_t *newloc, dict_t *xdata); + +void +ec_rmdir(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_rmdir_cbk_t func, void *data, loc_t *loc, int xflags, + dict_t *xdata); + +void +ec_setattr(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_setattr_cbk_t func, void *data, loc_t *loc, + struct iatt *stbuf, int32_t valid, dict_t *xdata); + +void +ec_fsetattr(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_fsetattr_cbk_t func, void *data, fd_t *fd, + struct iatt *stbuf, int32_t valid, dict_t *xdata); + +void +ec_setxattr(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_setxattr_cbk_t func, void *data, loc_t *loc, + dict_t *dict, int32_t flags, dict_t *xdata); + +void +ec_fsetxattr(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_fsetxattr_cbk_t func, void *data, fd_t *fd, + dict_t *dict, int32_t flags, dict_t *xdata); + +void +ec_stat(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_stat_cbk_t func, void *data, loc_t *loc, dict_t *xdata); + +void +ec_fstat(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_fstat_cbk_t func, void *data, fd_t *fd, dict_t *xdata); + +void +ec_statfs(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_statfs_cbk_t func, void *data, loc_t *loc, + dict_t *xdata); + +void +ec_symlink(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_symlink_cbk_t func, void *data, + const char *linkname, loc_t *loc, mode_t umask, dict_t *xdata); + +void +ec_fallocate(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_fallocate_cbk_t func, void *data, fd_t *fd, + int32_t mode, off_t offset, size_t len, dict_t *xdata); + +void +ec_discard(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_discard_cbk_t func, void *data, fd_t *fd, + off_t offset, size_t len, dict_t *xdata); + +void +ec_truncate(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_truncate_cbk_t func, void *data, loc_t *loc, + off_t offset, dict_t *xdata); + +void +ec_ftruncate(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_ftruncate_cbk_t func, void *data, fd_t *fd, + off_t offset, dict_t *xdata); + +void +ec_unlink(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_unlink_cbk_t func, void *data, loc_t *loc, + int xflags, dict_t *xdata); + +void +ec_writev(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_writev_cbk_t func, void *data, fd_t *fd, + struct iovec *vector, int32_t count, off_t offset, uint32_t flags, + struct iobref *iobref, dict_t *xdata); + +void +ec_xattrop(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_xattrop_cbk_t func, void *data, loc_t *loc, + gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata); + +void +ec_fxattrop(call_frame_t *frame, xlator_t *this, uintptr_t target, + int32_t minimum, fop_fxattrop_cbk_t func, void *data, fd_t *fd, + gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata); + +void +ec_seek(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_seek_cbk_t func, void *data, fd_t *fd, off_t offset, + gf_seek_what_t what, dict_t *xdata); + +void +ec_ipc(call_frame_t *frame, xlator_t *this, uintptr_t target, int32_t minimum, + fop_ipc_cbk_t func, void *data, int32_t op, dict_t *xdata); #endif /* __EC_FOPS_H__ */ diff --git a/xlators/cluster/ec/src/ec-galois.h b/xlators/cluster/ec/src/ec-galois.h index 02e6b6c1bc2..ed55d53e419 100644 --- a/xlators/cluster/ec/src/ec-galois.h +++ b/xlators/cluster/ec/src/ec-galois.h @@ -15,12 +15,18 @@ #include "ec-types.h" -ec_gf_t *ec_gf_prepare(uint32_t bits, uint32_t mod); -void ec_gf_destroy(ec_gf_t *gf); +ec_gf_t * +ec_gf_prepare(uint32_t bits, uint32_t mod); +void +ec_gf_destroy(ec_gf_t *gf); -uint32_t ec_gf_add(ec_gf_t *gf, uint32_t a, uint32_t b); -uint32_t ec_gf_mul(ec_gf_t *gf, uint32_t a, uint32_t b); -uint32_t ec_gf_div(ec_gf_t *gf, uint32_t a, uint32_t b); -uint32_t ec_gf_exp(ec_gf_t *gf, uint32_t a, uint32_t b); +uint32_t +ec_gf_add(ec_gf_t *gf, uint32_t a, uint32_t b); +uint32_t +ec_gf_mul(ec_gf_t *gf, uint32_t a, uint32_t b); +uint32_t +ec_gf_div(ec_gf_t *gf, uint32_t a, uint32_t b); +uint32_t +ec_gf_exp(ec_gf_t *gf, uint32_t a, uint32_t b); #endif /* __EC_GALOIS_H__ */ diff --git a/xlators/cluster/ec/src/ec-heald.h b/xlators/cluster/ec/src/ec-heald.h index 2a8488124c4..4d141d767e5 100644 --- a/xlators/cluster/ec/src/ec-heald.h +++ b/xlators/cluster/ec/src/ec-heald.h @@ -16,10 +16,10 @@ #include "ec-types.h" int -ec_xl_op (xlator_t *this, dict_t *input, dict_t *output); +ec_xl_op(xlator_t *this, dict_t *input, dict_t *output); int -ec_selfheal_daemon_init (xlator_t *this); +ec_selfheal_daemon_init(xlator_t *this); void ec_shd_index_healer_wake(ec_t *ec); diff --git a/xlators/cluster/ec/src/ec-helpers.h b/xlators/cluster/ec/src/ec-helpers.h index b548f802361..015db514e05 100644 --- a/xlators/cluster/ec/src/ec-helpers.h +++ b/xlators/cluster/ec/src/ec-helpers.h @@ -17,60 +17,77 @@ #define EC_IS_ERR(_x) (((uintptr_t)(_x) & ~0xfffULL) == ~0xfffULL) #define EC_GET_ERR(_x) ((int32_t)(intptr_t)(_x)) -#define EC_ALIGN_CHECK(_ptr, _align) \ - ((((uintptr_t)(_ptr)) & ((_align) - 1)) == 0) - -const char * ec_bin(char * str, size_t size, uint64_t value, int32_t digits); -const char * ec_fop_name(int32_t id); -void ec_trace(const char * event, ec_fop_data_t * fop, const char * fmt, ...); -int32_t ec_bits_consume(uint64_t * n); -size_t ec_iov_copy_to(void * dst, struct iovec * vector, int32_t count, - off_t offset, size_t size); -int32_t ec_buffer_alloc(xlator_t *xl, size_t size, struct iobref **piobref, - void **ptr); -int32_t ec_dict_set_array(dict_t *dict, char *key, - uint64_t *value, int32_t size); -int32_t ec_dict_get_array (dict_t *dict, char *key, uint64_t value[], - int32_t size); - -int32_t ec_dict_del_array(dict_t *dict, char *key, - uint64_t *value, int32_t size); -int32_t ec_dict_set_number(dict_t * dict, char * key, uint64_t value); -int32_t ec_dict_del_number(dict_t * dict, char * key, uint64_t * value); -int32_t ec_dict_set_config(dict_t * dict, char * key, ec_config_t * config); -int32_t ec_dict_del_config(dict_t * dict, char * key, ec_config_t * config); - -int32_t ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent); -int32_t ec_loc_update(xlator_t *xl, loc_t *loc, inode_t *inode, - struct iatt *iatt); - -int32_t ec_loc_from_fd(xlator_t * xl, loc_t * loc, fd_t * fd); -int32_t ec_loc_from_loc(xlator_t * xl, loc_t * dst, loc_t * src); - -void ec_owner_set(call_frame_t * frame, void * owner); -void ec_owner_copy(call_frame_t * frame, gf_lkowner_t * owner); - -ec_inode_t * __ec_inode_get(inode_t * inode, xlator_t * xl); -ec_inode_t * ec_inode_get(inode_t * inode, xlator_t * xl); -ec_fd_t * __ec_fd_get(fd_t * fd, xlator_t * xl); -ec_fd_t * ec_fd_get(fd_t * fd, xlator_t * xl); +#define EC_ALIGN_CHECK(_ptr, _align) ((((uintptr_t)(_ptr)) & ((_align)-1)) == 0) + +const char * +ec_bin(char *str, size_t size, uint64_t value, int32_t digits); +const char * +ec_fop_name(int32_t id); +void +ec_trace(const char *event, ec_fop_data_t *fop, const char *fmt, ...); +int32_t +ec_bits_consume(uint64_t *n); +size_t +ec_iov_copy_to(void *dst, struct iovec *vector, int32_t count, off_t offset, + size_t size); +int32_t +ec_buffer_alloc(xlator_t *xl, size_t size, struct iobref **piobref, void **ptr); +int32_t +ec_dict_set_array(dict_t *dict, char *key, uint64_t *value, int32_t size); +int32_t +ec_dict_get_array(dict_t *dict, char *key, uint64_t value[], int32_t size); + +int32_t +ec_dict_del_array(dict_t *dict, char *key, uint64_t *value, int32_t size); +int32_t +ec_dict_set_number(dict_t *dict, char *key, uint64_t value); +int32_t +ec_dict_del_number(dict_t *dict, char *key, uint64_t *value); +int32_t +ec_dict_set_config(dict_t *dict, char *key, ec_config_t *config); +int32_t +ec_dict_del_config(dict_t *dict, char *key, ec_config_t *config); + +int32_t +ec_loc_parent(xlator_t *xl, loc_t *loc, loc_t *parent); +int32_t +ec_loc_update(xlator_t *xl, loc_t *loc, inode_t *inode, struct iatt *iatt); + +int32_t +ec_loc_from_fd(xlator_t *xl, loc_t *loc, fd_t *fd); +int32_t +ec_loc_from_loc(xlator_t *xl, loc_t *dst, loc_t *src); + +void +ec_owner_set(call_frame_t *frame, void *owner); +void +ec_owner_copy(call_frame_t *frame, gf_lkowner_t *owner); + +ec_inode_t * +__ec_inode_get(inode_t *inode, xlator_t *xl); +ec_inode_t * +ec_inode_get(inode_t *inode, xlator_t *xl); +ec_fd_t * +__ec_fd_get(fd_t *fd, xlator_t *xl); +ec_fd_t * +ec_fd_get(fd_t *fd, xlator_t *xl); static inline uint32_t ec_adjust_size_down(ec_t *ec, uint64_t *value, gf_boolean_t scale) { - uint64_t head, tmp; + uint64_t head, tmp; - tmp = *value; - head = tmp % ec->stripe_size; - tmp -= head; + tmp = *value; + head = tmp % ec->stripe_size; + tmp -= head; - if (scale) { - tmp /= ec->fragments; - } + if (scale) { + tmp /= ec->fragments; + } - *value = tmp; + *value = tmp; - return (uint32_t)head; + return (uint32_t)head; } /* This function can cause an overflow if the passed value is too near to the @@ -79,35 +96,35 @@ ec_adjust_size_down(ec_t *ec, uint64_t *value, gf_boolean_t scale) static inline int32_t ec_adjust_size_up(ec_t *ec, uint64_t *value, gf_boolean_t scale) { - uint64_t tmp; - int32_t tail; - - tmp = *value; - /* We first adjust the value down. This never causes overflow. */ - tail = ec_adjust_size_down(ec, &tmp, scale); - - /* If the value was already aligned, tail will be 0 and nothing else - * needs to be done. */ - if (tail != 0) { - /* Otherwise, we need to compute the real tail and adjust the - * returned value to the next stripe. */ - tail = ec->stripe_size - tail; - if (scale) { - tmp += ec->fragment_size; - } else { - tmp += ec->stripe_size; - /* If no scaling is requested there's a possibility of - * overflow. */ - if (tmp < ec->stripe_size) { - tmp = UINT64_MAX; - tail = -tail; - } - } + uint64_t tmp; + int32_t tail; + + tmp = *value; + /* We first adjust the value down. This never causes overflow. */ + tail = ec_adjust_size_down(ec, &tmp, scale); + + /* If the value was already aligned, tail will be 0 and nothing else + * needs to be done. */ + if (tail != 0) { + /* Otherwise, we need to compute the real tail and adjust the + * returned value to the next stripe. */ + tail = ec->stripe_size - tail; + if (scale) { + tmp += ec->fragment_size; + } else { + tmp += ec->stripe_size; + /* If no scaling is requested there's a possibility of + * overflow. */ + if (tmp < ec->stripe_size) { + tmp = UINT64_MAX; + tail = -tail; + } } + } - *value = tmp; + *value = tmp; - return tail; + return tail; } /* This function is equivalent to ec_adjust_size_down() but with a potentially @@ -115,19 +132,19 @@ ec_adjust_size_up(ec_t *ec, uint64_t *value, gf_boolean_t scale) static inline uint32_t ec_adjust_offset_down(ec_t *ec, off_t *value, gf_boolean_t scale) { - off_t head, tmp; + off_t head, tmp; - tmp = *value; - head = tmp % ec->stripe_size; - tmp -= head; + tmp = *value; + head = tmp % ec->stripe_size; + tmp -= head; - if (scale) { - tmp /= ec->fragments; - } + if (scale) { + tmp /= ec->fragments; + } - *value = tmp; + *value = tmp; - return (uint32_t)head; + return (uint32_t)head; } /* This function is equivalent to ec_adjust_size_up() but with a potentially @@ -135,48 +152,49 @@ ec_adjust_offset_down(ec_t *ec, off_t *value, gf_boolean_t scale) static inline int32_t ec_adjust_offset_up(ec_t *ec, off_t *value, gf_boolean_t scale) { - uint64_t tail, tmp; - - /* An offset is a signed type that can only have positive values, so - * we take advantage of this to avoid overflows. We simply convert it - * to an unsigned integer and operate normally. This won't cause an - * overflow. Overflow is only checked when converting back to an - * off_t. */ - tmp = *value; - tail = ec->stripe_size; - tail -= (tmp + tail - 1) % tail + 1; - tmp += tail; - if (scale) { - /* If we are scaling, we'll never get an overflow. */ - tmp /= ec->fragments; - } else { - /* Check if there has been an overflow. */ - if ((off_t)tmp < 0) { - tmp = GF_OFF_MAX; - tail = -tail; - } + uint64_t tail, tmp; + + /* An offset is a signed type that can only have positive values, so + * we take advantage of this to avoid overflows. We simply convert it + * to an unsigned integer and operate normally. This won't cause an + * overflow. Overflow is only checked when converting back to an + * off_t. */ + tmp = *value; + tail = ec->stripe_size; + tail -= (tmp + tail - 1) % tail + 1; + tmp += tail; + if (scale) { + /* If we are scaling, we'll never get an overflow. */ + tmp /= ec->fragments; + } else { + /* Check if there has been an overflow. */ + if ((off_t)tmp < 0) { + tmp = GF_OFF_MAX; + tail = -tail; } + } - *value = (off_t)tmp; + *value = (off_t)tmp; - return (int32_t)tail; + return (int32_t)tail; } -static inline int32_t ec_is_power_of_2(uint32_t value) +static inline int32_t +ec_is_power_of_2(uint32_t value) { return (value != 0) && ((value & (value - 1)) == 0); } gf_boolean_t -ec_is_internal_xattr (dict_t *dict, char *key, data_t *value, void *data); +ec_is_internal_xattr(dict_t *dict, char *key, data_t *value, void *data); void -ec_filter_internal_xattrs (dict_t *xattr); +ec_filter_internal_xattrs(dict_t *xattr); gf_boolean_t -ec_is_data_fop (glusterfs_fop_t fop); +ec_is_data_fop(glusterfs_fop_t fop); int32_t -ec_launch_replace_heal (ec_t *ec); +ec_launch_replace_heal(ec_t *ec); #endif /* __EC_HELPERS_H__ */ diff --git a/xlators/cluster/ec/src/ec-mem-types.h b/xlators/cluster/ec/src/ec-mem-types.h index 8109a422d9d..fc33d09ea33 100644 --- a/xlators/cluster/ec/src/ec-mem-types.h +++ b/xlators/cluster/ec/src/ec-mem-types.h @@ -13,8 +13,7 @@ #include "mem-types.h" -enum gf_ec_mem_types_ -{ +enum gf_ec_mem_types_ { ec_mt_ec_t = gf_common_mt_end + 1, ec_mt_xlator_t, ec_mt_ec_inode_t, diff --git a/xlators/cluster/ec/src/ec-messages.h b/xlators/cluster/ec/src/ec-messages.h index f5138ad8e57..5f673d69aa4 100644 --- a/xlators/cluster/ec/src/ec-messages.h +++ b/xlators/cluster/ec/src/ec-messages.h @@ -23,83 +23,38 @@ * glfs-message-id.h. */ -GLFS_MSGID(EC, - EC_MSG_INVALID_CONFIG, - EC_MSG_HEAL_FAIL, - EC_MSG_DICT_COMBINE_FAIL, - EC_MSG_STIME_COMBINE_FAIL, - EC_MSG_INVALID_DICT_NUMS, - EC_MSG_IATT_COMBINE_FAIL, - EC_MSG_INVALID_FORMAT, - EC_MSG_DICT_GET_FAILED, - EC_MSG_UNHANDLED_STATE, - EC_MSG_FILE_DESC_REF_FAIL, - EC_MSG_LOC_COPY_FAIL, - EC_MSG_BUF_REF_FAIL, - EC_MSG_DICT_REF_FAIL, - EC_MSG_LK_UNLOCK_FAILED, - EC_MSG_UNLOCK_FAILED, - EC_MSG_LOC_PARENT_INODE_MISSING, - EC_MSG_INVALID_LOC_NAME, - EC_MSG_NO_MEMORY, - EC_MSG_GFID_MISMATCH, - EC_MSG_UNSUPPORTED_VERSION, - EC_MSG_FD_CREATE_FAIL, - EC_MSG_READDIRP_REQ_PREP_FAIL, - EC_MSG_LOOKUP_REQ_PREP_FAIL, - EC_MSG_INODE_REF_FAIL, - EC_MSG_LOOKUP_READAHEAD_FAIL, - EC_MSG_FRAME_MISMATCH, - EC_MSG_XLATOR_MISMATCH, - EC_MSG_VECTOR_MISMATCH, - EC_MSG_IATT_MISMATCH, - EC_MSG_FD_MISMATCH, - EC_MSG_DICT_MISMATCH, - EC_MSG_INDEX_DIR_GET_FAIL, - EC_MSG_PREOP_LOCK_FAILED, - EC_MSG_CHILDS_INSUFFICIENT, - EC_MSG_OP_EXEC_UNAVAIL, - EC_MSG_UNLOCK_DELAY_FAILED, - EC_MSG_SIZE_VERS_UPDATE_FAIL, - EC_MSG_INVALID_REQUEST, - EC_MSG_INVALID_LOCK_TYPE, - EC_MSG_SIZE_VERS_GET_FAIL, - EC_MSG_FILE_SIZE_GET_FAIL, - EC_MSG_FOP_MISMATCH, - EC_MSG_SUBVOL_ID_DICT_SET_FAIL, - EC_MSG_SUBVOL_BUILD_FAIL, - EC_MSG_XLATOR_INIT_FAIL, - EC_MSG_NO_PARENTS, - EC_MSG_TIMER_CREATE_FAIL, - EC_MSG_TOO_MANY_SUBVOLS, - EC_MSG_DATA_UNAVAILABLE, - EC_MSG_INODE_REMOVE_FAIL, - EC_MSG_INVALID_REDUNDANCY, - EC_MSG_XLATOR_PARSE_OPT_FAIL, - EC_MSG_OP_FAIL_ON_SUBVOLS, - EC_MSG_INVALID_INODE, - EC_MSG_LOCK_MISMATCH, - EC_MSG_XDATA_MISMATCH, - EC_MSG_HEALING_INFO, - EC_MSG_HEAL_SUCCESS, - EC_MSG_FULL_SWEEP_START, - EC_MSG_FULL_SWEEP_STOP, - EC_MSG_INVALID_FOP, - EC_MSG_EC_UP, - EC_MSG_EC_DOWN, - EC_MSG_SIZE_XATTR_GET_FAIL, - EC_MSG_VER_XATTR_GET_FAIL, - EC_MSG_CONFIG_XATTR_GET_FAIL, - EC_MSG_CONFIG_XATTR_INVALID, - EC_MSG_EXTENSION, - EC_MSG_EXTENSION_NONE, - EC_MSG_EXTENSION_UNKNOWN, - EC_MSG_EXTENSION_UNSUPPORTED, - EC_MSG_EXTENSION_FAILED, - EC_MSG_NO_GF, - EC_MSG_MATRIX_FAILED, - EC_MSG_DYN_CREATE_FAILED, - EC_MSG_DYN_CODEGEN_FAILED -); +GLFS_MSGID(EC, EC_MSG_INVALID_CONFIG, EC_MSG_HEAL_FAIL, + EC_MSG_DICT_COMBINE_FAIL, EC_MSG_STIME_COMBINE_FAIL, + EC_MSG_INVALID_DICT_NUMS, EC_MSG_IATT_COMBINE_FAIL, + EC_MSG_INVALID_FORMAT, EC_MSG_DICT_GET_FAILED, + EC_MSG_UNHANDLED_STATE, EC_MSG_FILE_DESC_REF_FAIL, + EC_MSG_LOC_COPY_FAIL, EC_MSG_BUF_REF_FAIL, EC_MSG_DICT_REF_FAIL, + EC_MSG_LK_UNLOCK_FAILED, EC_MSG_UNLOCK_FAILED, + EC_MSG_LOC_PARENT_INODE_MISSING, EC_MSG_INVALID_LOC_NAME, + EC_MSG_NO_MEMORY, EC_MSG_GFID_MISMATCH, EC_MSG_UNSUPPORTED_VERSION, + EC_MSG_FD_CREATE_FAIL, EC_MSG_READDIRP_REQ_PREP_FAIL, + EC_MSG_LOOKUP_REQ_PREP_FAIL, EC_MSG_INODE_REF_FAIL, + EC_MSG_LOOKUP_READAHEAD_FAIL, EC_MSG_FRAME_MISMATCH, + EC_MSG_XLATOR_MISMATCH, EC_MSG_VECTOR_MISMATCH, EC_MSG_IATT_MISMATCH, + EC_MSG_FD_MISMATCH, EC_MSG_DICT_MISMATCH, EC_MSG_INDEX_DIR_GET_FAIL, + EC_MSG_PREOP_LOCK_FAILED, EC_MSG_CHILDS_INSUFFICIENT, + EC_MSG_OP_EXEC_UNAVAIL, EC_MSG_UNLOCK_DELAY_FAILED, + EC_MSG_SIZE_VERS_UPDATE_FAIL, EC_MSG_INVALID_REQUEST, + EC_MSG_INVALID_LOCK_TYPE, EC_MSG_SIZE_VERS_GET_FAIL, + EC_MSG_FILE_SIZE_GET_FAIL, EC_MSG_FOP_MISMATCH, + EC_MSG_SUBVOL_ID_DICT_SET_FAIL, EC_MSG_SUBVOL_BUILD_FAIL, + EC_MSG_XLATOR_INIT_FAIL, EC_MSG_NO_PARENTS, EC_MSG_TIMER_CREATE_FAIL, + EC_MSG_TOO_MANY_SUBVOLS, EC_MSG_DATA_UNAVAILABLE, + EC_MSG_INODE_REMOVE_FAIL, EC_MSG_INVALID_REDUNDANCY, + EC_MSG_XLATOR_PARSE_OPT_FAIL, EC_MSG_OP_FAIL_ON_SUBVOLS, + EC_MSG_INVALID_INODE, EC_MSG_LOCK_MISMATCH, EC_MSG_XDATA_MISMATCH, + EC_MSG_HEALING_INFO, EC_MSG_HEAL_SUCCESS, EC_MSG_FULL_SWEEP_START, + EC_MSG_FULL_SWEEP_STOP, EC_MSG_INVALID_FOP, EC_MSG_EC_UP, + EC_MSG_EC_DOWN, EC_MSG_SIZE_XATTR_GET_FAIL, + EC_MSG_VER_XATTR_GET_FAIL, EC_MSG_CONFIG_XATTR_GET_FAIL, + EC_MSG_CONFIG_XATTR_INVALID, EC_MSG_EXTENSION, EC_MSG_EXTENSION_NONE, + EC_MSG_EXTENSION_UNKNOWN, EC_MSG_EXTENSION_UNSUPPORTED, + EC_MSG_EXTENSION_FAILED, EC_MSG_NO_GF, EC_MSG_MATRIX_FAILED, + EC_MSG_DYN_CREATE_FAILED, EC_MSG_DYN_CODEGEN_FAILED); #endif /* !_EC_MESSAGES_H_ */ diff --git a/xlators/cluster/ec/src/ec-method.h b/xlators/cluster/ec/src/ec-method.h index 9ba5069ff0e..3d6393bed06 100644 --- a/xlators/cluster/ec/src/ec-method.h +++ b/xlators/cluster/ec/src/ec-method.h @@ -24,7 +24,7 @@ /* Determines the maximum size of the matrix used to encode/decode data */ #define EC_METHOD_MAX_FRAGMENTS 16 /* Determines the maximum number of usable elements in the Galois Field */ -#define EC_METHOD_MAX_NODES (EC_GF_SIZE - 1) +#define EC_METHOD_MAX_NODES (EC_GF_SIZE - 1) #define EC_METHOD_WORD_SIZE 64 @@ -34,7 +34,8 @@ int32_t ec_method_init(xlator_t *xl, ec_matrix_list_t *list, uint32_t columns, uint32_t rows, uint32_t max, const char *gen); -void ec_method_fini(ec_matrix_list_t *list); +void +ec_method_fini(ec_matrix_list_t *list); int32_t ec_method_update(xlator_t *xl, ec_matrix_list_t *list, const char *gen); diff --git a/xlators/cluster/ec/src/ec-types.h b/xlators/cluster/ec/src/ec-types.h index 3a0267bf176..80d9c0d4014 100644 --- a/xlators/cluster/ec/src/ec-types.h +++ b/xlators/cluster/ec/src/ec-types.h @@ -128,75 +128,59 @@ typedef void (*ec_wind_f)(ec_t *, ec_fop_data_t *, int32_t); typedef int32_t (*ec_handler_f)(ec_fop_data_t *, int32_t); typedef void (*ec_resume_f)(ec_fop_data_t *, int32_t); -enum _ec_read_policy { - EC_ROUND_ROBIN, - EC_GFID_HASH, - EC_READ_POLICY_MAX -}; +enum _ec_read_policy { EC_ROUND_ROBIN, EC_GFID_HASH, EC_READ_POLICY_MAX }; -enum _ec_heal_need { - EC_HEAL_NONEED, - EC_HEAL_MAYBE, - EC_HEAL_MUST -}; +enum _ec_heal_need { EC_HEAL_NONEED, EC_HEAL_MAYBE, EC_HEAL_MUST }; -enum _ec_stripe_part { - EC_STRIPE_HEAD, - EC_STRIPE_TAIL -}; +enum _ec_stripe_part { EC_STRIPE_HEAD, EC_STRIPE_TAIL }; /* Enumartions to indicate FD status. */ -typedef enum { - EC_FD_NOT_OPENED, - EC_FD_OPENED, - EC_FD_OPENING -} ec_fd_status_t; +typedef enum { EC_FD_NOT_OPENED, EC_FD_OPENED, EC_FD_OPENING } ec_fd_status_t; struct _ec_config { uint32_t version; - uint8_t algorithm; - uint8_t gf_word_size; - uint8_t bricks; - uint8_t redundancy; + uint8_t algorithm; + uint8_t gf_word_size; + uint8_t bricks; + uint8_t redundancy; uint32_t chunk_size; }; struct _ec_fd { - loc_t loc; + loc_t loc; uintptr_t open; - int32_t flags; + int32_t flags; ec_fd_status_t fd_status[0]; }; struct _ec_stripe { - struct list_head lru; /* LRU list member */ - uint64_t frag_offset; /* Fragment offset of this stripe */ - char data[]; /* Contents of the stripe */ + struct list_head lru; /* LRU list member */ + uint64_t frag_offset; /* Fragment offset of this stripe */ + char data[]; /* Contents of the stripe */ }; struct _ec_stripe_list { - struct list_head lru; - uint32_t count; - uint32_t max; + struct list_head lru; + uint32_t count; + uint32_t max; }; struct _ec_inode { - ec_lock_t *inode_lock; - gf_boolean_t have_info; - gf_boolean_t have_config; - gf_boolean_t have_version; - gf_boolean_t have_size; - ec_config_t config; - uint64_t pre_version[2]; - uint64_t post_version[2]; - uint64_t pre_size; - uint64_t post_size; - uint64_t dirty[2]; - struct list_head heal; - ec_stripe_list_t stripe_cache; + ec_lock_t *inode_lock; + gf_boolean_t have_info; + gf_boolean_t have_config; + gf_boolean_t have_version; + gf_boolean_t have_size; + ec_config_t config; + uint64_t pre_version[2]; + uint64_t post_version[2]; + uint64_t pre_size; + uint64_t post_size; + uint64_t dirty[2]; + struct list_head heal; + ec_stripe_list_t stripe_cache; }; - typedef int32_t (*fop_heal_cbk_t)(call_frame_t *, void *, xlator_t *, int32_t, int32_t, uintptr_t, uintptr_t, uintptr_t, dict_t *); @@ -205,105 +189,105 @@ typedef int32_t (*fop_fheal_cbk_t)(call_frame_t *, void *, xlator_t *, int32_t, dict_t *); union _ec_cbk { - fop_access_cbk_t access; - fop_create_cbk_t create; - fop_discard_cbk_t discard; - fop_entrylk_cbk_t entrylk; - fop_fentrylk_cbk_t fentrylk; - fop_fallocate_cbk_t fallocate; - fop_flush_cbk_t flush; - fop_fsync_cbk_t fsync; - fop_fsyncdir_cbk_t fsyncdir; - fop_getxattr_cbk_t getxattr; - fop_fgetxattr_cbk_t fgetxattr; - fop_heal_cbk_t heal; - fop_fheal_cbk_t fheal; - fop_inodelk_cbk_t inodelk; - fop_finodelk_cbk_t finodelk; - fop_link_cbk_t link; - fop_lk_cbk_t lk; - fop_lookup_cbk_t lookup; - fop_mkdir_cbk_t mkdir; - fop_mknod_cbk_t mknod; - fop_open_cbk_t open; - fop_opendir_cbk_t opendir; - fop_readdir_cbk_t readdir; - fop_readdirp_cbk_t readdirp; - fop_readlink_cbk_t readlink; - fop_readv_cbk_t readv; - fop_removexattr_cbk_t removexattr; + fop_access_cbk_t access; + fop_create_cbk_t create; + fop_discard_cbk_t discard; + fop_entrylk_cbk_t entrylk; + fop_fentrylk_cbk_t fentrylk; + fop_fallocate_cbk_t fallocate; + fop_flush_cbk_t flush; + fop_fsync_cbk_t fsync; + fop_fsyncdir_cbk_t fsyncdir; + fop_getxattr_cbk_t getxattr; + fop_fgetxattr_cbk_t fgetxattr; + fop_heal_cbk_t heal; + fop_fheal_cbk_t fheal; + fop_inodelk_cbk_t inodelk; + fop_finodelk_cbk_t finodelk; + fop_link_cbk_t link; + fop_lk_cbk_t lk; + fop_lookup_cbk_t lookup; + fop_mkdir_cbk_t mkdir; + fop_mknod_cbk_t mknod; + fop_open_cbk_t open; + fop_opendir_cbk_t opendir; + fop_readdir_cbk_t readdir; + fop_readdirp_cbk_t readdirp; + fop_readlink_cbk_t readlink; + fop_readv_cbk_t readv; + fop_removexattr_cbk_t removexattr; fop_fremovexattr_cbk_t fremovexattr; - fop_rename_cbk_t rename; - fop_rmdir_cbk_t rmdir; - fop_setattr_cbk_t setattr; - fop_fsetattr_cbk_t fsetattr; - fop_setxattr_cbk_t setxattr; - fop_fsetxattr_cbk_t fsetxattr; - fop_stat_cbk_t stat; - fop_fstat_cbk_t fstat; - fop_statfs_cbk_t statfs; - fop_symlink_cbk_t symlink; - fop_truncate_cbk_t truncate; - fop_ftruncate_cbk_t ftruncate; - fop_unlink_cbk_t unlink; - fop_writev_cbk_t writev; - fop_xattrop_cbk_t xattrop; - fop_fxattrop_cbk_t fxattrop; - fop_zerofill_cbk_t zerofill; - fop_seek_cbk_t seek; - fop_ipc_cbk_t ipc; + fop_rename_cbk_t rename; + fop_rmdir_cbk_t rmdir; + fop_setattr_cbk_t setattr; + fop_fsetattr_cbk_t fsetattr; + fop_setxattr_cbk_t setxattr; + fop_fsetxattr_cbk_t fsetxattr; + fop_stat_cbk_t stat; + fop_fstat_cbk_t fstat; + fop_statfs_cbk_t statfs; + fop_symlink_cbk_t symlink; + fop_truncate_cbk_t truncate; + fop_ftruncate_cbk_t ftruncate; + fop_unlink_cbk_t unlink; + fop_writev_cbk_t writev; + fop_xattrop_cbk_t xattrop; + fop_fxattrop_cbk_t fxattrop; + fop_zerofill_cbk_t zerofill; + fop_seek_cbk_t seek; + fop_ipc_cbk_t ipc; }; struct _ec_lock { - ec_inode_t *ctx; - gf_timer_t *timer; + ec_inode_t *ctx; + gf_timer_t *timer; /* List of owners of this lock. All fops added to this list are running * concurrently. */ - struct list_head owners; + struct list_head owners; /* List of fops waiting to be an owner of the lock. Fops are added to this * list when the current owner has an incompatible access (conflicting lock) * or the lock is not acquired yet. */ - struct list_head waiting; + struct list_head waiting; /* List of fops that will wait until the next unlock/lock cycle. This * happens when the currently acquired lock is decided to be released as * soon as possible. In this case, all frozen fops will be continued only * after the lock is reacquired. */ - struct list_head frozen; - - uintptr_t mask; - uintptr_t good_mask; - uintptr_t healing; - uint32_t refs_owners; /* Refs for fops owning the lock */ - uint32_t refs_pending; /* Refs assigned to fops being prepared */ - uint32_t waiting_flags; /*Track xattrop/dirty marking*/ - gf_boolean_t acquired; - gf_boolean_t unlock_now; - gf_boolean_t release; - gf_boolean_t query; - fd_t *fd; - loc_t loc; + struct list_head frozen; + + uintptr_t mask; + uintptr_t good_mask; + uintptr_t healing; + uint32_t refs_owners; /* Refs for fops owning the lock */ + uint32_t refs_pending; /* Refs assigned to fops being prepared */ + uint32_t waiting_flags; /*Track xattrop/dirty marking*/ + gf_boolean_t acquired; + gf_boolean_t unlock_now; + gf_boolean_t release; + gf_boolean_t query; + fd_t *fd; + loc_t loc; union { - entrylk_type type; - struct gf_flock flock; + entrylk_type type; + struct gf_flock flock; }; }; struct _ec_lock_link { - ec_lock_t *lock; - ec_fop_data_t *fop; - struct list_head owner_list; - struct list_head wait_list; - gf_boolean_t update[2]; - gf_boolean_t dirty[2]; - gf_boolean_t optimistic_changelog; - loc_t *base; - uint64_t size; - uint32_t waiting_flags; - off_t fl_start; - off_t fl_end; + ec_lock_t *lock; + ec_fop_data_t *fop; + struct list_head owner_list; + struct list_head wait_list; + gf_boolean_t update[2]; + gf_boolean_t dirty[2]; + gf_boolean_t optimistic_changelog; + loc_t *base; + uint64_t size; + uint32_t waiting_flags; + off_t fl_start; + off_t fl_end; }; /* This structure keeps a range of fragment offsets affected by a fop. Since @@ -320,113 +304,113 @@ struct _ec_fragment_range { /* EC xlator data structure to collect all the data required to perform * the file operation.*/ struct _ec_fop_data { - int32_t id; /* ID of the file operation */ - int32_t refs; - int32_t state; - int32_t minimum; /* Minimum number of successful - operation required to conclude a - fop as successful */ - int32_t expected; - int32_t winds; - int32_t jobs; - int32_t error; - ec_fop_data_t *parent; - xlator_t *xl; /* points to EC xlator */ - call_frame_t *req_frame; /* frame of the calling xlator */ - call_frame_t *frame; /* frame used by this fop */ - struct list_head cbk_list; /* sorted list of groups of answers */ - struct list_head answer_list; /* list of answers */ - struct list_head pending_list; /* member of ec_t.pending_fops */ - ec_cbk_data_t *answer; /* accepted answer */ - int32_t lock_count; - int32_t locked; - ec_lock_link_t locks[2]; - int32_t first_lock; - gf_lock_t lock; - - uint32_t flags; - uint32_t first; - uintptr_t mask; - uintptr_t healing; /*Dispatch is done but call is successful only - if fop->minimum number of subvolumes succeed - which are not healing*/ - uintptr_t remaining; - uintptr_t received; /* Mask of responses */ - uintptr_t good; - - uid_t uid; - gid_t gid; - - ec_wind_f wind; /* Function to wind to */ - ec_handler_f handler; /* FOP manager function */ - ec_resume_f resume; - ec_cbk_t cbks; /* Callback function for this FOP */ - void *data; - ec_heal_t *heal; - struct list_head healer; - - uint64_t user_size; - uint32_t head; - - int32_t use_fd; /* Indicates whether this FOP uses FD or - not */ - - dict_t *xdata; - dict_t *dict; - int32_t int32; - uint32_t uint32; - uint64_t size; - off_t offset; - mode_t mode[2]; - entrylk_cmd entrylk_cmd; - entrylk_type entrylk_type; + int32_t id; /* ID of the file operation */ + int32_t refs; + int32_t state; + int32_t minimum; /* Minimum number of successful + operation required to conclude a + fop as successful */ + int32_t expected; + int32_t winds; + int32_t jobs; + int32_t error; + ec_fop_data_t *parent; + xlator_t *xl; /* points to EC xlator */ + call_frame_t *req_frame; /* frame of the calling xlator */ + call_frame_t *frame; /* frame used by this fop */ + struct list_head cbk_list; /* sorted list of groups of answers */ + struct list_head answer_list; /* list of answers */ + struct list_head pending_list; /* member of ec_t.pending_fops */ + ec_cbk_data_t *answer; /* accepted answer */ + int32_t lock_count; + int32_t locked; + ec_lock_link_t locks[2]; + int32_t first_lock; + gf_lock_t lock; + + uint32_t flags; + uint32_t first; + uintptr_t mask; + uintptr_t healing; /*Dispatch is done but call is successful only + if fop->minimum number of subvolumes succeed + which are not healing*/ + uintptr_t remaining; + uintptr_t received; /* Mask of responses */ + uintptr_t good; + + uid_t uid; + gid_t gid; + + ec_wind_f wind; /* Function to wind to */ + ec_handler_f handler; /* FOP manager function */ + ec_resume_f resume; + ec_cbk_t cbks; /* Callback function for this FOP */ + void *data; + ec_heal_t *heal; + struct list_head healer; + + uint64_t user_size; + uint32_t head; + + int32_t use_fd; /* Indicates whether this FOP uses FD or + not */ + + dict_t *xdata; + dict_t *dict; + int32_t int32; + uint32_t uint32; + uint64_t size; + off_t offset; + mode_t mode[2]; + entrylk_cmd entrylk_cmd; + entrylk_type entrylk_type; gf_xattrop_flags_t xattrop_flags; - dev_t dev; - inode_t *inode; - fd_t *fd; /* FD of the file on which FOP is - being carried upon */ - struct iatt iatt; - char *str[2]; - loc_t loc[2]; /* Holds the location details for - the file */ - struct gf_flock flock; - struct iovec *vector; - struct iobref *buffers; - gf_seek_what_t seek; - ec_fragment_range_t frag_range; /* This will hold the range of stripes - affected by the fop. */ - char *errstr; /*String of fop name, path and gfid + dev_t dev; + inode_t *inode; + fd_t *fd; /* FD of the file on which FOP is + being carried upon */ + struct iatt iatt; + char *str[2]; + loc_t loc[2]; /* Holds the location details for + the file */ + struct gf_flock flock; + struct iovec *vector; + struct iobref *buffers; + gf_seek_what_t seek; + ec_fragment_range_t frag_range; /* This will hold the range of stripes + affected by the fop. */ + char *errstr; /*String of fop name, path and gfid to be used in gf_msg. */ }; struct _ec_cbk_data { - struct list_head list; /* item in the sorted list of groups */ - struct list_head answer_list; /* item in the list of answers */ - ec_fop_data_t *fop; - ec_cbk_data_t *next; /* next answer in the same group */ - uint32_t idx; - int32_t op_ret; - int32_t op_errno; - int32_t count; - uintptr_t mask; - - dict_t *xdata; - dict_t *dict; - int32_t int32; - uintptr_t uintptr[3]; - uint64_t size; - uint64_t version[2]; - inode_t *inode; - fd_t *fd; - struct statvfs statvfs; - struct iatt iatt[5]; - struct gf_flock flock; - struct iovec *vector; - struct iobref *buffers; - char *str; - gf_dirent_t entries; - off_t offset; - gf_seek_what_t what; + struct list_head list; /* item in the sorted list of groups */ + struct list_head answer_list; /* item in the list of answers */ + ec_fop_data_t *fop; + ec_cbk_data_t *next; /* next answer in the same group */ + uint32_t idx; + int32_t op_ret; + int32_t op_errno; + int32_t count; + uintptr_t mask; + + dict_t *xdata; + dict_t *dict; + int32_t int32; + uintptr_t uintptr[3]; + uint64_t size; + uint64_t version[2]; + inode_t *inode; + fd_t *fd; + struct statvfs statvfs; + struct iatt iatt[5]; + struct gf_flock flock; + struct iovec *vector; + struct iobref *buffers; + char *str; + gf_dirent_t entries; + off_t offset; + gf_seek_what_t what; }; enum _ec_gf_opcode { @@ -441,26 +425,26 @@ enum _ec_gf_opcode { struct _ec_gf_op { ec_gf_opcode_t op; - uint32_t arg1; - uint32_t arg2; - uint32_t arg3; + uint32_t arg1; + uint32_t arg2; + uint32_t arg3; }; struct _ec_gf_mul { - uint32_t regs; - uint32_t map[EC_GF_MAX_REGS]; + uint32_t regs; + uint32_t map[EC_GF_MAX_REGS]; ec_gf_op_t *ops; }; struct _ec_gf { - uint32_t bits; - uint32_t size; - uint32_t mod; - uint32_t min_ops; - uint32_t max_ops; - uint32_t avg_ops; - uint32_t *log; - uint32_t *pow; + uint32_t bits; + uint32_t size; + uint32_t mod; + uint32_t min_ops; + uint32_t max_ops; + uint32_t avg_ops; + uint32_t *log; + uint32_t *pow; ec_gf_mul_t **table; }; @@ -483,207 +467,206 @@ struct _ec_code_gen { }; struct _ec_code { - gf_lock_t lock; - struct list_head spaces; - ec_gf_t *gf; - ec_code_gen_t *gen; + gf_lock_t lock; + struct list_head spaces; + ec_gf_t *gf; + ec_code_gen_t *gen; }; struct _ec_code_arg { - uint32_t value; + uint32_t value; }; struct _ec_code_op { - ec_gf_opcode_t op; - ec_code_arg_t arg1; - ec_code_arg_t arg2; - ec_code_arg_t arg3; + ec_gf_opcode_t op; + ec_code_arg_t arg1; + ec_code_arg_t arg2; + ec_code_arg_t arg3; }; struct _ec_code_builder { - ec_code_t *code; - uint64_t address; - uint8_t *data; - uint32_t size; - int32_t error; - uint32_t regs; - uint32_t bits; - uint32_t width; - uint32_t count; - uint32_t base; - uint32_t map[EC_GF_MAX_REGS]; - gf_boolean_t linear; - uint64_t loop; - ec_code_op_t ops[0]; + ec_code_t *code; + uint64_t address; + uint8_t *data; + uint32_t size; + int32_t error; + uint32_t regs; + uint32_t bits; + uint32_t width; + uint32_t count; + uint32_t base; + uint32_t map[EC_GF_MAX_REGS]; + gf_boolean_t linear; + uint64_t loop; + ec_code_op_t ops[0]; }; struct _ec_code_chunk { - struct list_head list; - size_t size; - ec_code_space_t *space; + struct list_head list; + size_t size; + ec_code_space_t *space; }; struct _ec_code_space { - struct list_head list; - struct list_head chunks; - ec_code_t *code; - void *exec; - size_t size; + struct list_head list; + struct list_head chunks; + ec_code_t *code; + void *exec; + size_t size; }; - union _ec_code_func { - ec_code_func_linear_t linear; + ec_code_func_linear_t linear; ec_code_func_interleaved_t interleaved; }; struct _ec_matrix_row { - ec_code_func_t func; - uint32_t *values; + ec_code_func_t func; + uint32_t *values; }; struct _ec_matrix { struct list_head lru; - uint32_t refs; - uint32_t columns; - uint32_t rows; - uintptr_t mask; - ec_code_t *code; - uint32_t *values; - ec_matrix_row_t row_data[0]; + uint32_t refs; + uint32_t columns; + uint32_t rows; + uintptr_t mask; + ec_code_t *code; + uint32_t *values; + ec_matrix_row_t row_data[0]; }; struct _ec_matrix_list { - struct list_head lru; - gf_lock_t lock; - uint32_t columns; - uint32_t rows; - uint32_t max; - uint32_t count; - uint32_t stripe; - struct mem_pool *pool; - ec_gf_t *gf; - ec_code_t *code; - ec_matrix_t *encode; - ec_matrix_t **objects; + struct list_head lru; + gf_lock_t lock; + uint32_t columns; + uint32_t rows; + uint32_t max; + uint32_t count; + uint32_t stripe; + struct mem_pool *pool; + ec_gf_t *gf; + ec_code_t *code; + ec_matrix_t *encode; + ec_matrix_t **objects; }; struct _ec_heal { - struct list_head list; - gf_lock_t lock; - xlator_t *xl; - ec_fop_data_t *fop; - void *data; - ec_fop_data_t *lookup; - loc_t loc; - struct iatt iatt; - char *symlink; - fd_t *fd; - int32_t partial; - int32_t done; - int32_t error; - gf_boolean_t nameheal; - uintptr_t available; - uintptr_t good; - uintptr_t bad; - uintptr_t open; - uintptr_t fixed; - uint64_t offset; - uint64_t size; - uint64_t total_size; - uint64_t version[2]; - uint64_t raw_size; + struct list_head list; + gf_lock_t lock; + xlator_t *xl; + ec_fop_data_t *fop; + void *data; + ec_fop_data_t *lookup; + loc_t loc; + struct iatt iatt; + char *symlink; + fd_t *fd; + int32_t partial; + int32_t done; + int32_t error; + gf_boolean_t nameheal; + uintptr_t available; + uintptr_t good; + uintptr_t bad; + uintptr_t open; + uintptr_t fixed; + uint64_t offset; + uint64_t size; + uint64_t total_size; + uint64_t version[2]; + uint64_t raw_size; }; struct subvol_healer { - xlator_t *this; - int subvol; - gf_boolean_t running; - gf_boolean_t rerun; - pthread_mutex_t mutex; - pthread_cond_t cond; - pthread_t thread; + xlator_t *this; + int subvol; + gf_boolean_t running; + gf_boolean_t rerun; + pthread_mutex_t mutex; + pthread_cond_t cond; + pthread_t thread; }; struct _ec_self_heald { - gf_boolean_t iamshd; - gf_boolean_t enabled; - int timeout; - uint32_t max_threads; - uint32_t wait_qlength; - struct subvol_healer *index_healers; - struct subvol_healer *full_healers; + gf_boolean_t iamshd; + gf_boolean_t enabled; + int timeout; + uint32_t max_threads; + uint32_t wait_qlength; + struct subvol_healer *index_healers; + struct subvol_healer *full_healers; }; struct _ec_statistics { - struct { - gf_atomic_t hits; /* Cache hits. */ - gf_atomic_t misses; /* Cache misses. */ - gf_atomic_t updates; /* Number of times an existing stripe has - been updated with new content. */ - gf_atomic_t invals; /* Number of times an existing stripe has - been invalidated because of truncates - or discards. */ - gf_atomic_t evicts; /* Number of times that an existing entry - has been evicted to make room for newer - entries. */ - gf_atomic_t allocs; /* Number of memory allocations made to - store stripes. */ - gf_atomic_t errors; /* Number of errors that have caused extra - requests. (Basically memory allocation - errors). */ - } stripe_cache; + struct { + gf_atomic_t hits; /* Cache hits. */ + gf_atomic_t misses; /* Cache misses. */ + gf_atomic_t updates; /* Number of times an existing stripe has + been updated with new content. */ + gf_atomic_t invals; /* Number of times an existing stripe has + been invalidated because of truncates + or discards. */ + gf_atomic_t evicts; /* Number of times that an existing entry + has been evicted to make room for newer + entries. */ + gf_atomic_t allocs; /* Number of memory allocations made to + store stripes. */ + gf_atomic_t errors; /* Number of errors that have caused extra + requests. (Basically memory allocation + errors). */ + } stripe_cache; }; struct _ec { - xlator_t *xl; - int32_t healers; - int32_t heal_waiters; - int32_t nodes; /* Total number of bricks(n) */ - int32_t bits_for_nodes; - int32_t fragments; /* Data bricks(k) */ - int32_t redundancy; /* Redundant bricks(m) */ - uint32_t fragment_size; /* Size of fragment/chunk on a - brick. */ - uint32_t stripe_size; /* (fragment_size * fragments) - maximum size of user data - stored in one stripe. */ - int32_t up; /* Represents whether EC volume is - up or not. */ - uint32_t idx; - uint32_t xl_up_count; /* Number of UP bricks. */ - uintptr_t xl_up; /* Bit flag representing UP - bricks */ - uint32_t xl_notify_count; /* Number of notifications. */ - uintptr_t xl_notify; /* Bit flag representing - notification for bricks. */ - uintptr_t node_mask; - xlator_t **xl_list; - gf_lock_t lock; - gf_timer_t *timer; - gf_boolean_t shutdown; - gf_boolean_t eager_lock; - gf_boolean_t other_eager_lock; - gf_boolean_t optimistic_changelog; - gf_boolean_t parallel_writes; - uint32_t stripe_cache; - uint32_t background_heals; - uint32_t heal_wait_qlen; - uint32_t self_heal_window_size; /* max size of read/writes */ - uint32_t eager_lock_timeout; - uint32_t other_eager_lock_timeout; - struct list_head pending_fops; - struct list_head heal_waiting; - struct list_head healing; - struct mem_pool *fop_pool; - struct mem_pool *cbk_pool; - struct mem_pool *lock_pool; - ec_self_heald_t shd; - char vol_uuid[UUID_SIZE + 1]; - dict_t *leaf_to_subvolid; - ec_read_policy_t read_policy; - ec_matrix_list_t matrix; - ec_statistics_t stats; + xlator_t *xl; + int32_t healers; + int32_t heal_waiters; + int32_t nodes; /* Total number of bricks(n) */ + int32_t bits_for_nodes; + int32_t fragments; /* Data bricks(k) */ + int32_t redundancy; /* Redundant bricks(m) */ + uint32_t fragment_size; /* Size of fragment/chunk on a + brick. */ + uint32_t stripe_size; /* (fragment_size * fragments) + maximum size of user data + stored in one stripe. */ + int32_t up; /* Represents whether EC volume is + up or not. */ + uint32_t idx; + uint32_t xl_up_count; /* Number of UP bricks. */ + uintptr_t xl_up; /* Bit flag representing UP + bricks */ + uint32_t xl_notify_count; /* Number of notifications. */ + uintptr_t xl_notify; /* Bit flag representing + notification for bricks. */ + uintptr_t node_mask; + xlator_t **xl_list; + gf_lock_t lock; + gf_timer_t *timer; + gf_boolean_t shutdown; + gf_boolean_t eager_lock; + gf_boolean_t other_eager_lock; + gf_boolean_t optimistic_changelog; + gf_boolean_t parallel_writes; + uint32_t stripe_cache; + uint32_t background_heals; + uint32_t heal_wait_qlen; + uint32_t self_heal_window_size; /* max size of read/writes */ + uint32_t eager_lock_timeout; + uint32_t other_eager_lock_timeout; + struct list_head pending_fops; + struct list_head heal_waiting; + struct list_head healing; + struct mem_pool *fop_pool; + struct mem_pool *cbk_pool; + struct mem_pool *lock_pool; + ec_self_heald_t shd; + char vol_uuid[UUID_SIZE + 1]; + dict_t *leaf_to_subvolid; + ec_read_policy_t read_policy; + ec_matrix_list_t matrix; + ec_statistics_t stats; }; #endif /* __EC_TYPES_H__ */ diff --git a/xlators/cluster/ec/src/ec.h b/xlators/cluster/ec/src/ec.h index e2ec9cf04f5..1b210d9adc1 100644 --- a/xlators/cluster/ec/src/ec.h +++ b/xlators/cluster/ec/src/ec.h @@ -13,15 +13,15 @@ #include "ec-method.h" -#define EC_XATTR_PREFIX "trusted.ec." -#define EC_XATTR_CONFIG EC_XATTR_PREFIX"config" -#define EC_XATTR_SIZE EC_XATTR_PREFIX"size" -#define EC_XATTR_VERSION EC_XATTR_PREFIX"version" -#define EC_XATTR_HEAL EC_XATTR_PREFIX"heal" -#define EC_XATTR_DIRTY EC_XATTR_PREFIX"dirty" -#define EC_STRIPE_CACHE_MAX_SIZE 10 +#define EC_XATTR_PREFIX "trusted.ec." +#define EC_XATTR_CONFIG EC_XATTR_PREFIX "config" +#define EC_XATTR_SIZE EC_XATTR_PREFIX "size" +#define EC_XATTR_VERSION EC_XATTR_PREFIX "version" +#define EC_XATTR_HEAL EC_XATTR_PREFIX "heal" +#define EC_XATTR_DIRTY EC_XATTR_PREFIX "dirty" +#define EC_STRIPE_CACHE_MAX_SIZE 10 #define EC_VERSION_SIZE 2 -#define EC_SHD_INODE_LRU_LIMIT 10 +#define EC_SHD_INODE_LRU_LIMIT 10 #define EC_MAX_FRAGMENTS EC_METHOD_MAX_FRAGMENTS /* The maximum number of nodes is derived from the maximum allowed fragments diff --git a/xlators/cluster/stripe/src/stripe-mem-types.h b/xlators/cluster/stripe/src/stripe-mem-types.h index e9ac9cf4648..dcbef31212b 100644 --- a/xlators/cluster/stripe/src/stripe-mem-types.h +++ b/xlators/cluster/stripe/src/stripe-mem-types.h @@ -8,24 +8,22 @@ cases as published by the Free Software Foundation. */ - #ifndef __STRIPE_MEM_TYPES_H__ #define __STRIPE_MEM_TYPES_H__ #include "mem-types.h" enum gf_stripe_mem_types_ { - gf_stripe_mt_iovec = gf_common_mt_end + 1, - gf_stripe_mt_stripe_replies, - gf_stripe_mt_stripe_fd_ctx_t, - gf_stripe_mt_char, - gf_stripe_mt_int8_t, - gf_stripe_mt_int32_t, - gf_stripe_mt_xlator_t, - gf_stripe_mt_stripe_private_t, - gf_stripe_mt_stripe_options, - gf_stripe_mt_xattr_sort_t, - gf_stripe_mt_end + gf_stripe_mt_iovec = gf_common_mt_end + 1, + gf_stripe_mt_stripe_replies, + gf_stripe_mt_stripe_fd_ctx_t, + gf_stripe_mt_char, + gf_stripe_mt_int8_t, + gf_stripe_mt_int32_t, + gf_stripe_mt_xlator_t, + gf_stripe_mt_stripe_private_t, + gf_stripe_mt_stripe_options, + gf_stripe_mt_xattr_sort_t, + gf_stripe_mt_end }; #endif - diff --git a/xlators/cluster/stripe/src/stripe.h b/xlators/cluster/stripe/src/stripe.h index 1e2fcb4e659..103c96491ff 100644 --- a/xlators/cluster/stripe/src/stripe.h +++ b/xlators/cluster/stripe/src/stripe.h @@ -8,7 +8,6 @@ cases as published by the Free Software Foundation. */ - #ifndef _STRIPE_H_ #define _STRIPE_H_ @@ -24,53 +23,55 @@ #include <signal.h> #define STRIPE_PATHINFO_HEADER "STRIPE:" -#define STRIPE_MIN_BLOCK_SIZE (16*GF_UNIT_KB) - -#define STRIPE_STACK_UNWIND(fop, frame, params ...) do { \ - stripe_local_t *__local = NULL; \ - if (frame) { \ - __local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - if (__local) { \ - stripe_local_wipe(__local); \ - mem_put (__local); \ - } \ - } while (0) - -#define STRIPE_STACK_DESTROY(frame) do { \ - stripe_local_t *__local = NULL; \ - __local = frame->local; \ - frame->local = NULL; \ - STACK_DESTROY (frame->root); \ - if (__local) { \ - stripe_local_wipe (__local); \ - mem_put (__local); \ - } \ - } while (0) - -#define STRIPE_VALIDATE_FCTX(fctx, label) do { \ - int idx = 0; \ - if (!fctx) { \ - op_errno = EINVAL; \ - goto label; \ - } \ - for (idx = 0; idx < fctx->stripe_count; idx++) { \ - if (!fctx->xl_array[idx]) { \ - gf_log (this->name, GF_LOG_ERROR, \ - "fctx->xl_array[%d] is NULL", \ - idx); \ - op_errno = ESTALE; \ - goto label; \ - } \ - } \ - } while (0) +#define STRIPE_MIN_BLOCK_SIZE (16 * GF_UNIT_KB) + +#define STRIPE_STACK_UNWIND(fop, frame, params...) \ + do { \ + stripe_local_t *__local = NULL; \ + if (frame) { \ + __local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + if (__local) { \ + stripe_local_wipe(__local); \ + mem_put(__local); \ + } \ + } while (0) + +#define STRIPE_STACK_DESTROY(frame) \ + do { \ + stripe_local_t *__local = NULL; \ + __local = frame->local; \ + frame->local = NULL; \ + STACK_DESTROY(frame->root); \ + if (__local) { \ + stripe_local_wipe(__local); \ + mem_put(__local); \ + } \ + } while (0) + +#define STRIPE_VALIDATE_FCTX(fctx, label) \ + do { \ + int idx = 0; \ + if (!fctx) { \ + op_errno = EINVAL; \ + goto label; \ + } \ + for (idx = 0; idx < fctx->stripe_count; idx++) { \ + if (!fctx->xl_array[idx]) { \ + gf_log(this->name, GF_LOG_ERROR, "fctx->xl_array[%d] is NULL", \ + idx); \ + op_errno = ESTALE; \ + goto label; \ + } \ + } \ + } while (0) typedef struct stripe_xattr_sort { - int pos; - int xattr_len; - char *xattr_value; + int pos; + int xattr_len; + char *xattr_value; } stripe_xattr_sort_t; /** @@ -78,204 +79,213 @@ typedef struct stripe_xattr_sort { * information, which is used for striping on a file. */ struct stripe_options { - struct stripe_options *next; - char path_pattern[256]; - uint64_t block_size; + struct stripe_options *next; + char path_pattern[256]; + uint64_t block_size; }; /** * Private structure for stripe translator */ struct stripe_private { - struct stripe_options *pattern; - xlator_t **xl_array; - uint64_t block_size; - gf_lock_t lock; - uint8_t nodes_down; - int8_t first_child_down; - int *last_event; - int8_t child_count; - gf_boolean_t xattr_supported; /* default yes */ - gf_boolean_t coalesce; - char vol_uuid[UUID_SIZE + 1]; + struct stripe_options *pattern; + xlator_t **xl_array; + uint64_t block_size; + gf_lock_t lock; + uint8_t nodes_down; + int8_t first_child_down; + int *last_event; + int8_t child_count; + gf_boolean_t xattr_supported; /* default yes */ + gf_boolean_t coalesce; + char vol_uuid[UUID_SIZE + 1]; }; /** * Used to keep info about the replies received from readv/writev calls */ struct stripe_replies { - struct iovec *vector; - int32_t count; //count of vector - int32_t op_ret; //op_ret of readv - int32_t op_errno; - int32_t requested_size; - struct iatt stbuf; /* 'stbuf' is also a part of reply */ + struct iovec *vector; + int32_t count; // count of vector + int32_t op_ret; // op_ret of readv + int32_t op_errno; + int32_t requested_size; + struct iatt stbuf; /* 'stbuf' is also a part of reply */ }; typedef struct _stripe_fd_ctx { - off_t stripe_size; - int stripe_count; - int stripe_coalesce; - int static_array; - xlator_t **xl_array; + off_t stripe_size; + int stripe_count; + int stripe_coalesce; + int static_array; + xlator_t **xl_array; } stripe_fd_ctx_t; - /** * Local structure to be passed with all the frames in case of STACK_WIND */ struct stripe_local; /* this itself is used inside the structure; */ struct stripe_local { - struct stripe_local *next; - call_frame_t *orig_frame; - - stripe_fd_ctx_t *fctx; - - /* Used by _cbk functions */ - struct iatt stbuf; - struct iatt pre_buf; - struct iatt post_buf; - struct iatt preparent; - struct iatt postparent; - - off_t stbuf_size; - off_t prebuf_size; - off_t postbuf_size; - off_t preparent_size; - off_t postparent_size; - - blkcnt_t stbuf_blocks; - blkcnt_t prebuf_blocks; - blkcnt_t postbuf_blocks; - blkcnt_t preparent_blocks; - blkcnt_t postparent_blocks; - - struct stripe_replies *replies; - struct statvfs statvfs_buf; - dir_entry_t *entry; - - int8_t revalidate; - int8_t failed; - int8_t unwind; - - size_t readv_size; - int32_t entry_count; - int32_t node_index; - int32_t call_count; - int32_t wind_count; /* used instead of child_cound - in case of read and write */ - int32_t op_ret; - int32_t op_errno; - int32_t count; - int32_t flags; - char *name; - inode_t *inode; - - loc_t loc; - loc_t loc2; - - mode_t mode; - dev_t rdev; - /* For File I/O fops */ - dict_t *xdata; - - stripe_xattr_sort_t *xattr_list; - int32_t xattr_total_len; - int32_t nallocs; - char xsel[256]; - - /* General usage */ - off_t offset; - off_t stripe_size; - - int xattr_self_heal_needed; - int entry_self_heal_needed; - - int8_t *list; - struct gf_flock lock; - fd_t *fd; - void *value; - struct iobref *iobref; - gf_dirent_t entries; - gf_dirent_t *dirent; - dict_t *xattr; - uuid_t ia_gfid; - - int xflag; - mode_t umask; + struct stripe_local *next; + call_frame_t *orig_frame; + + stripe_fd_ctx_t *fctx; + + /* Used by _cbk functions */ + struct iatt stbuf; + struct iatt pre_buf; + struct iatt post_buf; + struct iatt preparent; + struct iatt postparent; + + off_t stbuf_size; + off_t prebuf_size; + off_t postbuf_size; + off_t preparent_size; + off_t postparent_size; + + blkcnt_t stbuf_blocks; + blkcnt_t prebuf_blocks; + blkcnt_t postbuf_blocks; + blkcnt_t preparent_blocks; + blkcnt_t postparent_blocks; + + struct stripe_replies *replies; + struct statvfs statvfs_buf; + dir_entry_t *entry; + + int8_t revalidate; + int8_t failed; + int8_t unwind; + + size_t readv_size; + int32_t entry_count; + int32_t node_index; + int32_t call_count; + int32_t wind_count; /* used instead of child_cound + in case of read and write */ + int32_t op_ret; + int32_t op_errno; + int32_t count; + int32_t flags; + char *name; + inode_t *inode; + + loc_t loc; + loc_t loc2; + + mode_t mode; + dev_t rdev; + /* For File I/O fops */ + dict_t *xdata; + + stripe_xattr_sort_t *xattr_list; + int32_t xattr_total_len; + int32_t nallocs; + char xsel[256]; + + /* General usage */ + off_t offset; + off_t stripe_size; + + int xattr_self_heal_needed; + int entry_self_heal_needed; + + int8_t *list; + struct gf_flock lock; + fd_t *fd; + void *value; + struct iobref *iobref; + gf_dirent_t entries; + gf_dirent_t *dirent; + dict_t *xattr; + uuid_t ia_gfid; + + int xflag; + mode_t umask; }; -typedef struct stripe_local stripe_local_t; +typedef struct stripe_local stripe_local_t; typedef struct stripe_private stripe_private_t; /* * Determine the stripe index of a particular frame based on the translator. */ -static inline int32_t stripe_get_frame_index(stripe_fd_ctx_t *fctx, - call_frame_t *prev) +static inline int32_t +stripe_get_frame_index(stripe_fd_ctx_t *fctx, call_frame_t *prev) { - int32_t i, idx = -1; + int32_t i, idx = -1; - for (i = 0; i < fctx->stripe_count; i++) { - if (fctx->xl_array[i] == prev->this) { - idx = i; - break; - } - } + for (i = 0; i < fctx->stripe_count; i++) { + if (fctx->xl_array[i] == prev->this) { + idx = i; + break; + } + } - return idx; + return idx; } -static inline void stripe_copy_xl_array(xlator_t **dst, xlator_t **src, - int count) +static inline void +stripe_copy_xl_array(xlator_t **dst, xlator_t **src, int count) { - int i; + int i; - for (i = 0; i < count; i++) - dst[i] = src[i]; + for (i = 0; i < count; i++) + dst[i] = src[i]; } -void stripe_local_wipe (stripe_local_t *local); -int32_t stripe_ctx_handle (xlator_t *this, call_frame_t *prev, - stripe_local_t *local, dict_t *dict); -void stripe_aggregate_xattr (dict_t *dst, dict_t *src); -int32_t stripe_xattr_request_build (xlator_t *this, dict_t *dict, - uint64_t stripe_size, uint32_t stripe_count, - uint32_t stripe_index, - uint32_t stripe_coalesce); -int32_t stripe_get_matching_bs (const char *path, stripe_private_t *priv); -int set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data); -int32_t stripe_iatt_merge (struct iatt *from, struct iatt *to); -int32_t stripe_fill_pathinfo_xattr (xlator_t *this, stripe_local_t *local, - char **xattr_serz); -int32_t stripe_free_xattr_str (stripe_local_t *local); -int32_t stripe_xattr_aggregate (char *buffer, stripe_local_t *local, - int32_t *total); -off_t coalesced_offset(off_t offset, uint64_t stripe_size, int stripe_count); -off_t uncoalesced_size(off_t size, uint64_t stripe_size, int stripe_count, - int stripe_index); +void +stripe_local_wipe(stripe_local_t *local); +int32_t +stripe_ctx_handle(xlator_t *this, call_frame_t *prev, stripe_local_t *local, + dict_t *dict); +void +stripe_aggregate_xattr(dict_t *dst, dict_t *src); +int32_t +stripe_xattr_request_build(xlator_t *this, dict_t *dict, uint64_t stripe_size, + uint32_t stripe_count, uint32_t stripe_index, + uint32_t stripe_coalesce); +int32_t +stripe_get_matching_bs(const char *path, stripe_private_t *priv); +int +set_stripe_block_size(xlator_t *this, stripe_private_t *priv, char *data); +int32_t +stripe_iatt_merge(struct iatt *from, struct iatt *to); +int32_t +stripe_fill_pathinfo_xattr(xlator_t *this, stripe_local_t *local, + char **xattr_serz); +int32_t +stripe_free_xattr_str(stripe_local_t *local); +int32_t +stripe_xattr_aggregate(char *buffer, stripe_local_t *local, int32_t *total); +off_t +coalesced_offset(off_t offset, uint64_t stripe_size, int stripe_count); +off_t +uncoalesced_size(off_t size, uint64_t stripe_size, int stripe_count, + int stripe_index); int32_t -stripe_fill_lockinfo_xattr (xlator_t *this, stripe_local_t *local, - void **xattr_serz); +stripe_fill_lockinfo_xattr(xlator_t *this, stripe_local_t *local, + void **xattr_serz); /* * Adjust the size attribute for files if coalesce is enabled. */ -static inline void correct_file_size(struct iatt *buf, stripe_fd_ctx_t *fctx, - call_frame_t *prev) +static inline void +correct_file_size(struct iatt *buf, stripe_fd_ctx_t *fctx, call_frame_t *prev) { - int index; + int index; - if (!IA_ISREG(buf->ia_type)) - return; + if (!IA_ISREG(buf->ia_type)) + return; - if (!fctx || !fctx->stripe_coalesce) - return; + if (!fctx || !fctx->stripe_coalesce) + return; - index = stripe_get_frame_index(fctx, prev); - buf->ia_size = uncoalesced_size(buf->ia_size, fctx->stripe_size, - fctx->stripe_count, index); + index = stripe_get_frame_index(fctx, prev); + buf->ia_size = uncoalesced_size(buf->ia_size, fctx->stripe_size, + fctx->stripe_count, index); } #endif /* _STRIPE_H_ */ diff --git a/xlators/debug/delay-gen/src/delay-gen-mem-types.h b/xlators/debug/delay-gen/src/delay-gen-mem-types.h index 8c54f5f922e..63a15a70da3 100644 --- a/xlators/debug/delay-gen/src/delay-gen-mem-types.h +++ b/xlators/debug/delay-gen/src/delay-gen-mem-types.h @@ -8,15 +8,14 @@ * cases as published by the Free Software Foundation. */ - #ifndef __DELAY_GEN_MEM_TYPES_H__ #define __DELAY_GEN_MEM_TYPES_H__ #include "mem-types.h" enum gf_delay_gen_mem_types_ { - gf_delay_gen_mt_dg_t = gf_common_mt_end + 1, - gf_delay_gen_mt_end + gf_delay_gen_mt_dg_t = gf_common_mt_end + 1, + gf_delay_gen_mt_end }; #endif /* __DELAY_GEN_MEM_TYPES_H__ */ diff --git a/xlators/debug/delay-gen/src/delay-gen.h b/xlators/debug/delay-gen/src/delay-gen.h index e1111c782e2..5e4d179f0b4 100644 --- a/xlators/debug/delay-gen/src/delay-gen.h +++ b/xlators/debug/delay-gen/src/delay-gen.h @@ -8,7 +8,6 @@ * cases as published by the Free Software Foundation. */ - #ifndef __DELAY_GEN_H__ #define __DELAY_GEN_H__ @@ -19,10 +18,10 @@ #include "defaults.h" typedef struct { - int enable[GF_FOP_MAXVALUE]; - int op_count; - int delay_ppm; - int delay_duration; + int enable[GF_FOP_MAXVALUE]; + int op_count; + int delay_ppm; + int delay_duration; } dg_t; #endif /* __DELAY_GEN_H__ */ diff --git a/xlators/debug/error-gen/src/error-gen-mem-types.h b/xlators/debug/error-gen/src/error-gen-mem-types.h index f02280535df..2facd6b27cb 100644 --- a/xlators/debug/error-gen/src/error-gen-mem-types.h +++ b/xlators/debug/error-gen/src/error-gen-mem-types.h @@ -14,7 +14,7 @@ #include "mem-types.h" enum gf_error_gen_mem_types_ { - gf_error_gen_mt_eg_t = gf_common_mt_end + 1, - gf_error_gen_mt_end + gf_error_gen_mt_eg_t = gf_common_mt_end + 1, + gf_error_gen_mt_end }; #endif diff --git a/xlators/debug/error-gen/src/error-gen.h b/xlators/debug/error-gen/src/error-gen.h index 2cd95de335a..ffa09252d0f 100644 --- a/xlators/debug/error-gen/src/error-gen.h +++ b/xlators/debug/error-gen/src/error-gen.h @@ -22,29 +22,29 @@ * range. */ enum GF_PSEUDO_ERRORS { - GF_ERROR_SHORT_WRITE = 1000, /* short writev return value */ - GF_ERROR_MAX + GF_ERROR_SHORT_WRITE = 1000, /* short writev return value */ + GF_ERROR_MAX }; typedef struct { - int enable[GF_FOP_MAXVALUE]; - int op_count; - /* - * This is only an iteration number in the random-failure case. For - * the normal controlled-probability case, it's actually a numerator - * for the failure probability (see FAILURE_GRANULARITY declaration). - * It's just not worth blowing up the diff by changing it. - */ - int failure_iter_no; - char *error_no; - int error_no_int; - gf_boolean_t random_failure; - gf_lock_t lock; + int enable[GF_FOP_MAXVALUE]; + int op_count; + /* + * This is only an iteration number in the random-failure case. For + * the normal controlled-probability case, it's actually a numerator + * for the failure probability (see FAILURE_GRANULARITY declaration). + * It's just not worth blowing up the diff by changing it. + */ + int failure_iter_no; + char *error_no; + int error_no_int; + gf_boolean_t random_failure; + gf_lock_t lock; } eg_t; typedef struct { - int error_no_count; - int error_no[20]; + int error_no_count; + int error_no[20]; } sys_error_t; #endif diff --git a/xlators/debug/io-stats/src/io-stats-mem-types.h b/xlators/debug/io-stats/src/io-stats-mem-types.h index 9dde9373264..bc25fd2ca4e 100644 --- a/xlators/debug/io-stats/src/io-stats-mem-types.h +++ b/xlators/debug/io-stats/src/io-stats-mem-types.h @@ -16,13 +16,12 @@ extern const char *__progname; enum gf_io_stats_mem_types_ { - gf_io_stats_mt_ios_conf = gf_common_mt_end + 1, - gf_io_stats_mt_ios_fd, - gf_io_stats_mt_ios_stat, - gf_io_stats_mt_ios_stat_list, - gf_io_stats_mt_ios_sample_buf, - gf_io_stats_mt_ios_sample, - gf_io_stats_mt_end + gf_io_stats_mt_ios_conf = gf_common_mt_end + 1, + gf_io_stats_mt_ios_fd, + gf_io_stats_mt_ios_stat, + gf_io_stats_mt_ios_stat_list, + gf_io_stats_mt_ios_sample_buf, + gf_io_stats_mt_ios_sample, + gf_io_stats_mt_end }; #endif - diff --git a/xlators/debug/trace/src/trace-mem-types.h b/xlators/debug/trace/src/trace-mem-types.h index 9fa7d97c2ca..cf05a77b9f1 100644 --- a/xlators/debug/trace/src/trace-mem-types.h +++ b/xlators/debug/trace/src/trace-mem-types.h @@ -8,14 +8,13 @@ cases as published by the Free Software Foundation. */ - #ifndef __TRACE_MEM_TYPES_H__ #define __TRACE_MEM_TYPES_H__ #include "mem-types.h" enum gf_trace_mem_types_ { - gf_trace_mt_trace_conf_t = gf_common_mt_end + 1, - gf_trace_mt_end + gf_trace_mt_trace_conf_t = gf_common_mt_end + 1, + gf_trace_mt_end }; #endif diff --git a/xlators/debug/trace/src/trace.h b/xlators/debug/trace/src/trace.h index 3b5f7891d00..815647c05be 100644 --- a/xlators/debug/trace/src/trace.h +++ b/xlators/debug/trace/src/trace.h @@ -22,35 +22,34 @@ #define TRACE_DEFAULT_HISTORY_SIZE 1024 typedef struct { - /* Since the longest fop name is fremovexattr i.e 12 characters, array size - * is kept 24, i.e double of the maximum. - */ - char name[24]; - int enabled; + /* Since the longest fop name is fremovexattr i.e 12 characters, array size + * is kept 24, i.e double of the maximum. + */ + char name[24]; + int enabled; } trace_fop_name_t; trace_fop_name_t trace_fop_names[GF_FOP_MAXVALUE]; typedef struct { - gf_boolean_t log_file; - gf_boolean_t log_history; - size_t history_size; - int trace_log_level; + gf_boolean_t log_file; + gf_boolean_t log_history; + size_t history_size; + int trace_log_level; } trace_conf_t; -#define TRACE_STACK_UNWIND(op, frame, params ...) \ - do { \ - frame->local = NULL; \ - STACK_UNWIND_STRICT (op, frame, params); \ - } while (0); - -#define LOG_ELEMENT(_conf, _string) \ - do { \ - if (_conf) { \ - if ((_conf->log_history) == _gf_true) \ - gf_log_eh ("%s", _string); \ - if ((_conf->log_file) == _gf_true) \ - gf_log (THIS->name, _conf->trace_log_level, \ - "%s", _string); \ - } \ - } while (0); +#define TRACE_STACK_UNWIND(op, frame, params...) \ + do { \ + frame->local = NULL; \ + STACK_UNWIND_STRICT(op, frame, params); \ + } while (0); + +#define LOG_ELEMENT(_conf, _string) \ + do { \ + if (_conf) { \ + if ((_conf->log_history) == _gf_true) \ + gf_log_eh("%s", _string); \ + if ((_conf->log_file) == _gf_true) \ + gf_log(THIS->name, _conf->trace_log_level, "%s", _string); \ + } \ + } while (0); diff --git a/xlators/encryption/crypt/src/crypt-common.h b/xlators/encryption/crypt/src/crypt-common.h index 7c212ad5d25..123d5c2a631 100644 --- a/xlators/encryption/crypt/src/crypt-common.h +++ b/xlators/encryption/crypt/src/crypt-common.h @@ -12,75 +12,79 @@ #define __CRYPT_COMMON_H__ #define INVAL_SUBVERSION_NUMBER (0xff) -#define CRYPT_INVAL_OP (GF_FOP_NULL) - -#define CRYPTO_FORMAT_PREFIX "trusted.glusterfs.crypt.att.cfmt" -#define FSIZE_XATTR_PREFIX "trusted.glusterfs.crypt.att.size" -#define SUBREQ_PREFIX "trusted.glusterfs.crypt.msg.sreq" -#define FSIZE_MSG_PREFIX "trusted.glusterfs.crypt.msg.size" -#define DE_MSG_PREFIX "trusted.glusterfs.crypt.msg.dent" -#define REQUEST_ID_PREFIX "trusted.glusterfs.crypt.msg.rqid" -#define MSGFLAGS_PREFIX "trusted.glusterfs.crypt.msg.xfgs" +#define CRYPT_INVAL_OP (GF_FOP_NULL) +#define CRYPTO_FORMAT_PREFIX "trusted.glusterfs.crypt.att.cfmt" +#define FSIZE_XATTR_PREFIX "trusted.glusterfs.crypt.att.size" +#define SUBREQ_PREFIX "trusted.glusterfs.crypt.msg.sreq" +#define FSIZE_MSG_PREFIX "trusted.glusterfs.crypt.msg.size" +#define DE_MSG_PREFIX "trusted.glusterfs.crypt.msg.dent" +#define REQUEST_ID_PREFIX "trusted.glusterfs.crypt.msg.rqid" +#define MSGFLAGS_PREFIX "trusted.glusterfs.crypt.msg.xfgs" /* messages for crypt_open() */ -#define MSGFLAGS_REQUEST_MTD_RLOCK 1 /* take read lock and don't unlock */ -#define MSGFLAGS_REQUEST_MTD_WLOCK 2 /* take write lock and don't unlock */ +#define MSGFLAGS_REQUEST_MTD_RLOCK 1 /* take read lock and don't unlock */ +#define MSGFLAGS_REQUEST_MTD_WLOCK 2 /* take write lock and don't unlock */ #define AES_BLOCK_BITS (4) /* AES_BLOCK_SIZE == 1 << AES_BLOCK_BITS */ -#define noop do {; } while (0) -#define cassert(cond) ({ switch (-1) { case (cond): case 0: break; } }) +#define noop \ + do { \ + ; \ + } while (0) +#define cassert(cond) \ + ({ \ + switch (-1) { \ + case (cond): \ + case 0: \ + break; \ + } \ + }) #define __round_mask(x, y) ((__typeof__(x))((y)-1)) -#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) +#define round_up(x, y) ((((x)-1) | __round_mask(x, y)) + 1) /* * Format of file's metadata */ struct crypt_format { - uint8_t loader_id; /* version of metadata loader */ - uint8_t versioned[0]; /* file's metadata of specific version */ + uint8_t loader_id; /* version of metadata loader */ + uint8_t versioned[0]; /* file's metadata of specific version */ } __attribute__((packed)); -typedef enum { - AES_CIPHER_ALG, - LAST_CIPHER_ALG -} cipher_alg_t; +typedef enum { AES_CIPHER_ALG, LAST_CIPHER_ALG } cipher_alg_t; -typedef enum { - XTS_CIPHER_MODE, - LAST_CIPHER_MODE -} cipher_mode_t; +typedef enum { XTS_CIPHER_MODE, LAST_CIPHER_MODE } cipher_mode_t; -typedef enum { - MTD_LOADER_V1, - LAST_MTD_LOADER -} mtd_loader_id; +typedef enum { MTD_LOADER_V1, LAST_MTD_LOADER } mtd_loader_id; -static inline void msgflags_set_mtd_rlock(uint32_t *flags) +static inline void +msgflags_set_mtd_rlock(uint32_t *flags) { - *flags |= MSGFLAGS_REQUEST_MTD_RLOCK; + *flags |= MSGFLAGS_REQUEST_MTD_RLOCK; } -static inline void msgflags_set_mtd_wlock(uint32_t *flags) +static inline void +msgflags_set_mtd_wlock(uint32_t *flags) { - *flags |= MSGFLAGS_REQUEST_MTD_WLOCK; + *flags |= MSGFLAGS_REQUEST_MTD_WLOCK; } -static inline gf_boolean_t msgflags_check_mtd_rlock(uint32_t *flags) +static inline gf_boolean_t +msgflags_check_mtd_rlock(uint32_t *flags) { - return *flags & MSGFLAGS_REQUEST_MTD_RLOCK; + return *flags & MSGFLAGS_REQUEST_MTD_RLOCK; } -static inline gf_boolean_t msgflags_check_mtd_wlock(uint32_t *flags) +static inline gf_boolean_t +msgflags_check_mtd_wlock(uint32_t *flags) { - return *flags & MSGFLAGS_REQUEST_MTD_WLOCK; + return *flags & MSGFLAGS_REQUEST_MTD_WLOCK; } -static inline gf_boolean_t msgflags_check_mtd_lock(uint32_t *flags) +static inline gf_boolean_t +msgflags_check_mtd_lock(uint32_t *flags) { - return msgflags_check_mtd_rlock(flags) || - msgflags_check_mtd_wlock(flags); + return msgflags_check_mtd_rlock(flags) || msgflags_check_mtd_wlock(flags); } /* @@ -88,10 +92,10 @@ static inline gf_boolean_t msgflags_check_mtd_lock(uint32_t *flags) * (maybe partially) by @count bytes * at offset @start. */ -static inline off_t logical_blocks_occupied(uint64_t start, off_t count, - int blkbits) +static inline off_t +logical_blocks_occupied(uint64_t start, off_t count, int blkbits) { - return ((start + count - 1) >> blkbits) - (start >> blkbits) + 1; + return ((start + count - 1) >> blkbits) - (start >> blkbits) + 1; } /* @@ -99,32 +103,20 @@ static inline off_t logical_blocks_occupied(uint64_t start, off_t count, * and @off2 respectively) in the same logical * block. */ -static inline int in_same_lblock(uint64_t off1, uint64_t off2, - int blkbits) +static inline int +in_same_lblock(uint64_t off1, uint64_t off2, int blkbits) { - return off1 >> blkbits == off2 >> blkbits; + return off1 >> blkbits == off2 >> blkbits; } -static inline void dump_cblock(xlator_t *this, unsigned char *buf) +static inline void +dump_cblock(xlator_t *this, unsigned char *buf) { - gf_log(this->name, GF_LOG_DEBUG, - "dump cblock: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", - (buf)[0], - (buf)[1], - (buf)[2], - (buf)[3], - (buf)[4], - (buf)[5], - (buf)[6], - (buf)[7], - (buf)[8], - (buf)[9], - (buf)[10], - (buf)[11], - (buf)[12], - (buf)[13], - (buf)[14], - (buf)[15]); + gf_log(this->name, GF_LOG_DEBUG, + "dump cblock: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x", + (buf)[0], (buf)[1], (buf)[2], (buf)[3], (buf)[4], (buf)[5], (buf)[6], + (buf)[7], (buf)[8], (buf)[9], (buf)[10], (buf)[11], (buf)[12], + (buf)[13], (buf)[14], (buf)[15]); } #endif /* __CRYPT_COMMON_H__ */ diff --git a/xlators/encryption/crypt/src/crypt-mem-types.h b/xlators/encryption/crypt/src/crypt-mem-types.h index 1954c579423..7e9fb90ed43 100644 --- a/xlators/encryption/crypt/src/crypt-mem-types.h +++ b/xlators/encryption/crypt/src/crypt-mem-types.h @@ -8,24 +8,23 @@ cases as published by the Free Software Foundation. */ - #ifndef __CRYPT_MEM_TYPES_H__ #define __CRYPT_MEM_TYPES_H__ #include "mem-types.h" enum gf_crypt_mem_types_ { - gf_crypt_mt_priv = gf_common_mt_end + 1, - gf_crypt_mt_inode, - gf_crypt_mt_data, - gf_crypt_mt_mtd, - gf_crypt_mt_loc, - gf_crypt_mt_iatt, - gf_crypt_mt_key, - gf_crypt_mt_iovec, - gf_crypt_mt_char, - gf_crypt_mt_local, - gf_crypt_mt_end, + gf_crypt_mt_priv = gf_common_mt_end + 1, + gf_crypt_mt_inode, + gf_crypt_mt_data, + gf_crypt_mt_mtd, + gf_crypt_mt_loc, + gf_crypt_mt_iatt, + gf_crypt_mt_key, + gf_crypt_mt_iovec, + gf_crypt_mt_char, + gf_crypt_mt_local, + gf_crypt_mt_end, }; #endif /* __CRYPT_MEM_TYPES_H__ */ @@ -40,6 +39,3 @@ enum gf_crypt_mem_types_ { scroll-step: 1 End: */ - - - diff --git a/xlators/encryption/crypt/src/crypt.h b/xlators/encryption/crypt/src/crypt.h index 5a2b1a9cc3b..390eee831b1 100644 --- a/xlators/encryption/crypt/src/crypt.h +++ b/xlators/encryption/crypt/src/crypt.h @@ -20,11 +20,11 @@ #include "crypt-mem-types.h" #include "compat.h" -#define CRYPT_XLATOR_ID (0) +#define CRYPT_XLATOR_ID (0) #define MAX_IOVEC_BITS (3) #define MAX_IOVEC (1 << MAX_IOVEC_BITS) -#define KEY_FACTOR_BITS (6) +#define KEY_FACTOR_BITS (6) #define DEBUG_CRYPT (0) #define TRIVIAL_TFM (0) @@ -40,8 +40,8 @@ typedef off_t loff_t; #endif struct crypt_key { - uint32_t len; - const char *label; + uint32_t len; + const char *label; }; /* @@ -49,113 +49,110 @@ struct crypt_key { * enumeration but before LAST_KEY_TYPE */ typedef enum { - MASTER_VOL_KEY, - NMTD_VOL_KEY, - NMTD_LINK_KEY, - EMTD_FILE_KEY, - DATA_FILE_KEY_256, - DATA_FILE_KEY_512, - LAST_KEY_TYPE -}crypt_key_type; + MASTER_VOL_KEY, + NMTD_VOL_KEY, + NMTD_LINK_KEY, + EMTD_FILE_KEY, + DATA_FILE_KEY_256, + DATA_FILE_KEY_512, + LAST_KEY_TYPE +} crypt_key_type; struct kderive_context { - const unsigned char *pkey;/* parent key */ - uint32_t pkey_len; /* parent key size, bits */ - uint32_t ckey_len; /* child key size, bits */ - unsigned char *fid; /* fixed input data, NIST 800-108, 5.1 */ - uint32_t fid_len; /* fid len, bytes */ - unsigned char *out; /* contains child keying material */ - uint32_t out_len; /* out len, bytes */ + const unsigned char *pkey; /* parent key */ + uint32_t pkey_len; /* parent key size, bits */ + uint32_t ckey_len; /* child key size, bits */ + unsigned char *fid; /* fixed input data, NIST 800-108, 5.1 */ + uint32_t fid_len; /* fid len, bytes */ + unsigned char *out; /* contains child keying material */ + uint32_t out_len; /* out len, bytes */ }; -typedef enum { - DATA_ATOM, - HOLE_ATOM, - LAST_DATA_TYPE -}atom_data_type; +typedef enum { DATA_ATOM, HOLE_ATOM, LAST_DATA_TYPE } atom_data_type; typedef enum { - HEAD_ATOM, - TAIL_ATOM, - FULL_ATOM, - LAST_LOCALITY_TYPE -}atom_locality_type; + HEAD_ATOM, + TAIL_ATOM, + FULL_ATOM, + LAST_LOCALITY_TYPE +} atom_locality_type; typedef enum { - MTD_CREATE, - MTD_APPEND, - MTD_OVERWRITE, - MTD_CUT, - MTD_LAST_OP + MTD_CREATE, + MTD_APPEND, + MTD_OVERWRITE, + MTD_CUT, + MTD_LAST_OP } mtd_op_t; struct xts128_context { - void *key1, *key2; - block128_f block1,block2; + void *key1, *key2; + block128_f block1, block2; }; struct object_cipher_info { - cipher_alg_t o_alg; - cipher_mode_t o_mode; - uint32_t o_block_bits; - uint32_t o_dkey_size; /* raw data key size in bits */ - union { - struct { - unsigned char ivec[16]; - AES_KEY dkey[2]; - AES_KEY tkey; /* key used for tweaking */ - XTS128_CONTEXT xts; - } aes_xts; - } u; + cipher_alg_t o_alg; + cipher_mode_t o_mode; + uint32_t o_block_bits; + uint32_t o_dkey_size; /* raw data key size in bits */ + union { + struct { + unsigned char ivec[16]; + AES_KEY dkey[2]; + AES_KEY tkey; /* key used for tweaking */ + XTS128_CONTEXT xts; + } aes_xts; + } u; }; struct master_cipher_info { - /* - * attributes inherited by newly created regular files - */ - cipher_alg_t m_alg; - cipher_mode_t m_mode; - uint32_t m_block_bits; - uint32_t m_dkey_size; /* raw key size in bits */ - /* - * master key - */ - unsigned char m_key[MASTER_VOL_KEY_SIZE]; - /* - * volume key for oid authentication - */ - unsigned char m_nmtd_key[NMTD_VOL_KEY_SIZE]; + /* + * attributes inherited by newly created regular files + */ + cipher_alg_t m_alg; + cipher_mode_t m_mode; + uint32_t m_block_bits; + uint32_t m_dkey_size; /* raw key size in bits */ + /* + * master key + */ + unsigned char m_key[MASTER_VOL_KEY_SIZE]; + /* + * volume key for oid authentication + */ + unsigned char m_nmtd_key[NMTD_VOL_KEY_SIZE]; }; /* -* This info is not changed during file's life + * This info is not changed during file's life */ struct crypt_inode_info { #if DEBUG_CRYPT - loc_t *loc; /* pathname that the file has been - opened, or created with */ + loc_t *loc; /* pathname that the file has been + opened, or created with */ #endif - uint16_t nr_minor; - uuid_t oid; - struct object_cipher_info cinfo; + uint16_t nr_minor; + uuid_t oid; + struct object_cipher_info cinfo; }; /* * this should locate in secure memory */ typedef struct { - struct master_cipher_info master; + struct master_cipher_info master; } crypt_private_t; -static inline struct master_cipher_info *get_master_cinfo(crypt_private_t *priv) +static inline struct master_cipher_info * +get_master_cinfo(crypt_private_t *priv) { - return &priv->master; + return &priv->master; } -static inline struct object_cipher_info *get_object_cinfo(struct crypt_inode_info - *info) +static inline struct object_cipher_info * +get_object_cinfo(struct crypt_inode_info *info) { - return &info->cinfo; + return &info->cinfo; } /* @@ -163,518 +160,531 @@ static inline struct object_cipher_info *get_object_cinfo(struct crypt_inode_inf * of atoms in an aligned vector */ struct avec_config { - uint32_t atom_size; - atom_data_type type; - size_t orig_size; - off_t orig_offset; - size_t expanded_size; - off_t aligned_offset; - - uint32_t off_in_head; - uint32_t off_in_tail; - uint32_t gap_in_tail; - uint32_t nr_full_blocks; - - struct iovec *avec; /* aligned vector */ - uint32_t acount; /* number of avec components. The same - * as number of occupied logical blocks */ - char **pool; - uint32_t blocks_in_pool; - uint32_t cursor; /* makes sense only for ordered writes, - * so there is no races on this counter. - * - * Cursor is per-config object, we don't - * reset cursor for atoms of different - * localities (head, tail, full) - */ + uint32_t atom_size; + atom_data_type type; + size_t orig_size; + off_t orig_offset; + size_t expanded_size; + off_t aligned_offset; + + uint32_t off_in_head; + uint32_t off_in_tail; + uint32_t gap_in_tail; + uint32_t nr_full_blocks; + + struct iovec *avec; /* aligned vector */ + uint32_t acount; /* number of avec components. The same + * as number of occupied logical blocks */ + char **pool; + uint32_t blocks_in_pool; + uint32_t cursor; /* makes sense only for ordered writes, + * so there is no races on this counter. + * + * Cursor is per-config object, we don't + * reset cursor for atoms of different + * localities (head, tail, full) + */ }; - typedef struct { - glusterfs_fop_t fop; /* code of FOP this local info built for */ - fd_t *fd; - inode_t *inode; - loc_t *loc; - int32_t mac_idx; - loc_t *newloc; - int32_t flags; - int32_t wbflags; - struct crypt_inode_info *info; - struct iobref *iobref; - struct iobref *iobref_data; - off_t offset; - - uint64_t old_file_size; /* per FOP, retrieved under lock held */ - uint64_t cur_file_size; /* per iteration, before issuing IOs */ - uint64_t new_file_size; /* per iteration, after issuing IOs */ - - uint64_t io_offset; /* offset of IOs issued per iteration */ - uint64_t io_offset_nopad; /* offset of user's data in the atom */ - uint32_t io_size; /* size of IOs issued per iteration */ - uint32_t io_size_nopad; /* size of user's data in the IOs */ - uint32_t eof_padding_size; /* size od EOF padding in the IOs */ - - gf_lock_t call_lock; /* protect nr_calls from many cbks */ - int32_t nr_calls; - - atom_data_type active_setup; /* which setup (hole or date) - is currently active */ - /* data setup */ - struct avec_config data_conf; - - /* hole setup */ - int hole_conv_in_proggress; - gf_lock_t hole_lock; /* protect hole config from many cbks */ - int hole_handled; - struct avec_config hole_conf; - struct iatt buf; - struct iatt prebuf; - struct iatt postbuf; - struct iatt *prenewparent; - struct iatt *postnewparent; - int32_t op_ret; - int32_t op_errno; - int32_t rw_count; /* total read or written */ - gf_lock_t rw_count_lock; /* protect the counter above */ - unsigned char *format; /* for create, update format string */ - uint32_t format_size; - uint32_t msgflags; /* messages for crypt_open() */ - dict_t *xdata; - dict_t *xattr; - struct iovec vec; /* contains last file's atom for - read-prune-write sequence */ - gf_boolean_t custom_mtd; - /* - * the next 3 fields are used by readdir and friends - */ - gf_dirent_t *de; /* directory entry */ - char *de_path; /* pathname of directory entry */ - uint32_t de_prefix_len; /* length of the parent's pathname */ - gf_dirent_t *entries; - - uint32_t update_disk_file_size:1; + glusterfs_fop_t fop; /* code of FOP this local info built for */ + fd_t *fd; + inode_t *inode; + loc_t *loc; + int32_t mac_idx; + loc_t *newloc; + int32_t flags; + int32_t wbflags; + struct crypt_inode_info *info; + struct iobref *iobref; + struct iobref *iobref_data; + off_t offset; + + uint64_t old_file_size; /* per FOP, retrieved under lock held */ + uint64_t cur_file_size; /* per iteration, before issuing IOs */ + uint64_t new_file_size; /* per iteration, after issuing IOs */ + + uint64_t io_offset; /* offset of IOs issued per iteration */ + uint64_t io_offset_nopad; /* offset of user's data in the atom */ + uint32_t io_size; /* size of IOs issued per iteration */ + uint32_t io_size_nopad; /* size of user's data in the IOs */ + uint32_t eof_padding_size; /* size od EOF padding in the IOs */ + + gf_lock_t call_lock; /* protect nr_calls from many cbks */ + int32_t nr_calls; + + atom_data_type active_setup; /* which setup (hole or date) + is currently active */ + /* data setup */ + struct avec_config data_conf; + + /* hole setup */ + int hole_conv_in_proggress; + gf_lock_t hole_lock; /* protect hole config from many cbks */ + int hole_handled; + struct avec_config hole_conf; + struct iatt buf; + struct iatt prebuf; + struct iatt postbuf; + struct iatt *prenewparent; + struct iatt *postnewparent; + int32_t op_ret; + int32_t op_errno; + int32_t rw_count; /* total read or written */ + gf_lock_t rw_count_lock; /* protect the counter above */ + unsigned char *format; /* for create, update format string */ + uint32_t format_size; + uint32_t msgflags; /* messages for crypt_open() */ + dict_t *xdata; + dict_t *xattr; + struct iovec vec; /* contains last file's atom for + read-prune-write sequence */ + gf_boolean_t custom_mtd; + /* + * the next 3 fields are used by readdir and friends + */ + gf_dirent_t *de; /* directory entry */ + char *de_path; /* pathname of directory entry */ + uint32_t de_prefix_len; /* length of the parent's pathname */ + gf_dirent_t *entries; + + uint32_t update_disk_file_size : 1; } crypt_local_t; /* This represents a (read)modify-write atom */ struct rmw_atom { - atom_locality_type locality; - /* - * read-modify-write sequence of the atom - */ - int32_t (*rmw)(call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - struct iovec *vec, - int32_t count, - struct iatt *stbuf, - struct iobref *iobref, - dict_t *xdata); - /* - * offset of the logical block in a file - */ - loff_t (*offset_at)(call_frame_t *frame, - struct object_cipher_info *object); - /* - * IO offset in an atom - */ - uint32_t (*offset_in)(call_frame_t *frame, - struct object_cipher_info *object); - /* - * number of bytes of plain text of this atom that user - * wants to read/write. - * It can be smaller than atom_size in the case of head - * or tail atoms. - */ - uint32_t (*io_size_nopad)(call_frame_t *frame, - struct object_cipher_info *object); - /* - * which iovec represents the atom - */ - struct iovec *(*get_iovec)(call_frame_t *frame, uint32_t count); - /* - * how many bytes of partial block should be uptodated by - * reading from disk. - * This is used to perform a read component of RMW (read-modify-write). - */ - uint32_t (*count_to_uptodate)(call_frame_t *frame, struct object_cipher_info *object); - struct avec_config *(*get_config)(call_frame_t *frame); + atom_locality_type locality; + /* + * read-modify-write sequence of the atom + */ + int32_t (*rmw)(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iovec *vec, + int32_t count, struct iatt *stbuf, struct iobref *iobref, + dict_t *xdata); + /* + * offset of the logical block in a file + */ + loff_t (*offset_at)(call_frame_t *frame, struct object_cipher_info *object); + /* + * IO offset in an atom + */ + uint32_t (*offset_in)(call_frame_t *frame, + struct object_cipher_info *object); + /* + * number of bytes of plain text of this atom that user + * wants to read/write. + * It can be smaller than atom_size in the case of head + * or tail atoms. + */ + uint32_t (*io_size_nopad)(call_frame_t *frame, + struct object_cipher_info *object); + /* + * which iovec represents the atom + */ + struct iovec *(*get_iovec)(call_frame_t *frame, uint32_t count); + /* + * how many bytes of partial block should be uptodated by + * reading from disk. + * This is used to perform a read component of RMW (read-modify-write). + */ + uint32_t (*count_to_uptodate)(call_frame_t *frame, + struct object_cipher_info *object); + struct avec_config *(*get_config)(call_frame_t *frame); }; struct data_cipher_alg { - gf_boolean_t atomic; /* true means that algorithm requires - to pad data before cipher transform */ - gf_boolean_t should_pad; /* true means that algorithm requires - to pad the end of file with extra-data */ - uint32_t blkbits; /* blksize = 1 << blkbits */ - /* - * any preliminary sanity checks goes here - */ - int32_t (*init)(void); - /* - * set alg-mode specific inode info - */ - int32_t (*set_private)(struct crypt_inode_info *info, - struct master_cipher_info *master); - /* - * check alg-mode specific data key - */ - int32_t (*check_key)(uint32_t key_size); - void (*set_iv)(off_t offset, struct object_cipher_info *object); - int32_t (*encrypt)(const unsigned char *from, unsigned char *to, - size_t length, off_t offset, const int enc, - struct object_cipher_info *object); + gf_boolean_t atomic; /* true means that algorithm requires + to pad data before cipher transform */ + gf_boolean_t should_pad; /* true means that algorithm requires + to pad the end of file with extra-data */ + uint32_t blkbits; /* blksize = 1 << blkbits */ + /* + * any preliminary sanity checks goes here + */ + int32_t (*init)(void); + /* + * set alg-mode specific inode info + */ + int32_t (*set_private)(struct crypt_inode_info *info, + struct master_cipher_info *master); + /* + * check alg-mode specific data key + */ + int32_t (*check_key)(uint32_t key_size); + void (*set_iv)(off_t offset, struct object_cipher_info *object); + int32_t (*encrypt)(const unsigned char *from, unsigned char *to, + size_t length, off_t offset, const int enc, + struct object_cipher_info *object); }; /* * version-dependent metadata loader */ struct crypt_mtd_loader { - /* - * return core format size - */ - size_t (*format_size)(mtd_op_t op, size_t old_size); - /* - * pack version-specific metadata of an object - * at ->create() - */ - int32_t (*create_format)(unsigned char *wire, - loc_t *loc, - struct crypt_inode_info *info, - struct master_cipher_info *master); - /* - * extract version-specific metadata of an object - * at ->open() time - */ - int32_t (*open_format)(unsigned char *wire, - int32_t len, - loc_t *loc, - struct crypt_inode_info *info, - struct master_cipher_info *master, - crypt_local_t *local, - gf_boolean_t load_info); - int32_t (*update_format)(unsigned char *new, - unsigned char *old, - size_t old_len, - int32_t mac_idx, - mtd_op_t op, - loc_t *loc, - struct crypt_inode_info *info, - struct master_cipher_info *master, - crypt_local_t *local); + /* + * return core format size + */ + size_t (*format_size)(mtd_op_t op, size_t old_size); + /* + * pack version-specific metadata of an object + * at ->create() + */ + int32_t (*create_format)(unsigned char *wire, loc_t *loc, + struct crypt_inode_info *info, + struct master_cipher_info *master); + /* + * extract version-specific metadata of an object + * at ->open() time + */ + int32_t (*open_format)(unsigned char *wire, int32_t len, loc_t *loc, + struct crypt_inode_info *info, + struct master_cipher_info *master, + crypt_local_t *local, gf_boolean_t load_info); + int32_t (*update_format)(unsigned char *new, unsigned char *old, + size_t old_len, int32_t mac_idx, mtd_op_t op, + loc_t *loc, struct crypt_inode_info *info, + struct master_cipher_info *master, + crypt_local_t *local); }; -typedef int32_t (*end_writeback_handler_t)(call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - struct iatt *prebuf, - struct iatt *postbuf, - dict_t *xdata); +typedef int32_t (*end_writeback_handler_t)(call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, + int32_t op_errno, + struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata); typedef void (*linkop_wind_handler_t)(call_frame_t *frame, xlator_t *this); typedef void (*linkop_unwind_handler_t)(call_frame_t *frame); - /* Declarations */ /* keys.c */ extern struct crypt_key crypt_keys[LAST_KEY_TYPE]; -int32_t get_nmtd_vol_key(struct master_cipher_info *master); -int32_t get_nmtd_link_key(loc_t *loc, - struct master_cipher_info *master, - unsigned char *result); -int32_t get_emtd_file_key(struct crypt_inode_info *info, - struct master_cipher_info *master, - unsigned char *result); -int32_t get_data_file_key(struct crypt_inode_info *info, - struct master_cipher_info *master, - uint32_t keysize, - unsigned char *key); +int32_t +get_nmtd_vol_key(struct master_cipher_info *master); +int32_t +get_nmtd_link_key(loc_t *loc, struct master_cipher_info *master, + unsigned char *result); +int32_t +get_emtd_file_key(struct crypt_inode_info *info, + struct master_cipher_info *master, unsigned char *result); +int32_t +get_data_file_key(struct crypt_inode_info *info, + struct master_cipher_info *master, uint32_t keysize, + unsigned char *key); /* data.c */ -extern struct data_cipher_alg data_cipher_algs[LAST_CIPHER_ALG][LAST_CIPHER_MODE]; -void encrypt_aligned_iov(struct object_cipher_info *object, - struct iovec *vec, - int count, - off_t off); -void decrypt_aligned_iov(struct object_cipher_info *object, - struct iovec *vec, - int count, - off_t off); -int32_t align_iov_by_atoms(xlator_t *this, - crypt_local_t *local, - struct object_cipher_info *object, - struct iovec *vec /* input vector */, - int32_t count /* number of vec components */, - struct iovec *avec /* aligned vector */, - char **blocks /* pool of blocks */, - uint32_t *blocks_allocated, - struct avec_config *conf); -int32_t set_config_avec_data(xlator_t *this, - crypt_local_t *local, - struct avec_config *conf, - struct object_cipher_info *object, - struct iovec *vec, - int32_t vec_count); -int32_t set_config_avec_hole(xlator_t *this, - crypt_local_t *local, - struct avec_config *conf, - struct object_cipher_info *object, - glusterfs_fop_t fop); -void set_gap_at_end(call_frame_t *frame, struct object_cipher_info *object, - struct avec_config *conf, atom_data_type dtype); -void set_config_offsets(call_frame_t *frame, - xlator_t *this, - uint64_t offset, - uint64_t count, - atom_data_type dtype, - int32_t setup_gap_in_tail); +extern struct data_cipher_alg data_cipher_algs[LAST_CIPHER_ALG] + [LAST_CIPHER_MODE]; +void +encrypt_aligned_iov(struct object_cipher_info *object, struct iovec *vec, + int count, off_t off); +void +decrypt_aligned_iov(struct object_cipher_info *object, struct iovec *vec, + int count, off_t off); +int32_t +align_iov_by_atoms(xlator_t *this, crypt_local_t *local, + struct object_cipher_info *object, + struct iovec *vec /* input vector */, + int32_t count /* number of vec components */, + struct iovec *avec /* aligned vector */, + char **blocks /* pool of blocks */, + uint32_t *blocks_allocated, struct avec_config *conf); +int32_t +set_config_avec_data(xlator_t *this, crypt_local_t *local, + struct avec_config *conf, + struct object_cipher_info *object, struct iovec *vec, + int32_t vec_count); +int32_t +set_config_avec_hole(xlator_t *this, crypt_local_t *local, + struct avec_config *conf, + struct object_cipher_info *object, glusterfs_fop_t fop); +void +set_gap_at_end(call_frame_t *frame, struct object_cipher_info *object, + struct avec_config *conf, atom_data_type dtype); +void +set_config_offsets(call_frame_t *frame, xlator_t *this, uint64_t offset, + uint64_t count, atom_data_type dtype, + int32_t setup_gap_in_tail); /* metadata.c */ -extern struct crypt_mtd_loader mtd_loaders [LAST_MTD_LOADER]; - -int32_t alloc_format(crypt_local_t *local, size_t size); -int32_t alloc_format_create(crypt_local_t *local); -void free_format(crypt_local_t *local); -size_t format_size(mtd_op_t op, size_t old_size); -size_t new_format_size(void); -int32_t open_format(unsigned char *str, int32_t len, loc_t *loc, - struct crypt_inode_info *info, - struct master_cipher_info *master, crypt_local_t *local, - gf_boolean_t load_info); -int32_t update_format(unsigned char *new, unsigned char *old, - size_t old_len, int32_t mac_idx, mtd_op_t op, loc_t *loc, - struct crypt_inode_info *info, - struct master_cipher_info *master, - crypt_local_t *local); -int32_t create_format(unsigned char *wire, - loc_t *loc, - struct crypt_inode_info *info, - struct master_cipher_info *master); +extern struct crypt_mtd_loader mtd_loaders[LAST_MTD_LOADER]; + +int32_t +alloc_format(crypt_local_t *local, size_t size); +int32_t +alloc_format_create(crypt_local_t *local); +void +free_format(crypt_local_t *local); +size_t +format_size(mtd_op_t op, size_t old_size); +size_t +new_format_size(void); +int32_t +open_format(unsigned char *str, int32_t len, loc_t *loc, + struct crypt_inode_info *info, struct master_cipher_info *master, + crypt_local_t *local, gf_boolean_t load_info); +int32_t +update_format(unsigned char *new, unsigned char *old, size_t old_len, + int32_t mac_idx, mtd_op_t op, loc_t *loc, + struct crypt_inode_info *info, struct master_cipher_info *master, + crypt_local_t *local); +int32_t +create_format(unsigned char *wire, loc_t *loc, struct crypt_inode_info *info, + struct master_cipher_info *master); /* atom.c */ -struct rmw_atom *atom_by_types(atom_data_type data, - atom_locality_type locality); -void submit_partial(call_frame_t *frame, - xlator_t *this, - fd_t *fd, - atom_locality_type ltype); -void submit_full(call_frame_t *frame, xlator_t *this); +struct rmw_atom * +atom_by_types(atom_data_type data, atom_locality_type locality); +void +submit_partial(call_frame_t *frame, xlator_t *this, fd_t *fd, + atom_locality_type ltype); +void +submit_full(call_frame_t *frame, xlator_t *this); /* crypt.c */ -end_writeback_handler_t dispatch_end_writeback(glusterfs_fop_t fop); -void set_local_io_params_writev(call_frame_t *frame, - struct object_cipher_info *object, - struct rmw_atom *atom, off_t io_offset, - uint32_t io_size); -void link_wind(call_frame_t *frame, xlator_t *this); -void unlink_wind(call_frame_t *frame, xlator_t *this); -void link_unwind(call_frame_t *frame); -void unlink_unwind(call_frame_t *frame); -void rename_wind(call_frame_t *frame, xlator_t *this); -void rename_unwind(call_frame_t *frame); +end_writeback_handler_t +dispatch_end_writeback(glusterfs_fop_t fop); +void +set_local_io_params_writev(call_frame_t *frame, + struct object_cipher_info *object, + struct rmw_atom *atom, off_t io_offset, + uint32_t io_size); +void +link_wind(call_frame_t *frame, xlator_t *this); +void +unlink_wind(call_frame_t *frame, xlator_t *this); +void +link_unwind(call_frame_t *frame); +void +unlink_unwind(call_frame_t *frame); +void +rename_wind(call_frame_t *frame, xlator_t *this); +void +rename_unwind(call_frame_t *frame); /* Inline functions */ -static inline int32_t crypt_xlator_id(void) +static inline int32_t +crypt_xlator_id(void) { - return CRYPT_XLATOR_ID; + return CRYPT_XLATOR_ID; } -static inline mtd_loader_id current_mtd_loader(void) +static inline mtd_loader_id +current_mtd_loader(void) { - return MTD_LOADER_V1; + return MTD_LOADER_V1; } -static inline uint32_t master_key_size (void) +static inline uint32_t +master_key_size(void) { - return crypt_keys[MASTER_VOL_KEY].len >> 3; + return crypt_keys[MASTER_VOL_KEY].len >> 3; } -static inline uint32_t nmtd_vol_key_size (void) +static inline uint32_t +nmtd_vol_key_size(void) { - return crypt_keys[NMTD_VOL_KEY].len >> 3; + return crypt_keys[NMTD_VOL_KEY].len >> 3; } -static inline uint32_t alg_mode_blkbits(cipher_alg_t alg, - cipher_mode_t mode) +static inline uint32_t +alg_mode_blkbits(cipher_alg_t alg, cipher_mode_t mode) { - return data_cipher_algs[alg][mode].blkbits; + return data_cipher_algs[alg][mode].blkbits; } -static inline uint32_t alg_mode_blksize(cipher_alg_t alg, - cipher_mode_t mode) +static inline uint32_t +alg_mode_blksize(cipher_alg_t alg, cipher_mode_t mode) { - return 1 << alg_mode_blkbits(alg, mode); + return 1 << alg_mode_blkbits(alg, mode); } -static inline gf_boolean_t alg_mode_atomic(cipher_alg_t alg, - cipher_mode_t mode) +static inline gf_boolean_t +alg_mode_atomic(cipher_alg_t alg, cipher_mode_t mode) { - return data_cipher_algs[alg][mode].atomic; + return data_cipher_algs[alg][mode].atomic; } -static inline gf_boolean_t alg_mode_should_pad(cipher_alg_t alg, - cipher_mode_t mode) +static inline gf_boolean_t +alg_mode_should_pad(cipher_alg_t alg, cipher_mode_t mode) { - return data_cipher_algs[alg][mode].should_pad; + return data_cipher_algs[alg][mode].should_pad; } -static inline uint32_t master_alg_blksize(struct master_cipher_info *mr) +static inline uint32_t +master_alg_blksize(struct master_cipher_info *mr) { - return alg_mode_blksize(mr->m_alg, mr->m_mode); + return alg_mode_blksize(mr->m_alg, mr->m_mode); } -static inline uint32_t master_alg_blkbits(struct master_cipher_info *mr) +static inline uint32_t +master_alg_blkbits(struct master_cipher_info *mr) { - return alg_mode_blkbits(mr->m_alg, mr->m_mode); + return alg_mode_blkbits(mr->m_alg, mr->m_mode); } -static inline gf_boolean_t master_alg_atomic(struct master_cipher_info *mr) +static inline gf_boolean_t +master_alg_atomic(struct master_cipher_info *mr) { - return alg_mode_atomic(mr->m_alg, mr->m_mode); + return alg_mode_atomic(mr->m_alg, mr->m_mode); } -static inline gf_boolean_t master_alg_should_pad(struct master_cipher_info *mr) +static inline gf_boolean_t +master_alg_should_pad(struct master_cipher_info *mr) { - return alg_mode_should_pad(mr->m_alg, mr->m_mode); + return alg_mode_should_pad(mr->m_alg, mr->m_mode); } -static inline uint32_t object_alg_blksize(struct object_cipher_info *ob) +static inline uint32_t +object_alg_blksize(struct object_cipher_info *ob) { - return alg_mode_blksize(ob->o_alg, ob->o_mode); + return alg_mode_blksize(ob->o_alg, ob->o_mode); } -static inline uint32_t object_alg_blkbits(struct object_cipher_info *ob) +static inline uint32_t +object_alg_blkbits(struct object_cipher_info *ob) { - return alg_mode_blkbits(ob->o_alg, ob->o_mode); + return alg_mode_blkbits(ob->o_alg, ob->o_mode); } -static inline gf_boolean_t object_alg_atomic(struct object_cipher_info *ob) +static inline gf_boolean_t +object_alg_atomic(struct object_cipher_info *ob) { - return alg_mode_atomic(ob->o_alg, ob->o_mode); + return alg_mode_atomic(ob->o_alg, ob->o_mode); } -static inline gf_boolean_t object_alg_should_pad(struct object_cipher_info *ob) +static inline gf_boolean_t +object_alg_should_pad(struct object_cipher_info *ob) { - return alg_mode_should_pad(ob->o_alg, ob->o_mode); + return alg_mode_should_pad(ob->o_alg, ob->o_mode); } -static inline uint32_t aes_raw_key_size(struct master_cipher_info *master) +static inline uint32_t +aes_raw_key_size(struct master_cipher_info *master) { - return master->m_dkey_size >> 3; + return master->m_dkey_size >> 3; } -static inline struct avec_config *get_hole_conf(call_frame_t *frame) +static inline struct avec_config * +get_hole_conf(call_frame_t *frame) { - return &(((crypt_local_t *)frame->local)->hole_conf); + return &(((crypt_local_t *)frame->local)->hole_conf); } -static inline struct avec_config *get_data_conf(call_frame_t *frame) +static inline struct avec_config * +get_data_conf(call_frame_t *frame) { - return &(((crypt_local_t *)frame->local)->data_conf); + return &(((crypt_local_t *)frame->local)->data_conf); } -static inline int32_t get_atom_bits (struct object_cipher_info *object) +static inline int32_t +get_atom_bits(struct object_cipher_info *object) { - return object->o_block_bits; + return object->o_block_bits; } -static inline int32_t get_atom_size (struct object_cipher_info *object) +static inline int32_t +get_atom_size(struct object_cipher_info *object) { - return 1 << get_atom_bits(object); + return 1 << get_atom_bits(object); } -static inline int32_t has_head_block(struct avec_config *conf) +static inline int32_t +has_head_block(struct avec_config *conf) { - return conf->off_in_head || - (conf->acount == 1 && conf->off_in_tail); + return conf->off_in_head || (conf->acount == 1 && conf->off_in_tail); } -static inline int32_t has_tail_block(struct avec_config *conf) +static inline int32_t +has_tail_block(struct avec_config *conf) { - return conf->off_in_tail && conf->acount > 1; + return conf->off_in_tail && conf->acount > 1; } -static inline int32_t has_full_blocks(struct avec_config *conf) +static inline int32_t +has_full_blocks(struct avec_config *conf) { - return conf->nr_full_blocks; + return conf->nr_full_blocks; } -static inline int32_t should_submit_head_block(struct avec_config *conf) +static inline int32_t +should_submit_head_block(struct avec_config *conf) { - return has_head_block(conf) && (conf->cursor == 0); + return has_head_block(conf) && (conf->cursor == 0); } -static inline int32_t should_submit_tail_block(struct avec_config *conf) +static inline int32_t +should_submit_tail_block(struct avec_config *conf) { - return has_tail_block(conf) && (conf->cursor == conf->acount - 1); + return has_tail_block(conf) && (conf->cursor == conf->acount - 1); } -static inline int32_t should_submit_full_block(struct avec_config *conf) +static inline int32_t +should_submit_full_block(struct avec_config *conf) { - uint32_t start = has_head_block(conf) ? 1 : 0; + uint32_t start = has_head_block(conf) ? 1 : 0; - return has_full_blocks(conf) && - conf->cursor >= start && - conf->cursor < start + conf->nr_full_blocks; + return has_full_blocks(conf) && conf->cursor >= start && + conf->cursor < start + conf->nr_full_blocks; } #if DEBUG_CRYPT -static inline void crypt_check_input_len(size_t len, - struct object_cipher_info *object) +static inline void +crypt_check_input_len(size_t len, struct object_cipher_info *object) { - if (object_alg_should_pad(object) && (len & (object_alg_blksize(object) - 1))) - gf_log ("crypt", GF_LOG_DEBUG, "bad input len: %d", (int)len); + if (object_alg_should_pad(object) && + (len & (object_alg_blksize(object) - 1))) + gf_log("crypt", GF_LOG_DEBUG, "bad input len: %d", (int)len); } -static inline void check_head_block(struct avec_config *conf) +static inline void +check_head_block(struct avec_config *conf) { - if (!has_head_block(conf)) - gf_log("crypt", GF_LOG_DEBUG, "not a head atom"); + if (!has_head_block(conf)) + gf_log("crypt", GF_LOG_DEBUG, "not a head atom"); } -static inline void check_tail_block(struct avec_config *conf) +static inline void +check_tail_block(struct avec_config *conf) { - if (!has_tail_block(conf)) - gf_log("crypt", GF_LOG_DEBUG, "not a tail atom"); + if (!has_tail_block(conf)) + gf_log("crypt", GF_LOG_DEBUG, "not a tail atom"); } -static inline void check_full_block(struct avec_config *conf) +static inline void +check_full_block(struct avec_config *conf) { - if (!has_full_blocks(conf)) - gf_log("crypt", GF_LOG_DEBUG, "not a full atom"); + if (!has_full_blocks(conf)) + gf_log("crypt", GF_LOG_DEBUG, "not a full atom"); } -static inline void check_cursor_head(struct avec_config *conf) +static inline void +check_cursor_head(struct avec_config *conf) { - if (!has_head_block(conf)) - gf_log("crypt", - GF_LOG_DEBUG, "Illegal call of head atom method"); - else if (conf->cursor != 0) - gf_log("crypt", - GF_LOG_DEBUG, "Cursor (%d) is not at head atom", - conf->cursor); + if (!has_head_block(conf)) + gf_log("crypt", GF_LOG_DEBUG, "Illegal call of head atom method"); + else if (conf->cursor != 0) + gf_log("crypt", GF_LOG_DEBUG, "Cursor (%d) is not at head atom", + conf->cursor); } -static inline void check_cursor_full(struct avec_config *conf) +static inline void +check_cursor_full(struct avec_config *conf) { - if (!has_full_blocks(conf)) - gf_log("crypt", - GF_LOG_DEBUG, "Illegal call of full atom method"); - if (has_head_block(conf) && (conf->cursor == 0)) - gf_log("crypt", - GF_LOG_DEBUG, "Cursor is not at full atom"); + if (!has_full_blocks(conf)) + gf_log("crypt", GF_LOG_DEBUG, "Illegal call of full atom method"); + if (has_head_block(conf) && (conf->cursor == 0)) + gf_log("crypt", GF_LOG_DEBUG, "Cursor is not at full atom"); } /* * FIXME: use avec->iov_len to check setup */ -static inline int data_local_invariant(crypt_local_t *local) +static inline int +data_local_invariant(crypt_local_t *local) { - return 0; + return 0; } #else @@ -687,207 +697,225 @@ static inline int data_local_invariant(crypt_local_t *local) #endif /* DEBUG_CRYPT */ -static inline struct avec_config *conf_by_type(call_frame_t *frame, - atom_data_type dtype) +static inline struct avec_config * +conf_by_type(call_frame_t *frame, atom_data_type dtype) { - struct avec_config *conf = NULL; + struct avec_config *conf = NULL; - switch (dtype) { - case HOLE_ATOM: - conf = get_hole_conf(frame); - break; - case DATA_ATOM: - conf = get_data_conf(frame); - break; - default: - gf_log("crypt", GF_LOG_DEBUG, "bad atom type"); - } - return conf; + switch (dtype) { + case HOLE_ATOM: + conf = get_hole_conf(frame); + break; + case DATA_ATOM: + conf = get_data_conf(frame); + break; + default: + gf_log("crypt", GF_LOG_DEBUG, "bad atom type"); + } + return conf; } -static inline uint32_t nr_calls_head(struct avec_config *conf) +static inline uint32_t +nr_calls_head(struct avec_config *conf) { - return has_head_block(conf) ? 1 : 0; + return has_head_block(conf) ? 1 : 0; } -static inline uint32_t nr_calls_tail(struct avec_config *conf) +static inline uint32_t +nr_calls_tail(struct avec_config *conf) { - return has_tail_block(conf) ? 1 : 0; + return has_tail_block(conf) ? 1 : 0; } -static inline uint32_t nr_calls_full(struct avec_config *conf) +static inline uint32_t +nr_calls_full(struct avec_config *conf) { - switch(conf->type) { - case HOLE_ATOM: - return has_full_blocks(conf); - case DATA_ATOM: - return has_full_blocks(conf) ? - logical_blocks_occupied(0, - conf->nr_full_blocks, - MAX_IOVEC_BITS) : 0; - default: - gf_log("crypt", GF_LOG_DEBUG, "bad atom data type"); - return 0; - } + switch (conf->type) { + case HOLE_ATOM: + return has_full_blocks(conf); + case DATA_ATOM: + return has_full_blocks(conf) + ? logical_blocks_occupied(0, conf->nr_full_blocks, + MAX_IOVEC_BITS) + : 0; + default: + gf_log("crypt", GF_LOG_DEBUG, "bad atom data type"); + return 0; + } } -static inline uint32_t nr_calls(struct avec_config *conf) +static inline uint32_t +nr_calls(struct avec_config *conf) { - return nr_calls_head(conf) + nr_calls_tail(conf) + nr_calls_full(conf); + return nr_calls_head(conf) + nr_calls_tail(conf) + nr_calls_full(conf); } -static inline uint32_t nr_calls_data(call_frame_t *frame) +static inline uint32_t +nr_calls_data(call_frame_t *frame) { - return nr_calls(get_data_conf(frame)); + return nr_calls(get_data_conf(frame)); } -static inline uint32_t nr_calls_hole(call_frame_t *frame) +static inline uint32_t +nr_calls_hole(call_frame_t *frame) { - return nr_calls(get_hole_conf(frame)); + return nr_calls(get_hole_conf(frame)); } -static inline void get_one_call_nolock(call_frame_t *frame) +static inline void +get_one_call_nolock(call_frame_t *frame) { - crypt_local_t *local = frame->local; + crypt_local_t *local = frame->local; - ++local->nr_calls; + ++local->nr_calls; - //gf_log("crypt", GF_LOG_DEBUG, "get %d calls", 1); + // gf_log("crypt", GF_LOG_DEBUG, "get %d calls", 1); } -static inline void get_one_call(call_frame_t *frame) +static inline void +get_one_call(call_frame_t *frame) { - crypt_local_t *local = frame->local; + crypt_local_t *local = frame->local; - LOCK(&local->call_lock); - get_one_call_nolock(frame); - UNLOCK(&local->call_lock); + LOCK(&local->call_lock); + get_one_call_nolock(frame); + UNLOCK(&local->call_lock); } -static inline void get_nr_calls_nolock(call_frame_t *frame, int32_t nr) +static inline void +get_nr_calls_nolock(call_frame_t *frame, int32_t nr) { - crypt_local_t *local = frame->local; + crypt_local_t *local = frame->local; - local->nr_calls += nr; + local->nr_calls += nr; - //gf_log("crypt", GF_LOG_DEBUG, "get %d calls", nr); + // gf_log("crypt", GF_LOG_DEBUG, "get %d calls", nr); } -static inline void get_nr_calls(call_frame_t *frame, int32_t nr) +static inline void +get_nr_calls(call_frame_t *frame, int32_t nr) { - crypt_local_t *local = frame->local; + crypt_local_t *local = frame->local; - LOCK(&local->call_lock); - get_nr_calls_nolock(frame, nr); - UNLOCK(&local->call_lock); + LOCK(&local->call_lock); + get_nr_calls_nolock(frame, nr); + UNLOCK(&local->call_lock); } -static inline int put_one_call(crypt_local_t *local) +static inline int +put_one_call(crypt_local_t *local) { - uint32_t last = 0; + uint32_t last = 0; - LOCK(&local->call_lock); - if (--local->nr_calls == 0) - last = 1; + LOCK(&local->call_lock); + if (--local->nr_calls == 0) + last = 1; - //gf_log("crypt", GF_LOG_DEBUG, "put %d calls", 1); + // gf_log("crypt", GF_LOG_DEBUG, "put %d calls", 1); - UNLOCK(&local->call_lock); - return last; + UNLOCK(&local->call_lock); + return last; } -static inline int is_appended_write(call_frame_t *frame) +static inline int +is_appended_write(call_frame_t *frame) { - crypt_local_t *local = frame->local; - struct avec_config *conf = get_data_conf(frame); + crypt_local_t *local = frame->local; + struct avec_config *conf = get_data_conf(frame); - return conf->orig_offset + conf->orig_size > local->old_file_size; + return conf->orig_offset + conf->orig_size > local->old_file_size; } -static inline int is_ordered_mode(call_frame_t *frame) +static inline int +is_ordered_mode(call_frame_t *frame) { #if 0 crypt_local_t *local = frame->local; return local->fop == GF_FOP_FTRUNCATE || (local->fop == GF_FOP_WRITE && is_appended_write(frame)); #endif - return 1; + return 1; } -static inline int32_t hole_conv_completed(crypt_local_t *local) +static inline int32_t +hole_conv_completed(crypt_local_t *local) { - struct avec_config *conf = &local->hole_conf; - return conf->cursor == conf->acount; + struct avec_config *conf = &local->hole_conf; + return conf->cursor == conf->acount; } -static inline int32_t data_write_in_progress(crypt_local_t *local) +static inline int32_t +data_write_in_progress(crypt_local_t *local) { - return local->active_setup == DATA_ATOM; + return local->active_setup == DATA_ATOM; } -static inline int32_t parent_is_crypt_xlator(call_frame_t *frame, - xlator_t *this) +static inline int32_t +parent_is_crypt_xlator(call_frame_t *frame, xlator_t *this) { - return frame->parent->this == this; + return frame->parent->this == this; } -static inline linkop_wind_handler_t linkop_wind_dispatch(glusterfs_fop_t fop) +static inline linkop_wind_handler_t +linkop_wind_dispatch(glusterfs_fop_t fop) { - switch(fop){ - case GF_FOP_LINK: - return link_wind; - case GF_FOP_UNLINK: - return unlink_wind; - case GF_FOP_RENAME: - return rename_wind; - default: - gf_log("crypt", GF_LOG_ERROR, "Bad link operation %d", fop); - return NULL; - } + switch (fop) { + case GF_FOP_LINK: + return link_wind; + case GF_FOP_UNLINK: + return unlink_wind; + case GF_FOP_RENAME: + return rename_wind; + default: + gf_log("crypt", GF_LOG_ERROR, "Bad link operation %d", fop); + return NULL; + } } -static inline linkop_unwind_handler_t linkop_unwind_dispatch(glusterfs_fop_t fop) +static inline linkop_unwind_handler_t +linkop_unwind_dispatch(glusterfs_fop_t fop) { - switch(fop){ - case GF_FOP_LINK: - return link_unwind; - case GF_FOP_UNLINK: - return unlink_unwind; - case GF_FOP_RENAME: - return rename_unwind; - default: - gf_log("crypt", GF_LOG_ERROR, "Bad link operation %d", fop); - return NULL; - } + switch (fop) { + case GF_FOP_LINK: + return link_unwind; + case GF_FOP_UNLINK: + return unlink_unwind; + case GF_FOP_RENAME: + return rename_unwind; + default: + gf_log("crypt", GF_LOG_ERROR, "Bad link operation %d", fop); + return NULL; + } } -static inline mtd_op_t linkop_mtdop_dispatch(glusterfs_fop_t fop) +static inline mtd_op_t +linkop_mtdop_dispatch(glusterfs_fop_t fop) { - switch (fop) { - case GF_FOP_LINK: - return MTD_APPEND; - case GF_FOP_UNLINK: - return MTD_CUT; - case GF_FOP_RENAME: - return MTD_OVERWRITE; - default: - gf_log("crypt", GF_LOG_WARNING, "Bad link operation %d", fop); - return MTD_LAST_OP; - } + switch (fop) { + case GF_FOP_LINK: + return MTD_APPEND; + case GF_FOP_UNLINK: + return MTD_CUT; + case GF_FOP_RENAME: + return MTD_OVERWRITE; + default: + gf_log("crypt", GF_LOG_WARNING, "Bad link operation %d", fop); + return MTD_LAST_OP; + } } -#define CRYPT_STACK_UNWIND(fop, frame, params ...) \ - do { \ - crypt_local_t *__local = NULL; \ - if (frame) { \ - __local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - if (__local) { \ - GF_FREE (__local); \ - } \ - } while (0) +#define CRYPT_STACK_UNWIND(fop, frame, params...) \ + do { \ + crypt_local_t *__local = NULL; \ + if (frame) { \ + __local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + if (__local) { \ + GF_FREE(__local); \ + } \ + } while (0) #endif /* __CRYPT_H__ */ diff --git a/xlators/encryption/crypt/src/metadata.h b/xlators/encryption/crypt/src/metadata.h index b67ae25b58c..0bcee1b18c8 100644 --- a/xlators/encryption/crypt/src/metadata.h +++ b/xlators/encryption/crypt/src/metadata.h @@ -11,11 +11,11 @@ #ifndef __METADATA_H__ #define __METADATA_H__ -#define NMTD_8_MAC_SIZE (8) -#define EMTD_8_MAC_SIZE (8) +#define NMTD_8_MAC_SIZE (8) +#define EMTD_8_MAC_SIZE (8) typedef uint8_t nmtd_8_mac_t[NMTD_8_MAC_SIZE]; -typedef uint8_t emtd_8_mac_t[EMTD_8_MAC_SIZE] ; +typedef uint8_t emtd_8_mac_t[EMTD_8_MAC_SIZE]; /* * Version "v1" of file's metadata. @@ -28,17 +28,17 @@ typedef uint8_t emtd_8_mac_t[EMTD_8_MAC_SIZE] ; * exactly one MAC) */ struct mtd_format_v1 { - /* EMTD, encrypted part of meta-data */ - uint8_t alg_id; /* cipher algorithm id (only AES for now) */ - uint8_t mode_id; /* cipher mode id; (only XTS for now) */ - uint8_t block_bits; /* encoded block size */ - uint8_t minor_id; /* client translator id */ - uint8_t dkey_factor; /* encoded size of the data key */ - /* MACs */ - emtd_8_mac_t gmac; /* MAC of the encrypted meta-data, 8 bytes */ - nmtd_8_mac_t omac; /* per-link MACs of the non-encrypted - * meta-data: at least one such MAC is always - * present */ + /* EMTD, encrypted part of meta-data */ + uint8_t alg_id; /* cipher algorithm id (only AES for now) */ + uint8_t mode_id; /* cipher mode id; (only XTS for now) */ + uint8_t block_bits; /* encoded block size */ + uint8_t minor_id; /* client translator id */ + uint8_t dkey_factor; /* encoded size of the data key */ + /* MACs */ + emtd_8_mac_t gmac; /* MAC of the encrypted meta-data, 8 bytes */ + nmtd_8_mac_t omac; /* per-link MACs of the non-encrypted + * meta-data: at least one such MAC is always + * present */ } __attribute__((packed)); /* @@ -46,29 +46,34 @@ struct mtd_format_v1 { * is file's gfid, which is generated on trusted machines. */ #define SIZE_OF_NMTD_V1 (sizeof(uuid_t)) -#define SIZE_OF_EMTD_V1 (offsetof(struct mtd_format_v1, gmac) - \ - offsetof(struct mtd_format_v1, alg_id)) +#define SIZE_OF_EMTD_V1 \ + (offsetof(struct mtd_format_v1, gmac) - \ + offsetof(struct mtd_format_v1, alg_id)) #define SIZE_OF_NMTD_V1_MAC (NMTD_8_MAC_SIZE) #define SIZE_OF_EMTD_V1_MAC (EMTD_8_MAC_SIZE) -static inline unsigned char *get_EMTD_V1(struct mtd_format_v1 *format) +static inline unsigned char * +get_EMTD_V1(struct mtd_format_v1 *format) { - return &format->alg_id; + return &format->alg_id; } -static inline unsigned char *get_NMTD_V1(struct crypt_inode_info *info) +static inline unsigned char * +get_NMTD_V1(struct crypt_inode_info *info) { - return info->oid; + return info->oid; } -static inline unsigned char *get_EMTD_V1_MAC(struct mtd_format_v1 *format) +static inline unsigned char * +get_EMTD_V1_MAC(struct mtd_format_v1 *format) { - return format->gmac; + return format->gmac; } -static inline unsigned char *get_NMTD_V1_MAC(struct mtd_format_v1 *format) +static inline unsigned char * +get_NMTD_V1_MAC(struct mtd_format_v1 *format) { - return format->omac; + return format->omac; } #endif /* __METADATA_H__ */ diff --git a/xlators/encryption/rot-13/src/rot-13.h b/xlators/encryption/rot-13/src/rot-13.h index a2017513437..edbc99798b4 100644 --- a/xlators/encryption/rot-13/src/rot-13.h +++ b/xlators/encryption/rot-13/src/rot-13.h @@ -11,8 +11,8 @@ #define __ROT_13_H__ typedef struct { - gf_boolean_t encrypt_write; - gf_boolean_t decrypt_read; + gf_boolean_t encrypt_write; + gf_boolean_t decrypt_read; } rot_13_private_t; #endif /* __ROT_13_H__ */ diff --git a/xlators/experimental/fdl/src/fdl.h b/xlators/experimental/fdl/src/fdl.h index 32e38c93f2d..827db9f1246 100644 --- a/xlators/experimental/fdl/src/fdl.h +++ b/xlators/experimental/fdl/src/fdl.h @@ -11,20 +11,20 @@ #ifndef _FDL_H_ #define _FDL_H_ -#define NEW_REQUEST (uint8_t)'N' +#define NEW_REQUEST (uint8_t)'N' typedef struct { - uint8_t event_type; /* e.g. NEW_REQUEST */ - uint8_t fop_type; /* e.g. GF_FOP_SETATTR */ - uint16_t request_id; - uint32_t ext_length; + uint8_t event_type; /* e.g. NEW_REQUEST */ + uint8_t fop_type; /* e.g. GF_FOP_SETATTR */ + uint16_t request_id; + uint32_t ext_length; } event_header_t; enum { - FDL_IPC_BASE = 0xfeedbee5, /* ... and they make honey */ - FDL_IPC_CHANGE_TERM, - FDL_IPC_GET_TERMS, - FDL_IPC_JBR_SERVER_ROLLBACK + FDL_IPC_BASE = 0xfeedbee5, /* ... and they make honey */ + FDL_IPC_CHANGE_TERM, + FDL_IPC_GET_TERMS, + FDL_IPC_JBR_SERVER_ROLLBACK }; #endif /* _FDL_H_ */ diff --git a/xlators/experimental/jbr-client/src/jbr-messages.h b/xlators/experimental/jbr-client/src/jbr-messages.h index 9f210184d81..ecbf569ec13 100644 --- a/xlators/experimental/jbr-client/src/jbr-messages.h +++ b/xlators/experimental/jbr-client/src/jbr-messages.h @@ -23,17 +23,8 @@ * glfs-message-id.h. */ -GLFS_MSGID(JBR, - J_MSG_INIT_FAIL, - J_MSG_RETRY_MSG, - J_MSG_MEM_ERR, - J_MSG_DICT_FLR, - J_MSG_GENERIC, - J_MSG_INVALID, - J_MSG_NO_DATA, - J_MSG_SYS_CALL_FAILURE, - J_MSG_QUORUM_NOT_MET, - J_MSG_LOCK_FAILURE -); +GLFS_MSGID(JBR, J_MSG_INIT_FAIL, J_MSG_RETRY_MSG, J_MSG_MEM_ERR, J_MSG_DICT_FLR, + J_MSG_GENERIC, J_MSG_INVALID, J_MSG_NO_DATA, J_MSG_SYS_CALL_FAILURE, + J_MSG_QUORUM_NOT_MET, J_MSG_LOCK_FAILURE); #endif /* _JBR_MESSAGES_H_ */ diff --git a/xlators/experimental/jbr-client/src/jbrc.h b/xlators/experimental/jbr-client/src/jbrc.h index c83259ca1bd..f99178402b3 100644 --- a/xlators/experimental/jbr-client/src/jbrc.h +++ b/xlators/experimental/jbr-client/src/jbrc.h @@ -12,16 +12,16 @@ #define _JBRC_H_ typedef struct { - xlator_t *active; - uint8_t up_children; - uint8_t n_children; - uint32_t kid_state; + xlator_t *active; + uint8_t up_children; + uint8_t n_children; + uint32_t kid_state; } jbrc_private_t; typedef struct { - call_stub_t *stub; - xlator_t *curr_xl; - uint16_t scars; + call_stub_t *stub; + xlator_t *curr_xl; + uint16_t scars; } jbrc_local_t; #endif /* _JBRC_H_ */ diff --git a/xlators/experimental/jbr-server/src/jbr-internal.h b/xlators/experimental/jbr-server/src/jbr-internal.h index 46a29910d1f..f225e988a5f 100644 --- a/xlators/experimental/jbr-server/src/jbr-internal.h +++ b/xlators/experimental/jbr-server/src/jbr-internal.h @@ -11,82 +11,82 @@ #include <sys/stat.h> #include <sys/types.h> -#define LEADER_XATTR "user.jbr.leader" -#define SECOND_CHILD(xl) (xl->children->next->xlator) -#define RECONCILER_PATH JBR_SCRIPT_PREFIX"/reconciler.py" -#define CHANGELOG_ENTRY_SIZE 128 +#define LEADER_XATTR "user.jbr.leader" +#define SECOND_CHILD(xl) (xl->children->next->xlator) +#define RECONCILER_PATH JBR_SCRIPT_PREFIX "/reconciler.py" +#define CHANGELOG_ENTRY_SIZE 128 enum { - gf_mt_jbr_private_t = gf_common_mt_end + 1, - gf_mt_jbr_fd_ctx_t, - gf_mt_jbr_inode_ctx_t, - gf_mt_jbr_dirty_t, - gf_mt_jbr_end + gf_mt_jbr_private_t = gf_common_mt_end + 1, + gf_mt_jbr_fd_ctx_t, + gf_mt_jbr_inode_ctx_t, + gf_mt_jbr_dirty_t, + gf_mt_jbr_end }; typedef enum jbr_recon_notify_ev_id_t { - JBR_RECON_SET_LEADER = 1, - JBR_RECON_ADD_CHILD = 2 + JBR_RECON_SET_LEADER = 1, + JBR_RECON_ADD_CHILD = 2 } jbr_recon_notify_ev_id_t; typedef struct _jbr_recon_notify_ev_s { - jbr_recon_notify_ev_id_t id; - uint32_t index; /* in case of add */ - struct list_head list; + jbr_recon_notify_ev_id_t id; + uint32_t index; /* in case of add */ + struct list_head list; } jbr_recon_notify_ev_t; typedef struct { - /* - * This is a hack to allow a non-leader to accept requests while the - * leader is down, and it only works for n=2. The way it works is that - * "config_leader" indicates the state from our options (via init or - * reconfigure) but "leader" is what the fop code actually looks at. If - * config_leader is true, then leader will *always* be true as well, - * giving that brick precedence. If config_leader is false, then - * leader will only be true if there is no connection to the other - * brick (tracked in jbr_notify). - * - * TBD: implement real leader election - */ - gf_boolean_t config_leader; - gf_boolean_t leader; - uint8_t up_children; - uint8_t n_children; - char *vol_file; - uint32_t current_term; - uint32_t kid_state; - gf_lock_t dirty_lock; - struct list_head dirty_fds; - uint32_t index; - gf_lock_t index_lock; - double quorum_pct; - int term_fd; - long term_total; - long term_read; - /* - * This is a super-duper hack, but it will do for now. The reason it's - * a hack is that we pass this to dict_set_static_bin, so we don't have - * to mess around with allocating and freeing it on every single IPC - * request, but it's totally not thread-safe. On the other hand, there - * should only be one reconciliation thread running and calling these - * functions at a time, so maybe that doesn't matter. - * - * TBD: re-evaluate how to manage this - */ - char term_buf[CHANGELOG_ENTRY_SIZE]; - gf_boolean_t child_up; /* To maintain the state of * - * the translator */ + /* + * This is a hack to allow a non-leader to accept requests while the + * leader is down, and it only works for n=2. The way it works is that + * "config_leader" indicates the state from our options (via init or + * reconfigure) but "leader" is what the fop code actually looks at. If + * config_leader is true, then leader will *always* be true as well, + * giving that brick precedence. If config_leader is false, then + * leader will only be true if there is no connection to the other + * brick (tracked in jbr_notify). + * + * TBD: implement real leader election + */ + gf_boolean_t config_leader; + gf_boolean_t leader; + uint8_t up_children; + uint8_t n_children; + char *vol_file; + uint32_t current_term; + uint32_t kid_state; + gf_lock_t dirty_lock; + struct list_head dirty_fds; + uint32_t index; + gf_lock_t index_lock; + double quorum_pct; + int term_fd; + long term_total; + long term_read; + /* + * This is a super-duper hack, but it will do for now. The reason it's + * a hack is that we pass this to dict_set_static_bin, so we don't have + * to mess around with allocating and freeing it on every single IPC + * request, but it's totally not thread-safe. On the other hand, there + * should only be one reconciliation thread running and calling these + * functions at a time, so maybe that doesn't matter. + * + * TBD: re-evaluate how to manage this + */ + char term_buf[CHANGELOG_ENTRY_SIZE]; + gf_boolean_t child_up; /* To maintain the state of * + * the translator */ } jbr_private_t; typedef struct { - call_stub_t *stub; - call_stub_t *qstub; - uint32_t call_count; - uint32_t successful_acks; - uint32_t successful_op_ret; - fd_t *fd; - struct list_head qlinks; - dict_t *xdata; + call_stub_t *stub; + call_stub_t *qstub; + uint32_t call_count; + uint32_t successful_acks; + uint32_t successful_op_ret; + fd_t *fd; + struct list_head qlinks; + dict_t *xdata; } jbr_local_t; /* @@ -96,22 +96,23 @@ typedef struct { typedef uint32_t log_id_t; typedef struct { - struct list_head links; - log_id_t id; + struct list_head links; + log_id_t id; } jbr_dirty_list_t; typedef struct { - fd_t *fd; - struct list_head dirty_list; - struct list_head fd_list; + fd_t *fd; + struct list_head dirty_list; + struct list_head fd_list; } jbr_fd_ctx_t; typedef struct { - gf_lock_t lock; - uint32_t active; - struct list_head aqueue; - uint32_t pending; - struct list_head pqueue; + gf_lock_t lock; + uint32_t active; + struct list_head aqueue; + uint32_t pending; + struct list_head pqueue; } jbr_inode_ctx_t; -void jbr_start_reconciler (xlator_t *this); +void +jbr_start_reconciler(xlator_t *this); diff --git a/xlators/features/arbiter/src/arbiter-mem-types.h b/xlators/features/arbiter/src/arbiter-mem-types.h index ccf864cdef0..0f77cfd05f4 100644 --- a/xlators/features/arbiter/src/arbiter-mem-types.h +++ b/xlators/features/arbiter/src/arbiter-mem-types.h @@ -12,7 +12,7 @@ #include "mem-types.h" typedef enum gf_arbiter_mem_types_ { - gf_arbiter_mt_inode_ctx_t = gf_common_mt_end + 1, - gf_arbiter_mt_end + gf_arbiter_mt_inode_ctx_t = gf_common_mt_end + 1, + gf_arbiter_mt_end } gf_arbiter_mem_types_t; #endif diff --git a/xlators/features/arbiter/src/arbiter.h b/xlators/features/arbiter/src/arbiter.h index f52b45fad20..ce1c909f70f 100644 --- a/xlators/features/arbiter/src/arbiter.h +++ b/xlators/features/arbiter/src/arbiter.h @@ -15,7 +15,7 @@ #include "common-utils.h" typedef struct arbiter_inode_ctx_ { - struct iatt iattbuf; + struct iatt iattbuf; } arbiter_inode_ctx_t; #endif /* _ARBITER_H */ diff --git a/xlators/features/barrier/src/barrier-mem-types.h b/xlators/features/barrier/src/barrier-mem-types.h index 36647a66966..93ccab633ce 100644 --- a/xlators/features/barrier/src/barrier-mem-types.h +++ b/xlators/features/barrier/src/barrier-mem-types.h @@ -14,7 +14,7 @@ #include "mem-types.h" enum gf_barrier_mem_types_ { - gf_barrier_mt_priv_t = gf_common_mt_end + 1, - gf_barrier_mt_end + gf_barrier_mt_priv_t = gf_common_mt_end + 1, + gf_barrier_mt_end }; #endif diff --git a/xlators/features/barrier/src/barrier.h b/xlators/features/barrier/src/barrier.h index 0d646f90474..d11d71d151e 100644 --- a/xlators/features/barrier/src/barrier.h +++ b/xlators/features/barrier/src/barrier.h @@ -16,67 +16,73 @@ #include "timer.h" #include "call-stub.h" -#define BARRIER_FOP_CBK(fop_name, label, frame, this, params ...) \ - do { \ - barrier_priv_t *_priv = NULL; \ - call_stub_t *_stub = NULL; \ - gf_boolean_t _barrier_enabled= _gf_false; \ - struct list_head queue = {0, }; \ - \ - INIT_LIST_HEAD (&queue); \ - \ - _priv = this->private; \ - GF_ASSERT (_priv); \ - \ - LOCK (&_priv->lock); \ - { \ - if (_priv->barrier_enabled) { \ - _barrier_enabled = _priv->barrier_enabled;\ - \ - _stub = fop_##fop_name##_cbk_stub \ - (frame, \ - barrier_##fop_name##_cbk_resume,\ - params); \ - if (!_stub) { \ - __barrier_disable (this, &queue);\ - goto unlock; \ - } \ - \ - __barrier_enqueue (this, _stub); \ - } \ - } \ -unlock: \ - UNLOCK (&_priv->lock); \ - \ - if (_stub) \ - goto label; \ - \ - if (_barrier_enabled && !_stub) { \ - gf_log (this->name, GF_LOG_CRITICAL, \ - "Failed to barrier FOPs, disabling " \ - "barrier. FOP: %s, ERROR: %s", \ - #fop_name, strerror (ENOMEM)); \ - barrier_dequeue_all (this, &queue); \ - } \ - barrier_local_free_gfid (frame); \ - STACK_UNWIND_STRICT (fop_name, frame, params); \ - goto label; \ - } while (0) +#define BARRIER_FOP_CBK(fop_name, label, frame, this, params...) \ + do { \ + barrier_priv_t *_priv = NULL; \ + call_stub_t *_stub = NULL; \ + gf_boolean_t _barrier_enabled = _gf_false; \ + struct list_head queue = { \ + 0, \ + }; \ + \ + INIT_LIST_HEAD(&queue); \ + \ + _priv = this->private; \ + GF_ASSERT(_priv); \ + \ + LOCK(&_priv->lock); \ + { \ + if (_priv->barrier_enabled) { \ + _barrier_enabled = _priv->barrier_enabled; \ + \ + _stub = fop_##fop_name##_cbk_stub( \ + frame, barrier_##fop_name##_cbk_resume, params); \ + if (!_stub) { \ + __barrier_disable(this, &queue); \ + goto unlock; \ + } \ + \ + __barrier_enqueue(this, _stub); \ + } \ + } \ + unlock: \ + UNLOCK(&_priv->lock); \ + \ + if (_stub) \ + goto label; \ + \ + if (_barrier_enabled && !_stub) { \ + gf_log(this->name, GF_LOG_CRITICAL, \ + "Failed to barrier FOPs, disabling " \ + "barrier. FOP: %s, ERROR: %s", \ + #fop_name, strerror(ENOMEM)); \ + barrier_dequeue_all(this, &queue); \ + } \ + barrier_local_free_gfid(frame); \ + STACK_UNWIND_STRICT(fop_name, frame, params); \ + goto label; \ + } while (0) typedef struct { - gf_timer_t *timer; - gf_boolean_t barrier_enabled; - gf_lock_t lock; - struct list_head queue; - struct timespec timeout; - uint32_t queue_size; + gf_timer_t *timer; + gf_boolean_t barrier_enabled; + gf_lock_t lock; + struct list_head queue; + struct timespec timeout; + uint32_t queue_size; } barrier_priv_t; -int __barrier_enable (xlator_t *this, barrier_priv_t *priv); -void __barrier_enqueue (xlator_t *this, call_stub_t *stub); -void __barrier_disable (xlator_t *this, struct list_head *queue); -void barrier_timeout (void *data); -void barrier_dequeue_all (xlator_t *this, struct list_head *queue); -call_stub_t *__barrier_dequeue (xlator_t *this, struct list_head *queue); +int +__barrier_enable(xlator_t *this, barrier_priv_t *priv); +void +__barrier_enqueue(xlator_t *this, call_stub_t *stub); +void +__barrier_disable(xlator_t *this, struct list_head *queue); +void +barrier_timeout(void *data); +void +barrier_dequeue_all(xlator_t *this, struct list_head *queue); +call_stub_t * +__barrier_dequeue(xlator_t *this, struct list_head *queue); #endif diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h index 89a67cc10b1..6f59933a31d 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h @@ -23,62 +23,30 @@ * glfs-message-id.h. */ -GLFS_MSGID(BITROT_BITD, - BRB_MSG_FD_CREATE_FAILED, - BRB_MSG_READV_FAILED, - BRB_MSG_BLOCK_READ_FAILED, - BRB_MSG_CALC_CHECKSUM_FAILED, - BRB_MSG_NO_MEMORY, - BRB_MSG_GET_SIGN_FAILED, - BRB_MSG_SET_SIGN_FAILED, - BRB_MSG_OP_FAILED, - BRB_MSG_READ_AND_SIGN_FAILED, - BRB_MSG_SIGN_FAILED, - BRB_MSG_GET_SUBVOL_FAILED, - BRB_MSG_SET_TIMER_FAILED, - BRB_MSG_GET_INFO_FAILED, - BRB_MSG_PATH_FAILED, - BRB_MSG_MARK_BAD_FILE, - BRB_MSG_TRIGGER_SIGN, - BRB_MSG_REGISTER_FAILED, - BRB_MSG_CRAWLING_START, - BRB_MSG_SPAWN_FAILED, - BRB_MSG_INVALID_SUBVOL_CHILD, - BRB_MSG_SKIP_OBJECT, - BRB_MSG_NO_CHILD, - BRB_MSG_CHECKSUM_MISMATCH, - BRB_MSG_MARK_CORRUPTED, - BRB_MSG_CRAWLING_FINISH, - BRB_MSG_CALC_ERROR, - BRB_MSG_LOOKUP_FAILED, - BRB_MSG_PARTIAL_VERSION_PRESENCE, - BRB_MSG_MEM_ACNT_FAILED, - BRB_MSG_TIMER_WHEEL_UNAVAILABLE, - BRB_MSG_BITROT_LOADED, - BRB_MSG_SCALE_DOWN_FAILED, - BRB_MSG_SCALE_UP_FAILED, - BRB_MSG_SCALE_DOWN_SCRUBBER, - BRB_MSG_SCALING_UP_SCRUBBER, - BRB_MSG_UNKNOWN_THROTTLE, - BRB_MSG_RATE_LIMIT_INFO, - BRB_MSG_SCRUB_INFO, - BRB_MSG_CONNECTED_TO_BRICK, - BRB_MSG_BRICK_INFO, - BRB_MSG_SUBVOL_CONNECT_FAILED, - BRB_MSG_INVALID_SUBVOL, - BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, - BRB_MSG_SCRUB_START, - BRB_MSG_SCRUB_FINISH, - BRB_MSG_SCRUB_RUNNING, - BRB_MSG_SCRUB_RESCHEDULED, - BRB_MSG_SCRUB_TUNABLE, - BRB_MSG_SCRUB_THREAD_CLEANUP, - BRB_MSG_SCRUBBER_CLEANED, - BRB_MSG_GENERIC_SSM_INFO, - BRB_MSG_ZERO_TIMEOUT_BUG, - BRB_MSG_BAD_OBJ_READDIR_FAIL, - BRB_MSG_SSM_FAILED, - BRB_MSG_SCRUB_WAIT_FAILED -); +GLFS_MSGID(BITROT_BITD, BRB_MSG_FD_CREATE_FAILED, BRB_MSG_READV_FAILED, + BRB_MSG_BLOCK_READ_FAILED, BRB_MSG_CALC_CHECKSUM_FAILED, + BRB_MSG_NO_MEMORY, BRB_MSG_GET_SIGN_FAILED, BRB_MSG_SET_SIGN_FAILED, + BRB_MSG_OP_FAILED, BRB_MSG_READ_AND_SIGN_FAILED, BRB_MSG_SIGN_FAILED, + BRB_MSG_GET_SUBVOL_FAILED, BRB_MSG_SET_TIMER_FAILED, + BRB_MSG_GET_INFO_FAILED, BRB_MSG_PATH_FAILED, BRB_MSG_MARK_BAD_FILE, + BRB_MSG_TRIGGER_SIGN, BRB_MSG_REGISTER_FAILED, + BRB_MSG_CRAWLING_START, BRB_MSG_SPAWN_FAILED, + BRB_MSG_INVALID_SUBVOL_CHILD, BRB_MSG_SKIP_OBJECT, BRB_MSG_NO_CHILD, + BRB_MSG_CHECKSUM_MISMATCH, BRB_MSG_MARK_CORRUPTED, + BRB_MSG_CRAWLING_FINISH, BRB_MSG_CALC_ERROR, BRB_MSG_LOOKUP_FAILED, + BRB_MSG_PARTIAL_VERSION_PRESENCE, BRB_MSG_MEM_ACNT_FAILED, + BRB_MSG_TIMER_WHEEL_UNAVAILABLE, BRB_MSG_BITROT_LOADED, + BRB_MSG_SCALE_DOWN_FAILED, BRB_MSG_SCALE_UP_FAILED, + BRB_MSG_SCALE_DOWN_SCRUBBER, BRB_MSG_SCALING_UP_SCRUBBER, + BRB_MSG_UNKNOWN_THROTTLE, BRB_MSG_RATE_LIMIT_INFO, + BRB_MSG_SCRUB_INFO, BRB_MSG_CONNECTED_TO_BRICK, BRB_MSG_BRICK_INFO, + BRB_MSG_SUBVOL_CONNECT_FAILED, BRB_MSG_INVALID_SUBVOL, + BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, BRB_MSG_SCRUB_START, + BRB_MSG_SCRUB_FINISH, BRB_MSG_SCRUB_RUNNING, + BRB_MSG_SCRUB_RESCHEDULED, BRB_MSG_SCRUB_TUNABLE, + BRB_MSG_SCRUB_THREAD_CLEANUP, BRB_MSG_SCRUBBER_CLEANED, + BRB_MSG_GENERIC_SSM_INFO, BRB_MSG_ZERO_TIMEOUT_BUG, + BRB_MSG_BAD_OBJ_READDIR_FAIL, BRB_MSG_SSM_FAILED, + BRB_MSG_SCRUB_WAIT_FAILED); #endif /* !_BITROT_BITD_MESSAGES_H_ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h index 02bd0fab04e..24128b90a66 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h @@ -16,33 +16,33 @@ #include <pthread.h> struct br_scrub_stats { - uint64_t scrubbed_files; /* Total number of scrubbed file */ + uint64_t scrubbed_files; /* Total number of scrubbed file */ - uint64_t unsigned_files; /* Total number of unsigned file */ + uint64_t unsigned_files; /* Total number of unsigned file */ - uint64_t scrub_duration; /* Duration of last scrub */ + uint64_t scrub_duration; /* Duration of last scrub */ - char last_scrub_time[1024]; /*last scrub completion time */ + char last_scrub_time[1024]; /*last scrub completion time */ - struct timeval scrub_start_tv; /* Scrubbing starting time*/ + struct timeval scrub_start_tv; /* Scrubbing starting time*/ - struct timeval scrub_end_tv; /* Scrubbing finishing time */ + struct timeval scrub_end_tv; /* Scrubbing finishing time */ - int8_t scrub_running; /* Scrub running or not */ + int8_t scrub_running; /* Scrub running or not */ - pthread_mutex_t lock; + pthread_mutex_t lock; }; typedef struct br_scrub_stats br_scrub_stats_t; void -br_inc_unsigned_file_count (br_scrub_stats_t *scrub_stat); +br_inc_unsigned_file_count(br_scrub_stats_t *scrub_stat); void -br_inc_scrubbed_file (br_scrub_stats_t *scrub_stat); +br_inc_scrubbed_file(br_scrub_stats_t *scrub_stat); void -br_update_scrub_start_time (br_scrub_stats_t *scrub_stat, struct timeval *tv); +br_update_scrub_start_time(br_scrub_stats_t *scrub_stat, struct timeval *tv); void -br_update_scrub_finish_time (br_scrub_stats_t *scrub_stat, char *timestr, - struct timeval *tv); +br_update_scrub_finish_time(br_scrub_stats_t *scrub_stat, char *timestr, + struct timeval *tv); #endif /* __BIT_ROT_SCRUB_STATUS_H__ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h index 8cc88ec153e..7a3c14abb93 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h @@ -14,24 +14,33 @@ #include "xlator.h" #include "bit-rot.h" -void *br_fsscanner (void *); +void * +br_fsscanner(void *); -int32_t br_fsscan_schedule (xlator_t *); -int32_t br_fsscan_reschedule (xlator_t *); -int32_t br_fsscan_activate (xlator_t *); -int32_t br_fsscan_deactivate (xlator_t *); -int32_t br_fsscan_ondemand (xlator_t *); +int32_t +br_fsscan_schedule(xlator_t *); +int32_t +br_fsscan_reschedule(xlator_t *); +int32_t +br_fsscan_activate(xlator_t *); +int32_t +br_fsscan_deactivate(xlator_t *); +int32_t +br_fsscan_ondemand(xlator_t *); -int32_t br_scrubber_handle_options (xlator_t *, br_private_t *, dict_t *); +int32_t +br_scrubber_handle_options(xlator_t *, br_private_t *, dict_t *); int32_t -br_scrubber_monitor_init (xlator_t *, br_private_t *); +br_scrubber_monitor_init(xlator_t *, br_private_t *); -int32_t br_scrubber_init (xlator_t *, br_private_t *); +int32_t +br_scrubber_init(xlator_t *, br_private_t *); -int32_t br_collect_bad_objects_from_children (xlator_t *this, dict_t *dict); +int32_t +br_collect_bad_objects_from_children(xlator_t *this, dict_t *dict); void -br_child_set_scrub_state (br_child_t *, gf_boolean_t); +br_child_set_scrub_state(br_child_t *, gf_boolean_t); #endif /* __BIT_ROT_SCRUB_H__ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h index 8609477180b..f3fbe2928b7 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h @@ -14,24 +14,25 @@ #include "xlator.h" typedef enum br_scrub_state { - BR_SCRUB_STATE_INACTIVE = 0, - BR_SCRUB_STATE_PENDING, - BR_SCRUB_STATE_ACTIVE, - BR_SCRUB_STATE_PAUSED, - BR_SCRUB_STATE_IPAUSED, - BR_SCRUB_STATE_STALLED, - BR_SCRUB_MAXSTATES, + BR_SCRUB_STATE_INACTIVE = 0, + BR_SCRUB_STATE_PENDING, + BR_SCRUB_STATE_ACTIVE, + BR_SCRUB_STATE_PAUSED, + BR_SCRUB_STATE_IPAUSED, + BR_SCRUB_STATE_STALLED, + BR_SCRUB_MAXSTATES, } br_scrub_state_t; typedef enum br_scrub_event { - BR_SCRUB_EVENT_SCHEDULE = 0, - BR_SCRUB_EVENT_PAUSE, - BR_SCRUB_EVENT_ONDEMAND, - BR_SCRUB_MAXEVENTS, + BR_SCRUB_EVENT_SCHEDULE = 0, + BR_SCRUB_EVENT_PAUSE, + BR_SCRUB_EVENT_ONDEMAND, + BR_SCRUB_MAXEVENTS, } br_scrub_event_t; struct br_monitor; -int32_t br_scrub_state_machine (xlator_t *, gf_boolean_t); +int32_t +br_scrub_state_machine(xlator_t *, gf_boolean_t); #endif /* __BIT_ROT_SSM_H__ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h index 670060c8d88..962b4d717e6 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot.h @@ -37,271 +37,270 @@ #define BR_WORKERS 4 typedef enum scrub_throttle { - BR_SCRUB_THROTTLE_VOID = -1, - BR_SCRUB_THROTTLE_LAZY = 0, - BR_SCRUB_THROTTLE_NORMAL = 1, - BR_SCRUB_THROTTLE_AGGRESSIVE = 2, - BR_SCRUB_THROTTLE_STALLED = 3, + BR_SCRUB_THROTTLE_VOID = -1, + BR_SCRUB_THROTTLE_LAZY = 0, + BR_SCRUB_THROTTLE_NORMAL = 1, + BR_SCRUB_THROTTLE_AGGRESSIVE = 2, + BR_SCRUB_THROTTLE_STALLED = 3, } scrub_throttle_t; typedef enum scrub_freq { - BR_FSSCRUB_FREQ_HOURLY = 1, - BR_FSSCRUB_FREQ_DAILY, - BR_FSSCRUB_FREQ_WEEKLY, - BR_FSSCRUB_FREQ_BIWEEKLY, - BR_FSSCRUB_FREQ_MONTHLY, - BR_FSSCRUB_FREQ_MINUTE, - BR_FSSCRUB_FREQ_STALLED, + BR_FSSCRUB_FREQ_HOURLY = 1, + BR_FSSCRUB_FREQ_DAILY, + BR_FSSCRUB_FREQ_WEEKLY, + BR_FSSCRUB_FREQ_BIWEEKLY, + BR_FSSCRUB_FREQ_MONTHLY, + BR_FSSCRUB_FREQ_MINUTE, + BR_FSSCRUB_FREQ_STALLED, } scrub_freq_t; -#define signature_size(hl) (sizeof (br_isignature_t) + hl + 1) +#define signature_size(hl) (sizeof(br_isignature_t) + hl + 1) struct br_scanfs { - gf_lock_t entrylock; + gf_lock_t entrylock; - pthread_mutex_t waitlock; - pthread_cond_t waitcond; + pthread_mutex_t waitlock; + pthread_cond_t waitcond; - unsigned int entries; - struct list_head queued; - struct list_head ready; + unsigned int entries; + struct list_head queued; + struct list_head ready; }; /* just need three states to track child status */ typedef enum br_child_state { - BR_CHILD_STATE_CONNECTED = 1, - BR_CHILD_STATE_INITIALIZING, - BR_CHILD_STATE_CONNFAILED, - BR_CHILD_STATE_DISCONNECTED, + BR_CHILD_STATE_CONNECTED = 1, + BR_CHILD_STATE_INITIALIZING, + BR_CHILD_STATE_CONNFAILED, + BR_CHILD_STATE_DISCONNECTED, } br_child_state_t; struct br_child { - pthread_mutex_t lock; /* protects child state */ - char witnessed; /* witnessed at least one successful - connection */ - br_child_state_t c_state; /* current state of this child */ + pthread_mutex_t lock; /* protects child state */ + char witnessed; /* witnessed at least one successful + connection */ + br_child_state_t c_state; /* current state of this child */ - char child_up; /* Indicates whether this child is - up or not */ - xlator_t *xl; /* client xlator corresponding to - this child */ - inode_table_t *table; /* inode table for this child */ - char brick_path[PATH_MAX]; /* brick export directory of this - child */ - struct list_head list; /* hook to attach to the list of - UP children */ - xlator_t *this; /* Bit rot xlator */ + char child_up; /* Indicates whether this child is + up or not */ + xlator_t *xl; /* client xlator corresponding to + this child */ + inode_table_t *table; /* inode table for this child */ + char brick_path[PATH_MAX]; /* brick export directory of this + child */ + struct list_head list; /* hook to attach to the list of + UP children */ + xlator_t *this; /* Bit rot xlator */ - pthread_t thread; /* initial crawler for unsigned - object(s) or scrub crawler */ - int threadrunning; /* active thread */ + pthread_t thread; /* initial crawler for unsigned + object(s) or scrub crawler */ + int threadrunning; /* active thread */ - struct mem_pool *timer_pool; /* timer-wheel's timer mem-pool */ + struct mem_pool *timer_pool; /* timer-wheel's timer mem-pool */ - struct timeval tv; + struct timeval tv; - struct br_scanfs fsscan; /* per subvolume FS scanner */ + struct br_scanfs fsscan; /* per subvolume FS scanner */ - gf_boolean_t active_scrubbing; /* Actively scrubbing or not */ + gf_boolean_t active_scrubbing; /* Actively scrubbing or not */ }; typedef struct br_child br_child_t; struct br_obj_n_workers { - struct list_head objects; /* queue of objects expired from the - timer wheel and ready to be picked - up for signing */ - pthread_t workers[BR_WORKERS]; /* Threads which pick up the objects - from the above queue and start - signing each object */ + struct list_head objects; /* queue of objects expired from the + timer wheel and ready to be picked + up for signing */ + pthread_t workers[BR_WORKERS]; /* Threads which pick up the objects + from the above queue and start + signing each object */ }; struct br_scrubber { - xlator_t *this; + xlator_t *this; - scrub_throttle_t throttle; + scrub_throttle_t throttle; - /** - * frequency of scanning for this subvolume. this should - * normally be per-child, but since all children follow the - * same frequency for a volume, this option ends up here - * instead of br_child_t. - */ - scrub_freq_t frequency; + /** + * frequency of scanning for this subvolume. this should + * normally be per-child, but since all children follow the + * same frequency for a volume, this option ends up here + * instead of br_child_t. + */ + scrub_freq_t frequency; - gf_boolean_t frequency_reconf; - gf_boolean_t throttle_reconf; + gf_boolean_t frequency_reconf; + gf_boolean_t throttle_reconf; - pthread_mutex_t mutex; - pthread_cond_t cond; + pthread_mutex_t mutex; + pthread_cond_t cond; - unsigned int nr_scrubbers; - struct list_head scrubbers; + unsigned int nr_scrubbers; + struct list_head scrubbers; - /** - * list of "rotatable" subvolume(s) undergoing scrubbing - */ - struct list_head scrublist; + /** + * list of "rotatable" subvolume(s) undergoing scrubbing + */ + struct list_head scrublist; }; struct br_monitor { - gf_lock_t lock; - pthread_t thread; /* Monitor thread */ - - gf_boolean_t inited; - pthread_mutex_t mutex; - pthread_cond_t cond; /* Thread starts and will be waiting on cond. - First child which is up wakes this up */ - - xlator_t *this; - /* scheduler */ - uint32_t boot; - - int32_t active_child_count; /* Number of children currently scrubbing */ - gf_boolean_t kick; /* This variable tracks the scrubber is - * kicked or not. Both 'kick' and - * 'active_child_count' uses the same pair - * of mutex-cond variable, i.e, wakelock and - * wakecond. */ - - pthread_mutex_t wakelock; - pthread_cond_t wakecond; - - gf_boolean_t done; - pthread_mutex_t donelock; - pthread_cond_t donecond; - - struct gf_tw_timer_list *timer; - br_scrub_state_t state; /* current scrub state */ + gf_lock_t lock; + pthread_t thread; /* Monitor thread */ + + gf_boolean_t inited; + pthread_mutex_t mutex; + pthread_cond_t cond; /* Thread starts and will be waiting on cond. + First child which is up wakes this up */ + + xlator_t *this; + /* scheduler */ + uint32_t boot; + + int32_t active_child_count; /* Number of children currently scrubbing */ + gf_boolean_t kick; /* This variable tracks the scrubber is + * kicked or not. Both 'kick' and + * 'active_child_count' uses the same pair + * of mutex-cond variable, i.e, wakelock and + * wakecond. */ + + pthread_mutex_t wakelock; + pthread_cond_t wakecond; + + gf_boolean_t done; + pthread_mutex_t donelock; + pthread_cond_t donecond; + + struct gf_tw_timer_list *timer; + br_scrub_state_t state; /* current scrub state */ }; typedef struct br_obj_n_workers br_obj_n_workers_t; typedef struct br_private br_private_t; -typedef void (*br_scrubbed_file_update) (br_private_t *priv); +typedef void (*br_scrubbed_file_update)(br_private_t *priv); struct br_private { - pthread_mutex_t lock; + pthread_mutex_t lock; - struct list_head bricks; /* list of bricks from which enents - have been received */ + struct list_head bricks; /* list of bricks from which enents + have been received */ - struct list_head signing; + struct list_head signing; - pthread_cond_t object_cond; /* handling signing of objects */ - int child_count; - br_child_t *children; /* list of subvolumes */ - int up_children; + pthread_cond_t object_cond; /* handling signing of objects */ + int child_count; + br_child_t *children; /* list of subvolumes */ + int up_children; - pthread_cond_t cond; /* handling CHILD_UP notifications */ - pthread_t thread; /* thread for connecting each UP - child with changelog */ + pthread_cond_t cond; /* handling CHILD_UP notifications */ + pthread_t thread; /* thread for connecting each UP + child with changelog */ - struct tvec_base *timer_wheel; /* timer wheel where the objects which - changelog has sent sits and waits - for expiry */ - br_obj_n_workers_t *obj_queue; /* place holder for all the objects - that are expired from timer wheel - and ready to be picked up for - signing and the workers which sign - the objects */ + struct tvec_base *timer_wheel; /* timer wheel where the objects which + changelog has sent sits and waits + for expiry */ + br_obj_n_workers_t *obj_queue; /* place holder for all the objects + that are expired from timer wheel + and ready to be picked up for + signing and the workers which sign + the objects */ - uint32_t expiry_time; /* objects "wait" time */ + uint32_t expiry_time; /* objects "wait" time */ - tbf_t *tbf; /* token bucket filter */ + tbf_t *tbf; /* token bucket filter */ - gf_boolean_t iamscrubber; /* function as a fs scrubber */ + gf_boolean_t iamscrubber; /* function as a fs scrubber */ - struct br_scrub_stats scrub_stat; /* statistics of scrub*/ + struct br_scrub_stats scrub_stat; /* statistics of scrub*/ - struct br_scrubber fsscrub; /* scrubbers for this subvolume */ + struct br_scrubber fsscrub; /* scrubbers for this subvolume */ - struct br_monitor scrub_monitor; /* scrubber monitor */ + struct br_monitor scrub_monitor; /* scrubber monitor */ }; struct br_object { - xlator_t *this; + xlator_t *this; - uuid_t gfid; + uuid_t gfid; - unsigned long signedversion; /* version against which this object will - be signed */ - br_child_t *child; /* object's subvolume */ + unsigned long signedversion; /* version against which this object will + be signed */ + br_child_t *child; /* object's subvolume */ - int sign_info; + int sign_info; - struct list_head list; /* hook to add to the queue once the - object is expired from timer wheel */ - void *data; + struct list_head list; /* hook to add to the queue once the + object is expired from timer wheel */ + void *data; }; typedef struct br_object br_object_t; -typedef int32_t (br_scrub_ssm_call) (xlator_t *); +typedef int32_t(br_scrub_ssm_call)(xlator_t *); void -br_log_object (xlator_t *, char *, uuid_t, int32_t); +br_log_object(xlator_t *, char *, uuid_t, int32_t); void -br_log_object_path (xlator_t *, char *, const char *, int32_t); +br_log_object_path(xlator_t *, char *, const char *, int32_t); int32_t -br_calculate_obj_checksum (unsigned char *, - br_child_t *, fd_t *, struct iatt *); +br_calculate_obj_checksum(unsigned char *, br_child_t *, fd_t *, struct iatt *); int32_t -br_prepare_loc (xlator_t *, br_child_t *, loc_t *, gf_dirent_t *, loc_t *); +br_prepare_loc(xlator_t *, br_child_t *, loc_t *, gf_dirent_t *, loc_t *); gf_boolean_t -bitd_is_bad_file (xlator_t *, br_child_t *, loc_t *, fd_t *); +bitd_is_bad_file(xlator_t *, br_child_t *, loc_t *, fd_t *); static inline void -_br_set_child_state (br_child_t *child, br_child_state_t state) +_br_set_child_state(br_child_t *child, br_child_state_t state) { - child->c_state = state; + child->c_state = state; } static inline int -_br_is_child_connected (br_child_t *child) +_br_is_child_connected(br_child_t *child) { - return (child->c_state == BR_CHILD_STATE_CONNECTED); + return (child->c_state == BR_CHILD_STATE_CONNECTED); } static inline int -_br_is_child_scrub_active (br_child_t *child) +_br_is_child_scrub_active(br_child_t *child) { - return child->active_scrubbing; + return child->active_scrubbing; } static inline int -_br_child_failed_conn (br_child_t *child) +_br_child_failed_conn(br_child_t *child) { - return (child->c_state == BR_CHILD_STATE_CONNFAILED); + return (child->c_state == BR_CHILD_STATE_CONNFAILED); } static inline int -_br_child_witnessed_connection (br_child_t *child) +_br_child_witnessed_connection(br_child_t *child) { - return (child->witnessed == 1); + return (child->witnessed == 1); } /* scrub state */ static inline void -_br_monitor_set_scrub_state (struct br_monitor *scrub_monitor, - br_scrub_state_t state) +_br_monitor_set_scrub_state(struct br_monitor *scrub_monitor, + br_scrub_state_t state) { - scrub_monitor->state = state; + scrub_monitor->state = state; } static inline br_scrub_event_t -_br_child_get_scrub_event (struct br_scrubber *fsscrub) +_br_child_get_scrub_event(struct br_scrubber *fsscrub) { - return (fsscrub->frequency == BR_FSSCRUB_FREQ_STALLED) - ? BR_SCRUB_EVENT_PAUSE : BR_SCRUB_EVENT_SCHEDULE; + return (fsscrub->frequency == BR_FSSCRUB_FREQ_STALLED) + ? BR_SCRUB_EVENT_PAUSE + : BR_SCRUB_EVENT_SCHEDULE; } int32_t -br_get_bad_objects_list (xlator_t *this, dict_t **dict); - +br_get_bad_objects_list(xlator_t *this, dict_t **dict); #endif /* __BIT_ROT_H__ */ diff --git a/xlators/features/bit-rot/src/stub/bit-rot-common.h b/xlators/features/bit-rot/src/stub/bit-rot-common.h index 2afc9f47c29..ef683ac7f9f 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-common.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-common.h @@ -14,71 +14,71 @@ #include "glusterfs.h" #include "bit-rot-object-version.h" -#define BR_VXATTR_VERSION (1 << 0) +#define BR_VXATTR_VERSION (1 << 0) #define BR_VXATTR_SIGNATURE (1 << 1) #define BR_VXATTR_SIGN_MISSING (BR_VXATTR_SIGNATURE) -#define BR_VXATTR_ALL_MISSING \ - (BR_VXATTR_VERSION | BR_VXATTR_SIGNATURE) +#define BR_VXATTR_ALL_MISSING (BR_VXATTR_VERSION | BR_VXATTR_SIGNATURE) -#define BR_BAD_OBJ_CONTAINER (uuid_t){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8} +#define BR_BAD_OBJ_CONTAINER \ + (uuid_t) { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8 } typedef enum br_vxattr_state { - BR_VXATTR_STATUS_FULL = 0, - BR_VXATTR_STATUS_MISSING = 1, - BR_VXATTR_STATUS_UNSIGNED = 2, - BR_VXATTR_STATUS_INVALID = 3, + BR_VXATTR_STATUS_FULL = 0, + BR_VXATTR_STATUS_MISSING = 1, + BR_VXATTR_STATUS_UNSIGNED = 2, + BR_VXATTR_STATUS_INVALID = 3, } br_vxattr_status_t; typedef enum br_sign_state { - BR_SIGN_INVALID = -1, - BR_SIGN_NORMAL = 0, - BR_SIGN_REOPEN_WAIT = 1, - BR_SIGN_QUICK = 2, + BR_SIGN_INVALID = -1, + BR_SIGN_NORMAL = 0, + BR_SIGN_REOPEN_WAIT = 1, + BR_SIGN_QUICK = 2, } br_sign_state_t; static inline br_vxattr_status_t -br_version_xattr_state (dict_t *xattr, br_version_t **obuf, - br_signature_t **sbuf, gf_boolean_t *objbad) +br_version_xattr_state(dict_t *xattr, br_version_t **obuf, + br_signature_t **sbuf, gf_boolean_t *objbad) { - int32_t ret = 0; - int32_t vxattr = 0; - br_vxattr_status_t status; - void *data = NULL; - - /** - * The key being present in the dict indicates the xattr was set on - * disk. The presence of xattr itself as of now is suffecient to say - * the the object is bad. - */ - *objbad = _gf_false; - ret = dict_get_bin (xattr, BITROT_OBJECT_BAD_KEY, (void **)&data); - if (!ret) - *objbad = _gf_true; - - ret = dict_get_bin (xattr, BITROT_CURRENT_VERSION_KEY, (void **)obuf); - if (ret) - vxattr |= BR_VXATTR_VERSION; - - ret = dict_get_bin (xattr, BITROT_SIGNING_VERSION_KEY, (void **)sbuf); - if (ret) - vxattr |= BR_VXATTR_SIGNATURE; - - switch (vxattr) { + int32_t ret = 0; + int32_t vxattr = 0; + br_vxattr_status_t status; + void *data = NULL; + + /** + * The key being present in the dict indicates the xattr was set on + * disk. The presence of xattr itself as of now is suffecient to say + * the the object is bad. + */ + *objbad = _gf_false; + ret = dict_get_bin(xattr, BITROT_OBJECT_BAD_KEY, (void **)&data); + if (!ret) + *objbad = _gf_true; + + ret = dict_get_bin(xattr, BITROT_CURRENT_VERSION_KEY, (void **)obuf); + if (ret) + vxattr |= BR_VXATTR_VERSION; + + ret = dict_get_bin(xattr, BITROT_SIGNING_VERSION_KEY, (void **)sbuf); + if (ret) + vxattr |= BR_VXATTR_SIGNATURE; + + switch (vxattr) { case 0: - status = BR_VXATTR_STATUS_FULL; - break; + status = BR_VXATTR_STATUS_FULL; + break; case BR_VXATTR_SIGN_MISSING: - status = BR_VXATTR_STATUS_UNSIGNED; - break; + status = BR_VXATTR_STATUS_UNSIGNED; + break; case BR_VXATTR_ALL_MISSING: - status = BR_VXATTR_STATUS_MISSING; - break; + status = BR_VXATTR_STATUS_MISSING; + break; default: - status = BR_VXATTR_STATUS_INVALID; - } + status = BR_VXATTR_STATUS_INVALID; + } - return status; + return status; } /** @@ -86,13 +86,13 @@ br_version_xattr_state (dict_t *xattr, br_version_t **obuf, * signing. */ typedef struct br_isignature_in { - int8_t signaturetype; /* signature type */ + int8_t signaturetype; /* signature type */ - unsigned long signedversion; /* version against which the - object was signed */ + unsigned long signedversion; /* version against which the + object was signed */ - size_t signaturelen; /* signature length */ - char signature[0]; /* object signature */ + size_t signaturelen; /* signature length */ + char signature[0]; /* object signature */ } br_isignature_t; /** @@ -100,80 +100,79 @@ typedef struct br_isignature_in { * verification. */ typedef struct br_isignature_out { - char stale; /* stale signature? */ + char stale; /* stale signature? */ - unsigned long version; /* current signed version */ + unsigned long version; /* current signed version */ - uint32_t time[2]; /* time when the object - got dirtied */ + uint32_t time[2]; /* time when the object + got dirtied */ - int8_t signaturetype; /* hash type */ - size_t signaturelen; /* signature length */ - char signature[0]; /* signature (hash) */ + int8_t signaturetype; /* hash type */ + size_t signaturelen; /* signature length */ + char signature[0]; /* signature (hash) */ } br_isignature_out_t; typedef struct br_stub_init { - uint32_t timebuf[2]; - char export[PATH_MAX]; + uint32_t timebuf[2]; + char export[PATH_MAX]; } br_stub_init_t; typedef enum { - BR_SIGNATURE_TYPE_VOID = -1, /* object is not signed */ - BR_SIGNATURE_TYPE_ZERO = 0, /* min boundary */ - BR_SIGNATURE_TYPE_SHA256 = 1, /* signed with SHA256 */ - BR_SIGNATURE_TYPE_MAX = 2, /* max boundary */ + BR_SIGNATURE_TYPE_VOID = -1, /* object is not signed */ + BR_SIGNATURE_TYPE_ZERO = 0, /* min boundary */ + BR_SIGNATURE_TYPE_SHA256 = 1, /* signed with SHA256 */ + BR_SIGNATURE_TYPE_MAX = 2, /* max boundary */ } br_signature_type; /* BitRot stub start time (virtual xattr) */ -#define GLUSTERFS_GET_BR_STUB_INIT_TIME "trusted.glusterfs.bit-rot.stub-init" +#define GLUSTERFS_GET_BR_STUB_INIT_TIME "trusted.glusterfs.bit-rot.stub-init" /* signing/reopen hint */ #define BR_OBJECT_RESIGN 0 -#define BR_OBJECT_REOPEN 1 -#define BR_REOPEN_SIGN_HINT_KEY "trusted.glusterfs.bit-rot.reopen-hint" +#define BR_OBJECT_REOPEN 1 +#define BR_REOPEN_SIGN_HINT_KEY "trusted.glusterfs.bit-rot.reopen-hint" static inline int -br_is_signature_type_valid (int8_t signaturetype) +br_is_signature_type_valid(int8_t signaturetype) { - return ((signaturetype > BR_SIGNATURE_TYPE_ZERO) - && (signaturetype < BR_SIGNATURE_TYPE_MAX)); + return ((signaturetype > BR_SIGNATURE_TYPE_ZERO) && + (signaturetype < BR_SIGNATURE_TYPE_MAX)); } static inline void -br_set_default_ongoingversion (br_version_t *buf, uint32_t *tv) +br_set_default_ongoingversion(br_version_t *buf, uint32_t *tv) { - buf->ongoingversion = BITROT_DEFAULT_CURRENT_VERSION; - buf->timebuf[0] = tv[0]; - buf->timebuf[1] = tv[1]; + buf->ongoingversion = BITROT_DEFAULT_CURRENT_VERSION; + buf->timebuf[0] = tv[0]; + buf->timebuf[1] = tv[1]; } static inline void -br_set_default_signature (br_signature_t *buf, size_t *size) +br_set_default_signature(br_signature_t *buf, size_t *size) { - buf->signaturetype = (int8_t) BR_SIGNATURE_TYPE_VOID; - buf->signedversion = BITROT_DEFAULT_SIGNING_VERSION; + buf->signaturetype = (int8_t)BR_SIGNATURE_TYPE_VOID; + buf->signedversion = BITROT_DEFAULT_SIGNING_VERSION; - *size = sizeof (br_signature_t); /* no signature */ + *size = sizeof(br_signature_t); /* no signature */ } static inline void -br_set_ongoingversion (br_version_t *buf, - unsigned long version, uint32_t *tv) +br_set_ongoingversion(br_version_t *buf, unsigned long version, uint32_t *tv) { - buf->ongoingversion = version; - buf->timebuf[0] = tv[0]; - buf->timebuf[1] = tv[1]; + buf->ongoingversion = version; + buf->timebuf[0] = tv[0]; + buf->timebuf[1] = tv[1]; } static inline void -br_set_signature (br_signature_t *buf, - br_isignature_t *sign, size_t signaturelen, size_t *size) +br_set_signature(br_signature_t *buf, br_isignature_t *sign, + size_t signaturelen, size_t *size) { - buf->signaturetype = sign->signaturetype; - buf->signedversion = ntohl (sign->signedversion); + buf->signaturetype = sign->signaturetype; + buf->signedversion = ntohl(sign->signedversion); - memcpy (buf->signature, sign->signature, signaturelen); - *size = sizeof (br_signature_t) + signaturelen; + memcpy(buf->signature, sign->signature, signaturelen); + *size = sizeof(br_signature_t) + signaturelen; } #endif /* __BIT_ROT_COMMON_H__ */ diff --git a/xlators/features/bit-rot/src/stub/bit-rot-object-version.h b/xlators/features/bit-rot/src/stub/bit-rot-object-version.h index 1f2497aebe9..7ae6a5200df 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-object-version.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-object-version.h @@ -15,16 +15,16 @@ * on-disk formats for ongoing version and object signature. */ typedef struct br_version { - unsigned long ongoingversion; - uint32_t timebuf[2]; + unsigned long ongoingversion; + uint32_t timebuf[2]; } br_version_t; -typedef struct __attribute__ ((__packed__)) br_signature { - int8_t signaturetype; +typedef struct __attribute__((__packed__)) br_signature { + int8_t signaturetype; - unsigned long signedversion; + unsigned long signedversion; - char signature[0]; + char signature[0]; } br_signature_t; #endif diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h index 1652a3ebf8d..a3e7b03291e 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h @@ -14,22 +14,22 @@ #include "mem-types.h" enum br_mem_types { - gf_br_stub_mt_private_t = gf_common_mt_end + 1, - gf_br_stub_mt_version_t, - gf_br_stub_mt_inode_ctx_t, - gf_br_stub_mt_signature_t, - gf_br_mt_br_private_t, - gf_br_mt_br_child_t, - gf_br_mt_br_object_t, - gf_br_mt_br_ob_n_wk_t, - gf_br_mt_br_scrubber_t, - gf_br_mt_br_fsscan_entry_t, - gf_br_stub_mt_br_stub_fd_t, - gf_br_stub_mt_br_scanner_freq_t, - gf_br_stub_mt_sigstub_t, - gf_br_mt_br_child_event_t, - gf_br_stub_mt_misc, - gf_br_stub_mt_end, + gf_br_stub_mt_private_t = gf_common_mt_end + 1, + gf_br_stub_mt_version_t, + gf_br_stub_mt_inode_ctx_t, + gf_br_stub_mt_signature_t, + gf_br_mt_br_private_t, + gf_br_mt_br_child_t, + gf_br_mt_br_object_t, + gf_br_mt_br_ob_n_wk_t, + gf_br_mt_br_scrubber_t, + gf_br_mt_br_fsscan_entry_t, + gf_br_stub_mt_br_stub_fd_t, + gf_br_stub_mt_br_scanner_freq_t, + gf_br_stub_mt_sigstub_t, + gf_br_mt_br_child_event_t, + gf_br_stub_mt_misc, + gf_br_stub_mt_end, }; #endif diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h index 2ade4f03997..cccc3b9c599 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h @@ -23,40 +23,22 @@ * glfs-message-id.h. */ -GLFS_MSGID(BITROT_STUB, - BRS_MSG_NO_MEMORY, - BRS_MSG_SET_EVENT_FAILED, - BRS_MSG_MEM_ACNT_FAILED, - BRS_MSG_CREATE_FRAME_FAILED, - BRS_MSG_SET_CONTEXT_FAILED, - BRS_MSG_CHANGE_VERSION_FAILED, - BRS_MSG_ADD_FD_TO_LIST_FAILED, - BRS_MSG_SET_FD_CONTEXT_FAILED, - BRS_MSG_CREATE_ANONYMOUS_FD_FAILED, - BRS_MSG_NO_CHILD, - BRS_MSG_STUB_ALLOC_FAILED, - BRS_MSG_GET_INODE_CONTEXT_FAILED, - BRS_MSG_CANCEL_SIGN_THREAD_FAILED, - BRS_MSG_ADD_FD_TO_INODE, - BRS_MSG_SIGN_VERSION_ERROR, - BRS_MSG_BAD_OBJ_MARK_FAIL, - BRS_MSG_NON_SCRUB_BAD_OBJ_MARK, - BRS_MSG_REMOVE_INTERNAL_XATTR, - BRS_MSG_SET_INTERNAL_XATTR, - BRS_MSG_BAD_OBJECT_ACCESS, - BRS_MSG_BAD_CONTAINER_FAIL, - BRS_MSG_BAD_OBJECT_DIR_FAIL, - BRS_MSG_BAD_OBJECT_DIR_SEEK_FAIL, - BRS_MSG_BAD_OBJECT_DIR_TELL_FAIL, - BRS_MSG_BAD_OBJECT_DIR_READ_FAIL, - BRS_MSG_GET_FD_CONTEXT_FAILED, - BRS_MSG_BAD_HANDLE_DIR_NULL, - BRS_MSG_BAD_OBJ_THREAD_FAIL, - BRS_MSG_BAD_OBJ_DIR_CLOSE_FAIL, - BRS_MSG_LINK_FAIL, - BRS_MSG_BAD_OBJ_UNLINK_FAIL, - BRS_MSG_DICT_SET_FAILED, - BRS_MSG_PATH_GET_FAILED -); +GLFS_MSGID(BITROT_STUB, BRS_MSG_NO_MEMORY, BRS_MSG_SET_EVENT_FAILED, + BRS_MSG_MEM_ACNT_FAILED, BRS_MSG_CREATE_FRAME_FAILED, + BRS_MSG_SET_CONTEXT_FAILED, BRS_MSG_CHANGE_VERSION_FAILED, + BRS_MSG_ADD_FD_TO_LIST_FAILED, BRS_MSG_SET_FD_CONTEXT_FAILED, + BRS_MSG_CREATE_ANONYMOUS_FD_FAILED, BRS_MSG_NO_CHILD, + BRS_MSG_STUB_ALLOC_FAILED, BRS_MSG_GET_INODE_CONTEXT_FAILED, + BRS_MSG_CANCEL_SIGN_THREAD_FAILED, BRS_MSG_ADD_FD_TO_INODE, + BRS_MSG_SIGN_VERSION_ERROR, BRS_MSG_BAD_OBJ_MARK_FAIL, + BRS_MSG_NON_SCRUB_BAD_OBJ_MARK, BRS_MSG_REMOVE_INTERNAL_XATTR, + BRS_MSG_SET_INTERNAL_XATTR, BRS_MSG_BAD_OBJECT_ACCESS, + BRS_MSG_BAD_CONTAINER_FAIL, BRS_MSG_BAD_OBJECT_DIR_FAIL, + BRS_MSG_BAD_OBJECT_DIR_SEEK_FAIL, BRS_MSG_BAD_OBJECT_DIR_TELL_FAIL, + BRS_MSG_BAD_OBJECT_DIR_READ_FAIL, BRS_MSG_GET_FD_CONTEXT_FAILED, + BRS_MSG_BAD_HANDLE_DIR_NULL, BRS_MSG_BAD_OBJ_THREAD_FAIL, + BRS_MSG_BAD_OBJ_DIR_CLOSE_FAIL, BRS_MSG_LINK_FAIL, + BRS_MSG_BAD_OBJ_UNLINK_FAIL, BRS_MSG_DICT_SET_FAILED, + BRS_MSG_PATH_GET_FAILED); #endif /* !_BITROT_STUB_MESSAGES_H_ */ diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h index e15f1cecbc0..a15667e323a 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h @@ -1,11 +1,11 @@ - /* - Copyright (c) 2015 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. +/* + Copyright (c) 2015 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 __BIT_ROT_STUB_H__ #define __BIT_ROT_STUB_H__ @@ -25,305 +25,302 @@ #include "syncop.h" #include "syncop-utils.h" -#define BAD_OBJECT_THREAD_STACK_SIZE ((size_t)(1024*1024)) +#define BAD_OBJECT_THREAD_STACK_SIZE ((size_t)(1024 * 1024)) #define BR_STUB_DUMP_STR_SIZE 65536 -#define BR_PATH_MAX_EXTRA (PATH_MAX+1024) -#define BR_PATH_MAX_PLUS (PATH_MAX+2048) +#define BR_PATH_MAX_EXTRA (PATH_MAX + 1024) +#define BR_PATH_MAX_PLUS (PATH_MAX + 2048) /* * Oops. Spelling mistake. Correcting it */ -#define OLD_BR_STUB_QUARANTINE_DIR GF_HIDDEN_PATH"/quanrantine" -#define BR_STUB_QUARANTINE_DIR GF_HIDDEN_PATH"/quarantine" +#define OLD_BR_STUB_QUARANTINE_DIR GF_HIDDEN_PATH "/quanrantine" +#define BR_STUB_QUARANTINE_DIR GF_HIDDEN_PATH "/quarantine" /* do not reference frame->local in cbk unless initialized. * Assigned 0x1 marks verisoning flag between call path and * cbk path. */ -#define BR_STUB_VER_NOT_ACTIVE_THEN_GOTO(frame, priv, label) do { \ - if (priv->do_versioning) \ - frame->local = (void *)0x1; \ - else \ - goto label; \ - } while (0) - -#define BR_STUB_VER_COND_GOTO(priv, cond, label) do { \ - if (!priv->do_versioning || cond) \ - goto label; \ - } while (0) - -#define BR_STUB_VER_ENABLED_IN_CALLPATH(frame, flag) do { \ - if (frame->local) \ - flag = _gf_true; \ - if (frame->local == (void *) 0x1) \ - frame->local = NULL; \ - } while (0) - -#define BR_STUB_RESET_LOCAL_NULL(frame) do { \ - if (frame->local == (void *)0x1) \ - frame->local = NULL; \ - } while (0) - -typedef int (br_stub_version_cbk) (call_frame_t *, void *, - xlator_t *, int32_t, int32_t, dict_t *); +#define BR_STUB_VER_NOT_ACTIVE_THEN_GOTO(frame, priv, label) \ + do { \ + if (priv->do_versioning) \ + frame->local = (void *)0x1; \ + else \ + goto label; \ + } while (0) + +#define BR_STUB_VER_COND_GOTO(priv, cond, label) \ + do { \ + if (!priv->do_versioning || cond) \ + goto label; \ + } while (0) + +#define BR_STUB_VER_ENABLED_IN_CALLPATH(frame, flag) \ + do { \ + if (frame->local) \ + flag = _gf_true; \ + if (frame->local == (void *)0x1) \ + frame->local = NULL; \ + } while (0) + +#define BR_STUB_RESET_LOCAL_NULL(frame) \ + do { \ + if (frame->local == (void *)0x1) \ + frame->local = NULL; \ + } while (0) + +typedef int(br_stub_version_cbk)(call_frame_t *, void *, xlator_t *, int32_t, + int32_t, dict_t *); typedef struct br_stub_inode_ctx { - int need_writeback; /* does the inode need - a writeback to disk? */ - unsigned long currentversion; /* ongoing version */ - - int info_sign; - struct list_head fd_list; /* list of open fds or fds participating in - write operations */ - gf_boolean_t bad_object; + int need_writeback; /* does the inode need + a writeback to disk? */ + unsigned long currentversion; /* ongoing version */ + + int info_sign; + struct list_head fd_list; /* list of open fds or fds participating in + write operations */ + gf_boolean_t bad_object; } br_stub_inode_ctx_t; typedef struct br_stub_fd { - fd_t *fd; - struct list_head list; - struct bad_object_dir { - DIR *dir; - off_t dir_eof; - } bad_object; + fd_t *fd; + struct list_head list; + struct bad_object_dir { + DIR *dir; + off_t dir_eof; + } bad_object; } br_stub_fd_t; -#define I_DIRTY (1<<0) /* inode needs writeback */ -#define I_MODIFIED (1<<1) -#define WRITEBACK_DURABLE 1 /* writeback is durable */ +#define I_DIRTY (1 << 0) /* inode needs writeback */ +#define I_MODIFIED (1 << 1) +#define WRITEBACK_DURABLE 1 /* writeback is durable */ /** * This could just have been a plain struct without unions and all, * but we may need additional things in the future. */ typedef struct br_stub_local { - call_stub_t *fopstub; /* stub for original fop */ - - int versioningtype; /* not much used atm */ - - union { - struct br_stub_ctx { - fd_t *fd; - uuid_t gfid; - inode_t *inode; - unsigned long version; - } context; - } u; + call_stub_t *fopstub; /* stub for original fop */ + + int versioningtype; /* not much used atm */ + + union { + struct br_stub_ctx { + fd_t *fd; + uuid_t gfid; + inode_t *inode; + unsigned long version; + } context; + } u; } br_stub_local_t; #define BR_STUB_NO_VERSIONING (1 << 0) #define BR_STUB_INCREMENTAL_VERSIONING (1 << 1) typedef struct br_stub_private { - gf_boolean_t do_versioning; + gf_boolean_t do_versioning; - uint32_t boot[2]; - char export[PATH_MAX]; + uint32_t boot[2]; + char export[PATH_MAX]; - pthread_mutex_t lock; - pthread_cond_t cond; + pthread_mutex_t lock; + pthread_cond_t cond; - struct list_head squeue; /* ordered signing queue */ - pthread_t signth; - struct bad_objects_container { - pthread_t thread; - pthread_mutex_t bad_lock; - pthread_cond_t bad_cond; - struct list_head bad_queue; - } container; - struct mem_pool *local_pool; + struct list_head squeue; /* ordered signing queue */ + pthread_t signth; + struct bad_objects_container { + pthread_t thread; + pthread_mutex_t bad_lock; + pthread_cond_t bad_cond; + struct list_head bad_queue; + } container; + struct mem_pool *local_pool; - char stub_basepath[BR_PATH_MAX_EXTRA]; + char stub_basepath[BR_PATH_MAX_EXTRA]; - uuid_t bad_object_dir_gfid; + uuid_t bad_object_dir_gfid; } br_stub_private_t; br_stub_fd_t * -br_stub_fd_new (void); - +br_stub_fd_new(void); int -__br_stub_fd_ctx_set (xlator_t *this, fd_t *fd, br_stub_fd_t *br_stub_fd); +__br_stub_fd_ctx_set(xlator_t *this, fd_t *fd, br_stub_fd_t *br_stub_fd); br_stub_fd_t * -__br_stub_fd_ctx_get (xlator_t *this, fd_t *fd); +__br_stub_fd_ctx_get(xlator_t *this, fd_t *fd); br_stub_fd_t * -br_stub_fd_ctx_get (xlator_t *this, fd_t *fd); +br_stub_fd_ctx_get(xlator_t *this, fd_t *fd); int32_t -br_stub_fd_ctx_set (xlator_t *this, fd_t *fd, br_stub_fd_t *br_stub_fd); +br_stub_fd_ctx_set(xlator_t *this, fd_t *fd, br_stub_fd_t *br_stub_fd); static inline gf_boolean_t -__br_stub_is_bad_object (br_stub_inode_ctx_t *ctx) +__br_stub_is_bad_object(br_stub_inode_ctx_t *ctx) { - return ctx->bad_object; + return ctx->bad_object; } static inline void -__br_stub_mark_object_bad (br_stub_inode_ctx_t *ctx) +__br_stub_mark_object_bad(br_stub_inode_ctx_t *ctx) { - ctx->bad_object = _gf_true; + ctx->bad_object = _gf_true; } /* inode writeback helpers */ static inline void -__br_stub_mark_inode_dirty (br_stub_inode_ctx_t *ctx) +__br_stub_mark_inode_dirty(br_stub_inode_ctx_t *ctx) { - ctx->need_writeback |= I_DIRTY; + ctx->need_writeback |= I_DIRTY; } static inline void -__br_stub_mark_inode_synced (br_stub_inode_ctx_t *ctx) +__br_stub_mark_inode_synced(br_stub_inode_ctx_t *ctx) { - ctx->need_writeback &= ~I_DIRTY; + ctx->need_writeback &= ~I_DIRTY; } static inline int -__br_stub_is_inode_dirty (br_stub_inode_ctx_t *ctx) +__br_stub_is_inode_dirty(br_stub_inode_ctx_t *ctx) { - return (ctx->need_writeback & I_DIRTY); + return (ctx->need_writeback & I_DIRTY); } /* inode mofification markers */ static inline void -__br_stub_set_inode_modified (br_stub_inode_ctx_t *ctx) +__br_stub_set_inode_modified(br_stub_inode_ctx_t *ctx) { - ctx->need_writeback |= I_MODIFIED; + ctx->need_writeback |= I_MODIFIED; } static inline void -__br_stub_unset_inode_modified (br_stub_inode_ctx_t *ctx) +__br_stub_unset_inode_modified(br_stub_inode_ctx_t *ctx) { - ctx->need_writeback &= ~I_MODIFIED; + ctx->need_writeback &= ~I_MODIFIED; } static inline int -__br_stub_is_inode_modified (br_stub_inode_ctx_t *ctx) +__br_stub_is_inode_modified(br_stub_inode_ctx_t *ctx) { - return (ctx->need_writeback & I_MODIFIED); + return (ctx->need_writeback & I_MODIFIED); } - static inline int -br_stub_require_release_call (xlator_t *this, fd_t *fd, br_stub_fd_t **fd_ctx) +br_stub_require_release_call(xlator_t *this, fd_t *fd, br_stub_fd_t **fd_ctx) { - int32_t ret = 0; - br_stub_fd_t *br_stub_fd = NULL; + int32_t ret = 0; + br_stub_fd_t *br_stub_fd = NULL; - br_stub_fd = br_stub_fd_new (); - if (!br_stub_fd) - return -1; + br_stub_fd = br_stub_fd_new(); + if (!br_stub_fd) + return -1; - br_stub_fd->fd = fd; - INIT_LIST_HEAD (&br_stub_fd->list); + br_stub_fd->fd = fd; + INIT_LIST_HEAD(&br_stub_fd->list); - ret = br_stub_fd_ctx_set (this, fd, br_stub_fd); - if (ret) - gf_msg (this->name, GF_LOG_WARNING, 0, - BRS_MSG_SET_CONTEXT_FAILED, - "could not set fd context (for release callback"); - else - *fd_ctx = br_stub_fd; + ret = br_stub_fd_ctx_set(this, fd, br_stub_fd); + if (ret) + gf_msg(this->name, GF_LOG_WARNING, 0, BRS_MSG_SET_CONTEXT_FAILED, + "could not set fd context (for release callback"); + else + *fd_ctx = br_stub_fd; - return ret; + return ret; } /* get/set inode context helpers */ static inline int -__br_stub_get_inode_ctx (xlator_t *this, - inode_t *inode, uint64_t *ctx) +__br_stub_get_inode_ctx(xlator_t *this, inode_t *inode, uint64_t *ctx) { - return __inode_ctx_get (inode, this, ctx); + return __inode_ctx_get(inode, this, ctx); } static inline int -br_stub_get_inode_ctx (xlator_t *this, - inode_t *inode, uint64_t *ctx) +br_stub_get_inode_ctx(xlator_t *this, inode_t *inode, uint64_t *ctx) { - int ret = -1; + int ret = -1; - LOCK (&inode->lock); - { - ret = __br_stub_get_inode_ctx (this, inode, ctx); - } - UNLOCK (&inode->lock); + LOCK(&inode->lock); + { + ret = __br_stub_get_inode_ctx(this, inode, ctx); + } + UNLOCK(&inode->lock); - return ret; + return ret; } static inline int -br_stub_set_inode_ctx (xlator_t *this, - inode_t *inode, br_stub_inode_ctx_t *ctx) +br_stub_set_inode_ctx(xlator_t *this, inode_t *inode, br_stub_inode_ctx_t *ctx) { - uint64_t ctx_addr = (uint64_t) ctx; - return inode_ctx_set (inode, this, &ctx_addr); + uint64_t ctx_addr = (uint64_t)ctx; + return inode_ctx_set(inode, this, &ctx_addr); } /* version get/set helpers */ static inline unsigned long -__br_stub_writeback_version (br_stub_inode_ctx_t *ctx) +__br_stub_writeback_version(br_stub_inode_ctx_t *ctx) { - return (ctx->currentversion + 1); + return (ctx->currentversion + 1); } static inline void -__br_stub_set_ongoing_version (br_stub_inode_ctx_t *ctx, unsigned long version) +__br_stub_set_ongoing_version(br_stub_inode_ctx_t *ctx, unsigned long version) { - if (ctx->currentversion < version) - ctx->currentversion = version; - else - gf_msg ("bit-rot-stub", GF_LOG_WARNING, 0, - BRS_MSG_CHANGE_VERSION_FAILED, "current version: %lu" - "new version: %lu", ctx->currentversion, version); + if (ctx->currentversion < version) + ctx->currentversion = version; + else + gf_msg("bit-rot-stub", GF_LOG_WARNING, 0, BRS_MSG_CHANGE_VERSION_FAILED, + "current version: %lu" + "new version: %lu", + ctx->currentversion, version); } static inline int -__br_stub_can_trigger_release (inode_t *inode, - br_stub_inode_ctx_t *ctx, unsigned long *version) +__br_stub_can_trigger_release(inode_t *inode, br_stub_inode_ctx_t *ctx, + unsigned long *version) { - /** - * If the inode is modified, then it has to be dirty. An inode is - * marked dirty once version is increased. Its marked as modified - * when the modification call (write/truncate) which triggered - * the versioning is successful. - */ - if (__br_stub_is_inode_modified (ctx) - && list_empty (&ctx->fd_list) - && (ctx->info_sign != BR_SIGN_REOPEN_WAIT)) { - - GF_ASSERT (__br_stub_is_inode_dirty (ctx) == 0); - - if (version) - *version = htonl (ctx->currentversion); - return 1; - } - - return 0; + /** + * If the inode is modified, then it has to be dirty. An inode is + * marked dirty once version is increased. Its marked as modified + * when the modification call (write/truncate) which triggered + * the versioning is successful. + */ + if (__br_stub_is_inode_modified(ctx) && list_empty(&ctx->fd_list) && + (ctx->info_sign != BR_SIGN_REOPEN_WAIT)) { + GF_ASSERT(__br_stub_is_inode_dirty(ctx) == 0); + + if (version) + *version = htonl(ctx->currentversion); + return 1; + } + + return 0; } static inline int32_t -br_stub_get_ongoing_version (xlator_t *this, - inode_t *inode, unsigned long *version) +br_stub_get_ongoing_version(xlator_t *this, inode_t *inode, + unsigned long *version) { - int32_t ret = 0; - uint64_t ctx_addr = 0; - br_stub_inode_ctx_t *ctx = NULL; - - LOCK (&inode->lock); - { - ret = __inode_ctx_get (inode, this, &ctx_addr); - if (ret < 0) - goto unblock; - ctx = (br_stub_inode_ctx_t *) (long) ctx_addr; - *version = ctx->currentversion; - } - unblock: - UNLOCK (&inode->lock); - - return ret; + int32_t ret = 0; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + + LOCK(&inode->lock); + { + ret = __inode_ctx_get(inode, this, &ctx_addr); + if (ret < 0) + goto unblock; + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + *version = ctx->currentversion; + } +unblock: + UNLOCK(&inode->lock); + + return ret; } /** @@ -332,45 +329,44 @@ br_stub_get_ongoing_version (xlator_t *this, * *needs* to be valid in the caller. */ static inline br_stub_inode_ctx_t * -__br_stub_get_ongoing_version_ctx (xlator_t *this, - inode_t *inode, unsigned long *version) +__br_stub_get_ongoing_version_ctx(xlator_t *this, inode_t *inode, + unsigned long *version) { - int32_t ret = 0; - uint64_t ctx_addr = 0; - br_stub_inode_ctx_t *ctx = NULL; - - ret = __inode_ctx_get (inode, this, &ctx_addr); - if (ret < 0) - return NULL; - ctx = (br_stub_inode_ctx_t *) (long) ctx_addr; - if (version) - *version = ctx->currentversion; - - return ctx; + int32_t ret = 0; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + + ret = __inode_ctx_get(inode, this, &ctx_addr); + if (ret < 0) + return NULL; + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + if (version) + *version = ctx->currentversion; + + return ctx; } /* filter for xattr fetch */ static inline int -br_stub_is_internal_xattr (const char *name) +br_stub_is_internal_xattr(const char *name) { - if (name - && ((strncmp (name, BITROT_CURRENT_VERSION_KEY, - SLEN (BITROT_CURRENT_VERSION_KEY)) == 0) - || (strncmp (name, BITROT_SIGNING_VERSION_KEY, - SLEN (BITROT_SIGNING_VERSION_KEY)) == 0))) - return 1; - return 0; + if (name && ((strncmp(name, BITROT_CURRENT_VERSION_KEY, + SLEN(BITROT_CURRENT_VERSION_KEY)) == 0) || + (strncmp(name, BITROT_SIGNING_VERSION_KEY, + SLEN(BITROT_SIGNING_VERSION_KEY)) == 0))) + return 1; + return 0; } static inline void -br_stub_remove_vxattrs (dict_t *xattr) +br_stub_remove_vxattrs(dict_t *xattr) { - if (xattr) { - dict_del (xattr, BITROT_OBJECT_BAD_KEY); - dict_del (xattr, BITROT_CURRENT_VERSION_KEY); - dict_del (xattr, BITROT_SIGNING_VERSION_KEY); - dict_del (xattr, BITROT_SIGNING_XATTR_SIZE_KEY); - } + if (xattr) { + dict_del(xattr, BITROT_OBJECT_BAD_KEY); + dict_del(xattr, BITROT_CURRENT_VERSION_KEY); + dict_del(xattr, BITROT_SIGNING_VERSION_KEY); + dict_del(xattr, BITROT_SIGNING_XATTR_SIZE_KEY); + } } /** @@ -384,64 +380,63 @@ br_stub_remove_vxattrs (dict_t *xattr) * errors can be made into enums. */ static inline int -br_stub_is_bad_object (xlator_t *this, inode_t *inode) +br_stub_is_bad_object(xlator_t *this, inode_t *inode) { - int bad_object = 0; - gf_boolean_t tmp = _gf_false; - uint64_t ctx_addr = 0; - br_stub_inode_ctx_t *ctx = NULL; - int32_t ret = -1; - - ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - BRS_MSG_GET_INODE_CONTEXT_FAILED, - "failed to get the inode context for the inode %s", - uuid_utoa (inode->gfid)); - bad_object = -1; - goto out; - } - - ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; - - LOCK (&inode->lock); - { - tmp = __br_stub_is_bad_object (ctx); - if (tmp) - bad_object = -2; - } - UNLOCK (&inode->lock); + int bad_object = 0; + gf_boolean_t tmp = _gf_false; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + int32_t ret = -1; + + ret = br_stub_get_inode_ctx(this, inode, &ctx_addr); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, BRS_MSG_GET_INODE_CONTEXT_FAILED, + "failed to get the inode context for the inode %s", + uuid_utoa(inode->gfid)); + bad_object = -1; + goto out; + } + + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + + LOCK(&inode->lock); + { + tmp = __br_stub_is_bad_object(ctx); + if (tmp) + bad_object = -2; + } + UNLOCK(&inode->lock); out: - return bad_object; + return bad_object; } static inline int32_t -br_stub_mark_object_bad (xlator_t *this, inode_t *inode) +br_stub_mark_object_bad(xlator_t *this, inode_t *inode) { - int32_t ret = -1; - uint64_t ctx_addr = 0; - br_stub_inode_ctx_t *ctx = NULL; - - ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " - "inode context for the inode %s", - uuid_utoa (inode->gfid)); - goto out; - } - - ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; - - LOCK (&inode->lock); - { - __br_stub_mark_object_bad (ctx); - } - UNLOCK (&inode->lock); + int32_t ret = -1; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + + ret = br_stub_get_inode_ctx(this, inode, &ctx_addr); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, BRS_MSG_GET_INODE_CONTEXT_FAILED, + "failed to get the " + "inode context for the inode %s", + uuid_utoa(inode->gfid)); + goto out; + } + + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + + LOCK(&inode->lock); + { + __br_stub_mark_object_bad(ctx); + } + UNLOCK(&inode->lock); out: - return ret; + return ret; } /** @@ -449,68 +444,68 @@ out: * given to the caller and the caller has to decide what to do. */ static inline int32_t -br_stub_mark_xdata_bad_object (xlator_t *this, inode_t *inode, dict_t *xdata) +br_stub_mark_xdata_bad_object(xlator_t *this, inode_t *inode, dict_t *xdata) { - int32_t ret = 0; + int32_t ret = 0; - if (br_stub_is_bad_object (this, inode) == -2) - ret = dict_set_int32 (xdata, GLUSTERFS_BAD_INODE, 1); + if (br_stub_is_bad_object(this, inode) == -2) + ret = dict_set_int32(xdata, GLUSTERFS_BAD_INODE, 1); - return ret; + return ret; } int32_t -br_stub_add_fd_to_inode (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx); +br_stub_add_fd_to_inode(xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx); br_sign_state_t -__br_stub_inode_sign_state (br_stub_inode_ctx_t *ctx, glusterfs_fop_t fop, - fd_t *fd); +__br_stub_inode_sign_state(br_stub_inode_ctx_t *ctx, glusterfs_fop_t fop, + fd_t *fd); int -br_stub_dir_create (xlator_t *this, br_stub_private_t *priv); +br_stub_dir_create(xlator_t *this, br_stub_private_t *priv); int -br_stub_add (xlator_t *this, uuid_t gfid); +br_stub_add(xlator_t *this, uuid_t gfid); int32_t -br_stub_create_stub_gfid (xlator_t *this, char *stub_gfid_path, uuid_t gfid); +br_stub_create_stub_gfid(xlator_t *this, char *stub_gfid_path, uuid_t gfid); int -br_stub_dir_create (xlator_t *this, br_stub_private_t *priv); +br_stub_dir_create(xlator_t *this, br_stub_private_t *priv); call_stub_t * -__br_stub_dequeue (struct list_head *callstubs); +__br_stub_dequeue(struct list_head *callstubs); void -__br_stub_enqueue (struct list_head *callstubs, call_stub_t *stub); +__br_stub_enqueue(struct list_head *callstubs, call_stub_t *stub); void -br_stub_worker_enqueue (xlator_t *this, call_stub_t *stub); +br_stub_worker_enqueue(xlator_t *this, call_stub_t *stub); void * -br_stub_worker (void *data); +br_stub_worker(void *data); int32_t -br_stub_lookup_wrapper (call_frame_t *frame, xlator_t *this, - loc_t *loc, dict_t *xattr_req); +br_stub_lookup_wrapper(call_frame_t *frame, xlator_t *this, loc_t *loc, + dict_t *xattr_req); int32_t -br_stub_readdir_wrapper (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t off, dict_t *xdata); +br_stub_readdir_wrapper(call_frame_t *frame, xlator_t *this, fd_t *fd, + size_t size, off_t off, dict_t *xdata); int -br_stub_del (xlator_t *this, uuid_t gfid); +br_stub_del(xlator_t *this, uuid_t gfid); int -br_stub_bad_objects_path (xlator_t *this, fd_t *fd, gf_dirent_t *entries, - dict_t **dict); +br_stub_bad_objects_path(xlator_t *this, fd_t *fd, gf_dirent_t *entries, + dict_t **dict); void -br_stub_entry_xattr_fill (xlator_t *this, char *hpath, gf_dirent_t *entry, - dict_t *dict); +br_stub_entry_xattr_fill(xlator_t *this, char *hpath, gf_dirent_t *entry, + dict_t *dict); int -br_stub_get_path_of_gfid (xlator_t *this, inode_t *parent, inode_t *inode, - uuid_t gfid, char **path); +br_stub_get_path_of_gfid(xlator_t *this, inode_t *parent, inode_t *inode, + uuid_t gfid, char **path); #endif /* __BIT_ROT_STUB_H__ */ diff --git a/xlators/features/changelog/lib/src/changelog-lib-messages.h b/xlators/features/changelog/lib/src/changelog-lib-messages.h index 2061217b801..32b3497d89d 100644 --- a/xlators/features/changelog/lib/src/changelog-lib-messages.h +++ b/xlators/features/changelog/lib/src/changelog-lib-messages.h @@ -23,39 +23,26 @@ * glfs-message-id.h. */ -GLFS_MSGID(CHANGELOG_LIB, - CHANGELOG_LIB_MSG_OPEN_FAILED, - CHANGELOG_LIB_MSG_FAILED_TO_RMDIR, - CHANGELOG_LIB_MSG_SCRATCH_DIR_ENTRIES_CREATION_ERROR, - CHANGELOG_LIB_MSG_THREAD_CREATION_FAILED, - CHANGELOG_LIB_MSG_OPENDIR_ERROR, - CHANGELOG_LIB_MSG_RENAME_FAILED, - CHANGELOG_LIB_MSG_READ_ERROR, - CHANGELOG_LIB_MSG_HTIME_ERROR, - CHANGELOG_LIB_MSG_GET_TIME_ERROR, - CHANGELOG_LIB_MSG_WRITE_FAILED, - CHANGELOG_LIB_MSG_PTHREAD_ERROR, - CHANGELOG_LIB_MSG_MMAP_FAILED, - CHANGELOG_LIB_MSG_MUNMAP_FAILED, - CHANGELOG_LIB_MSG_ASCII_ERROR, - CHANGELOG_LIB_MSG_STAT_FAILED, - CHANGELOG_LIB_MSG_GET_XATTR_FAILED, - CHANGELOG_LIB_MSG_PUBLISH_ERROR, - CHANGELOG_LIB_MSG_PARSE_ERROR, - CHANGELOG_LIB_MSG_TOTAL_LOG_INFO, - CHANGELOG_LIB_MSG_CLEANUP_ERROR, - CHANGELOG_LIB_MSG_UNLINK_FAILED, - CHANGELOG_LIB_MSG_NOTIFY_REGISTER_FAILED, - CHANGELOG_LIB_MSG_INVOKE_RPC_FAILED, - CHANGELOG_LIB_MSG_DRAINING_EVENT_INFO, - CHANGELOG_LIB_MSG_CLEANING_BRICK_ENTRY_INFO, - CHANGELOG_LIB_MSG_FREEING_ENTRY_INFO, - CHANGELOG_LIB_MSG_XDR_DECODING_FAILED, - CHANGELOG_LIB_MSG_NOTIFY_REGISTER_INFO, - CHANGELOG_LIB_MSG_THREAD_CLEANUP_WARNING, - CHANGELOG_LIB_MSG_COPY_FROM_BUFFER_FAILED, - CHANGELOG_LIB_MSG_PTHREAD_JOIN_FAILED, - CHANGELOG_LIB_MSG_HIST_FAILED -); +GLFS_MSGID( + CHANGELOG_LIB, CHANGELOG_LIB_MSG_OPEN_FAILED, + CHANGELOG_LIB_MSG_FAILED_TO_RMDIR, + CHANGELOG_LIB_MSG_SCRATCH_DIR_ENTRIES_CREATION_ERROR, + CHANGELOG_LIB_MSG_THREAD_CREATION_FAILED, CHANGELOG_LIB_MSG_OPENDIR_ERROR, + CHANGELOG_LIB_MSG_RENAME_FAILED, CHANGELOG_LIB_MSG_READ_ERROR, + CHANGELOG_LIB_MSG_HTIME_ERROR, CHANGELOG_LIB_MSG_GET_TIME_ERROR, + CHANGELOG_LIB_MSG_WRITE_FAILED, CHANGELOG_LIB_MSG_PTHREAD_ERROR, + CHANGELOG_LIB_MSG_MMAP_FAILED, CHANGELOG_LIB_MSG_MUNMAP_FAILED, + CHANGELOG_LIB_MSG_ASCII_ERROR, CHANGELOG_LIB_MSG_STAT_FAILED, + CHANGELOG_LIB_MSG_GET_XATTR_FAILED, CHANGELOG_LIB_MSG_PUBLISH_ERROR, + CHANGELOG_LIB_MSG_PARSE_ERROR, CHANGELOG_LIB_MSG_TOTAL_LOG_INFO, + CHANGELOG_LIB_MSG_CLEANUP_ERROR, CHANGELOG_LIB_MSG_UNLINK_FAILED, + CHANGELOG_LIB_MSG_NOTIFY_REGISTER_FAILED, + CHANGELOG_LIB_MSG_INVOKE_RPC_FAILED, CHANGELOG_LIB_MSG_DRAINING_EVENT_INFO, + CHANGELOG_LIB_MSG_CLEANING_BRICK_ENTRY_INFO, + CHANGELOG_LIB_MSG_FREEING_ENTRY_INFO, CHANGELOG_LIB_MSG_XDR_DECODING_FAILED, + CHANGELOG_LIB_MSG_NOTIFY_REGISTER_INFO, + CHANGELOG_LIB_MSG_THREAD_CLEANUP_WARNING, + CHANGELOG_LIB_MSG_COPY_FROM_BUFFER_FAILED, + CHANGELOG_LIB_MSG_PTHREAD_JOIN_FAILED, CHANGELOG_LIB_MSG_HIST_FAILED); #endif /* !_CHANGELOG_MESSAGES_H_ */ diff --git a/xlators/features/changelog/lib/src/gf-changelog-helpers.h b/xlators/features/changelog/lib/src/gf-changelog-helpers.h index b05628ee70d..cfb26a0081e 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-helpers.h +++ b/xlators/features/changelog/lib/src/gf-changelog-helpers.h @@ -23,27 +23,28 @@ #include "changelog-rpc-common.h" #include "gf-changelog-journal.h" -#define GF_CHANGELOG_TRACKER "tracker" +#define GF_CHANGELOG_TRACKER "tracker" -#define GF_CHANGELOG_CURRENT_DIR ".current" -#define GF_CHANGELOG_PROCESSED_DIR ".processed" +#define GF_CHANGELOG_CURRENT_DIR ".current" +#define GF_CHANGELOG_PROCESSED_DIR ".processed" #define GF_CHANGELOG_PROCESSING_DIR ".processing" -#define GF_CHANGELOG_HISTORY_DIR ".history" +#define GF_CHANGELOG_HISTORY_DIR ".history" #define TIMESTAMP_LENGTH 10 #ifndef MAXLINE #define MAXLINE 4096 #endif -#define GF_CHANGELOG_FILL_BUFFER(ptr, ascii, off, len) do { \ - memcpy (ascii + off, ptr, len); \ - off += len; \ - } while (0) +#define GF_CHANGELOG_FILL_BUFFER(ptr, ascii, off, len) \ + do { \ + memcpy(ascii + off, ptr, len); \ + off += len; \ + } while (0) typedef struct read_line { - int rl_cnt; - char *rl_bufptr; - char rl_buf[MAXLINE]; + int rl_cnt; + char *rl_bufptr; + char rl_buf[MAXLINE]; } read_line_t; struct gf_changelog; @@ -55,51 +56,50 @@ struct gf_event; * ->next_seq holds the next _expected_ sequence number. */ struct gf_event_list { - pthread_mutex_t lock; /* protects this structure */ - pthread_cond_t cond; + pthread_mutex_t lock; /* protects this structure */ + pthread_cond_t cond; - pthread_t invoker; + pthread_t invoker; - unsigned long next_seq; /* next sequence number expected: - zero during bootstrap */ + unsigned long next_seq; /* next sequence number expected: + zero during bootstrap */ - struct gf_changelog *entry; /* backpointer to it's brick - encapsulator (entry) */ - struct list_head events; /* list of events */ + struct gf_changelog *entry; /* backpointer to it's brick + encapsulator (entry) */ + struct list_head events; /* list of events */ }; /** * include a refcount if it's of use by additional layers */ struct gf_event { - int count; + int count; - unsigned long seq; + unsigned long seq; - struct list_head list; + struct list_head list; - struct iovec iov[0]; + struct iovec iov[0]; }; -#define GF_EVENT_CALLOC_SIZE(cnt, len) \ - (sizeof (struct gf_event) + (cnt * sizeof (struct iovec)) + len) +#define GF_EVENT_CALLOC_SIZE(cnt, len) \ + (sizeof(struct gf_event) + (cnt * sizeof(struct iovec)) + len) /** * assign the base address of the IO vector to the correct memory o * area and set it's addressable length. */ -#define GF_EVENT_ASSIGN_IOVEC(vec, event, len, pos) \ - do { \ - vec->iov_base = ((char *)event) + \ - sizeof (struct gf_event) + \ - (event->count * sizeof (struct iovec)) + pos; \ - vec->iov_len = len; \ - pos += len; \ - } while (0) +#define GF_EVENT_ASSIGN_IOVEC(vec, event, len, pos) \ + do { \ + vec->iov_base = ((char *)event) + sizeof(struct gf_event) + \ + (event->count * sizeof(struct iovec)) + pos; \ + vec->iov_len = len; \ + pos += len; \ + } while (0) typedef enum gf_changelog_conn_state { - GF_CHANGELOG_CONN_STATE_PENDING = 0, - GF_CHANGELOG_CONN_STATE_ACCEPTED, - GF_CHANGELOG_CONN_STATE_DISCONNECTED, + GF_CHANGELOG_CONN_STATE_PENDING = 0, + GF_CHANGELOG_CONN_STATE_ACCEPTED, + GF_CHANGELOG_CONN_STATE_DISCONNECTED, } gf_changelog_conn_state_t; /** @@ -107,153 +107,152 @@ typedef enum gf_changelog_conn_state { * notifications are streamed. */ typedef struct gf_changelog { - gf_lock_t statelock; - gf_changelog_conn_state_t connstate; + gf_lock_t statelock; + gf_changelog_conn_state_t connstate; - xlator_t *this; + xlator_t *this; - struct list_head list; /* list of instances */ + struct list_head list; /* list of instances */ - char brick[PATH_MAX]; /* brick path for this end-point */ + char brick[PATH_MAX]; /* brick path for this end-point */ - changelog_rpc_t grpc; /* rpc{-clnt,svc} for this brick */ -#define RPC_PROBER(ent) ent->grpc.rpc -#define RPC_REBORP(ent) ent->grpc.svc -#define RPC_SOCK(ent) ent->grpc.sock + changelog_rpc_t grpc; /* rpc{-clnt,svc} for this brick */ +#define RPC_PROBER(ent) ent->grpc.rpc +#define RPC_REBORP(ent) ent->grpc.svc +#define RPC_SOCK(ent) ent->grpc.sock - unsigned int notify; /* notification flag(s) */ + unsigned int notify; /* notification flag(s) */ - FINI *fini; /* destructor callback */ - CALLBACK *callback; /* event callback dispatcher */ - CONNECT *connected; /* connect callback */ - DISCONNECT *disconnected; /* disconnection callback */ + FINI *fini; /* destructor callback */ + CALLBACK *callback; /* event callback dispatcher */ + CONNECT *connected; /* connect callback */ + DISCONNECT *disconnected; /* disconnection callback */ - void *ptr; /* owner specific private data */ - xlator_t *invokerxl; /* consumers _this_, if valid, - assigned to THIS before cbk is - invoked */ + void *ptr; /* owner specific private data */ + xlator_t *invokerxl; /* consumers _this_, if valid, + assigned to THIS before cbk is + invoked */ - gf_boolean_t ordered; + gf_boolean_t ordered; - void (*queueevent) (struct gf_event_list *, struct gf_event *); - void (*pickevent) (struct gf_event_list *, struct gf_event **); + void (*queueevent)(struct gf_event_list *, struct gf_event *); + void (*pickevent)(struct gf_event_list *, struct gf_event **); - struct gf_event_list event; + struct gf_event_list event; } gf_changelog_t; static inline int -gf_changelog_filter_check (gf_changelog_t *entry, changelog_event_t *event) +gf_changelog_filter_check(gf_changelog_t *entry, changelog_event_t *event) { - if (event->ev_type & entry->notify) - return 1; - return 0; + if (event->ev_type & entry->notify) + return 1; + return 0; } -#define GF_NEED_ORDERED_EVENTS(ent) (ent->ordered == _gf_true) +#define GF_NEED_ORDERED_EVENTS(ent) (ent->ordered == _gf_true) /** private structure */ typedef struct gf_private { - pthread_mutex_t lock; /* protects ->connections, cleanups */ - pthread_cond_t cond; + pthread_mutex_t lock; /* protects ->connections, cleanups */ + pthread_cond_t cond; - void *api; /* pointer for API access */ + void *api; /* pointer for API access */ - pthread_t poller; /* event poller thread */ - pthread_t connectionjanitor; /* connection cleaner */ + pthread_t poller; /* event poller thread */ + pthread_t connectionjanitor; /* connection cleaner */ - struct list_head connections; /* list of connections */ - struct list_head cleanups; /* list of connection to be - cleaned up */ + struct list_head connections; /* list of connections */ + struct list_head cleanups; /* list of connection to be + cleaned up */ } gf_private_t; -#define GF_CHANGELOG_GET_API_PTR(this) (((gf_private_t *) this->private)->api) +#define GF_CHANGELOG_GET_API_PTR(this) (((gf_private_t *)this->private)->api) /** * upcall: invoke callback with _correct_ THIS */ -#define GF_CHANGELOG_INVOKE_CBK(this, cbk, brick, args ...) \ - do { \ - xlator_t *old_this = NULL; \ - xlator_t *invokerxl = NULL; \ - \ - invokerxl = entry->invokerxl; \ - old_this = this; \ - \ - if (invokerxl) { \ - THIS = invokerxl; \ - } \ - \ - cbk (invokerxl, brick, args); \ - THIS = old_this; \ - \ - } while (0) - -#define SAVE_THIS(xl) \ - do { \ - old_this = xl; \ - THIS = master; \ - } while (0) - -#define RESTORE_THIS() \ - do { \ - if (old_this) \ - THIS = old_this; \ - } while (0) +#define GF_CHANGELOG_INVOKE_CBK(this, cbk, brick, args...) \ + do { \ + xlator_t *old_this = NULL; \ + xlator_t *invokerxl = NULL; \ + \ + invokerxl = entry->invokerxl; \ + old_this = this; \ + \ + if (invokerxl) { \ + THIS = invokerxl; \ + } \ + \ + cbk(invokerxl, brick, args); \ + THIS = old_this; \ + \ + } while (0) + +#define SAVE_THIS(xl) \ + do { \ + old_this = xl; \ + THIS = master; \ + } while (0) + +#define RESTORE_THIS() \ + do { \ + if (old_this) \ + THIS = old_this; \ + } while (0) /** APIs and the rest */ void * -gf_changelog_process (void *data); +gf_changelog_process(void *data); ssize_t -gf_changelog_read_path (int fd, char *buffer, size_t bufsize); +gf_changelog_read_path(int fd, char *buffer, size_t bufsize); void -gf_rfc3986_encode_space_newline (unsigned char *s, char *enc, char *estr); +gf_rfc3986_encode_space_newline(unsigned char *s, char *enc, char *estr); size_t -gf_changelog_write (int fd, char *buffer, size_t len); +gf_changelog_write(int fd, char *buffer, size_t len); ssize_t -gf_readline (int fd, void *vptr, size_t maxlen); +gf_readline(int fd, void *vptr, size_t maxlen); int -gf_ftruncate (int fd, off_t length); +gf_ftruncate(int fd, off_t length); off_t -gf_lseek (int fd, off_t offset, int whence); +gf_lseek(int fd, off_t offset, int whence); int -gf_changelog_consume (xlator_t *this, - gf_changelog_journal_t *jnl, - char *from_path, gf_boolean_t no_publish); +gf_changelog_consume(xlator_t *this, gf_changelog_journal_t *jnl, + char *from_path, gf_boolean_t no_publish); int -gf_changelog_publish (xlator_t *this, - gf_changelog_journal_t *jnl, char *from_path); +gf_changelog_publish(xlator_t *this, gf_changelog_journal_t *jnl, + char *from_path); int -gf_thread_cleanup (xlator_t *this, pthread_t thread); +gf_thread_cleanup(xlator_t *this, pthread_t thread); void * -gf_changelog_callback_invoker (void *arg); +gf_changelog_callback_invoker(void *arg); int -gf_cleanup_event (xlator_t *, struct gf_event_list *); +gf_cleanup_event(xlator_t *, struct gf_event_list *); /* (un)ordered event queueing */ void -queue_ordered_event (struct gf_event_list *, struct gf_event *); +queue_ordered_event(struct gf_event_list *, struct gf_event *); void -queue_unordered_event (struct gf_event_list *, struct gf_event *); +queue_unordered_event(struct gf_event_list *, struct gf_event *); /* (un)ordered event picking */ void -pick_event_ordered (struct gf_event_list *, struct gf_event **); +pick_event_ordered(struct gf_event_list *, struct gf_event **); void -pick_event_unordered (struct gf_event_list *, struct gf_event **); +pick_event_unordered(struct gf_event_list *, struct gf_event **); /* connection janitor thread */ void * -gf_changelog_connection_janitor (void *); +gf_changelog_connection_janitor(void *); #endif diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal.h b/xlators/features/changelog/lib/src/gf-changelog-journal.h index 46d50f159d9..ba5b9bf827e 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-journal.h +++ b/xlators/features/changelog/lib/src/gf-changelog-journal.h @@ -17,91 +17,91 @@ #include "changelog.h" enum api_conn { - JNL_API_CONNECTED, - JNL_API_CONN_INPROGESS, - JNL_API_DISCONNECTED, + JNL_API_CONNECTED, + JNL_API_CONN_INPROGESS, + JNL_API_DISCONNECTED, }; typedef struct gf_changelog_entry { - char path[PATH_MAX]; + char path[PATH_MAX]; - struct list_head list; + struct list_head list; } gf_changelog_entry_t; typedef struct gf_changelog_processor { - pthread_mutex_t lock; /* protects ->entries */ - pthread_cond_t cond; /* waiter during empty list */ - gf_boolean_t waiting; + pthread_mutex_t lock; /* protects ->entries */ + pthread_cond_t cond; /* waiter during empty list */ + gf_boolean_t waiting; - pthread_t processor; /* thread-id of journal processing thread */ + pthread_t processor; /* thread-id of journal processing thread */ - struct list_head entries; + struct list_head entries; } gf_changelog_processor_t; typedef struct gf_changelog_journal { - DIR *jnl_dir; /* 'processing' directory stream */ + DIR *jnl_dir; /* 'processing' directory stream */ - int jnl_fd; /* fd to the tracker file */ + int jnl_fd; /* fd to the tracker file */ - char jnl_brickpath[PATH_MAX]; /* brick path for this end-point */ + char jnl_brickpath[PATH_MAX]; /* brick path for this end-point */ - gf_changelog_processor_t *jnl_proc; + gf_changelog_processor_t *jnl_proc; - char *jnl_working_dir; /* scratch directory */ + char *jnl_working_dir; /* scratch directory */ - char jnl_current_dir[PATH_MAX]; - char jnl_processed_dir[PATH_MAX]; - char jnl_processing_dir[PATH_MAX]; + char jnl_current_dir[PATH_MAX]; + char jnl_processed_dir[PATH_MAX]; + char jnl_processing_dir[PATH_MAX]; - char rfc3986_space_newline[256]; /* RFC 3986 string encoding */ + char rfc3986_space_newline[256]; /* RFC 3986 string encoding */ - struct gf_changelog_journal *hist_jnl; - int hist_done; /* holds 0 done scanning, - 1 keep scanning and -1 error */ + struct gf_changelog_journal *hist_jnl; + int hist_done; /* holds 0 done scanning, + 1 keep scanning and -1 error */ - pthread_spinlock_t lock; - int connected; - xlator_t *this; + pthread_spinlock_t lock; + int connected; + xlator_t *this; } gf_changelog_journal_t; -#define JNL_SET_API_STATE(jnl, state) (jnl->connected = state) -#define JNL_IS_API_DISCONNECTED(jnl) (jnl->connected == JNL_API_DISCONNECTED) +#define JNL_SET_API_STATE(jnl, state) (jnl->connected = state) +#define JNL_IS_API_DISCONNECTED(jnl) (jnl->connected == JNL_API_DISCONNECTED) /* History API */ typedef struct gf_changelog_history_data { - int len; + int len; - int htime_fd; + int htime_fd; - /* parallelism count */ - int n_parallel; + /* parallelism count */ + int n_parallel; - /* history from, to indexes */ - unsigned long from; - unsigned long to; - xlator_t *this; + /* history from, to indexes */ + unsigned long from; + unsigned long to; + xlator_t *this; } gf_changelog_history_data_t; typedef struct gf_changelog_consume_data { - /** set of inputs */ + /** set of inputs */ - /* fd to read from */ - int fd; + /* fd to read from */ + int fd; - /* from @offset */ - off_t offset; + /* from @offset */ + off_t offset; - xlator_t *this; + xlator_t *this; - gf_changelog_journal_t *jnl; + gf_changelog_journal_t *jnl; - /** set of outputs */ + /** set of outputs */ - /* return value */ - int retval; + /* return value */ + int retval; - /* journal processed */ - char changelog[PATH_MAX]; + /* journal processed */ + char changelog[PATH_MAX]; } gf_changelog_consume_data_t; /* event handler */ diff --git a/xlators/features/changelog/lib/src/gf-changelog-rpc.h b/xlators/features/changelog/lib/src/gf-changelog-rpc.h index 1c982eef809..975307b99d3 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-rpc.h +++ b/xlators/features/changelog/lib/src/gf-changelog-rpc.h @@ -16,11 +16,13 @@ #include "gf-changelog-helpers.h" #include "changelog-rpc-common.h" -struct rpc_clnt *gf_changelog_rpc_init (xlator_t *, gf_changelog_t *); +struct rpc_clnt * +gf_changelog_rpc_init(xlator_t *, gf_changelog_t *); -int gf_changelog_invoke_rpc (xlator_t *, gf_changelog_t *, int); +int +gf_changelog_invoke_rpc(xlator_t *, gf_changelog_t *, int); rpcsvc_t * -gf_changelog_reborp_init_rpc_listner (xlator_t *, char *, char *, void *); +gf_changelog_reborp_init_rpc_listner(xlator_t *, char *, char *, void *); #endif diff --git a/xlators/features/changelog/src/changelog-encoders.h b/xlators/features/changelog/src/changelog-encoders.h index d6a50cc9ef7..ca42c4c4fe0 100644 --- a/xlators/features/changelog/src/changelog-encoders.h +++ b/xlators/features/changelog/src/changelog-encoders.h @@ -16,36 +16,34 @@ #include "changelog-helpers.h" -#define CHANGELOG_STORE_ASCII(priv, buf, off, gfid, gfid_len, cld) do { \ - CHANGELOG_FILL_BUFFER (buffer, off, \ - priv->maps[cld->cld_type], 1); \ - CHANGELOG_FILL_BUFFER (buffer, \ - off, gfid, gfid_len); \ - } while (0) - -#define CHANGELOG_STORE_BINARY(priv, buf, off, gfid, cld) do { \ - CHANGELOG_FILL_BUFFER (buffer, off, \ - priv->maps[cld->cld_type], 1); \ - CHANGELOG_FILL_BUFFER (buffer, \ - off, gfid, sizeof (uuid_t)); \ - } while (0) +#define CHANGELOG_STORE_ASCII(priv, buf, off, gfid, gfid_len, cld) \ + do { \ + CHANGELOG_FILL_BUFFER(buffer, off, priv->maps[cld->cld_type], 1); \ + CHANGELOG_FILL_BUFFER(buffer, off, gfid, gfid_len); \ + } while (0) + +#define CHANGELOG_STORE_BINARY(priv, buf, off, gfid, cld) \ + do { \ + CHANGELOG_FILL_BUFFER(buffer, off, priv->maps[cld->cld_type], 1); \ + CHANGELOG_FILL_BUFFER(buffer, off, gfid, sizeof(uuid_t)); \ + } while (0) size_t -entry_fn (void *data, char *buffer, gf_boolean_t encode); +entry_fn(void *data, char *buffer, gf_boolean_t encode); size_t -del_entry_fn (void *data, char *buffer, gf_boolean_t encode); +del_entry_fn(void *data, char *buffer, gf_boolean_t encode); size_t -fop_fn (void *data, char *buffer, gf_boolean_t encode); +fop_fn(void *data, char *buffer, gf_boolean_t encode); size_t -number_fn (void *data, char *buffer, gf_boolean_t encode); +number_fn(void *data, char *buffer, gf_boolean_t encode); void -entry_free_fn (void *data); +entry_free_fn(void *data); void -del_entry_free_fn (void *data); +del_entry_free_fn(void *data); int -changelog_encode_binary (xlator_t *, changelog_log_data_t *); +changelog_encode_binary(xlator_t *, changelog_log_data_t *); int -changelog_encode_ascii (xlator_t *, changelog_log_data_t *); +changelog_encode_ascii(xlator_t *, changelog_log_data_t *); void changelog_encode_change(changelog_priv_t *); diff --git a/xlators/features/changelog/src/changelog-ev-handle.h b/xlators/features/changelog/src/changelog-ev-handle.h index e89af8793a8..7e543a0edb3 100644 --- a/xlators/features/changelog/src/changelog-ev-handle.h +++ b/xlators/features/changelog/src/changelog-ev-handle.h @@ -20,59 +20,58 @@ struct changelog_clnt; typedef struct changelog_rpc_clnt { - xlator_t *this; + xlator_t *this; - gf_lock_t lock; + gf_lock_t lock; - gf_atomic_t ref; - gf_boolean_t disconnected; + gf_atomic_t ref; + gf_boolean_t disconnected; - unsigned int filter; - char sock[UNIX_PATH_MAX]; + unsigned int filter; + char sock[UNIX_PATH_MAX]; - struct changelog_clnt *c_clnt; /* back pointer to list holder */ + struct changelog_clnt *c_clnt; /* back pointer to list holder */ - struct rpc_clnt *rpc; /* RPC client endpoint */ + struct rpc_clnt *rpc; /* RPC client endpoint */ - struct list_head list; /* ->pending, ->waitq, ->active */ + struct list_head list; /* ->pending, ->waitq, ->active */ - void (*cleanup) - (struct changelog_rpc_clnt *); /* cleanup handler */ + void (*cleanup)(struct changelog_rpc_clnt *); /* cleanup handler */ } changelog_rpc_clnt_t; static inline void -changelog_rpc_clnt_ref (changelog_rpc_clnt_t *crpc) +changelog_rpc_clnt_ref(changelog_rpc_clnt_t *crpc) { - GF_ATOMIC_INC (crpc->ref); + GF_ATOMIC_INC(crpc->ref); } static inline void -changelog_set_disconnect_flag (changelog_rpc_clnt_t *crpc, gf_boolean_t flag) +changelog_set_disconnect_flag(changelog_rpc_clnt_t *crpc, gf_boolean_t flag) { - crpc->disconnected = flag; + crpc->disconnected = flag; } static inline int -changelog_rpc_clnt_is_disconnected (changelog_rpc_clnt_t *crpc) +changelog_rpc_clnt_is_disconnected(changelog_rpc_clnt_t *crpc) { - return (crpc->disconnected == _gf_true); + return (crpc->disconnected == _gf_true); } static inline void -changelog_rpc_clnt_unref (changelog_rpc_clnt_t *crpc) +changelog_rpc_clnt_unref(changelog_rpc_clnt_t *crpc) { - gf_boolean_t gone = _gf_false; - uint64_t ref = 0; + gf_boolean_t gone = _gf_false; + uint64_t ref = 0; - ref = GF_ATOMIC_DEC (crpc->ref); + ref = GF_ATOMIC_DEC(crpc->ref); - if (!ref && changelog_rpc_clnt_is_disconnected (crpc)) { - list_del (&crpc->list); - gone = _gf_true; - } + if (!ref && changelog_rpc_clnt_is_disconnected(crpc)) { + list_del(&crpc->list); + gone = _gf_true; + } - if (gone) - crpc->cleanup (crpc); + if (gone) + crpc->cleanup(crpc); } /** @@ -100,35 +99,36 @@ changelog_rpc_clnt_unref (changelog_rpc_clnt_t *crpc) */ typedef struct changelog_clnt { - xlator_t *this; + xlator_t *this; - /* pending connections */ - pthread_mutex_t pending_lock; - pthread_cond_t pending_cond; - struct list_head pending; + /* pending connections */ + pthread_mutex_t pending_lock; + pthread_cond_t pending_cond; + struct list_head pending; - /* current active connections */ - gf_lock_t active_lock; - struct list_head active; + /* current active connections */ + gf_lock_t active_lock; + struct list_head active; - gf_lock_t wait_lock; - struct list_head waitq; + gf_lock_t wait_lock; + struct list_head waitq; - /* consumer part of rot-buffs */ - rbuf_t *rbuf; - unsigned long sequence; + /* consumer part of rot-buffs */ + rbuf_t *rbuf; + unsigned long sequence; } changelog_clnt_t; -void *changelog_ev_connector (void *); +void * +changelog_ev_connector(void *); -void *changelog_ev_dispatch (void *); +void * +changelog_ev_dispatch(void *); /* APIs */ void -changelog_ev_queue_connection (changelog_clnt_t *, changelog_rpc_clnt_t *); +changelog_ev_queue_connection(changelog_clnt_t *, changelog_rpc_clnt_t *); void -changelog_ev_cleanup_connections (xlator_t *, changelog_clnt_t *); +changelog_ev_cleanup_connections(xlator_t *, changelog_clnt_t *); #endif - diff --git a/xlators/features/changelog/src/changelog-helpers.h b/xlators/features/changelog/src/changelog-helpers.h index 1551337c16f..10d457e8cf5 100644 --- a/xlators/features/changelog/src/changelog-helpers.h +++ b/xlators/features/changelog/src/changelog-helpers.h @@ -30,44 +30,44 @@ * the changelog entry */ typedef struct changelog_log_data { - /* rollover related */ - unsigned long cld_roll_time; + /* rollover related */ + unsigned long cld_roll_time; - /* reopen changelog? */ - gf_boolean_t cld_finale; + /* reopen changelog? */ + gf_boolean_t cld_finale; - changelog_log_type cld_type; + changelog_log_type cld_type; - /** - * sincd gfid is _always_ a necessity, it's not a part - * of the iobuf. by doing this we do not add any overhead - * for data and metadata related fops. - */ - uuid_t cld_gfid; + /** + * sincd gfid is _always_ a necessity, it's not a part + * of the iobuf. by doing this we do not add any overhead + * for data and metadata related fops. + */ + uuid_t cld_gfid; - /** - * iobufs are used for optionals records: pargfid, path, - * write offsets etc.. It's the fop implementers job - * to allocate (iobuf_get() in the fop) and get unref'ed - * in the callback (CHANGELOG_STACK_UNWIND). - */ - struct iobuf *cld_iobuf; + /** + * iobufs are used for optionals records: pargfid, path, + * write offsets etc.. It's the fop implementers job + * to allocate (iobuf_get() in the fop) and get unref'ed + * in the callback (CHANGELOG_STACK_UNWIND). + */ + struct iobuf *cld_iobuf; #define cld_ptr cld_iobuf->ptr - /** - * after allocation you can point this to the length of - * usable data, but make sure it does not exceed the - * the size of the requested iobuf. - */ - size_t cld_iobuf_len; + /** + * after allocation you can point this to the length of + * usable data, but make sure it does not exceed the + * the size of the requested iobuf. + */ + size_t cld_iobuf_len; #define cld_ptr_len cld_iobuf_len - /** - * number of optional records - */ - int cld_xtra_records; + /** + * number of optional records + */ + int cld_xtra_records; } changelog_log_data_t; /** @@ -77,55 +77,54 @@ typedef struct changelog_log_data { typedef struct changelog_priv changelog_priv_t; typedef struct changelog_dispatcher { - void *cd_data; - int (*dispatchfn) (xlator_t *, changelog_priv_t *, void *, - changelog_log_data_t *, changelog_log_data_t *); + void *cd_data; + int (*dispatchfn)(xlator_t *, changelog_priv_t *, void *, + changelog_log_data_t *, changelog_log_data_t *); } changelog_dispatcher_t; struct changelog_bootstrap { - changelog_mode_t mode; - int (*ctor) (xlator_t *, changelog_dispatcher_t *); - int (*dtor) (xlator_t *, changelog_dispatcher_t *); + changelog_mode_t mode; + int (*ctor)(xlator_t *, changelog_dispatcher_t *); + int (*dtor)(xlator_t *, changelog_dispatcher_t *); }; struct changelog_encoder { - changelog_encoder_t encoder; - int (*encode) (xlator_t *, changelog_log_data_t *); + changelog_encoder_t encoder; + int (*encode)(xlator_t *, changelog_log_data_t *); }; - /* xlator private */ typedef struct changelog_time_slice { - /** - * just in case we need nanosecond granularity some day. - * field is unused as of now (maybe we'd need it later). - */ - struct timeval tv_start; - - /** - * version of changelog file, incremented each time changes - * rollover. - */ - unsigned long changelog_version[CHANGELOG_MAX_TYPE]; + /** + * just in case we need nanosecond granularity some day. + * field is unused as of now (maybe we'd need it later). + */ + struct timeval tv_start; + + /** + * version of changelog file, incremented each time changes + * rollover. + */ + unsigned long changelog_version[CHANGELOG_MAX_TYPE]; } changelog_time_slice_t; typedef struct changelog_rollover { - /* rollover thread */ - pthread_t rollover_th; + /* rollover thread */ + pthread_t rollover_th; - xlator_t *this; + xlator_t *this; - pthread_mutex_t lock; - pthread_cond_t cond; - gf_boolean_t notify; + pthread_mutex_t lock; + pthread_cond_t cond; + gf_boolean_t notify; } changelog_rollover_t; typedef struct changelog_fsync { - /* fsync() thread */ - pthread_t fsync_th; + /* fsync() thread */ + pthread_t fsync_th; - xlator_t *this; + xlator_t *this; } changelog_fsync_t; /* Draining during changelog rollover (for geo-rep snapshot dependency): @@ -145,198 +144,197 @@ typedef struct changelog_fsync { */ typedef enum chlog_fop_color { - FOP_COLOR_BLACK, - FOP_COLOR_WHITE + FOP_COLOR_BLACK, + FOP_COLOR_WHITE } chlog_fop_color_t; /* Barrier notify variable */ typedef struct barrier_notify { - pthread_mutex_t bnotify_mutex; - pthread_cond_t bnotify_cond; - gf_boolean_t bnotify; - gf_boolean_t bnotify_error; + pthread_mutex_t bnotify_mutex; + pthread_cond_t bnotify_cond; + gf_boolean_t bnotify; + gf_boolean_t bnotify_error; } barrier_notify_t; /* Two separate mutex and conditional variable set is used * to drain white and black fops. */ typedef struct drain_mgmt { - pthread_mutex_t drain_black_mutex; - pthread_cond_t drain_black_cond; - pthread_mutex_t drain_white_mutex; - pthread_cond_t drain_white_cond; - /* Represents black fops count in-transit */ - unsigned long black_fop_cnt; - /* Represents white fops count in-transit */ - unsigned long white_fop_cnt; - gf_boolean_t drain_wait_black; - gf_boolean_t drain_wait_white; + pthread_mutex_t drain_black_mutex; + pthread_cond_t drain_black_cond; + pthread_mutex_t drain_white_mutex; + pthread_cond_t drain_white_cond; + /* Represents black fops count in-transit */ + unsigned long black_fop_cnt; + /* Represents white fops count in-transit */ + unsigned long white_fop_cnt; + gf_boolean_t drain_wait_black; + gf_boolean_t drain_wait_white; } drain_mgmt_t; /* External barrier as a result of snap on/off indicating flag*/ typedef struct barrier_flags { - gf_lock_t lock; - gf_boolean_t barrier_ext; + gf_lock_t lock; + gf_boolean_t barrier_ext; } barrier_flags_t; /* Event selection */ typedef struct changelog_ev_selector { - gf_lock_t reflock; + gf_lock_t reflock; - /** - * Array of references for each selection bit. - */ - unsigned int ref[CHANGELOG_EV_SELECTION_RANGE]; + /** + * Array of references for each selection bit. + */ + unsigned int ref[CHANGELOG_EV_SELECTION_RANGE]; } changelog_ev_selector_t; - /* changelog's private structure */ struct changelog_priv { - gf_boolean_t active; + gf_boolean_t active; - /* to generate unique socket file per brick */ - char *changelog_brick; + /* to generate unique socket file per brick */ + char *changelog_brick; - /* logging directory */ - char *changelog_dir; + /* logging directory */ + char *changelog_dir; - /* htime directory */ - char *htime_dir; + /* htime directory */ + char *htime_dir; - /* one file for all changelog types */ - int changelog_fd; + /* one file for all changelog types */ + int changelog_fd; - /* htime fd for current changelog session */ - int htime_fd; + /* htime fd for current changelog session */ + int htime_fd; - /* c_snap_fd is fd for call-path changelog */ - int c_snap_fd; + /* c_snap_fd is fd for call-path changelog */ + int c_snap_fd; - /* rollover_count used by htime */ - int rollover_count; + /* rollover_count used by htime */ + int rollover_count; - gf_lock_t lock; + gf_lock_t lock; - /* lock to synchronize CSNAP updation */ - gf_lock_t c_snap_lock; + /* lock to synchronize CSNAP updation */ + gf_lock_t c_snap_lock; - /* written end of the pipe */ - int wfd; + /* written end of the pipe */ + int wfd; - /* rollover time */ - int32_t rollover_time; + /* rollover time */ + int32_t rollover_time; - /* fsync() interval */ - int32_t fsync_interval; + /* fsync() interval */ + int32_t fsync_interval; - /* changelog type maps */ - const char *maps[CHANGELOG_MAX_TYPE]; + /* changelog type maps */ + const char *maps[CHANGELOG_MAX_TYPE]; - /* time slicer */ - changelog_time_slice_t slice; + /* time slicer */ + changelog_time_slice_t slice; - /* context of the updater */ - changelog_dispatcher_t cd; + /* context of the updater */ + changelog_dispatcher_t cd; - /* context of the rollover thread */ - changelog_rollover_t cr; + /* context of the rollover thread */ + changelog_rollover_t cr; - /* context of fsync thread */ - changelog_fsync_t cf; + /* context of fsync thread */ + changelog_fsync_t cf; - /* operation mode */ - changelog_mode_t op_mode; + /* operation mode */ + changelog_mode_t op_mode; - /* bootstrap routine for 'current' logger */ - struct changelog_bootstrap *cb; + /* bootstrap routine for 'current' logger */ + struct changelog_bootstrap *cb; - /* encoder mode */ - changelog_encoder_t encode_mode; + /* encoder mode */ + changelog_encoder_t encode_mode; - /* encoder */ - struct changelog_encoder *ce; + /* encoder */ + struct changelog_encoder *ce; - /** - * snapshot dependency changes - */ + /** + * snapshot dependency changes + */ - /* Draining of fops*/ - drain_mgmt_t dm; + /* Draining of fops*/ + drain_mgmt_t dm; - /* Represents the active color. Initially by default black */ - chlog_fop_color_t current_color; + /* Represents the active color. Initially by default black */ + chlog_fop_color_t current_color; - /* flag to determine explicit rollover is triggered */ - gf_boolean_t explicit_rollover; + /* flag to determine explicit rollover is triggered */ + gf_boolean_t explicit_rollover; - /* barrier notification variable protected by mutex */ - barrier_notify_t bn; + /* barrier notification variable protected by mutex */ + barrier_notify_t bn; - /* barrier on/off indicating flags */ - barrier_flags_t bflags; + /* barrier on/off indicating flags */ + barrier_flags_t bflags; - /* changelog barrier on/off indicating flag */ - gf_boolean_t barrier_enabled; - struct list_head queue; - uint32_t queue_size; - gf_timer_t *timer; - struct timespec timeout; + /* changelog barrier on/off indicating flag */ + gf_boolean_t barrier_enabled; + struct list_head queue; + uint32_t queue_size; + gf_timer_t *timer; + struct timespec timeout; - /** - * buffers, RPC, event selection, notifications and other - * beasts. - */ + /** + * buffers, RPC, event selection, notifications and other + * beasts. + */ - /* epoll pthread */ - pthread_t poller; + /* epoll pthread */ + pthread_t poller; - /* rotational buffer */ - rbuf_t *rbuf; + /* rotational buffer */ + rbuf_t *rbuf; - /* changelog RPC server */ - rpcsvc_t *rpc; + /* changelog RPC server */ + rpcsvc_t *rpc; - /* event selection */ - changelog_ev_selector_t ev_selection; + /* event selection */ + changelog_ev_selector_t ev_selection; - /* client handling (reverse connection) */ - pthread_t connector; + /* client handling (reverse connection) */ + pthread_t connector; - int nr_dispatchers; - pthread_t *ev_dispatcher; + int nr_dispatchers; + pthread_t *ev_dispatcher; - changelog_clnt_t connections; + changelog_clnt_t connections; - /* glusterfind dependency to capture paths on deleted entries*/ - gf_boolean_t capture_del_path; + /* glusterfind dependency to capture paths on deleted entries*/ + gf_boolean_t capture_del_path; }; struct changelog_local { - inode_t *inode; - gf_boolean_t update_no_check; + inode_t *inode; + gf_boolean_t update_no_check; - changelog_log_data_t cld; + changelog_log_data_t cld; - /** - * ->prev_entry is used in cases when there needs to be - * additional changelog entry for the parent (eg. rename) - * It's analogous to ->next in single linked list world, - * but we call it as ->prev_entry... ha ha ha - */ - struct changelog_local *prev_entry; + /** + * ->prev_entry is used in cases when there needs to be + * additional changelog entry for the parent (eg. rename) + * It's analogous to ->next in single linked list world, + * but we call it as ->prev_entry... ha ha ha + */ + struct changelog_local *prev_entry; - /* snap dependency changes */ - chlog_fop_color_t color; + /* snap dependency changes */ + chlog_fop_color_t color; }; typedef struct changelog_local changelog_local_t; /* inode version is stored in inode ctx */ typedef struct changelog_inode_ctx { - unsigned long iversion[CHANGELOG_MAX_TYPE]; + unsigned long iversion[CHANGELOG_MAX_TYPE]; } changelog_inode_ctx_t; -#define CHANGELOG_INODE_VERSION_TYPE(ctx, type) &(ctx->iversion[type]) +#define CHANGELOG_INODE_VERSION_TYPE(ctx, type) &(ctx->iversion[type]) /** * Optional Records: @@ -344,269 +342,279 @@ typedef struct changelog_inode_ctx { * @changelog_opt_t struct. The array is allocated via @iobufs. */ typedef enum { - CHANGELOG_OPT_REC_FOP, - CHANGELOG_OPT_REC_ENTRY, - CHANGELOG_OPT_REC_UINT32, + CHANGELOG_OPT_REC_FOP, + CHANGELOG_OPT_REC_ENTRY, + CHANGELOG_OPT_REC_UINT32, } changelog_optional_rec_type_t; struct changelog_entry_fields { - uuid_t cef_uuid; - char *cef_bname; - char *cef_path; + uuid_t cef_uuid; + char *cef_bname; + char *cef_path; }; typedef struct { - /** - * @co_covert can be used to do post-processing of the record before - * it's persisted to the CHANGELOG. If this is NULL, then the record - * is persisted as per it's in memory format. - */ - size_t (*co_convert) (void *data, char *buffer, gf_boolean_t encode); - - /* release routines */ - void (*co_free) (void *data); - - /* type of the field */ - changelog_optional_rec_type_t co_type; - - /** - * sizeof of the 'valid' field in the union. This field is not used if - * @co_convert is specified. - */ - size_t co_len; - - union { - unsigned int co_uint32; - glusterfs_fop_t co_fop; - struct changelog_entry_fields co_entry; - }; + /** + * @co_covert can be used to do post-processing of the record before + * it's persisted to the CHANGELOG. If this is NULL, then the record + * is persisted as per it's in memory format. + */ + size_t (*co_convert)(void *data, char *buffer, gf_boolean_t encode); + + /* release routines */ + void (*co_free)(void *data); + + /* type of the field */ + changelog_optional_rec_type_t co_type; + + /** + * sizeof of the 'valid' field in the union. This field is not used if + * @co_convert is specified. + */ + size_t co_len; + + union { + unsigned int co_uint32; + glusterfs_fop_t co_fop; + struct changelog_entry_fields co_entry; + }; } changelog_opt_t; -#define CHANGELOG_OPT_RECORD_LEN sizeof (changelog_opt_t) +#define CHANGELOG_OPT_RECORD_LEN sizeof(changelog_opt_t) /** * helpers routines */ int -changelog_thread_cleanup (xlator_t *this, pthread_t thr_id); +changelog_thread_cleanup(xlator_t *this, pthread_t thr_id); void * -changelog_get_usable_buffer (changelog_local_t *local); +changelog_get_usable_buffer(changelog_local_t *local); void -changelog_set_usable_record_and_length (changelog_local_t *local, - size_t len, int xr); +changelog_set_usable_record_and_length(changelog_local_t *local, size_t len, + int xr); void -changelog_local_cleanup (xlator_t *xl, changelog_local_t *local); +changelog_local_cleanup(xlator_t *xl, changelog_local_t *local); changelog_local_t * -changelog_local_init (xlator_t *this, inode_t *inode, uuid_t gfid, - int xtra_records, gf_boolean_t update_flag); +changelog_local_init(xlator_t *this, inode_t *inode, uuid_t gfid, + int xtra_records, gf_boolean_t update_flag); int -changelog_start_next_change (xlator_t *this, - changelog_priv_t *priv, - unsigned long ts, gf_boolean_t finale); +changelog_start_next_change(xlator_t *this, changelog_priv_t *priv, + unsigned long ts, gf_boolean_t finale); int -changelog_open_journal (xlator_t *this, changelog_priv_t *priv); +changelog_open_journal(xlator_t *this, changelog_priv_t *priv); int -changelog_fill_rollover_data (changelog_log_data_t *cld, gf_boolean_t is_last); +changelog_fill_rollover_data(changelog_log_data_t *cld, gf_boolean_t is_last); int -changelog_inject_single_event (xlator_t *this, - changelog_priv_t *priv, - changelog_log_data_t *cld); +changelog_inject_single_event(xlator_t *this, changelog_priv_t *priv, + changelog_log_data_t *cld); size_t -changelog_entry_length (); +changelog_entry_length(); int -changelog_write (int fd, char *buffer, size_t len); +changelog_write(int fd, char *buffer, size_t len); int -changelog_write_change (changelog_priv_t *priv, char *buffer, size_t len); +changelog_write_change(changelog_priv_t *priv, char *buffer, size_t len); int -changelog_handle_change (xlator_t *this, - changelog_priv_t *priv, changelog_log_data_t *cld); +changelog_handle_change(xlator_t *this, changelog_priv_t *priv, + changelog_log_data_t *cld); void -changelog_update (xlator_t *this, changelog_priv_t *priv, - changelog_local_t *local, changelog_log_type type); +changelog_update(xlator_t *this, changelog_priv_t *priv, + changelog_local_t *local, changelog_log_type type); void * -changelog_rollover (void *data); +changelog_rollover(void *data); void * -changelog_fsync_thread (void *data); +changelog_fsync_thread(void *data); int -changelog_forget (xlator_t *this, inode_t *inode); +changelog_forget(xlator_t *this, inode_t *inode); int -htime_update (xlator_t *this, changelog_priv_t *priv, - unsigned long ts, char * buffer); +htime_update(xlator_t *this, changelog_priv_t *priv, unsigned long ts, + char *buffer); int -htime_open (xlator_t *this, changelog_priv_t *priv, unsigned long ts); +htime_open(xlator_t *this, changelog_priv_t *priv, unsigned long ts); int -htime_create (xlator_t *this, changelog_priv_t *priv, unsigned long ts); +htime_create(xlator_t *this, changelog_priv_t *priv, unsigned long ts); /* Geo-Rep snapshot dependency changes */ void -changelog_color_fop_and_inc_cnt (xlator_t *this, changelog_priv_t *priv, - changelog_local_t *local); +changelog_color_fop_and_inc_cnt(xlator_t *this, changelog_priv_t *priv, + changelog_local_t *local); void -changelog_inc_fop_cnt (xlator_t *this, changelog_priv_t *priv, - changelog_local_t *local); +changelog_inc_fop_cnt(xlator_t *this, changelog_priv_t *priv, + changelog_local_t *local); void -changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, - changelog_local_t *local); +changelog_dec_fop_cnt(xlator_t *this, changelog_priv_t *priv, + changelog_local_t *local); int -changelog_barrier_notify (changelog_priv_t *priv, char* buf); +changelog_barrier_notify(changelog_priv_t *priv, char *buf); void -changelog_barrier_cleanup (xlator_t *this, changelog_priv_t *priv, - struct list_head *queue); +changelog_barrier_cleanup(xlator_t *this, changelog_priv_t *priv, + struct list_head *queue); void -changelog_drain_white_fops (xlator_t *this, changelog_priv_t *priv); +changelog_drain_white_fops(xlator_t *this, changelog_priv_t *priv); void -changelog_drain_black_fops (xlator_t *this, changelog_priv_t *priv); +changelog_drain_black_fops(xlator_t *this, changelog_priv_t *priv); /* Crash consistency of changelog wrt snapshot */ int -changelog_snap_logging_stop ( xlator_t *this, changelog_priv_t *priv); +changelog_snap_logging_stop(xlator_t *this, changelog_priv_t *priv); int -changelog_snap_logging_start ( xlator_t *this, changelog_priv_t *priv); +changelog_snap_logging_start(xlator_t *this, changelog_priv_t *priv); int -changelog_snap_open ( xlator_t *this, changelog_priv_t *priv); +changelog_snap_open(xlator_t *this, changelog_priv_t *priv); int -changelog_snap_handle_ascii_change (xlator_t *this, - changelog_log_data_t *cld); +changelog_snap_handle_ascii_change(xlator_t *this, changelog_log_data_t *cld); int -changelog_snap_write_change (changelog_priv_t *priv, char *buffer, size_t len); |