From 45a71c0548b6fd2c757aa2e7b7671a1411948894 Mon Sep 17 00:00:00 2001 From: Gluster Ant Date: Wed, 12 Sep 2018 17:22:48 +0530 Subject: Land clang-format changes Change-Id: I6f5d8140a06f3c1b2d196849299f8d483028d33b --- xlators/cluster/afr/src/afr-dir-read.h | 21 +- xlators/cluster/afr/src/afr-dir-write.h | 33 +- xlators/cluster/afr/src/afr-inode-read.h | 29 +- xlators/cluster/afr/src/afr-inode-write.h | 78 +- xlators/cluster/afr/src/afr-mem-types.h | 68 +- xlators/cluster/afr/src/afr-messages.h | 66 +- xlators/cluster/afr/src/afr-self-heal.h | 444 ++++---- xlators/cluster/afr/src/afr-self-heald.h | 85 +- xlators/cluster/afr/src/afr-transaction.h | 50 +- xlators/cluster/afr/src/afr.h | 1755 +++++++++++++++-------------- 10 files changed, 1303 insertions(+), 1326 deletions(-) (limited to 'xlators/cluster/afr') 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 - 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__ */ -- cgit