diff options
author | Gluster Ant <bugzilla-bot@gluster.org> | 2018-09-12 17:22:48 +0530 |
---|---|---|
committer | Nigel Babu <nigelb@redhat.com> | 2018-09-12 17:22:48 +0530 |
commit | 45a71c0548b6fd2c757aa2e7b7671a1411948894 (patch) | |
tree | 2a5a9b73bae47ab53a41166fd041a06612587f48 /xlators/features | |
parent | be77dbbda692792335a8e9e7c02e0c281f003c40 (diff) |
Land clang-format changes
Change-Id: I6f5d8140a06f3c1b2d196849299f8d483028d33b
Diffstat (limited to 'xlators/features')
93 files changed, 4296 insertions, 4564 deletions
diff --git a/xlators/features/arbiter/src/arbiter-mem-types.h b/xlators/features/arbiter/src/arbiter-mem-types.h index ccf864cdef0..0f77cfd05f4 100644 --- a/xlators/features/arbiter/src/arbiter-mem-types.h +++ b/xlators/features/arbiter/src/arbiter-mem-types.h @@ -12,7 +12,7 @@ #include "mem-types.h" typedef enum gf_arbiter_mem_types_ { - gf_arbiter_mt_inode_ctx_t = gf_common_mt_end + 1, - gf_arbiter_mt_end + gf_arbiter_mt_inode_ctx_t = gf_common_mt_end + 1, + gf_arbiter_mt_end } gf_arbiter_mem_types_t; #endif diff --git a/xlators/features/arbiter/src/arbiter.h b/xlators/features/arbiter/src/arbiter.h index f52b45fad20..ce1c909f70f 100644 --- a/xlators/features/arbiter/src/arbiter.h +++ b/xlators/features/arbiter/src/arbiter.h @@ -15,7 +15,7 @@ #include "common-utils.h" typedef struct arbiter_inode_ctx_ { - struct iatt iattbuf; + struct iatt iattbuf; } arbiter_inode_ctx_t; #endif /* _ARBITER_H */ diff --git a/xlators/features/barrier/src/barrier-mem-types.h b/xlators/features/barrier/src/barrier-mem-types.h index 36647a66966..93ccab633ce 100644 --- a/xlators/features/barrier/src/barrier-mem-types.h +++ b/xlators/features/barrier/src/barrier-mem-types.h @@ -14,7 +14,7 @@ #include "mem-types.h" enum gf_barrier_mem_types_ { - gf_barrier_mt_priv_t = gf_common_mt_end + 1, - gf_barrier_mt_end + gf_barrier_mt_priv_t = gf_common_mt_end + 1, + gf_barrier_mt_end }; #endif diff --git a/xlators/features/barrier/src/barrier.h b/xlators/features/barrier/src/barrier.h index 0d646f90474..d11d71d151e 100644 --- a/xlators/features/barrier/src/barrier.h +++ b/xlators/features/barrier/src/barrier.h @@ -16,67 +16,73 @@ #include "timer.h" #include "call-stub.h" -#define BARRIER_FOP_CBK(fop_name, label, frame, this, params ...) \ - do { \ - barrier_priv_t *_priv = NULL; \ - call_stub_t *_stub = NULL; \ - gf_boolean_t _barrier_enabled= _gf_false; \ - struct list_head queue = {0, }; \ - \ - INIT_LIST_HEAD (&queue); \ - \ - _priv = this->private; \ - GF_ASSERT (_priv); \ - \ - LOCK (&_priv->lock); \ - { \ - if (_priv->barrier_enabled) { \ - _barrier_enabled = _priv->barrier_enabled;\ - \ - _stub = fop_##fop_name##_cbk_stub \ - (frame, \ - barrier_##fop_name##_cbk_resume,\ - params); \ - if (!_stub) { \ - __barrier_disable (this, &queue);\ - goto unlock; \ - } \ - \ - __barrier_enqueue (this, _stub); \ - } \ - } \ -unlock: \ - UNLOCK (&_priv->lock); \ - \ - if (_stub) \ - goto label; \ - \ - if (_barrier_enabled && !_stub) { \ - gf_log (this->name, GF_LOG_CRITICAL, \ - "Failed to barrier FOPs, disabling " \ - "barrier. FOP: %s, ERROR: %s", \ - #fop_name, strerror (ENOMEM)); \ - barrier_dequeue_all (this, &queue); \ - } \ - barrier_local_free_gfid (frame); \ - STACK_UNWIND_STRICT (fop_name, frame, params); \ - goto label; \ - } while (0) +#define BARRIER_FOP_CBK(fop_name, label, frame, this, params...) \ + do { \ + barrier_priv_t *_priv = NULL; \ + call_stub_t *_stub = NULL; \ + gf_boolean_t _barrier_enabled = _gf_false; \ + struct list_head queue = { \ + 0, \ + }; \ + \ + INIT_LIST_HEAD(&queue); \ + \ + _priv = this->private; \ + GF_ASSERT(_priv); \ + \ + LOCK(&_priv->lock); \ + { \ + if (_priv->barrier_enabled) { \ + _barrier_enabled = _priv->barrier_enabled; \ + \ + _stub = fop_##fop_name##_cbk_stub( \ + frame, barrier_##fop_name##_cbk_resume, params); \ + if (!_stub) { \ + __barrier_disable(this, &queue); \ + goto unlock; \ + } \ + \ + __barrier_enqueue(this, _stub); \ + } \ + } \ + unlock: \ + UNLOCK(&_priv->lock); \ + \ + if (_stub) \ + goto label; \ + \ + if (_barrier_enabled && !_stub) { \ + gf_log(this->name, GF_LOG_CRITICAL, \ + "Failed to barrier FOPs, disabling " \ + "barrier. FOP: %s, ERROR: %s", \ + #fop_name, strerror(ENOMEM)); \ + barrier_dequeue_all(this, &queue); \ + } \ + barrier_local_free_gfid(frame); \ + STACK_UNWIND_STRICT(fop_name, frame, params); \ + goto label; \ + } while (0) typedef struct { - gf_timer_t *timer; - gf_boolean_t barrier_enabled; - gf_lock_t lock; - struct list_head queue; - struct timespec timeout; - uint32_t queue_size; + gf_timer_t *timer; + gf_boolean_t barrier_enabled; + gf_lock_t lock; + struct list_head queue; + struct timespec timeout; + uint32_t queue_size; } barrier_priv_t; -int __barrier_enable (xlator_t *this, barrier_priv_t *priv); -void __barrier_enqueue (xlator_t *this, call_stub_t *stub); -void __barrier_disable (xlator_t *this, struct list_head *queue); -void barrier_timeout (void *data); -void barrier_dequeue_all (xlator_t *this, struct list_head *queue); -call_stub_t *__barrier_dequeue (xlator_t *this, struct list_head *queue); +int +__barrier_enable(xlator_t *this, barrier_priv_t *priv); +void +__barrier_enqueue(xlator_t *this, call_stub_t *stub); +void +__barrier_disable(xlator_t *this, struct list_head *queue); +void +barrier_timeout(void *data); +void +barrier_dequeue_all(xlator_t *this, struct list_head *queue); +call_stub_t * +__barrier_dequeue(xlator_t *this, struct list_head *queue); #endif diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h index 89a67cc10b1..6f59933a31d 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot-bitd-messages.h @@ -23,62 +23,30 @@ * glfs-message-id.h. */ -GLFS_MSGID(BITROT_BITD, - BRB_MSG_FD_CREATE_FAILED, - BRB_MSG_READV_FAILED, - BRB_MSG_BLOCK_READ_FAILED, - BRB_MSG_CALC_CHECKSUM_FAILED, - BRB_MSG_NO_MEMORY, - BRB_MSG_GET_SIGN_FAILED, - BRB_MSG_SET_SIGN_FAILED, - BRB_MSG_OP_FAILED, - BRB_MSG_READ_AND_SIGN_FAILED, - BRB_MSG_SIGN_FAILED, - BRB_MSG_GET_SUBVOL_FAILED, - BRB_MSG_SET_TIMER_FAILED, - BRB_MSG_GET_INFO_FAILED, - BRB_MSG_PATH_FAILED, - BRB_MSG_MARK_BAD_FILE, - BRB_MSG_TRIGGER_SIGN, - BRB_MSG_REGISTER_FAILED, - BRB_MSG_CRAWLING_START, - BRB_MSG_SPAWN_FAILED, - BRB_MSG_INVALID_SUBVOL_CHILD, - BRB_MSG_SKIP_OBJECT, - BRB_MSG_NO_CHILD, - BRB_MSG_CHECKSUM_MISMATCH, - BRB_MSG_MARK_CORRUPTED, - BRB_MSG_CRAWLING_FINISH, - BRB_MSG_CALC_ERROR, - BRB_MSG_LOOKUP_FAILED, - BRB_MSG_PARTIAL_VERSION_PRESENCE, - BRB_MSG_MEM_ACNT_FAILED, - BRB_MSG_TIMER_WHEEL_UNAVAILABLE, - BRB_MSG_BITROT_LOADED, - BRB_MSG_SCALE_DOWN_FAILED, - BRB_MSG_SCALE_UP_FAILED, - BRB_MSG_SCALE_DOWN_SCRUBBER, - BRB_MSG_SCALING_UP_SCRUBBER, - BRB_MSG_UNKNOWN_THROTTLE, - BRB_MSG_RATE_LIMIT_INFO, - BRB_MSG_SCRUB_INFO, - BRB_MSG_CONNECTED_TO_BRICK, - BRB_MSG_BRICK_INFO, - BRB_MSG_SUBVOL_CONNECT_FAILED, - BRB_MSG_INVALID_SUBVOL, - BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, - BRB_MSG_SCRUB_START, - BRB_MSG_SCRUB_FINISH, - BRB_MSG_SCRUB_RUNNING, - BRB_MSG_SCRUB_RESCHEDULED, - BRB_MSG_SCRUB_TUNABLE, - BRB_MSG_SCRUB_THREAD_CLEANUP, - BRB_MSG_SCRUBBER_CLEANED, - BRB_MSG_GENERIC_SSM_INFO, - BRB_MSG_ZERO_TIMEOUT_BUG, - BRB_MSG_BAD_OBJ_READDIR_FAIL, - BRB_MSG_SSM_FAILED, - BRB_MSG_SCRUB_WAIT_FAILED -); +GLFS_MSGID(BITROT_BITD, BRB_MSG_FD_CREATE_FAILED, BRB_MSG_READV_FAILED, + BRB_MSG_BLOCK_READ_FAILED, BRB_MSG_CALC_CHECKSUM_FAILED, + BRB_MSG_NO_MEMORY, BRB_MSG_GET_SIGN_FAILED, BRB_MSG_SET_SIGN_FAILED, + BRB_MSG_OP_FAILED, BRB_MSG_READ_AND_SIGN_FAILED, BRB_MSG_SIGN_FAILED, + BRB_MSG_GET_SUBVOL_FAILED, BRB_MSG_SET_TIMER_FAILED, + BRB_MSG_GET_INFO_FAILED, BRB_MSG_PATH_FAILED, BRB_MSG_MARK_BAD_FILE, + BRB_MSG_TRIGGER_SIGN, BRB_MSG_REGISTER_FAILED, + BRB_MSG_CRAWLING_START, BRB_MSG_SPAWN_FAILED, + BRB_MSG_INVALID_SUBVOL_CHILD, BRB_MSG_SKIP_OBJECT, BRB_MSG_NO_CHILD, + BRB_MSG_CHECKSUM_MISMATCH, BRB_MSG_MARK_CORRUPTED, + BRB_MSG_CRAWLING_FINISH, BRB_MSG_CALC_ERROR, BRB_MSG_LOOKUP_FAILED, + BRB_MSG_PARTIAL_VERSION_PRESENCE, BRB_MSG_MEM_ACNT_FAILED, + BRB_MSG_TIMER_WHEEL_UNAVAILABLE, BRB_MSG_BITROT_LOADED, + BRB_MSG_SCALE_DOWN_FAILED, BRB_MSG_SCALE_UP_FAILED, + BRB_MSG_SCALE_DOWN_SCRUBBER, BRB_MSG_SCALING_UP_SCRUBBER, + BRB_MSG_UNKNOWN_THROTTLE, BRB_MSG_RATE_LIMIT_INFO, + BRB_MSG_SCRUB_INFO, BRB_MSG_CONNECTED_TO_BRICK, BRB_MSG_BRICK_INFO, + BRB_MSG_SUBVOL_CONNECT_FAILED, BRB_MSG_INVALID_SUBVOL, + BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, BRB_MSG_SCRUB_START, + BRB_MSG_SCRUB_FINISH, BRB_MSG_SCRUB_RUNNING, + BRB_MSG_SCRUB_RESCHEDULED, BRB_MSG_SCRUB_TUNABLE, + BRB_MSG_SCRUB_THREAD_CLEANUP, BRB_MSG_SCRUBBER_CLEANED, + BRB_MSG_GENERIC_SSM_INFO, BRB_MSG_ZERO_TIMEOUT_BUG, + BRB_MSG_BAD_OBJ_READDIR_FAIL, BRB_MSG_SSM_FAILED, + BRB_MSG_SCRUB_WAIT_FAILED); #endif /* !_BITROT_BITD_MESSAGES_H_ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h index 02bd0fab04e..24128b90a66 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h @@ -16,33 +16,33 @@ #include <pthread.h> struct br_scrub_stats { - uint64_t scrubbed_files; /* Total number of scrubbed file */ + uint64_t scrubbed_files; /* Total number of scrubbed file */ - uint64_t unsigned_files; /* Total number of unsigned file */ + uint64_t unsigned_files; /* Total number of unsigned file */ - uint64_t scrub_duration; /* Duration of last scrub */ + uint64_t scrub_duration; /* Duration of last scrub */ - char last_scrub_time[1024]; /*last scrub completion time */ + char last_scrub_time[1024]; /*last scrub completion time */ - struct timeval scrub_start_tv; /* Scrubbing starting time*/ + struct timeval scrub_start_tv; /* Scrubbing starting time*/ - struct timeval scrub_end_tv; /* Scrubbing finishing time */ + struct timeval scrub_end_tv; /* Scrubbing finishing time */ - int8_t scrub_running; /* Scrub running or not */ + int8_t scrub_running; /* Scrub running or not */ - pthread_mutex_t lock; + pthread_mutex_t lock; }; typedef struct br_scrub_stats br_scrub_stats_t; void -br_inc_unsigned_file_count (br_scrub_stats_t *scrub_stat); +br_inc_unsigned_file_count(br_scrub_stats_t *scrub_stat); void -br_inc_scrubbed_file (br_scrub_stats_t *scrub_stat); +br_inc_scrubbed_file(br_scrub_stats_t *scrub_stat); void -br_update_scrub_start_time (br_scrub_stats_t *scrub_stat, struct timeval *tv); +br_update_scrub_start_time(br_scrub_stats_t *scrub_stat, struct timeval *tv); void -br_update_scrub_finish_time (br_scrub_stats_t *scrub_stat, char *timestr, - struct timeval *tv); +br_update_scrub_finish_time(br_scrub_stats_t *scrub_stat, char *timestr, + struct timeval *tv); #endif /* __BIT_ROT_SCRUB_STATUS_H__ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h index 8cc88ec153e..7a3c14abb93 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.h @@ -14,24 +14,33 @@ #include "xlator.h" #include "bit-rot.h" -void *br_fsscanner (void *); +void * +br_fsscanner(void *); -int32_t br_fsscan_schedule (xlator_t *); -int32_t br_fsscan_reschedule (xlator_t *); -int32_t br_fsscan_activate (xlator_t *); -int32_t br_fsscan_deactivate (xlator_t *); -int32_t br_fsscan_ondemand (xlator_t *); +int32_t +br_fsscan_schedule(xlator_t *); +int32_t +br_fsscan_reschedule(xlator_t *); +int32_t +br_fsscan_activate(xlator_t *); +int32_t +br_fsscan_deactivate(xlator_t *); +int32_t +br_fsscan_ondemand(xlator_t *); -int32_t br_scrubber_handle_options (xlator_t *, br_private_t *, dict_t *); +int32_t +br_scrubber_handle_options(xlator_t *, br_private_t *, dict_t *); int32_t -br_scrubber_monitor_init (xlator_t *, br_private_t *); +br_scrubber_monitor_init(xlator_t *, br_private_t *); -int32_t br_scrubber_init (xlator_t *, br_private_t *); +int32_t +br_scrubber_init(xlator_t *, br_private_t *); -int32_t br_collect_bad_objects_from_children (xlator_t *this, dict_t *dict); +int32_t +br_collect_bad_objects_from_children(xlator_t *this, dict_t *dict); void -br_child_set_scrub_state (br_child_t *, gf_boolean_t); +br_child_set_scrub_state(br_child_t *, gf_boolean_t); #endif /* __BIT_ROT_SCRUB_H__ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h index 8609477180b..f3fbe2928b7 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.h @@ -14,24 +14,25 @@ #include "xlator.h" typedef enum br_scrub_state { - BR_SCRUB_STATE_INACTIVE = 0, - BR_SCRUB_STATE_PENDING, - BR_SCRUB_STATE_ACTIVE, - BR_SCRUB_STATE_PAUSED, - BR_SCRUB_STATE_IPAUSED, - BR_SCRUB_STATE_STALLED, - BR_SCRUB_MAXSTATES, + BR_SCRUB_STATE_INACTIVE = 0, + BR_SCRUB_STATE_PENDING, + BR_SCRUB_STATE_ACTIVE, + BR_SCRUB_STATE_PAUSED, + BR_SCRUB_STATE_IPAUSED, + BR_SCRUB_STATE_STALLED, + BR_SCRUB_MAXSTATES, } br_scrub_state_t; typedef enum br_scrub_event { - BR_SCRUB_EVENT_SCHEDULE = 0, - BR_SCRUB_EVENT_PAUSE, - BR_SCRUB_EVENT_ONDEMAND, - BR_SCRUB_MAXEVENTS, + BR_SCRUB_EVENT_SCHEDULE = 0, + BR_SCRUB_EVENT_PAUSE, + BR_SCRUB_EVENT_ONDEMAND, + BR_SCRUB_MAXEVENTS, } br_scrub_event_t; struct br_monitor; -int32_t br_scrub_state_machine (xlator_t *, gf_boolean_t); +int32_t +br_scrub_state_machine(xlator_t *, gf_boolean_t); #endif /* __BIT_ROT_SSM_H__ */ diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h index 670060c8d88..962b4d717e6 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot.h @@ -37,271 +37,270 @@ #define BR_WORKERS 4 typedef enum scrub_throttle { - BR_SCRUB_THROTTLE_VOID = -1, - BR_SCRUB_THROTTLE_LAZY = 0, - BR_SCRUB_THROTTLE_NORMAL = 1, - BR_SCRUB_THROTTLE_AGGRESSIVE = 2, - BR_SCRUB_THROTTLE_STALLED = 3, + BR_SCRUB_THROTTLE_VOID = -1, + BR_SCRUB_THROTTLE_LAZY = 0, + BR_SCRUB_THROTTLE_NORMAL = 1, + BR_SCRUB_THROTTLE_AGGRESSIVE = 2, + BR_SCRUB_THROTTLE_STALLED = 3, } scrub_throttle_t; typedef enum scrub_freq { - BR_FSSCRUB_FREQ_HOURLY = 1, - BR_FSSCRUB_FREQ_DAILY, - BR_FSSCRUB_FREQ_WEEKLY, - BR_FSSCRUB_FREQ_BIWEEKLY, - BR_FSSCRUB_FREQ_MONTHLY, - BR_FSSCRUB_FREQ_MINUTE, - BR_FSSCRUB_FREQ_STALLED, + BR_FSSCRUB_FREQ_HOURLY = 1, + BR_FSSCRUB_FREQ_DAILY, + BR_FSSCRUB_FREQ_WEEKLY, + BR_FSSCRUB_FREQ_BIWEEKLY, + BR_FSSCRUB_FREQ_MONTHLY, + BR_FSSCRUB_FREQ_MINUTE, + BR_FSSCRUB_FREQ_STALLED, } scrub_freq_t; -#define signature_size(hl) (sizeof (br_isignature_t) + hl + 1) +#define signature_size(hl) (sizeof(br_isignature_t) + hl + 1) struct br_scanfs { - gf_lock_t entrylock; + gf_lock_t entrylock; - pthread_mutex_t waitlock; - pthread_cond_t waitcond; + pthread_mutex_t waitlock; + pthread_cond_t waitcond; - unsigned int entries; - struct list_head queued; - struct list_head ready; + unsigned int entries; + struct list_head queued; + struct list_head ready; }; /* just need three states to track child status */ typedef enum br_child_state { - BR_CHILD_STATE_CONNECTED = 1, - BR_CHILD_STATE_INITIALIZING, - BR_CHILD_STATE_CONNFAILED, - BR_CHILD_STATE_DISCONNECTED, + BR_CHILD_STATE_CONNECTED = 1, + BR_CHILD_STATE_INITIALIZING, + BR_CHILD_STATE_CONNFAILED, + BR_CHILD_STATE_DISCONNECTED, } br_child_state_t; struct br_child { - pthread_mutex_t lock; /* protects child state */ - char witnessed; /* witnessed at least one successful - connection */ - br_child_state_t c_state; /* current state of this child */ + pthread_mutex_t lock; /* protects child state */ + char witnessed; /* witnessed at least one successful + connection */ + br_child_state_t c_state; /* current state of this child */ - char child_up; /* Indicates whether this child is - up or not */ - xlator_t *xl; /* client xlator corresponding to - this child */ - inode_table_t *table; /* inode table for this child */ - char brick_path[PATH_MAX]; /* brick export directory of this - child */ - struct list_head list; /* hook to attach to the list of - UP children */ - xlator_t *this; /* Bit rot xlator */ + char child_up; /* Indicates whether this child is + up or not */ + xlator_t *xl; /* client xlator corresponding to + this child */ + inode_table_t *table; /* inode table for this child */ + char brick_path[PATH_MAX]; /* brick export directory of this + child */ + struct list_head list; /* hook to attach to the list of + UP children */ + xlator_t *this; /* Bit rot xlator */ - pthread_t thread; /* initial crawler for unsigned - object(s) or scrub crawler */ - int threadrunning; /* active thread */ + pthread_t thread; /* initial crawler for unsigned + object(s) or scrub crawler */ + int threadrunning; /* active thread */ - struct mem_pool *timer_pool; /* timer-wheel's timer mem-pool */ + struct mem_pool *timer_pool; /* timer-wheel's timer mem-pool */ - struct timeval tv; + struct timeval tv; - struct br_scanfs fsscan; /* per subvolume FS scanner */ + struct br_scanfs fsscan; /* per subvolume FS scanner */ - gf_boolean_t active_scrubbing; /* Actively scrubbing or not */ + gf_boolean_t active_scrubbing; /* Actively scrubbing or not */ }; typedef struct br_child br_child_t; struct br_obj_n_workers { - struct list_head objects; /* queue of objects expired from the - timer wheel and ready to be picked - up for signing */ - pthread_t workers[BR_WORKERS]; /* Threads which pick up the objects - from the above queue and start - signing each object */ + struct list_head objects; /* queue of objects expired from the + timer wheel and ready to be picked + up for signing */ + pthread_t workers[BR_WORKERS]; /* Threads which pick up the objects + from the above queue and start + signing each object */ }; struct br_scrubber { - xlator_t *this; + xlator_t *this; - scrub_throttle_t throttle; + scrub_throttle_t throttle; - /** - * frequency of scanning for this subvolume. this should - * normally be per-child, but since all children follow the - * same frequency for a volume, this option ends up here - * instead of br_child_t. - */ - scrub_freq_t frequency; + /** + * frequency of scanning for this subvolume. this should + * normally be per-child, but since all children follow the + * same frequency for a volume, this option ends up here + * instead of br_child_t. + */ + scrub_freq_t frequency; - gf_boolean_t frequency_reconf; - gf_boolean_t throttle_reconf; + gf_boolean_t frequency_reconf; + gf_boolean_t throttle_reconf; - pthread_mutex_t mutex; - pthread_cond_t cond; + pthread_mutex_t mutex; + pthread_cond_t cond; - unsigned int nr_scrubbers; - struct list_head scrubbers; + unsigned int nr_scrubbers; + struct list_head scrubbers; - /** - * list of "rotatable" subvolume(s) undergoing scrubbing - */ - struct list_head scrublist; + /** + * list of "rotatable" subvolume(s) undergoing scrubbing + */ + struct list_head scrublist; }; struct br_monitor { - gf_lock_t lock; - pthread_t thread; /* Monitor thread */ - - gf_boolean_t inited; - pthread_mutex_t mutex; - pthread_cond_t cond; /* Thread starts and will be waiting on cond. - First child which is up wakes this up */ - - xlator_t *this; - /* scheduler */ - uint32_t boot; - - int32_t active_child_count; /* Number of children currently scrubbing */ - gf_boolean_t kick; /* This variable tracks the scrubber is - * kicked or not. Both 'kick' and - * 'active_child_count' uses the same pair - * of mutex-cond variable, i.e, wakelock and - * wakecond. */ - - pthread_mutex_t wakelock; - pthread_cond_t wakecond; - - gf_boolean_t done; - pthread_mutex_t donelock; - pthread_cond_t donecond; - - struct gf_tw_timer_list *timer; - br_scrub_state_t state; /* current scrub state */ + gf_lock_t lock; + pthread_t thread; /* Monitor thread */ + + gf_boolean_t inited; + pthread_mutex_t mutex; + pthread_cond_t cond; /* Thread starts and will be waiting on cond. + First child which is up wakes this up */ + + xlator_t *this; + /* scheduler */ + uint32_t boot; + + int32_t active_child_count; /* Number of children currently scrubbing */ + gf_boolean_t kick; /* This variable tracks the scrubber is + * kicked or not. Both 'kick' and + * 'active_child_count' uses the same pair + * of mutex-cond variable, i.e, wakelock and + * wakecond. */ + + pthread_mutex_t wakelock; + pthread_cond_t wakecond; + + gf_boolean_t done; + pthread_mutex_t donelock; + pthread_cond_t donecond; + + struct gf_tw_timer_list *timer; + br_scrub_state_t state; /* current scrub state */ }; typedef struct br_obj_n_workers br_obj_n_workers_t; typedef struct br_private br_private_t; -typedef void (*br_scrubbed_file_update) (br_private_t *priv); +typedef void (*br_scrubbed_file_update)(br_private_t *priv); struct br_private { - pthread_mutex_t lock; + pthread_mutex_t lock; - struct list_head bricks; /* list of bricks from which enents - have been received */ + struct list_head bricks; /* list of bricks from which enents + have been received */ - struct list_head signing; + struct list_head signing; - pthread_cond_t object_cond; /* handling signing of objects */ - int child_count; - br_child_t *children; /* list of subvolumes */ - int up_children; + pthread_cond_t object_cond; /* handling signing of objects */ + int child_count; + br_child_t *children; /* list of subvolumes */ + int up_children; - pthread_cond_t cond; /* handling CHILD_UP notifications */ - pthread_t thread; /* thread for connecting each UP - child with changelog */ + pthread_cond_t cond; /* handling CHILD_UP notifications */ + pthread_t thread; /* thread for connecting each UP + child with changelog */ - struct tvec_base *timer_wheel; /* timer wheel where the objects which - changelog has sent sits and waits - for expiry */ - br_obj_n_workers_t *obj_queue; /* place holder for all the objects - that are expired from timer wheel - and ready to be picked up for - signing and the workers which sign - the objects */ + struct tvec_base *timer_wheel; /* timer wheel where the objects which + changelog has sent sits and waits + for expiry */ + br_obj_n_workers_t *obj_queue; /* place holder for all the objects + that are expired from timer wheel + and ready to be picked up for + signing and the workers which sign + the objects */ - uint32_t expiry_time; /* objects "wait" time */ + uint32_t expiry_time; /* objects "wait" time */ - tbf_t *tbf; /* token bucket filter */ + tbf_t *tbf; /* token bucket filter */ - gf_boolean_t iamscrubber; /* function as a fs scrubber */ + gf_boolean_t iamscrubber; /* function as a fs scrubber */ - struct br_scrub_stats scrub_stat; /* statistics of scrub*/ + struct br_scrub_stats scrub_stat; /* statistics of scrub*/ - struct br_scrubber fsscrub; /* scrubbers for this subvolume */ + struct br_scrubber fsscrub; /* scrubbers for this subvolume */ - struct br_monitor scrub_monitor; /* scrubber monitor */ + struct br_monitor scrub_monitor; /* scrubber monitor */ }; struct br_object { - xlator_t *this; + xlator_t *this; - uuid_t gfid; + uuid_t gfid; - unsigned long signedversion; /* version against which this object will - be signed */ - br_child_t *child; /* object's subvolume */ + unsigned long signedversion; /* version against which this object will + be signed */ + br_child_t *child; /* object's subvolume */ - int sign_info; + int sign_info; - struct list_head list; /* hook to add to the queue once the - object is expired from timer wheel */ - void *data; + struct list_head list; /* hook to add to the queue once the + object is expired from timer wheel */ + void *data; }; typedef struct br_object br_object_t; -typedef int32_t (br_scrub_ssm_call) (xlator_t *); +typedef int32_t(br_scrub_ssm_call)(xlator_t *); void -br_log_object (xlator_t *, char *, uuid_t, int32_t); +br_log_object(xlator_t *, char *, uuid_t, int32_t); void -br_log_object_path (xlator_t *, char *, const char *, int32_t); +br_log_object_path(xlator_t *, char *, const char *, int32_t); int32_t -br_calculate_obj_checksum (unsigned char *, - br_child_t *, fd_t *, struct iatt *); +br_calculate_obj_checksum(unsigned char *, br_child_t *, fd_t *, struct iatt *); int32_t -br_prepare_loc (xlator_t *, br_child_t *, loc_t *, gf_dirent_t *, loc_t *); +br_prepare_loc(xlator_t *, br_child_t *, loc_t *, gf_dirent_t *, loc_t *); gf_boolean_t -bitd_is_bad_file (xlator_t *, br_child_t *, loc_t *, fd_t *); +bitd_is_bad_file(xlator_t *, br_child_t *, loc_t *, fd_t *); static inline void -_br_set_child_state (br_child_t *child, br_child_state_t state) +_br_set_child_state(br_child_t *child, br_child_state_t state) { - child->c_state = state; + child->c_state = state; } static inline int -_br_is_child_connected (br_child_t *child) +_br_is_child_connected(br_child_t *child) { - return (child->c_state == BR_CHILD_STATE_CONNECTED); + return (child->c_state == BR_CHILD_STATE_CONNECTED); } static inline int -_br_is_child_scrub_active (br_child_t *child) +_br_is_child_scrub_active(br_child_t *child) { - return child->active_scrubbing; + return child->active_scrubbing; } static inline int -_br_child_failed_conn (br_child_t *child) +_br_child_failed_conn(br_child_t *child) { - return (child->c_state == BR_CHILD_STATE_CONNFAILED); + return (child->c_state == BR_CHILD_STATE_CONNFAILED); } static inline int -_br_child_witnessed_connection (br_child_t *child) +_br_child_witnessed_connection(br_child_t *child) { - return (child->witnessed == 1); + return (child->witnessed == 1); } /* scrub state */ static inline void -_br_monitor_set_scrub_state (struct br_monitor *scrub_monitor, - br_scrub_state_t state) +_br_monitor_set_scrub_state(struct br_monitor *scrub_monitor, + br_scrub_state_t state) { - scrub_monitor->state = state; + scrub_monitor->state = state; } static inline br_scrub_event_t -_br_child_get_scrub_event (struct br_scrubber *fsscrub) +_br_child_get_scrub_event(struct br_scrubber *fsscrub) { - return (fsscrub->frequency == BR_FSSCRUB_FREQ_STALLED) - ? BR_SCRUB_EVENT_PAUSE : BR_SCRUB_EVENT_SCHEDULE; + return (fsscrub->frequency == BR_FSSCRUB_FREQ_STALLED) + ? BR_SCRUB_EVENT_PAUSE + : BR_SCRUB_EVENT_SCHEDULE; } int32_t -br_get_bad_objects_list (xlator_t *this, dict_t **dict); - +br_get_bad_objects_list(xlator_t *this, dict_t **dict); #endif /* __BIT_ROT_H__ */ diff --git a/xlators/features/bit-rot/src/stub/bit-rot-common.h b/xlators/features/bit-rot/src/stub/bit-rot-common.h index 2afc9f47c29..ef683ac7f9f 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-common.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-common.h @@ -14,71 +14,71 @@ #include "glusterfs.h" #include "bit-rot-object-version.h" -#define BR_VXATTR_VERSION (1 << 0) +#define BR_VXATTR_VERSION (1 << 0) #define BR_VXATTR_SIGNATURE (1 << 1) #define BR_VXATTR_SIGN_MISSING (BR_VXATTR_SIGNATURE) -#define BR_VXATTR_ALL_MISSING \ - (BR_VXATTR_VERSION | BR_VXATTR_SIGNATURE) +#define BR_VXATTR_ALL_MISSING (BR_VXATTR_VERSION | BR_VXATTR_SIGNATURE) -#define BR_BAD_OBJ_CONTAINER (uuid_t){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8} +#define BR_BAD_OBJ_CONTAINER \ + (uuid_t) { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8 } typedef enum br_vxattr_state { - BR_VXATTR_STATUS_FULL = 0, - BR_VXATTR_STATUS_MISSING = 1, - BR_VXATTR_STATUS_UNSIGNED = 2, - BR_VXATTR_STATUS_INVALID = 3, + BR_VXATTR_STATUS_FULL = 0, + BR_VXATTR_STATUS_MISSING = 1, + BR_VXATTR_STATUS_UNSIGNED = 2, + BR_VXATTR_STATUS_INVALID = 3, } br_vxattr_status_t; typedef enum br_sign_state { - BR_SIGN_INVALID = -1, - BR_SIGN_NORMAL = 0, - BR_SIGN_REOPEN_WAIT = 1, - BR_SIGN_QUICK = 2, + BR_SIGN_INVALID = -1, + BR_SIGN_NORMAL = 0, + BR_SIGN_REOPEN_WAIT = 1, + BR_SIGN_QUICK = 2, } br_sign_state_t; static inline br_vxattr_status_t -br_version_xattr_state (dict_t *xattr, br_version_t **obuf, - br_signature_t **sbuf, gf_boolean_t *objbad) +br_version_xattr_state(dict_t *xattr, br_version_t **obuf, + br_signature_t **sbuf, gf_boolean_t *objbad) { - int32_t ret = 0; - int32_t vxattr = 0; - br_vxattr_status_t status; - void *data = NULL; - - /** - * The key being present in the dict indicates the xattr was set on - * disk. The presence of xattr itself as of now is suffecient to say - * the the object is bad. - */ - *objbad = _gf_false; - ret = dict_get_bin (xattr, BITROT_OBJECT_BAD_KEY, (void **)&data); - if (!ret) - *objbad = _gf_true; - - ret = dict_get_bin (xattr, BITROT_CURRENT_VERSION_KEY, (void **)obuf); - if (ret) - vxattr |= BR_VXATTR_VERSION; - - ret = dict_get_bin (xattr, BITROT_SIGNING_VERSION_KEY, (void **)sbuf); - if (ret) - vxattr |= BR_VXATTR_SIGNATURE; - - switch (vxattr) { + int32_t ret = 0; + int32_t vxattr = 0; + br_vxattr_status_t status; + void *data = NULL; + + /** + * The key being present in the dict indicates the xattr was set on + * disk. The presence of xattr itself as of now is suffecient to say + * the the object is bad. + */ + *objbad = _gf_false; + ret = dict_get_bin(xattr, BITROT_OBJECT_BAD_KEY, (void **)&data); + if (!ret) + *objbad = _gf_true; + + ret = dict_get_bin(xattr, BITROT_CURRENT_VERSION_KEY, (void **)obuf); + if (ret) + vxattr |= BR_VXATTR_VERSION; + + ret = dict_get_bin(xattr, BITROT_SIGNING_VERSION_KEY, (void **)sbuf); + if (ret) + vxattr |= BR_VXATTR_SIGNATURE; + + switch (vxattr) { case 0: - status = BR_VXATTR_STATUS_FULL; - break; + status = BR_VXATTR_STATUS_FULL; + break; case BR_VXATTR_SIGN_MISSING: - status = BR_VXATTR_STATUS_UNSIGNED; - break; + status = BR_VXATTR_STATUS_UNSIGNED; + break; case BR_VXATTR_ALL_MISSING: - status = BR_VXATTR_STATUS_MISSING; - break; + status = BR_VXATTR_STATUS_MISSING; + break; default: - status = BR_VXATTR_STATUS_INVALID; - } + status = BR_VXATTR_STATUS_INVALID; + } - return status; + return status; } /** @@ -86,13 +86,13 @@ br_version_xattr_state (dict_t *xattr, br_version_t **obuf, * signing. */ typedef struct br_isignature_in { - int8_t signaturetype; /* signature type */ + int8_t signaturetype; /* signature type */ - unsigned long signedversion; /* version against which the - object was signed */ + unsigned long signedversion; /* version against which the + object was signed */ - size_t signaturelen; /* signature length */ - char signature[0]; /* object signature */ + size_t signaturelen; /* signature length */ + char signature[0]; /* object signature */ } br_isignature_t; /** @@ -100,80 +100,79 @@ typedef struct br_isignature_in { * verification. */ typedef struct br_isignature_out { - char stale; /* stale signature? */ + char stale; /* stale signature? */ - unsigned long version; /* current signed version */ + unsigned long version; /* current signed version */ - uint32_t time[2]; /* time when the object - got dirtied */ + uint32_t time[2]; /* time when the object + got dirtied */ - int8_t signaturetype; /* hash type */ - size_t signaturelen; /* signature length */ - char signature[0]; /* signature (hash) */ + int8_t signaturetype; /* hash type */ + size_t signaturelen; /* signature length */ + char signature[0]; /* signature (hash) */ } br_isignature_out_t; typedef struct br_stub_init { - uint32_t timebuf[2]; - char export[PATH_MAX]; + uint32_t timebuf[2]; + char export[PATH_MAX]; } br_stub_init_t; typedef enum { - BR_SIGNATURE_TYPE_VOID = -1, /* object is not signed */ - BR_SIGNATURE_TYPE_ZERO = 0, /* min boundary */ - BR_SIGNATURE_TYPE_SHA256 = 1, /* signed with SHA256 */ - BR_SIGNATURE_TYPE_MAX = 2, /* max boundary */ + BR_SIGNATURE_TYPE_VOID = -1, /* object is not signed */ + BR_SIGNATURE_TYPE_ZERO = 0, /* min boundary */ + BR_SIGNATURE_TYPE_SHA256 = 1, /* signed with SHA256 */ + BR_SIGNATURE_TYPE_MAX = 2, /* max boundary */ } br_signature_type; /* BitRot stub start time (virtual xattr) */ -#define GLUSTERFS_GET_BR_STUB_INIT_TIME "trusted.glusterfs.bit-rot.stub-init" +#define GLUSTERFS_GET_BR_STUB_INIT_TIME "trusted.glusterfs.bit-rot.stub-init" /* signing/reopen hint */ #define BR_OBJECT_RESIGN 0 -#define BR_OBJECT_REOPEN 1 -#define BR_REOPEN_SIGN_HINT_KEY "trusted.glusterfs.bit-rot.reopen-hint" +#define BR_OBJECT_REOPEN 1 +#define BR_REOPEN_SIGN_HINT_KEY "trusted.glusterfs.bit-rot.reopen-hint" static inline int -br_is_signature_type_valid (int8_t signaturetype) +br_is_signature_type_valid(int8_t signaturetype) { - return ((signaturetype > BR_SIGNATURE_TYPE_ZERO) - && (signaturetype < BR_SIGNATURE_TYPE_MAX)); + return ((signaturetype > BR_SIGNATURE_TYPE_ZERO) && + (signaturetype < BR_SIGNATURE_TYPE_MAX)); } static inline void -br_set_default_ongoingversion (br_version_t *buf, uint32_t *tv) +br_set_default_ongoingversion(br_version_t *buf, uint32_t *tv) { - buf->ongoingversion = BITROT_DEFAULT_CURRENT_VERSION; - buf->timebuf[0] = tv[0]; - buf->timebuf[1] = tv[1]; + buf->ongoingversion = BITROT_DEFAULT_CURRENT_VERSION; + buf->timebuf[0] = tv[0]; + buf->timebuf[1] = tv[1]; } static inline void -br_set_default_signature (br_signature_t *buf, size_t *size) +br_set_default_signature(br_signature_t *buf, size_t *size) { - buf->signaturetype = (int8_t) BR_SIGNATURE_TYPE_VOID; - buf->signedversion = BITROT_DEFAULT_SIGNING_VERSION; + buf->signaturetype = (int8_t)BR_SIGNATURE_TYPE_VOID; + buf->signedversion = BITROT_DEFAULT_SIGNING_VERSION; - *size = sizeof (br_signature_t); /* no signature */ + *size = sizeof(br_signature_t); /* no signature */ } static inline void -br_set_ongoingversion (br_version_t *buf, - unsigned long version, uint32_t *tv) +br_set_ongoingversion(br_version_t *buf, unsigned long version, uint32_t *tv) { - buf->ongoingversion = version; - buf->timebuf[0] = tv[0]; - buf->timebuf[1] = tv[1]; + buf->ongoingversion = version; + buf->timebuf[0] = tv[0]; + buf->timebuf[1] = tv[1]; } static inline void -br_set_signature (br_signature_t *buf, - br_isignature_t *sign, size_t signaturelen, size_t *size) +br_set_signature(br_signature_t *buf, br_isignature_t *sign, + size_t signaturelen, size_t *size) { - buf->signaturetype = sign->signaturetype; - buf->signedversion = ntohl (sign->signedversion); + buf->signaturetype = sign->signaturetype; + buf->signedversion = ntohl(sign->signedversion); - memcpy (buf->signature, sign->signature, signaturelen); - *size = sizeof (br_signature_t) + signaturelen; + memcpy(buf->signature, sign->signature, signaturelen); + *size = sizeof(br_signature_t) + signaturelen; } #endif /* __BIT_ROT_COMMON_H__ */ diff --git a/xlators/features/bit-rot/src/stub/bit-rot-object-version.h b/xlators/features/bit-rot/src/stub/bit-rot-object-version.h index 1f2497aebe9..7ae6a5200df 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-object-version.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-object-version.h @@ -15,16 +15,16 @@ * on-disk formats for ongoing version and object signature. */ typedef struct br_version { - unsigned long ongoingversion; - uint32_t timebuf[2]; + unsigned long ongoingversion; + uint32_t timebuf[2]; } br_version_t; -typedef struct __attribute__ ((__packed__)) br_signature { - int8_t signaturetype; +typedef struct __attribute__((__packed__)) br_signature { + int8_t signaturetype; - unsigned long signedversion; + unsigned long signedversion; - char signature[0]; + char signature[0]; } br_signature_t; #endif diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h index 1652a3ebf8d..a3e7b03291e 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-mem-types.h @@ -14,22 +14,22 @@ #include "mem-types.h" enum br_mem_types { - gf_br_stub_mt_private_t = gf_common_mt_end + 1, - gf_br_stub_mt_version_t, - gf_br_stub_mt_inode_ctx_t, - gf_br_stub_mt_signature_t, - gf_br_mt_br_private_t, - gf_br_mt_br_child_t, - gf_br_mt_br_object_t, - gf_br_mt_br_ob_n_wk_t, - gf_br_mt_br_scrubber_t, - gf_br_mt_br_fsscan_entry_t, - gf_br_stub_mt_br_stub_fd_t, - gf_br_stub_mt_br_scanner_freq_t, - gf_br_stub_mt_sigstub_t, - gf_br_mt_br_child_event_t, - gf_br_stub_mt_misc, - gf_br_stub_mt_end, + gf_br_stub_mt_private_t = gf_common_mt_end + 1, + gf_br_stub_mt_version_t, + gf_br_stub_mt_inode_ctx_t, + gf_br_stub_mt_signature_t, + gf_br_mt_br_private_t, + gf_br_mt_br_child_t, + gf_br_mt_br_object_t, + gf_br_mt_br_ob_n_wk_t, + gf_br_mt_br_scrubber_t, + gf_br_mt_br_fsscan_entry_t, + gf_br_stub_mt_br_stub_fd_t, + gf_br_stub_mt_br_scanner_freq_t, + gf_br_stub_mt_sigstub_t, + gf_br_mt_br_child_event_t, + gf_br_stub_mt_misc, + gf_br_stub_mt_end, }; #endif diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h index 2ade4f03997..cccc3b9c599 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub-messages.h @@ -23,40 +23,22 @@ * glfs-message-id.h. */ -GLFS_MSGID(BITROT_STUB, - BRS_MSG_NO_MEMORY, - BRS_MSG_SET_EVENT_FAILED, - BRS_MSG_MEM_ACNT_FAILED, - BRS_MSG_CREATE_FRAME_FAILED, - BRS_MSG_SET_CONTEXT_FAILED, - BRS_MSG_CHANGE_VERSION_FAILED, - BRS_MSG_ADD_FD_TO_LIST_FAILED, - BRS_MSG_SET_FD_CONTEXT_FAILED, - BRS_MSG_CREATE_ANONYMOUS_FD_FAILED, - BRS_MSG_NO_CHILD, - BRS_MSG_STUB_ALLOC_FAILED, - BRS_MSG_GET_INODE_CONTEXT_FAILED, - BRS_MSG_CANCEL_SIGN_THREAD_FAILED, - BRS_MSG_ADD_FD_TO_INODE, - BRS_MSG_SIGN_VERSION_ERROR, - BRS_MSG_BAD_OBJ_MARK_FAIL, - BRS_MSG_NON_SCRUB_BAD_OBJ_MARK, - BRS_MSG_REMOVE_INTERNAL_XATTR, - BRS_MSG_SET_INTERNAL_XATTR, - BRS_MSG_BAD_OBJECT_ACCESS, - BRS_MSG_BAD_CONTAINER_FAIL, - BRS_MSG_BAD_OBJECT_DIR_FAIL, - BRS_MSG_BAD_OBJECT_DIR_SEEK_FAIL, - BRS_MSG_BAD_OBJECT_DIR_TELL_FAIL, - BRS_MSG_BAD_OBJECT_DIR_READ_FAIL, - BRS_MSG_GET_FD_CONTEXT_FAILED, - BRS_MSG_BAD_HANDLE_DIR_NULL, - BRS_MSG_BAD_OBJ_THREAD_FAIL, - BRS_MSG_BAD_OBJ_DIR_CLOSE_FAIL, - BRS_MSG_LINK_FAIL, - BRS_MSG_BAD_OBJ_UNLINK_FAIL, - BRS_MSG_DICT_SET_FAILED, - BRS_MSG_PATH_GET_FAILED -); +GLFS_MSGID(BITROT_STUB, BRS_MSG_NO_MEMORY, BRS_MSG_SET_EVENT_FAILED, + BRS_MSG_MEM_ACNT_FAILED, BRS_MSG_CREATE_FRAME_FAILED, + BRS_MSG_SET_CONTEXT_FAILED, BRS_MSG_CHANGE_VERSION_FAILED, + BRS_MSG_ADD_FD_TO_LIST_FAILED, BRS_MSG_SET_FD_CONTEXT_FAILED, + BRS_MSG_CREATE_ANONYMOUS_FD_FAILED, BRS_MSG_NO_CHILD, + BRS_MSG_STUB_ALLOC_FAILED, BRS_MSG_GET_INODE_CONTEXT_FAILED, + BRS_MSG_CANCEL_SIGN_THREAD_FAILED, BRS_MSG_ADD_FD_TO_INODE, + BRS_MSG_SIGN_VERSION_ERROR, BRS_MSG_BAD_OBJ_MARK_FAIL, + BRS_MSG_NON_SCRUB_BAD_OBJ_MARK, BRS_MSG_REMOVE_INTERNAL_XATTR, + BRS_MSG_SET_INTERNAL_XATTR, BRS_MSG_BAD_OBJECT_ACCESS, + BRS_MSG_BAD_CONTAINER_FAIL, BRS_MSG_BAD_OBJECT_DIR_FAIL, + BRS_MSG_BAD_OBJECT_DIR_SEEK_FAIL, BRS_MSG_BAD_OBJECT_DIR_TELL_FAIL, + BRS_MSG_BAD_OBJECT_DIR_READ_FAIL, BRS_MSG_GET_FD_CONTEXT_FAILED, + BRS_MSG_BAD_HANDLE_DIR_NULL, BRS_MSG_BAD_OBJ_THREAD_FAIL, + BRS_MSG_BAD_OBJ_DIR_CLOSE_FAIL, BRS_MSG_LINK_FAIL, + BRS_MSG_BAD_OBJ_UNLINK_FAIL, BRS_MSG_DICT_SET_FAILED, + BRS_MSG_PATH_GET_FAILED); #endif /* !_BITROT_STUB_MESSAGES_H_ */ diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h index e15f1cecbc0..a15667e323a 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h @@ -1,11 +1,11 @@ - /* - Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. +/* + Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef __BIT_ROT_STUB_H__ #define __BIT_ROT_STUB_H__ @@ -25,305 +25,302 @@ #include "syncop.h" #include "syncop-utils.h" -#define BAD_OBJECT_THREAD_STACK_SIZE ((size_t)(1024*1024)) +#define BAD_OBJECT_THREAD_STACK_SIZE ((size_t)(1024 * 1024)) #define BR_STUB_DUMP_STR_SIZE 65536 -#define BR_PATH_MAX_EXTRA (PATH_MAX+1024) -#define BR_PATH_MAX_PLUS (PATH_MAX+2048) +#define BR_PATH_MAX_EXTRA (PATH_MAX + 1024) +#define BR_PATH_MAX_PLUS (PATH_MAX + 2048) /* * Oops. Spelling mistake. Correcting it */ -#define OLD_BR_STUB_QUARANTINE_DIR GF_HIDDEN_PATH"/quanrantine" -#define BR_STUB_QUARANTINE_DIR GF_HIDDEN_PATH"/quarantine" +#define OLD_BR_STUB_QUARANTINE_DIR GF_HIDDEN_PATH "/quanrantine" +#define BR_STUB_QUARANTINE_DIR GF_HIDDEN_PATH "/quarantine" /* do not reference frame->local in cbk unless initialized. * Assigned 0x1 marks verisoning flag between call path and * cbk path. */ -#define BR_STUB_VER_NOT_ACTIVE_THEN_GOTO(frame, priv, label) do { \ - if (priv->do_versioning) \ - frame->local = (void *)0x1; \ - else \ - goto label; \ - } while (0) - -#define BR_STUB_VER_COND_GOTO(priv, cond, label) do { \ - if (!priv->do_versioning || cond) \ - goto label; \ - } while (0) - -#define BR_STUB_VER_ENABLED_IN_CALLPATH(frame, flag) do { \ - if (frame->local) \ - flag = _gf_true; \ - if (frame->local == (void *) 0x1) \ - frame->local = NULL; \ - } while (0) - -#define BR_STUB_RESET_LOCAL_NULL(frame) do { \ - if (frame->local == (void *)0x1) \ - frame->local = NULL; \ - } while (0) - -typedef int (br_stub_version_cbk) (call_frame_t *, void *, - xlator_t *, int32_t, int32_t, dict_t *); +#define BR_STUB_VER_NOT_ACTIVE_THEN_GOTO(frame, priv, label) \ + do { \ + if (priv->do_versioning) \ + frame->local = (void *)0x1; \ + else \ + goto label; \ + } while (0) + +#define BR_STUB_VER_COND_GOTO(priv, cond, label) \ + do { \ + if (!priv->do_versioning || cond) \ + goto label; \ + } while (0) + +#define BR_STUB_VER_ENABLED_IN_CALLPATH(frame, flag) \ + do { \ + if (frame->local) \ + flag = _gf_true; \ + if (frame->local == (void *)0x1) \ + frame->local = NULL; \ + } while (0) + +#define BR_STUB_RESET_LOCAL_NULL(frame) \ + do { \ + if (frame->local == (void *)0x1) \ + frame->local = NULL; \ + } while (0) + +typedef int(br_stub_version_cbk)(call_frame_t *, void *, xlator_t *, int32_t, + int32_t, dict_t *); typedef struct br_stub_inode_ctx { - int need_writeback; /* does the inode need - a writeback to disk? */ - unsigned long currentversion; /* ongoing version */ - - int info_sign; - struct list_head fd_list; /* list of open fds or fds participating in - write operations */ - gf_boolean_t bad_object; + int need_writeback; /* does the inode need + a writeback to disk? */ + unsigned long currentversion; /* ongoing version */ + + int info_sign; + struct list_head fd_list; /* list of open fds or fds participating in + write operations */ + gf_boolean_t bad_object; } br_stub_inode_ctx_t; typedef struct br_stub_fd { - fd_t *fd; - struct list_head list; - struct bad_object_dir { - DIR *dir; - off_t dir_eof; - } bad_object; + fd_t *fd; + struct list_head list; + struct bad_object_dir { + DIR *dir; + off_t dir_eof; + } bad_object; } br_stub_fd_t; -#define I_DIRTY (1<<0) /* inode needs writeback */ -#define I_MODIFIED (1<<1) -#define WRITEBACK_DURABLE 1 /* writeback is durable */ +#define I_DIRTY (1 << 0) /* inode needs writeback */ +#define I_MODIFIED (1 << 1) +#define WRITEBACK_DURABLE 1 /* writeback is durable */ /** * This could just have been a plain struct without unions and all, * but we may need additional things in the future. */ typedef struct br_stub_local { - call_stub_t *fopstub; /* stub for original fop */ - - int versioningtype; /* not much used atm */ - - union { - struct br_stub_ctx { - fd_t *fd; - uuid_t gfid; - inode_t *inode; - unsigned long version; - } context; - } u; + call_stub_t *fopstub; /* stub for original fop */ + + int versioningtype; /* not much used atm */ + + union { + struct br_stub_ctx { + fd_t *fd; + uuid_t gfid; + inode_t *inode; + unsigned long version; + } context; + } u; } br_stub_local_t; #define BR_STUB_NO_VERSIONING (1 << 0) #define BR_STUB_INCREMENTAL_VERSIONING (1 << 1) typedef struct br_stub_private { - gf_boolean_t do_versioning; + gf_boolean_t do_versioning; - uint32_t boot[2]; - char export[PATH_MAX]; + uint32_t boot[2]; + char export[PATH_MAX]; - pthread_mutex_t lock; - pthread_cond_t cond; + pthread_mutex_t lock; + pthread_cond_t cond; - struct list_head squeue; /* ordered signing queue */ - pthread_t signth; - struct bad_objects_container { - pthread_t thread; - pthread_mutex_t bad_lock; - pthread_cond_t bad_cond; - struct list_head bad_queue; - } container; - struct mem_pool *local_pool; + struct list_head squeue; /* ordered signing queue */ + pthread_t signth; + struct bad_objects_container { + pthread_t thread; + pthread_mutex_t bad_lock; + pthread_cond_t bad_cond; + struct list_head bad_queue; + } container; + struct mem_pool *local_pool; - char stub_basepath[BR_PATH_MAX_EXTRA]; + char stub_basepath[BR_PATH_MAX_EXTRA]; - uuid_t bad_object_dir_gfid; + uuid_t bad_object_dir_gfid; } br_stub_private_t; br_stub_fd_t * -br_stub_fd_new (void); - +br_stub_fd_new(void); int -__br_stub_fd_ctx_set (xlator_t *this, fd_t *fd, br_stub_fd_t *br_stub_fd); +__br_stub_fd_ctx_set(xlator_t *this, fd_t *fd, br_stub_fd_t *br_stub_fd); br_stub_fd_t * -__br_stub_fd_ctx_get (xlator_t *this, fd_t *fd); +__br_stub_fd_ctx_get(xlator_t *this, fd_t *fd); br_stub_fd_t * -br_stub_fd_ctx_get (xlator_t *this, fd_t *fd); +br_stub_fd_ctx_get(xlator_t *this, fd_t *fd); int32_t -br_stub_fd_ctx_set (xlator_t *this, fd_t *fd, br_stub_fd_t *br_stub_fd); +br_stub_fd_ctx_set(xlator_t *this, fd_t *fd, br_stub_fd_t *br_stub_fd); static inline gf_boolean_t -__br_stub_is_bad_object (br_stub_inode_ctx_t *ctx) +__br_stub_is_bad_object(br_stub_inode_ctx_t *ctx) { - return ctx->bad_object; + return ctx->bad_object; } static inline void -__br_stub_mark_object_bad (br_stub_inode_ctx_t *ctx) +__br_stub_mark_object_bad(br_stub_inode_ctx_t *ctx) { - ctx->bad_object = _gf_true; + ctx->bad_object = _gf_true; } /* inode writeback helpers */ static inline void -__br_stub_mark_inode_dirty (br_stub_inode_ctx_t *ctx) +__br_stub_mark_inode_dirty(br_stub_inode_ctx_t *ctx) { - ctx->need_writeback |= I_DIRTY; + ctx->need_writeback |= I_DIRTY; } static inline void -__br_stub_mark_inode_synced (br_stub_inode_ctx_t *ctx) +__br_stub_mark_inode_synced(br_stub_inode_ctx_t *ctx) { - ctx->need_writeback &= ~I_DIRTY; + ctx->need_writeback &= ~I_DIRTY; } static inline int -__br_stub_is_inode_dirty (br_stub_inode_ctx_t *ctx) +__br_stub_is_inode_dirty(br_stub_inode_ctx_t *ctx) { - return (ctx->need_writeback & I_DIRTY); + return (ctx->need_writeback & I_DIRTY); } /* inode mofification markers */ static inline void -__br_stub_set_inode_modified (br_stub_inode_ctx_t *ctx) +__br_stub_set_inode_modified(br_stub_inode_ctx_t *ctx) { - ctx->need_writeback |= I_MODIFIED; + ctx->need_writeback |= I_MODIFIED; } static inline void -__br_stub_unset_inode_modified (br_stub_inode_ctx_t *ctx) +__br_stub_unset_inode_modified(br_stub_inode_ctx_t *ctx) { - ctx->need_writeback &= ~I_MODIFIED; + ctx->need_writeback &= ~I_MODIFIED; } static inline int -__br_stub_is_inode_modified (br_stub_inode_ctx_t *ctx) +__br_stub_is_inode_modified(br_stub_inode_ctx_t *ctx) { - return (ctx->need_writeback & I_MODIFIED); + return (ctx->need_writeback & I_MODIFIED); } - static inline int -br_stub_require_release_call (xlator_t *this, fd_t *fd, br_stub_fd_t **fd_ctx) +br_stub_require_release_call(xlator_t *this, fd_t *fd, br_stub_fd_t **fd_ctx) { - int32_t ret = 0; - br_stub_fd_t *br_stub_fd = NULL; + int32_t ret = 0; + br_stub_fd_t *br_stub_fd = NULL; - br_stub_fd = br_stub_fd_new (); - if (!br_stub_fd) - return -1; + br_stub_fd = br_stub_fd_new(); + if (!br_stub_fd) + return -1; - br_stub_fd->fd = fd; - INIT_LIST_HEAD (&br_stub_fd->list); + br_stub_fd->fd = fd; + INIT_LIST_HEAD(&br_stub_fd->list); - ret = br_stub_fd_ctx_set (this, fd, br_stub_fd); - if (ret) - gf_msg (this->name, GF_LOG_WARNING, 0, - BRS_MSG_SET_CONTEXT_FAILED, - "could not set fd context (for release callback"); - else - *fd_ctx = br_stub_fd; + ret = br_stub_fd_ctx_set(this, fd, br_stub_fd); + if (ret) + gf_msg(this->name, GF_LOG_WARNING, 0, BRS_MSG_SET_CONTEXT_FAILED, + "could not set fd context (for release callback"); + else + *fd_ctx = br_stub_fd; - return ret; + return ret; } /* get/set inode context helpers */ static inline int -__br_stub_get_inode_ctx (xlator_t *this, - inode_t *inode, uint64_t *ctx) +__br_stub_get_inode_ctx(xlator_t *this, inode_t *inode, uint64_t *ctx) { - return __inode_ctx_get (inode, this, ctx); + return __inode_ctx_get(inode, this, ctx); } static inline int -br_stub_get_inode_ctx (xlator_t *this, - inode_t *inode, uint64_t *ctx) +br_stub_get_inode_ctx(xlator_t *this, inode_t *inode, uint64_t *ctx) { - int ret = -1; + int ret = -1; - LOCK (&inode->lock); - { - ret = __br_stub_get_inode_ctx (this, inode, ctx); - } - UNLOCK (&inode->lock); + LOCK(&inode->lock); + { + ret = __br_stub_get_inode_ctx(this, inode, ctx); + } + UNLOCK(&inode->lock); - return ret; + return ret; } static inline int -br_stub_set_inode_ctx (xlator_t *this, - inode_t *inode, br_stub_inode_ctx_t *ctx) +br_stub_set_inode_ctx(xlator_t *this, inode_t *inode, br_stub_inode_ctx_t *ctx) { - uint64_t ctx_addr = (uint64_t) ctx; - return inode_ctx_set (inode, this, &ctx_addr); + uint64_t ctx_addr = (uint64_t)ctx; + return inode_ctx_set(inode, this, &ctx_addr); } /* version get/set helpers */ static inline unsigned long -__br_stub_writeback_version (br_stub_inode_ctx_t *ctx) +__br_stub_writeback_version(br_stub_inode_ctx_t *ctx) { - return (ctx->currentversion + 1); + return (ctx->currentversion + 1); } static inline void -__br_stub_set_ongoing_version (br_stub_inode_ctx_t *ctx, unsigned long version) +__br_stub_set_ongoing_version(br_stub_inode_ctx_t *ctx, unsigned long version) { - if (ctx->currentversion < version) - ctx->currentversion = version; - else - gf_msg ("bit-rot-stub", GF_LOG_WARNING, 0, - BRS_MSG_CHANGE_VERSION_FAILED, "current version: %lu" - "new version: %lu", ctx->currentversion, version); + if (ctx->currentversion < version) + ctx->currentversion = version; + else + gf_msg("bit-rot-stub", GF_LOG_WARNING, 0, BRS_MSG_CHANGE_VERSION_FAILED, + "current version: %lu" + "new version: %lu", + ctx->currentversion, version); } static inline int -__br_stub_can_trigger_release (inode_t *inode, - br_stub_inode_ctx_t *ctx, unsigned long *version) +__br_stub_can_trigger_release(inode_t *inode, br_stub_inode_ctx_t *ctx, + unsigned long *version) { - /** - * If the inode is modified, then it has to be dirty. An inode is - * marked dirty once version is increased. Its marked as modified - * when the modification call (write/truncate) which triggered - * the versioning is successful. - */ - if (__br_stub_is_inode_modified (ctx) - && list_empty (&ctx->fd_list) - && (ctx->info_sign != BR_SIGN_REOPEN_WAIT)) { - - GF_ASSERT (__br_stub_is_inode_dirty (ctx) == 0); - - if (version) - *version = htonl (ctx->currentversion); - return 1; - } - - return 0; + /** + * If the inode is modified, then it has to be dirty. An inode is + * marked dirty once version is increased. Its marked as modified + * when the modification call (write/truncate) which triggered + * the versioning is successful. + */ + if (__br_stub_is_inode_modified(ctx) && list_empty(&ctx->fd_list) && + (ctx->info_sign != BR_SIGN_REOPEN_WAIT)) { + GF_ASSERT(__br_stub_is_inode_dirty(ctx) == 0); + + if (version) + *version = htonl(ctx->currentversion); + return 1; + } + + return 0; } static inline int32_t -br_stub_get_ongoing_version (xlator_t *this, - inode_t *inode, unsigned long *version) +br_stub_get_ongoing_version(xlator_t *this, inode_t *inode, + unsigned long *version) { - int32_t ret = 0; - uint64_t ctx_addr = 0; - br_stub_inode_ctx_t *ctx = NULL; - - LOCK (&inode->lock); - { - ret = __inode_ctx_get (inode, this, &ctx_addr); - if (ret < 0) - goto unblock; - ctx = (br_stub_inode_ctx_t *) (long) ctx_addr; - *version = ctx->currentversion; - } - unblock: - UNLOCK (&inode->lock); - - return ret; + int32_t ret = 0; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + + LOCK(&inode->lock); + { + ret = __inode_ctx_get(inode, this, &ctx_addr); + if (ret < 0) + goto unblock; + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + *version = ctx->currentversion; + } +unblock: + UNLOCK(&inode->lock); + + return ret; } /** @@ -332,45 +329,44 @@ br_stub_get_ongoing_version (xlator_t *this, * *needs* to be valid in the caller. */ static inline br_stub_inode_ctx_t * -__br_stub_get_ongoing_version_ctx (xlator_t *this, - inode_t *inode, unsigned long *version) +__br_stub_get_ongoing_version_ctx(xlator_t *this, inode_t *inode, + unsigned long *version) { - int32_t ret = 0; - uint64_t ctx_addr = 0; - br_stub_inode_ctx_t *ctx = NULL; - - ret = __inode_ctx_get (inode, this, &ctx_addr); - if (ret < 0) - return NULL; - ctx = (br_stub_inode_ctx_t *) (long) ctx_addr; - if (version) - *version = ctx->currentversion; - - return ctx; + int32_t ret = 0; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + + ret = __inode_ctx_get(inode, this, &ctx_addr); + if (ret < 0) + return NULL; + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + if (version) + *version = ctx->currentversion; + + return ctx; } /* filter for xattr fetch */ static inline int -br_stub_is_internal_xattr (const char *name) +br_stub_is_internal_xattr(const char *name) { - if (name - && ((strncmp (name, BITROT_CURRENT_VERSION_KEY, - SLEN (BITROT_CURRENT_VERSION_KEY)) == 0) - || (strncmp (name, BITROT_SIGNING_VERSION_KEY, - SLEN (BITROT_SIGNING_VERSION_KEY)) == 0))) - return 1; - return 0; + if (name && ((strncmp(name, BITROT_CURRENT_VERSION_KEY, + SLEN(BITROT_CURRENT_VERSION_KEY)) == 0) || + (strncmp(name, BITROT_SIGNING_VERSION_KEY, + SLEN(BITROT_SIGNING_VERSION_KEY)) == 0))) + return 1; + return 0; } static inline void -br_stub_remove_vxattrs (dict_t *xattr) +br_stub_remove_vxattrs(dict_t *xattr) { - if (xattr) { - dict_del (xattr, BITROT_OBJECT_BAD_KEY); - dict_del (xattr, BITROT_CURRENT_VERSION_KEY); - dict_del (xattr, BITROT_SIGNING_VERSION_KEY); - dict_del (xattr, BITROT_SIGNING_XATTR_SIZE_KEY); - } + if (xattr) { + dict_del(xattr, BITROT_OBJECT_BAD_KEY); + dict_del(xattr, BITROT_CURRENT_VERSION_KEY); + dict_del(xattr, BITROT_SIGNING_VERSION_KEY); + dict_del(xattr, BITROT_SIGNING_XATTR_SIZE_KEY); + } } /** @@ -384,64 +380,63 @@ br_stub_remove_vxattrs (dict_t *xattr) * errors can be made into enums. */ static inline int -br_stub_is_bad_object (xlator_t *this, inode_t *inode) +br_stub_is_bad_object(xlator_t *this, inode_t *inode) { - int bad_object = 0; - gf_boolean_t tmp = _gf_false; - uint64_t ctx_addr = 0; - br_stub_inode_ctx_t *ctx = NULL; - int32_t ret = -1; - - ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - BRS_MSG_GET_INODE_CONTEXT_FAILED, - "failed to get the inode context for the inode %s", - uuid_utoa (inode->gfid)); - bad_object = -1; - goto out; - } - - ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; - - LOCK (&inode->lock); - { - tmp = __br_stub_is_bad_object (ctx); - if (tmp) - bad_object = -2; - } - UNLOCK (&inode->lock); + int bad_object = 0; + gf_boolean_t tmp = _gf_false; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + int32_t ret = -1; + + ret = br_stub_get_inode_ctx(this, inode, &ctx_addr); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, BRS_MSG_GET_INODE_CONTEXT_FAILED, + "failed to get the inode context for the inode %s", + uuid_utoa(inode->gfid)); + bad_object = -1; + goto out; + } + + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + + LOCK(&inode->lock); + { + tmp = __br_stub_is_bad_object(ctx); + if (tmp) + bad_object = -2; + } + UNLOCK(&inode->lock); out: - return bad_object; + return bad_object; } static inline int32_t -br_stub_mark_object_bad (xlator_t *this, inode_t *inode) +br_stub_mark_object_bad(xlator_t *this, inode_t *inode) { - int32_t ret = -1; - uint64_t ctx_addr = 0; - br_stub_inode_ctx_t *ctx = NULL; - - ret = br_stub_get_inode_ctx (this, inode, &ctx_addr); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to get the " - "inode context for the inode %s", - uuid_utoa (inode->gfid)); - goto out; - } - - ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; - - LOCK (&inode->lock); - { - __br_stub_mark_object_bad (ctx); - } - UNLOCK (&inode->lock); + int32_t ret = -1; + uint64_t ctx_addr = 0; + br_stub_inode_ctx_t *ctx = NULL; + + ret = br_stub_get_inode_ctx(this, inode, &ctx_addr); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, BRS_MSG_GET_INODE_CONTEXT_FAILED, + "failed to get the " + "inode context for the inode %s", + uuid_utoa(inode->gfid)); + goto out; + } + + ctx = (br_stub_inode_ctx_t *)(long)ctx_addr; + + LOCK(&inode->lock); + { + __br_stub_mark_object_bad(ctx); + } + UNLOCK(&inode->lock); out: - return ret; + return ret; } /** @@ -449,68 +444,68 @@ out: * given to the caller and the caller has to decide what to do. */ static inline int32_t -br_stub_mark_xdata_bad_object (xlator_t *this, inode_t *inode, dict_t *xdata) +br_stub_mark_xdata_bad_object(xlator_t *this, inode_t *inode, dict_t *xdata) { - int32_t ret = 0; + int32_t ret = 0; - if (br_stub_is_bad_object (this, inode) == -2) - ret = dict_set_int32 (xdata, GLUSTERFS_BAD_INODE, 1); + if (br_stub_is_bad_object(this, inode) == -2) + ret = dict_set_int32(xdata, GLUSTERFS_BAD_INODE, 1); - return ret; + return ret; } int32_t -br_stub_add_fd_to_inode (xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx); +br_stub_add_fd_to_inode(xlator_t *this, fd_t *fd, br_stub_inode_ctx_t *ctx); br_sign_state_t -__br_stub_inode_sign_state (br_stub_inode_ctx_t *ctx, glusterfs_fop_t fop, - fd_t *fd); +__br_stub_inode_sign_state(br_stub_inode_ctx_t *ctx, glusterfs_fop_t fop, + fd_t *fd); int -br_stub_dir_create (xlator_t *this, br_stub_private_t *priv); +br_stub_dir_create(xlator_t *this, br_stub_private_t *priv); int -br_stub_add (xlator_t *this, uuid_t gfid); +br_stub_add(xlator_t *this, uuid_t gfid); int32_t -br_stub_create_stub_gfid (xlator_t *this, char *stub_gfid_path, uuid_t gfid); +br_stub_create_stub_gfid(xlator_t *this, char *stub_gfid_path, uuid_t gfid); int -br_stub_dir_create (xlator_t *this, br_stub_private_t *priv); +br_stub_dir_create(xlator_t *this, br_stub_private_t *priv); call_stub_t * -__br_stub_dequeue (struct list_head *callstubs); +__br_stub_dequeue(struct list_head *callstubs); void -__br_stub_enqueue (struct list_head *callstubs, call_stub_t *stub); +__br_stub_enqueue(struct list_head *callstubs, call_stub_t *stub); void -br_stub_worker_enqueue (xlator_t *this, call_stub_t *stub); +br_stub_worker_enqueue(xlator_t *this, call_stub_t *stub); void * -br_stub_worker (void *data); +br_stub_worker(void *data); int32_t -br_stub_lookup_wrapper (call_frame_t *frame, xlator_t *this, - loc_t *loc, dict_t *xattr_req); +br_stub_lookup_wrapper(call_frame_t *frame, xlator_t *this, loc_t *loc, + dict_t *xattr_req); int32_t -br_stub_readdir_wrapper (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t off, dict_t *xdata); +br_stub_readdir_wrapper(call_frame_t *frame, xlator_t *this, fd_t *fd, + size_t size, off_t off, dict_t *xdata); int -br_stub_del (xlator_t *this, uuid_t gfid); +br_stub_del(xlator_t *this, uuid_t gfid); int -br_stub_bad_objects_path (xlator_t *this, fd_t *fd, gf_dirent_t *entries, - dict_t **dict); +br_stub_bad_objects_path(xlator_t *this, fd_t *fd, gf_dirent_t *entries, + dict_t **dict); void -br_stub_entry_xattr_fill (xlator_t *this, char *hpath, gf_dirent_t *entry, - dict_t *dict); +br_stub_entry_xattr_fill(xlator_t *this, char *hpath, gf_dirent_t *entry, + dict_t *dict); int -br_stub_get_path_of_gfid (xlator_t *this, inode_t *parent, inode_t *inode, - uuid_t gfid, char **path); +br_stub_get_path_of_gfid(xlator_t *this, inode_t *parent, inode_t *inode, + uuid_t gfid, char **path); #endif /* __BIT_ROT_STUB_H__ */ diff --git a/xlators/features/changelog/lib/src/changelog-lib-messages.h b/xlators/features/changelog/lib/src/changelog-lib-messages.h index 2061217b801..32b3497d89d 100644 --- a/xlators/features/changelog/lib/src/changelog-lib-messages.h +++ b/xlators/features/changelog/lib/src/changelog-lib-messages.h @@ -23,39 +23,26 @@ * glfs-message-id.h. */ -GLFS_MSGID(CHANGELOG_LIB, - CHANGELOG_LIB_MSG_OPEN_FAILED, - CHANGELOG_LIB_MSG_FAILED_TO_RMDIR, - CHANGELOG_LIB_MSG_SCRATCH_DIR_ENTRIES_CREATION_ERROR, - CHANGELOG_LIB_MSG_THREAD_CREATION_FAILED, - CHANGELOG_LIB_MSG_OPENDIR_ERROR, - CHANGELOG_LIB_MSG_RENAME_FAILED, - CHANGELOG_LIB_MSG_READ_ERROR, - CHANGELOG_LIB_MSG_HTIME_ERROR, - CHANGELOG_LIB_MSG_GET_TIME_ERROR, - CHANGELOG_LIB_MSG_WRITE_FAILED, - CHANGELOG_LIB_MSG_PTHREAD_ERROR, - CHANGELOG_LIB_MSG_MMAP_FAILED, - CHANGELOG_LIB_MSG_MUNMAP_FAILED, - CHANGELOG_LIB_MSG_ASCII_ERROR, - CHANGELOG_LIB_MSG_STAT_FAILED, - CHANGELOG_LIB_MSG_GET_XATTR_FAILED, - CHANGELOG_LIB_MSG_PUBLISH_ERROR, - CHANGELOG_LIB_MSG_PARSE_ERROR, - CHANGELOG_LIB_MSG_TOTAL_LOG_INFO, - CHANGELOG_LIB_MSG_CLEANUP_ERROR, - CHANGELOG_LIB_MSG_UNLINK_FAILED, - CHANGELOG_LIB_MSG_NOTIFY_REGISTER_FAILED, - CHANGELOG_LIB_MSG_INVOKE_RPC_FAILED, - CHANGELOG_LIB_MSG_DRAINING_EVENT_INFO, - CHANGELOG_LIB_MSG_CLEANING_BRICK_ENTRY_INFO, - CHANGELOG_LIB_MSG_FREEING_ENTRY_INFO, - CHANGELOG_LIB_MSG_XDR_DECODING_FAILED, - CHANGELOG_LIB_MSG_NOTIFY_REGISTER_INFO, - CHANGELOG_LIB_MSG_THREAD_CLEANUP_WARNING, - CHANGELOG_LIB_MSG_COPY_FROM_BUFFER_FAILED, - CHANGELOG_LIB_MSG_PTHREAD_JOIN_FAILED, - CHANGELOG_LIB_MSG_HIST_FAILED -); +GLFS_MSGID( + CHANGELOG_LIB, CHANGELOG_LIB_MSG_OPEN_FAILED, + CHANGELOG_LIB_MSG_FAILED_TO_RMDIR, + CHANGELOG_LIB_MSG_SCRATCH_DIR_ENTRIES_CREATION_ERROR, + CHANGELOG_LIB_MSG_THREAD_CREATION_FAILED, CHANGELOG_LIB_MSG_OPENDIR_ERROR, + CHANGELOG_LIB_MSG_RENAME_FAILED, CHANGELOG_LIB_MSG_READ_ERROR, + CHANGELOG_LIB_MSG_HTIME_ERROR, CHANGELOG_LIB_MSG_GET_TIME_ERROR, + CHANGELOG_LIB_MSG_WRITE_FAILED, CHANGELOG_LIB_MSG_PTHREAD_ERROR, + CHANGELOG_LIB_MSG_MMAP_FAILED, CHANGELOG_LIB_MSG_MUNMAP_FAILED, + CHANGELOG_LIB_MSG_ASCII_ERROR, CHANGELOG_LIB_MSG_STAT_FAILED, + CHANGELOG_LIB_MSG_GET_XATTR_FAILED, CHANGELOG_LIB_MSG_PUBLISH_ERROR, + CHANGELOG_LIB_MSG_PARSE_ERROR, CHANGELOG_LIB_MSG_TOTAL_LOG_INFO, + CHANGELOG_LIB_MSG_CLEANUP_ERROR, CHANGELOG_LIB_MSG_UNLINK_FAILED, + CHANGELOG_LIB_MSG_NOTIFY_REGISTER_FAILED, + CHANGELOG_LIB_MSG_INVOKE_RPC_FAILED, CHANGELOG_LIB_MSG_DRAINING_EVENT_INFO, + CHANGELOG_LIB_MSG_CLEANING_BRICK_ENTRY_INFO, + CHANGELOG_LIB_MSG_FREEING_ENTRY_INFO, CHANGELOG_LIB_MSG_XDR_DECODING_FAILED, + CHANGELOG_LIB_MSG_NOTIFY_REGISTER_INFO, + CHANGELOG_LIB_MSG_THREAD_CLEANUP_WARNING, + CHANGELOG_LIB_MSG_COPY_FROM_BUFFER_FAILED, + CHANGELOG_LIB_MSG_PTHREAD_JOIN_FAILED, CHANGELOG_LIB_MSG_HIST_FAILED); #endif /* !_CHANGELOG_MESSAGES_H_ */ diff --git a/xlators/features/changelog/lib/src/gf-changelog-helpers.h b/xlators/features/changelog/lib/src/gf-changelog-helpers.h index b05628ee70d..cfb26a0081e 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-helpers.h +++ b/xlators/features/changelog/lib/src/gf-changelog-helpers.h @@ -23,27 +23,28 @@ #include "changelog-rpc-common.h" #include "gf-changelog-journal.h" -#define GF_CHANGELOG_TRACKER "tracker" +#define GF_CHANGELOG_TRACKER "tracker" -#define GF_CHANGELOG_CURRENT_DIR ".current" -#define GF_CHANGELOG_PROCESSED_DIR ".processed" +#define GF_CHANGELOG_CURRENT_DIR ".current" +#define GF_CHANGELOG_PROCESSED_DIR ".processed" #define GF_CHANGELOG_PROCESSING_DIR ".processing" -#define GF_CHANGELOG_HISTORY_DIR ".history" +#define GF_CHANGELOG_HISTORY_DIR ".history" #define TIMESTAMP_LENGTH 10 #ifndef MAXLINE #define MAXLINE 4096 #endif -#define GF_CHANGELOG_FILL_BUFFER(ptr, ascii, off, len) do { \ - memcpy (ascii + off, ptr, len); \ - off += len; \ - } while (0) +#define GF_CHANGELOG_FILL_BUFFER(ptr, ascii, off, len) \ + do { \ + memcpy(ascii + off, ptr, len); \ + off += len; \ + } while (0) typedef struct read_line { - int rl_cnt; - char *rl_bufptr; - char rl_buf[MAXLINE]; + int rl_cnt; + char *rl_bufptr; + char rl_buf[MAXLINE]; } read_line_t; struct gf_changelog; @@ -55,51 +56,50 @@ struct gf_event; * ->next_seq holds the next _expected_ sequence number. */ struct gf_event_list { - pthread_mutex_t lock; /* protects this structure */ - pthread_cond_t cond; + pthread_mutex_t lock; /* protects this structure */ + pthread_cond_t cond; - pthread_t invoker; + pthread_t invoker; - unsigned long next_seq; /* next sequence number expected: - zero during bootstrap */ + unsigned long next_seq; /* next sequence number expected: + zero during bootstrap */ - struct gf_changelog *entry; /* backpointer to it's brick - encapsulator (entry) */ - struct list_head events; /* list of events */ + struct gf_changelog *entry; /* backpointer to it's brick + encapsulator (entry) */ + struct list_head events; /* list of events */ }; /** * include a refcount if it's of use by additional layers */ struct gf_event { - int count; + int count; - unsigned long seq; + unsigned long seq; - struct list_head list; + struct list_head list; - struct iovec iov[0]; + struct iovec iov[0]; }; -#define GF_EVENT_CALLOC_SIZE(cnt, len) \ - (sizeof (struct gf_event) + (cnt * sizeof (struct iovec)) + len) +#define GF_EVENT_CALLOC_SIZE(cnt, len) \ + (sizeof(struct gf_event) + (cnt * sizeof(struct iovec)) + len) /** * assign the base address of the IO vector to the correct memory o * area and set it's addressable length. */ -#define GF_EVENT_ASSIGN_IOVEC(vec, event, len, pos) \ - do { \ - vec->iov_base = ((char *)event) + \ - sizeof (struct gf_event) + \ - (event->count * sizeof (struct iovec)) + pos; \ - vec->iov_len = len; \ - pos += len; \ - } while (0) +#define GF_EVENT_ASSIGN_IOVEC(vec, event, len, pos) \ + do { \ + vec->iov_base = ((char *)event) + sizeof(struct gf_event) + \ + (event->count * sizeof(struct iovec)) + pos; \ + vec->iov_len = len; \ + pos += len; \ + } while (0) typedef enum gf_changelog_conn_state { - GF_CHANGELOG_CONN_STATE_PENDING = 0, - GF_CHANGELOG_CONN_STATE_ACCEPTED, - GF_CHANGELOG_CONN_STATE_DISCONNECTED, + GF_CHANGELOG_CONN_STATE_PENDING = 0, + GF_CHANGELOG_CONN_STATE_ACCEPTED, + GF_CHANGELOG_CONN_STATE_DISCONNECTED, } gf_changelog_conn_state_t; /** @@ -107,153 +107,152 @@ typedef enum gf_changelog_conn_state { * notifications are streamed. */ typedef struct gf_changelog { - gf_lock_t statelock; - gf_changelog_conn_state_t connstate; + gf_lock_t statelock; + gf_changelog_conn_state_t connstate; - xlator_t *this; + xlator_t *this; - struct list_head list; /* list of instances */ + struct list_head list; /* list of instances */ - char brick[PATH_MAX]; /* brick path for this end-point */ + char brick[PATH_MAX]; /* brick path for this end-point */ - changelog_rpc_t grpc; /* rpc{-clnt,svc} for this brick */ -#define RPC_PROBER(ent) ent->grpc.rpc -#define RPC_REBORP(ent) ent->grpc.svc -#define RPC_SOCK(ent) ent->grpc.sock + changelog_rpc_t grpc; /* rpc{-clnt,svc} for this brick */ +#define RPC_PROBER(ent) ent->grpc.rpc +#define RPC_REBORP(ent) ent->grpc.svc +#define RPC_SOCK(ent) ent->grpc.sock - unsigned int notify; /* notification flag(s) */ + unsigned int notify; /* notification flag(s) */ - FINI *fini; /* destructor callback */ - CALLBACK *callback; /* event callback dispatcher */ - CONNECT *connected; /* connect callback */ - DISCONNECT *disconnected; /* disconnection callback */ + FINI *fini; /* destructor callback */ + CALLBACK *callback; /* event callback dispatcher */ + CONNECT *connected; /* connect callback */ + DISCONNECT *disconnected; /* disconnection callback */ - void *ptr; /* owner specific private data */ - xlator_t *invokerxl; /* consumers _this_, if valid, - assigned to THIS before cbk is - invoked */ + void *ptr; /* owner specific private data */ + xlator_t *invokerxl; /* consumers _this_, if valid, + assigned to THIS before cbk is + invoked */ - gf_boolean_t ordered; + gf_boolean_t ordered; - void (*queueevent) (struct gf_event_list *, struct gf_event *); - void (*pickevent) (struct gf_event_list *, struct gf_event **); + void (*queueevent)(struct gf_event_list *, struct gf_event *); + void (*pickevent)(struct gf_event_list *, struct gf_event **); - struct gf_event_list event; + struct gf_event_list event; } gf_changelog_t; static inline int -gf_changelog_filter_check (gf_changelog_t *entry, changelog_event_t *event) +gf_changelog_filter_check(gf_changelog_t *entry, changelog_event_t *event) { - if (event->ev_type & entry->notify) - return 1; - return 0; + if (event->ev_type & entry->notify) + return 1; + return 0; } -#define GF_NEED_ORDERED_EVENTS(ent) (ent->ordered == _gf_true) +#define GF_NEED_ORDERED_EVENTS(ent) (ent->ordered == _gf_true) /** private structure */ typedef struct gf_private { - pthread_mutex_t lock; /* protects ->connections, cleanups */ - pthread_cond_t cond; + pthread_mutex_t lock; /* protects ->connections, cleanups */ + pthread_cond_t cond; - void *api; /* pointer for API access */ + void *api; /* pointer for API access */ - pthread_t poller; /* event poller thread */ - pthread_t connectionjanitor; /* connection cleaner */ + pthread_t poller; /* event poller thread */ + pthread_t connectionjanitor; /* connection cleaner */ - struct list_head connections; /* list of connections */ - struct list_head cleanups; /* list of connection to be - cleaned up */ + struct list_head connections; /* list of connections */ + struct list_head cleanups; /* list of connection to be + cleaned up */ } gf_private_t; -#define GF_CHANGELOG_GET_API_PTR(this) (((gf_private_t *) this->private)->api) +#define GF_CHANGELOG_GET_API_PTR(this) (((gf_private_t *)this->private)->api) /** * upcall: invoke callback with _correct_ THIS */ -#define GF_CHANGELOG_INVOKE_CBK(this, cbk, brick, args ...) \ - do { \ - xlator_t *old_this = NULL; \ - xlator_t *invokerxl = NULL; \ - \ - invokerxl = entry->invokerxl; \ - old_this = this; \ - \ - if (invokerxl) { \ - THIS = invokerxl; \ - } \ - \ - cbk (invokerxl, brick, args); \ - THIS = old_this; \ - \ - } while (0) - -#define SAVE_THIS(xl) \ - do { \ - old_this = xl; \ - THIS = master; \ - } while (0) - -#define RESTORE_THIS() \ - do { \ - if (old_this) \ - THIS = old_this; \ - } while (0) +#define GF_CHANGELOG_INVOKE_CBK(this, cbk, brick, args...) \ + do { \ + xlator_t *old_this = NULL; \ + xlator_t *invokerxl = NULL; \ + \ + invokerxl = entry->invokerxl; \ + old_this = this; \ + \ + if (invokerxl) { \ + THIS = invokerxl; \ + } \ + \ + cbk(invokerxl, brick, args); \ + THIS = old_this; \ + \ + } while (0) + +#define SAVE_THIS(xl) \ + do { \ + old_this = xl; \ + THIS = master; \ + } while (0) + +#define RESTORE_THIS() \ + do { \ + if (old_this) \ + THIS = old_this; \ + } while (0) /** APIs and the rest */ void * -gf_changelog_process (void *data); +gf_changelog_process(void *data); ssize_t -gf_changelog_read_path (int fd, char *buffer, size_t bufsize); +gf_changelog_read_path(int fd, char *buffer, size_t bufsize); void -gf_rfc3986_encode_space_newline (unsigned char *s, char *enc, char *estr); +gf_rfc3986_encode_space_newline(unsigned char *s, char *enc, char *estr); size_t -gf_changelog_write (int fd, char *buffer, size_t len); +gf_changelog_write(int fd, char *buffer, size_t len); ssize_t -gf_readline (int fd, void *vptr, size_t maxlen); +gf_readline(int fd, void *vptr, size_t maxlen); int -gf_ftruncate (int fd, off_t length); +gf_ftruncate(int fd, off_t length); off_t -gf_lseek (int fd, off_t offset, int whence); +gf_lseek(int fd, off_t offset, int whence); int -gf_changelog_consume (xlator_t *this, - gf_changelog_journal_t *jnl, - char *from_path, gf_boolean_t no_publish); +gf_changelog_consume(xlator_t *this, gf_changelog_journal_t *jnl, + char *from_path, gf_boolean_t no_publish); int -gf_changelog_publish (xlator_t *this, - gf_changelog_journal_t *jnl, char *from_path); +gf_changelog_publish(xlator_t *this, gf_changelog_journal_t *jnl, + char *from_path); int -gf_thread_cleanup (xlator_t *this, pthread_t thread); +gf_thread_cleanup(xlator_t *this, pthread_t thread); void * -gf_changelog_callback_invoker (void *arg); +gf_changelog_callback_invoker(void *arg); int -gf_cleanup_event (xlator_t *, struct gf_event_list *); +gf_cleanup_event(xlator_t *, struct gf_event_list *); /* (un)ordered event queueing */ void -queue_ordered_event (struct gf_event_list *, struct gf_event *); +queue_ordered_event(struct gf_event_list *, struct gf_event *); void -queue_unordered_event (struct gf_event_list *, struct gf_event *); +queue_unordered_event(struct gf_event_list *, struct gf_event *); /* (un)ordered event picking */ void -pick_event_ordered (struct gf_event_list *, struct gf_event **); +pick_event_ordered(struct gf_event_list *, struct gf_event **); void -pick_event_unordered (struct gf_event_list *, struct gf_event **); +pick_event_unordered(struct gf_event_list *, struct gf_event **); /* connection janitor thread */ void * -gf_changelog_connection_janitor (void *); +gf_changelog_connection_janitor(void *); #endif diff --git a/xlators/features/changelog/lib/src/gf-changelog-journal.h b/xlators/features/changelog/lib/src/gf-changelog-journal.h index 46d50f159d9..ba5b9bf827e 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-journal.h +++ b/xlators/features/changelog/lib/src/gf-changelog-journal.h @@ -17,91 +17,91 @@ #include "changelog.h" enum api_conn { - JNL_API_CONNECTED, - JNL_API_CONN_INPROGESS, - JNL_API_DISCONNECTED, + JNL_API_CONNECTED, + JNL_API_CONN_INPROGESS, + JNL_API_DISCONNECTED, }; typedef struct gf_changelog_entry { - char path[PATH_MAX]; + char path[PATH_MAX]; - struct list_head list; + struct list_head list; } gf_changelog_entry_t; typedef struct gf_changelog_processor { - pthread_mutex_t lock; /* protects ->entries */ - pthread_cond_t cond; /* waiter during empty list */ - gf_boolean_t waiting; + pthread_mutex_t lock; /* protects ->entries */ + pthread_cond_t cond; /* waiter during empty list */ + gf_boolean_t waiting; - pthread_t processor; /* thread-id of journal processing thread */ + pthread_t processor; /* thread-id of journal processing thread */ - struct list_head entries; + struct list_head entries; } gf_changelog_processor_t; typedef struct gf_changelog_journal { - DIR *jnl_dir; /* 'processing' directory stream */ + DIR *jnl_dir; /* 'processing' directory stream */ - int jnl_fd; /* fd to the tracker file */ + int jnl_fd; /* fd to the tracker file */ - char jnl_brickpath[PATH_MAX]; /* brick path for this end-point */ + char jnl_brickpath[PATH_MAX]; /* brick path for this end-point */ - gf_changelog_processor_t *jnl_proc; + gf_changelog_processor_t *jnl_proc; - char *jnl_working_dir; /* scratch directory */ + char *jnl_working_dir; /* scratch directory */ - char jnl_current_dir[PATH_MAX]; - char jnl_processed_dir[PATH_MAX]; - char jnl_processing_dir[PATH_MAX]; + char jnl_current_dir[PATH_MAX]; + char jnl_processed_dir[PATH_MAX]; + char jnl_processing_dir[PATH_MAX]; - char rfc3986_space_newline[256]; /* RFC 3986 string encoding */ + char rfc3986_space_newline[256]; /* RFC 3986 string encoding */ - struct gf_changelog_journal *hist_jnl; - int hist_done; /* holds 0 done scanning, - 1 keep scanning and -1 error */ + struct gf_changelog_journal *hist_jnl; + int hist_done; /* holds 0 done scanning, + 1 keep scanning and -1 error */ - pthread_spinlock_t lock; - int connected; - xlator_t *this; + pthread_spinlock_t lock; + int connected; + xlator_t *this; } gf_changelog_journal_t; -#define JNL_SET_API_STATE(jnl, state) (jnl->connected = state) -#define JNL_IS_API_DISCONNECTED(jnl) (jnl->connected == JNL_API_DISCONNECTED) +#define JNL_SET_API_STATE(jnl, state) (jnl->connected = state) +#define JNL_IS_API_DISCONNECTED(jnl) (jnl->connected == JNL_API_DISCONNECTED) /* History API */ typedef struct gf_changelog_history_data { - int len; + int len; - int htime_fd; + int htime_fd; - /* parallelism count */ - int n_parallel; + /* parallelism count */ + int n_parallel; - /* history from, to indexes */ - unsigned long from; - unsigned long to; - xlator_t *this; + /* history from, to indexes */ + unsigned long from; + unsigned long to; + xlator_t *this; } gf_changelog_history_data_t; typedef struct gf_changelog_consume_data { - /** set of inputs */ + /** set of inputs */ - /* fd to read from */ - int fd; + /* fd to read from */ + int fd; - /* from @offset */ - off_t offset; + /* from @offset */ + off_t offset; - xlator_t *this; + xlator_t *this; - gf_changelog_journal_t *jnl; + gf_changelog_journal_t *jnl; - /** set of outputs */ + /** set of outputs */ - /* return value */ - int retval; + /* return value */ + int retval; - /* journal processed */ - char changelog[PATH_MAX]; + /* journal processed */ + char changelog[PATH_MAX]; } gf_changelog_consume_data_t; /* event handler */ diff --git a/xlators/features/changelog/lib/src/gf-changelog-rpc.h b/xlators/features/changelog/lib/src/gf-changelog-rpc.h index 1c982eef809..975307b99d3 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-rpc.h +++ b/xlators/features/changelog/lib/src/gf-changelog-rpc.h @@ -16,11 +16,13 @@ #include "gf-changelog-helpers.h" #include "changelog-rpc-common.h" -struct rpc_clnt *gf_changelog_rpc_init (xlator_t *, gf_changelog_t *); +struct rpc_clnt * +gf_changelog_rpc_init(xlator_t *, gf_changelog_t *); -int gf_changelog_invoke_rpc (xlator_t *, gf_changelog_t *, int); +int +gf_changelog_invoke_rpc(xlator_t *, gf_changelog_t *, int); rpcsvc_t * -gf_changelog_reborp_init_rpc_listner (xlator_t *, char *, char *, void *); +gf_changelog_reborp_init_rpc_listner(xlator_t *, char *, char *, void *); #endif diff --git a/xlators/features/changelog/src/changelog-encoders.h b/xlators/features/changelog/src/changelog-encoders.h index d6a50cc9ef7..ca42c4c4fe0 100644 --- a/xlators/features/changelog/src/changelog-encoders.h +++ b/xlators/features/changelog/src/changelog-encoders.h @@ -16,36 +16,34 @@ #include "changelog-helpers.h" -#define CHANGELOG_STORE_ASCII(priv, buf, off, gfid, gfid_len, cld) do { \ - CHANGELOG_FILL_BUFFER (buffer, off, \ - priv->maps[cld->cld_type], 1); \ - CHANGELOG_FILL_BUFFER (buffer, \ - off, gfid, gfid_len); \ - } while (0) - -#define CHANGELOG_STORE_BINARY(priv, buf, off, gfid, cld) do { \ - CHANGELOG_FILL_BUFFER (buffer, off, \ - priv->maps[cld->cld_type], 1); \ - CHANGELOG_FILL_BUFFER (buffer, \ - off, gfid, sizeof (uuid_t)); \ - } while (0) +#define CHANGELOG_STORE_ASCII(priv, buf, off, gfid, gfid_len, cld) \ + do { \ + CHANGELOG_FILL_BUFFER(buffer, off, priv->maps[cld->cld_type], 1); \ + CHANGELOG_FILL_BUFFER(buffer, off, gfid, gfid_len); \ + } while (0) + +#define CHANGELOG_STORE_BINARY(priv, buf, off, gfid, cld) \ + do { \ + CHANGELOG_FILL_BUFFER(buffer, off, priv->maps[cld->cld_type], 1); \ + CHANGELOG_FILL_BUFFER(buffer, off, gfid, sizeof(uuid_t)); \ + } while (0) size_t -entry_fn (void *data, char *buffer, gf_boolean_t encode); +entry_fn(void *data, char *buffer, gf_boolean_t encode); size_t -del_entry_fn (void *data, char *buffer, gf_boolean_t encode); +del_entry_fn(void *data, char *buffer, gf_boolean_t encode); size_t -fop_fn (void *data, char *buffer, gf_boolean_t encode); +fop_fn(void *data, char *buffer, gf_boolean_t encode); size_t -number_fn (void *data, char *buffer, gf_boolean_t encode); +number_fn(void *data, char *buffer, gf_boolean_t encode); void -entry_free_fn (void *data); +entry_free_fn(void *data); void -del_entry_free_fn (void *data); +del_entry_free_fn(void *data); int -changelog_encode_binary (xlator_t *, changelog_log_data_t *); +changelog_encode_binary(xlator_t *, changelog_log_data_t *); int -changelog_encode_ascii (xlator_t *, changelog_log_data_t *); +changelog_encode_ascii(xlator_t *, changelog_log_data_t *); void changelog_encode_change(changelog_priv_t *); diff --git a/xlators/features/changelog/src/changelog-ev-handle.h b/xlators/features/changelog/src/changelog-ev-handle.h index e89af8793a8..7e543a0edb3 100644 --- a/xlators/features/changelog/src/changelog-ev-handle.h +++ b/xlators/features/changelog/src/changelog-ev-handle.h @@ -20,59 +20,58 @@ struct changelog_clnt; typedef struct changelog_rpc_clnt { - xlator_t *this; + xlator_t *this; - gf_lock_t lock; + gf_lock_t lock; - gf_atomic_t ref; - gf_boolean_t disconnected; + gf_atomic_t ref; + gf_boolean_t disconnected; - unsigned int filter; - char sock[UNIX_PATH_MAX]; + unsigned int filter; + char sock[UNIX_PATH_MAX]; - struct changelog_clnt *c_clnt; /* back pointer to list holder */ + struct changelog_clnt *c_clnt; /* back pointer to list holder */ - struct rpc_clnt *rpc; /* RPC client endpoint */ + struct rpc_clnt *rpc; /* RPC client endpoint */ - struct list_head list; /* ->pending, ->waitq, ->active */ + struct list_head list; /* ->pending, ->waitq, ->active */ - void (*cleanup) - (struct changelog_rpc_clnt *); /* cleanup handler */ + void (*cleanup)(struct changelog_rpc_clnt *); /* cleanup handler */ } changelog_rpc_clnt_t; static inline void -changelog_rpc_clnt_ref (changelog_rpc_clnt_t *crpc) +changelog_rpc_clnt_ref(changelog_rpc_clnt_t *crpc) { - GF_ATOMIC_INC (crpc->ref); + GF_ATOMIC_INC(crpc->ref); } static inline void -changelog_set_disconnect_flag (changelog_rpc_clnt_t *crpc, gf_boolean_t flag) +changelog_set_disconnect_flag(changelog_rpc_clnt_t *crpc, gf_boolean_t flag) { - crpc->disconnected = flag; + crpc->disconnected = flag; } static inline int -changelog_rpc_clnt_is_disconnected (changelog_rpc_clnt_t *crpc) +changelog_rpc_clnt_is_disconnected(changelog_rpc_clnt_t *crpc) { - return (crpc->disconnected == _gf_true); + return (crpc->disconnected == _gf_true); } static inline void -changelog_rpc_clnt_unref (changelog_rpc_clnt_t *crpc) +changelog_rpc_clnt_unref(changelog_rpc_clnt_t *crpc) { - gf_boolean_t gone = _gf_false; - uint64_t ref = 0; + gf_boolean_t gone = _gf_false; + uint64_t ref = 0; - ref = GF_ATOMIC_DEC (crpc->ref); + ref = GF_ATOMIC_DEC(crpc->ref); - if (!ref && changelog_rpc_clnt_is_disconnected (crpc)) { - list_del (&crpc->list); - gone = _gf_true; - } + if (!ref && changelog_rpc_clnt_is_disconnected(crpc)) { + list_del(&crpc->list); + gone = _gf_true; + } - if (gone) - crpc->cleanup (crpc); + if (gone) + crpc->cleanup(crpc); } /** @@ -100,35 +99,36 @@ changelog_rpc_clnt_unref (changelog_rpc_clnt_t *crpc) */ typedef struct changelog_clnt { - xlator_t *this; + xlator_t *this; - /* pending connections */ - pthread_mutex_t pending_lock; - pthread_cond_t pending_cond; - struct list_head pending; + /* pending connections */ + pthread_mutex_t pending_lock; + pthread_cond_t pending_cond; + struct list_head pending; - /* current active connections */ - gf_lock_t active_lock; - struct list_head active; + /* current active connections */ + gf_lock_t active_lock; + struct list_head active; - gf_lock_t wait_lock; - struct list_head waitq; + gf_lock_t wait_lock; + struct list_head waitq; - /* consumer part of rot-buffs */ - rbuf_t *rbuf; - unsigned long sequence; + /* consumer part of rot-buffs */ + rbuf_t *rbuf; + unsigned long sequence; } changelog_clnt_t; -void *changelog_ev_connector (void *); +void * +changelog_ev_connector(void *); -void *changelog_ev_dispatch (void *); +void * +changelog_ev_dispatch(void *); /* APIs */ void -changelog_ev_queue_connection (changelog_clnt_t *, changelog_rpc_clnt_t *); +changelog_ev_queue_connection(changelog_clnt_t *, changelog_rpc_clnt_t *); void -changelog_ev_cleanup_connections (xlator_t *, changelog_clnt_t *); +changelog_ev_cleanup_connections(xlator_t *, changelog_clnt_t *); #endif - diff --git a/xlators/features/changelog/src/changelog-helpers.h b/xlators/features/changelog/src/changelog-helpers.h index 1551337c16f..10d457e8cf5 100644 --- a/xlators/features/changelog/src/changelog-helpers.h +++ b/xlators/features/changelog/src/changelog-helpers.h @@ -30,44 +30,44 @@ * the changelog entry */ typedef struct changelog_log_data { - /* rollover related */ - unsigned long cld_roll_time; + /* rollover related */ + unsigned long cld_roll_time; - /* reopen changelog? */ - gf_boolean_t cld_finale; + /* reopen changelog? */ + gf_boolean_t cld_finale; - changelog_log_type cld_type; + changelog_log_type cld_type; - /** - * sincd gfid is _always_ a necessity, it's not a part - * of the iobuf. by doing this we do not add any overhead - * for data and metadata related fops. - */ - uuid_t cld_gfid; + /** + * sincd gfid is _always_ a necessity, it's not a part + * of the iobuf. by doing this we do not add any overhead + * for data and metadata related fops. + */ + uuid_t cld_gfid; - /** - * iobufs are used for optionals records: pargfid, path, - * write offsets etc.. It's the fop implementers job - * to allocate (iobuf_get() in the fop) and get unref'ed - * in the callback (CHANGELOG_STACK_UNWIND). - */ - struct iobuf *cld_iobuf; + /** + * iobufs are used for optionals records: pargfid, path, + * write offsets etc.. It's the fop implementers job + * to allocate (iobuf_get() in the fop) and get unref'ed + * in the callback (CHANGELOG_STACK_UNWIND). + */ + struct iobuf *cld_iobuf; #define cld_ptr cld_iobuf->ptr - /** - * after allocation you can point this to the length of - * usable data, but make sure it does not exceed the - * the size of the requested iobuf. - */ - size_t cld_iobuf_len; + /** + * after allocation you can point this to the length of + * usable data, but make sure it does not exceed the + * the size of the requested iobuf. + */ + size_t cld_iobuf_len; #define cld_ptr_len cld_iobuf_len - /** - * number of optional records - */ - int cld_xtra_records; + /** + * number of optional records + */ + int cld_xtra_records; } changelog_log_data_t; /** @@ -77,55 +77,54 @@ typedef struct changelog_log_data { typedef struct changelog_priv changelog_priv_t; typedef struct changelog_dispatcher { - void *cd_data; - int (*dispatchfn) (xlator_t *, changelog_priv_t *, void *, - changelog_log_data_t *, changelog_log_data_t *); + void *cd_data; + int (*dispatchfn)(xlator_t *, changelog_priv_t *, void *, + changelog_log_data_t *, changelog_log_data_t *); } changelog_dispatcher_t; struct changelog_bootstrap { - changelog_mode_t mode; - int (*ctor) (xlator_t *, changelog_dispatcher_t *); - int (*dtor) (xlator_t *, changelog_dispatcher_t *); + changelog_mode_t mode; + int (*ctor)(xlator_t *, changelog_dispatcher_t *); + int (*dtor)(xlator_t *, changelog_dispatcher_t *); }; struct changelog_encoder { - changelog_encoder_t encoder; - int (*encode) (xlator_t *, changelog_log_data_t *); + changelog_encoder_t encoder; + int (*encode)(xlator_t *, changelog_log_data_t *); }; - /* xlator private */ typedef struct changelog_time_slice { - /** - * just in case we need nanosecond granularity some day. - * field is unused as of now (maybe we'd need it later). - */ - struct timeval tv_start; - - /** - * version of changelog file, incremented each time changes - * rollover. - */ - unsigned long changelog_version[CHANGELOG_MAX_TYPE]; + /** + * just in case we need nanosecond granularity some day. + * field is unused as of now (maybe we'd need it later). + */ + struct timeval tv_start; + + /** + * version of changelog file, incremented each time changes + * rollover. + */ + unsigned long changelog_version[CHANGELOG_MAX_TYPE]; } changelog_time_slice_t; typedef struct changelog_rollover { - /* rollover thread */ - pthread_t rollover_th; + /* rollover thread */ + pthread_t rollover_th; - xlator_t *this; + xlator_t *this; - pthread_mutex_t lock; - pthread_cond_t cond; - gf_boolean_t notify; + pthread_mutex_t lock; + pthread_cond_t cond; + gf_boolean_t notify; } changelog_rollover_t; typedef struct changelog_fsync { - /* fsync() thread */ - pthread_t fsync_th; + /* fsync() thread */ + pthread_t fsync_th; - xlator_t *this; + xlator_t *this; } changelog_fsync_t; /* Draining during changelog rollover (for geo-rep snapshot dependency): @@ -145,198 +144,197 @@ typedef struct changelog_fsync { */ typedef enum chlog_fop_color { - FOP_COLOR_BLACK, - FOP_COLOR_WHITE + FOP_COLOR_BLACK, + FOP_COLOR_WHITE } chlog_fop_color_t; /* Barrier notify variable */ typedef struct barrier_notify { - pthread_mutex_t bnotify_mutex; - pthread_cond_t bnotify_cond; - gf_boolean_t bnotify; - gf_boolean_t bnotify_error; + pthread_mutex_t bnotify_mutex; + pthread_cond_t bnotify_cond; + gf_boolean_t bnotify; + gf_boolean_t bnotify_error; } barrier_notify_t; /* Two separate mutex and conditional variable set is used * to drain white and black fops. */ typedef struct drain_mgmt { - pthread_mutex_t drain_black_mutex; - pthread_cond_t drain_black_cond; - pthread_mutex_t drain_white_mutex; - pthread_cond_t drain_white_cond; - /* Represents black fops count in-transit */ - unsigned long black_fop_cnt; - /* Represents white fops count in-transit */ - unsigned long white_fop_cnt; - gf_boolean_t drain_wait_black; - gf_boolean_t drain_wait_white; + pthread_mutex_t drain_black_mutex; + pthread_cond_t drain_black_cond; + pthread_mutex_t drain_white_mutex; + pthread_cond_t drain_white_cond; + /* Represents black fops count in-transit */ + unsigned long black_fop_cnt; + /* Represents white fops count in-transit */ + unsigned long white_fop_cnt; + gf_boolean_t drain_wait_black; + gf_boolean_t drain_wait_white; } drain_mgmt_t; /* External barrier as a result of snap on/off indicating flag*/ typedef struct barrier_flags { - gf_lock_t lock; - gf_boolean_t barrier_ext; + gf_lock_t lock; + gf_boolean_t barrier_ext; } barrier_flags_t; /* Event selection */ typedef struct changelog_ev_selector { - gf_lock_t reflock; + gf_lock_t reflock; - /** - * Array of references for each selection bit. - */ - unsigned int ref[CHANGELOG_EV_SELECTION_RANGE]; + /** + * Array of references for each selection bit. + */ + unsigned int ref[CHANGELOG_EV_SELECTION_RANGE]; } changelog_ev_selector_t; - /* changelog's private structure */ struct changelog_priv { - gf_boolean_t active; + gf_boolean_t active; - /* to generate unique socket file per brick */ - char *changelog_brick; + /* to generate unique socket file per brick */ + char *changelog_brick; - /* logging directory */ - char *changelog_dir; + /* logging directory */ + char *changelog_dir; - /* htime directory */ - char *htime_dir; + /* htime directory */ + char *htime_dir; - /* one file for all changelog types */ - int changelog_fd; + /* one file for all changelog types */ + int changelog_fd; - /* htime fd for current changelog session */ - int htime_fd; + /* htime fd for current changelog session */ + int htime_fd; - /* c_snap_fd is fd for call-path changelog */ - int c_snap_fd; + /* c_snap_fd is fd for call-path changelog */ + int c_snap_fd; - /* rollover_count used by htime */ - int rollover_count; + /* rollover_count used by htime */ + int rollover_count; - gf_lock_t lock; + gf_lock_t lock; - /* lock to synchronize CSNAP updation */ - gf_lock_t c_snap_lock; + /* lock to synchronize CSNAP updation */ + gf_lock_t c_snap_lock; - /* written end of the pipe */ - int wfd; + /* written end of the pipe */ + int wfd; - /* rollover time */ - int32_t rollover_time; + /* rollover time */ + int32_t rollover_time; - /* fsync() interval */ - int32_t fsync_interval; + /* fsync() interval */ + int32_t fsync_interval; - /* changelog type maps */ - const char *maps[CHANGELOG_MAX_TYPE]; + /* changelog type maps */ + const char *maps[CHANGELOG_MAX_TYPE]; - /* time slicer */ - changelog_time_slice_t slice; + /* time slicer */ + changelog_time_slice_t slice; - /* context of the updater */ - changelog_dispatcher_t cd; + /* context of the updater */ + changelog_dispatcher_t cd; - /* context of the rollover thread */ - changelog_rollover_t cr; + /* context of the rollover thread */ + changelog_rollover_t cr; - /* context of fsync thread */ - changelog_fsync_t cf; + /* context of fsync thread */ + changelog_fsync_t cf; - /* operation mode */ - changelog_mode_t op_mode; + /* operation mode */ + changelog_mode_t op_mode; - /* bootstrap routine for 'current' logger */ - struct changelog_bootstrap *cb; + /* bootstrap routine for 'current' logger */ + struct changelog_bootstrap *cb; - /* encoder mode */ - changelog_encoder_t encode_mode; + /* encoder mode */ + changelog_encoder_t encode_mode; - /* encoder */ - struct changelog_encoder *ce; + /* encoder */ + struct changelog_encoder *ce; - /** - * snapshot dependency changes - */ + /** + * snapshot dependency changes + */ - /* Draining of fops*/ - drain_mgmt_t dm; + /* Draining of fops*/ + drain_mgmt_t dm; - /* Represents the active color. Initially by default black */ - chlog_fop_color_t current_color; + /* Represents the active color. Initially by default black */ + chlog_fop_color_t current_color; - /* flag to determine explicit rollover is triggered */ - gf_boolean_t explicit_rollover; + /* flag to determine explicit rollover is triggered */ + gf_boolean_t explicit_rollover; - /* barrier notification variable protected by mutex */ - barrier_notify_t bn; + /* barrier notification variable protected by mutex */ + barrier_notify_t bn; - /* barrier on/off indicating flags */ - barrier_flags_t bflags; + /* barrier on/off indicating flags */ + barrier_flags_t bflags; - /* changelog barrier on/off indicating flag */ - gf_boolean_t barrier_enabled; - struct list_head queue; - uint32_t queue_size; - gf_timer_t *timer; - struct timespec timeout; + /* changelog barrier on/off indicating flag */ + gf_boolean_t barrier_enabled; + struct list_head queue; + uint32_t queue_size; + gf_timer_t *timer; + struct timespec timeout; - /** - * buffers, RPC, event selection, notifications and other - * beasts. - */ + /** + * buffers, RPC, event selection, notifications and other + * beasts. + */ - /* epoll pthread */ - pthread_t poller; + /* epoll pthread */ + pthread_t poller; - /* rotational buffer */ - rbuf_t *rbuf; + /* rotational buffer */ + rbuf_t *rbuf; - /* changelog RPC server */ - rpcsvc_t *rpc; + /* changelog RPC server */ + rpcsvc_t *rpc; - /* event selection */ - changelog_ev_selector_t ev_selection; + /* event selection */ + changelog_ev_selector_t ev_selection; - /* client handling (reverse connection) */ - pthread_t connector; + /* client handling (reverse connection) */ + pthread_t connector; - int nr_dispatchers; - pthread_t *ev_dispatcher; + int nr_dispatchers; + pthread_t *ev_dispatcher; - changelog_clnt_t connections; + changelog_clnt_t connections; - /* glusterfind dependency to capture paths on deleted entries*/ - gf_boolean_t capture_del_path; + /* glusterfind dependency to capture paths on deleted entries*/ + gf_boolean_t capture_del_path; }; struct changelog_local { - inode_t *inode; - gf_boolean_t update_no_check; + inode_t *inode; + gf_boolean_t update_no_check; - changelog_log_data_t cld; + changelog_log_data_t cld; - /** - * ->prev_entry is used in cases when there needs to be - * additional changelog entry for the parent (eg. rename) - * It's analogous to ->next in single linked list world, - * but we call it as ->prev_entry... ha ha ha - */ - struct changelog_local *prev_entry; + /** + * ->prev_entry is used in cases when there needs to be + * additional changelog entry for the parent (eg. rename) + * It's analogous to ->next in single linked list world, + * but we call it as ->prev_entry... ha ha ha + */ + struct changelog_local *prev_entry; - /* snap dependency changes */ - chlog_fop_color_t color; + /* snap dependency changes */ + chlog_fop_color_t color; }; typedef struct changelog_local changelog_local_t; /* inode version is stored in inode ctx */ typedef struct changelog_inode_ctx { - unsigned long iversion[CHANGELOG_MAX_TYPE]; + unsigned long iversion[CHANGELOG_MAX_TYPE]; } changelog_inode_ctx_t; -#define CHANGELOG_INODE_VERSION_TYPE(ctx, type) &(ctx->iversion[type]) +#define CHANGELOG_INODE_VERSION_TYPE(ctx, type) &(ctx->iversion[type]) /** * Optional Records: @@ -344,269 +342,279 @@ typedef struct changelog_inode_ctx { * @changelog_opt_t struct. The array is allocated via @iobufs. */ typedef enum { - CHANGELOG_OPT_REC_FOP, - CHANGELOG_OPT_REC_ENTRY, - CHANGELOG_OPT_REC_UINT32, + CHANGELOG_OPT_REC_FOP, + CHANGELOG_OPT_REC_ENTRY, + CHANGELOG_OPT_REC_UINT32, } changelog_optional_rec_type_t; struct changelog_entry_fields { - uuid_t cef_uuid; - char *cef_bname; - char *cef_path; + uuid_t cef_uuid; + char *cef_bname; + char *cef_path; }; typedef struct { - /** - * @co_covert can be used to do post-processing of the record before - * it's persisted to the CHANGELOG. If this is NULL, then the record - * is persisted as per it's in memory format. - */ - size_t (*co_convert) (void *data, char *buffer, gf_boolean_t encode); - - /* release routines */ - void (*co_free) (void *data); - - /* type of the field */ - changelog_optional_rec_type_t co_type; - - /** - * sizeof of the 'valid' field in the union. This field is not used if - * @co_convert is specified. - */ - size_t co_len; - - union { - unsigned int co_uint32; - glusterfs_fop_t co_fop; - struct changelog_entry_fields co_entry; - }; + /** + * @co_covert can be used to do post-processing of the record before + * it's persisted to the CHANGELOG. If this is NULL, then the record + * is persisted as per it's in memory format. + */ + size_t (*co_convert)(void *data, char *buffer, gf_boolean_t encode); + + /* release routines */ + void (*co_free)(void *data); + + /* type of the field */ + changelog_optional_rec_type_t co_type; + + /** + * sizeof of the 'valid' field in the union. This field is not used if + * @co_convert is specified. + */ + size_t co_len; + + union { + unsigned int co_uint32; + glusterfs_fop_t co_fop; + struct changelog_entry_fields co_entry; + }; } changelog_opt_t; -#define CHANGELOG_OPT_RECORD_LEN sizeof (changelog_opt_t) +#define CHANGELOG_OPT_RECORD_LEN sizeof(changelog_opt_t) /** * helpers routines */ int -changelog_thread_cleanup (xlator_t *this, pthread_t thr_id); +changelog_thread_cleanup(xlator_t *this, pthread_t thr_id); void * -changelog_get_usable_buffer (changelog_local_t *local); +changelog_get_usable_buffer(changelog_local_t *local); void -changelog_set_usable_record_and_length (changelog_local_t *local, - size_t len, int xr); +changelog_set_usable_record_and_length(changelog_local_t *local, size_t len, + int xr); void -changelog_local_cleanup (xlator_t *xl, changelog_local_t *local); +changelog_local_cleanup(xlator_t *xl, changelog_local_t *local); changelog_local_t * -changelog_local_init (xlator_t *this, inode_t *inode, uuid_t gfid, - int xtra_records, gf_boolean_t update_flag); +changelog_local_init(xlator_t *this, inode_t *inode, uuid_t gfid, + int xtra_records, gf_boolean_t update_flag); int -changelog_start_next_change (xlator_t *this, - changelog_priv_t *priv, - unsigned long ts, gf_boolean_t finale); +changelog_start_next_change(xlator_t *this, changelog_priv_t *priv, + unsigned long ts, gf_boolean_t finale); int -changelog_open_journal (xlator_t *this, changelog_priv_t *priv); +changelog_open_journal(xlator_t *this, changelog_priv_t *priv); int -changelog_fill_rollover_data (changelog_log_data_t *cld, gf_boolean_t is_last); +changelog_fill_rollover_data(changelog_log_data_t *cld, gf_boolean_t is_last); int -changelog_inject_single_event (xlator_t *this, - changelog_priv_t *priv, - changelog_log_data_t *cld); +changelog_inject_single_event(xlator_t *this, changelog_priv_t *priv, + changelog_log_data_t *cld); size_t -changelog_entry_length (); +changelog_entry_length(); int -changelog_write (int fd, char *buffer, size_t len); +changelog_write(int fd, char *buffer, size_t len); int -changelog_write_change (changelog_priv_t *priv, char *buffer, size_t len); +changelog_write_change(changelog_priv_t *priv, char *buffer, size_t len); int -changelog_handle_change (xlator_t *this, - changelog_priv_t *priv, changelog_log_data_t *cld); +changelog_handle_change(xlator_t *this, changelog_priv_t *priv, + changelog_log_data_t *cld); void -changelog_update (xlator_t *this, changelog_priv_t *priv, - changelog_local_t *local, changelog_log_type type); +changelog_update(xlator_t *this, changelog_priv_t *priv, + changelog_local_t *local, changelog_log_type type); void * -changelog_rollover (void *data); +changelog_rollover(void *data); void * -changelog_fsync_thread (void *data); +changelog_fsync_thread(void *data); int -changelog_forget (xlator_t *this, inode_t *inode); +changelog_forget(xlator_t *this, inode_t *inode); int -htime_update (xlator_t *this, changelog_priv_t *priv, - unsigned long ts, char * buffer); +htime_update(xlator_t *this, changelog_priv_t *priv, unsigned long ts, + char *buffer); int -htime_open (xlator_t *this, changelog_priv_t *priv, unsigned long ts); +htime_open(xlator_t *this, changelog_priv_t *priv, unsigned long ts); int -htime_create (xlator_t *this, changelog_priv_t *priv, unsigned long ts); +htime_create(xlator_t *this, changelog_priv_t *priv, unsigned long ts); /* Geo-Rep snapshot dependency changes */ void -changelog_color_fop_and_inc_cnt (xlator_t *this, changelog_priv_t *priv, - changelog_local_t *local); +changelog_color_fop_and_inc_cnt(xlator_t *this, changelog_priv_t *priv, + changelog_local_t *local); void -changelog_inc_fop_cnt (xlator_t *this, changelog_priv_t *priv, - changelog_local_t *local); +changelog_inc_fop_cnt(xlator_t *this, changelog_priv_t *priv, + changelog_local_t *local); void -changelog_dec_fop_cnt (xlator_t *this, changelog_priv_t *priv, - changelog_local_t *local); +changelog_dec_fop_cnt(xlator_t *this, changelog_priv_t *priv, + changelog_local_t *local); int -changelog_barrier_notify (changelog_priv_t *priv, char* buf); +changelog_barrier_notify(changelog_priv_t *priv, char *buf); void -changelog_barrier_cleanup (xlator_t *this, changelog_priv_t *priv, - struct list_head *queue); +changelog_barrier_cleanup(xlator_t *this, changelog_priv_t *priv, + struct list_head *queue); void -changelog_drain_white_fops (xlator_t *this, changelog_priv_t *priv); +changelog_drain_white_fops(xlator_t *this, changelog_priv_t *priv); void -changelog_drain_black_fops (xlator_t *this, changelog_priv_t *priv); +changelog_drain_black_fops(xlator_t *this, changelog_priv_t *priv); /* Crash consistency of changelog wrt snapshot */ int -changelog_snap_logging_stop ( xlator_t *this, changelog_priv_t *priv); +changelog_snap_logging_stop(xlator_t *this, changelog_priv_t *priv); int -changelog_snap_logging_start ( xlator_t *this, changelog_priv_t *priv); +changelog_snap_logging_start(xlator_t *this, changelog_priv_t *priv); int -changelog_snap_open ( xlator_t *this, changelog_priv_t *priv); +changelog_snap_open(xlator_t *this, changelog_priv_t *priv); int -changelog_snap_handle_ascii_change (xlator_t *this, - changelog_log_data_t *cld); +changelog_snap_handle_ascii_change(xlator_t *this, changelog_log_data_t *cld); int -changelog_snap_write_change (changelog_priv_t *priv, char *buffer, size_t len); +changelog_snap_write_change(changelog_priv_t *priv, char *buffer, size_t len); /* Changelog barrier routines */ -void __chlog_barrier_enqueue (xlator_t *this, call_stub_t *stub); -void __chlog_barrier_disable (xlator_t *this, struct list_head *queue); -void chlog_barrier_dequeue_all (xlator_t *this, struct list_head *queue); -call_stub_t *__chlog_barrier_dequeue (xlator_t *this, struct list_head *queue); -int __chlog_barrier_enable (xlator_t *this, changelog_priv_t *priv); +void +__chlog_barrier_enqueue(xlator_t *this, call_stub_t *stub); +void +__chlog_barrier_disable(xlator_t *this, struct list_head *queue); +void +chlog_barrier_dequeue_all(xlator_t *this, struct list_head *queue); +call_stub_t * +__chlog_barrier_dequeue(xlator_t *this, struct list_head *queue); +int +__chlog_barrier_enable(xlator_t *this, changelog_priv_t *priv); int32_t -changelog_fill_entry_buf (call_frame_t *frame, xlator_t *this, - loc_t *loc, changelog_local_t **local); +changelog_fill_entry_buf(call_frame_t *frame, xlator_t *this, loc_t *loc, + changelog_local_t **local); /* event selection routines */ -void changelog_select_event (xlator_t *, - changelog_ev_selector_t *, unsigned int); -void changelog_deselect_event (xlator_t *, - changelog_ev_selector_t *, unsigned int); -int changelog_init_event_selection (xlator_t *, - changelog_ev_selector_t *); -int changelog_cleanup_event_selection (xlator_t *, - changelog_ev_selector_t *); -int changelog_ev_selected (xlator_t *, - changelog_ev_selector_t *, unsigned int); void -changelog_dispatch_event (xlator_t *, changelog_priv_t *, changelog_event_t *); +changelog_select_event(xlator_t *, changelog_ev_selector_t *, unsigned int); +void +changelog_deselect_event(xlator_t *, changelog_ev_selector_t *, unsigned int); +int +changelog_init_event_selection(xlator_t *, changelog_ev_selector_t *); +int +changelog_cleanup_event_selection(xlator_t *, changelog_ev_selector_t *); +int +changelog_ev_selected(xlator_t *, changelog_ev_selector_t *, unsigned int); +void +changelog_dispatch_event(xlator_t *, changelog_priv_t *, changelog_event_t *); changelog_inode_ctx_t * -__changelog_inode_ctx_get (xlator_t *, inode_t *, unsigned long **, - unsigned long *, changelog_log_type); +__changelog_inode_ctx_get(xlator_t *, inode_t *, unsigned long **, + unsigned long *, changelog_log_type); int -resolve_pargfid_to_path (xlator_t *this, const uuid_t gfid, char **path, - char *bname); +resolve_pargfid_to_path(xlator_t *this, const uuid_t gfid, char **path, + char *bname); /* macros */ -#define CHANGELOG_STACK_UNWIND(fop, frame, params ...) do { \ - changelog_local_t *__local = NULL; \ - xlator_t *__xl = NULL; \ - if (frame) { \ - __local = frame->local; \ - __xl = frame->this; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - if (__local && __local->prev_entry) \ - changelog_local_cleanup (__xl, \ - __local->prev_entry); \ - changelog_local_cleanup (__xl, __local); \ - } while (0) - -#define CHANGELOG_IOBUF_REF(iobuf) do { \ - if (iobuf) \ - iobuf_ref (iobuf); \ - } while (0) - -#define CHANGELOG_IOBUF_UNREF(iobuf) do { \ - if (iobuf) \ - iobuf_unref (iobuf); \ - } while (0) - -#define CHANGELOG_FILL_BUFFER(buffer, off, val, len) do { \ - memcpy (buffer + off, val, len); \ - off += len; \ - } while (0) - -#define SLICE_VERSION_UPDATE(slice) do { \ - int i = 0; \ - for (; i < CHANGELOG_MAX_TYPE; i++) { \ - slice->changelog_version[i]++; \ - } \ - } while (0) - -#define CHANGELOG_FILL_UINT32(co, number, converter, xlen) do { \ - co->co_convert = converter; \ - co->co_free = NULL; \ - co->co_type = CHANGELOG_OPT_REC_UINT32; \ - co->co_uint32 = number; \ - xlen += sizeof (unsigned int); \ - } while (0) - -#define CHANGLOG_FILL_FOP_NUMBER(co, fop, converter, xlen) do { \ - co->co_convert = converter; \ - co->co_free = NULL; \ - co->co_type = CHANGELOG_OPT_REC_FOP; \ - co->co_fop = fop; \ - xlen += sizeof (fop); \ - } while (0) - -#define CHANGELOG_FILL_ENTRY(co, pargfid, bname, \ - converter, freefn, xlen, label) \ - do { \ - co->co_convert = converter; \ - co->co_free = freefn; \ - co->co_type = CHANGELOG_OPT_REC_ENTRY; \ - gf_uuid_copy (co->co_entry.cef_uuid, pargfid); \ - co->co_entry.cef_bname = gf_strdup(bname); \ - if (!co->co_entry.cef_bname) \ - goto label; \ - xlen += (UUID_CANONICAL_FORM_LEN + strlen (bname)); \ - } while (0) - -#define CHANGELOG_FILL_ENTRY_DIR_PATH(co, pargfid, bname, converter, \ - del_freefn, xlen, label, capture_del) \ - do { \ - co->co_convert = converter; \ - co->co_free = del_freefn; \ - co->co_type = CHANGELOG_OPT_REC_ENTRY; \ - gf_uuid_copy (co->co_entry.cef_uuid, pargfid); \ - co->co_entry.cef_bname = gf_strdup(bname); \ - if (!co->co_entry.cef_bname) \ - goto label; \ - xlen += (UUID_CANONICAL_FORM_LEN + strlen (bname)); \ - if (!capture_del || resolve_pargfid_to_path (this, pargfid, \ - &(co->co_entry.cef_path), co->co_entry.cef_bname)) { \ - co->co_entry.cef_path = gf_strdup ("\0"); \ - xlen += 1; \ - } else { \ - xlen += (strlen (co->co_entry.cef_path)); \ - } \ - } while (0) - -#define CHANGELOG_INIT(this, local, inode, gfid, xrec) \ - local = changelog_local_init (this, inode, gfid, xrec, _gf_false) - -#define CHANGELOG_INIT_NOCHECK(this, local, inode, gfid, xrec) \ - local = changelog_local_init (this, inode, gfid, xrec, _gf_true) - -#define CHANGELOG_NOT_ACTIVE_THEN_GOTO(frame, priv, label) do { \ - if (!priv->active) \ - goto label; \ - /* ignore rebalance process's activity. */ \ - if ((frame->root->pid == GF_CLIENT_PID_DEFRAG) || \ - (frame->root->pid == GF_CLIENT_PID_TIER_DEFRAG)) \ - goto label; \ - } while (0) +#define CHANGELOG_STACK_UNWIND(fop, frame, params...) \ + do { \ + changelog_local_t *__local = NULL; \ + xlator_t *__xl = NULL; \ + if (frame) { \ + __local = frame->local; \ + __xl = frame->this; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + if (__local && __local->prev_entry) \ + changelog_local_cleanup(__xl, __local->prev_entry); \ + changelog_local_cleanup(__xl, __local); \ + } while (0) + +#define CHANGELOG_IOBUF_REF(iobuf) \ + do { \ + if (iobuf) \ + iobuf_ref(iobuf); \ + } while (0) + +#define CHANGELOG_IOBUF_UNREF(iobuf) \ + do { \ + if (iobuf) \ + iobuf_unref(iobuf); \ + } while (0) + +#define CHANGELOG_FILL_BUFFER(buffer, off, val, len) \ + do { \ + memcpy(buffer + off, val, len); \ + off += len; \ + } while (0) + +#define SLICE_VERSION_UPDATE(slice) \ + do { \ + int i = 0; \ + for (; i < CHANGELOG_MAX_TYPE; i++) { \ + slice->changelog_version[i]++; \ + } \ + } while (0) + +#define CHANGELOG_FILL_UINT32(co, number, converter, xlen) \ + do { \ + co->co_convert = converter; \ + co->co_free = NULL; \ + co->co_type = CHANGELOG_OPT_REC_UINT32; \ + co->co_uint32 = number; \ + xlen += sizeof(unsigned int); \ + } while (0) + +#define CHANGLOG_FILL_FOP_NUMBER(co, fop, converter, xlen) \ + do { \ + co->co_convert = converter; \ + co->co_free = NULL; \ + co->co_type = CHANGELOG_OPT_REC_FOP; \ + co->co_fop = fop; \ + xlen += sizeof(fop); \ + } while (0) + +#define CHANGELOG_FILL_ENTRY(co, pargfid, bname, converter, freefn, xlen, \ + label) \ + do { \ + co->co_convert = converter; \ + co->co_free = freefn; \ + co->co_type = CHANGELOG_OPT_REC_ENTRY; \ + gf_uuid_copy(co->co_entry.cef_uuid, pargfid); \ + co->co_entry.cef_bname = gf_strdup(bname); \ + if (!co->co_entry.cef_bname) \ + goto label; \ + xlen += (UUID_CANONICAL_FORM_LEN + strlen(bname)); \ + } while (0) + +#define CHANGELOG_FILL_ENTRY_DIR_PATH(co, pargfid, bname, converter, \ + del_freefn, xlen, label, capture_del) \ + do { \ + co->co_convert = converter; \ + co->co_free = del_freefn; \ + co->co_type = CHANGELOG_OPT_REC_ENTRY; \ + gf_uuid_copy(co->co_entry.cef_uuid, pargfid); \ + co->co_entry.cef_bname = gf_strdup(bname); \ + if (!co->co_entry.cef_bname) \ + goto label; \ + xlen += (UUID_CANONICAL_FORM_LEN + strlen(bname)); \ + if (!capture_del || \ + resolve_pargfid_to_path(this, pargfid, &(co->co_entry.cef_path), \ + co->co_entry.cef_bname)) { \ + co->co_entry.cef_path = gf_strdup("\0"); \ + xlen += 1; \ + } else { \ + xlen += (strlen(co->co_entry.cef_path)); \ + } \ + } while (0) + +#define CHANGELOG_INIT(this, local, inode, gfid, xrec) \ + local = changelog_local_init(this, inode, gfid, xrec, _gf_false) + +#define CHANGELOG_INIT_NOCHECK(this, local, inode, gfid, xrec) \ + local = changelog_local_init(this, inode, gfid, xrec, _gf_true) + +#define CHANGELOG_NOT_ACTIVE_THEN_GOTO(frame, priv, label) \ + do { \ + if (!priv->active) \ + goto label; \ + /* ignore rebalance process's activity. */ \ + if ((frame->root->pid == GF_CLIENT_PID_DEFRAG) || \ + (frame->root->pid == GF_CLIENT_PID_TIER_DEFRAG)) \ + goto label; \ + } while (0) /* If it is a METADATA entry and fop num being GF_FOP_NULL, don't * log in the changelog as it is of no use. And also if it is @@ -615,78 +623,80 @@ resolve_pargfid_to_path (xlator_t *this, const uuid_t gfid, char **path, * to same changelog will be missed. Hence check for boundary * condition. */ -#define CHANGELOG_OP_BOUNDARY_CHECK(frame, label) do { \ - if (frame->root->op <= GF_FOP_NULL || \ - frame->root->op >= GF_FOP_MAXVALUE) \ - goto label; \ - } while (0) +#define CHANGELOG_OP_BOUNDARY_CHECK(frame, label) \ + do { \ + if (frame->root->op <= GF_FOP_NULL || \ + frame->root->op >= GF_FOP_MAXVALUE) \ + goto label; \ + } while (0) /** * ignore internal fops for all clients except AFR self-heal daemon */ -#define CHANGELOG_IF_INTERNAL_FOP_THEN_GOTO(frame, dict, label) do { \ - if ((frame->root->pid != GF_CLIENT_PID_SELF_HEALD) \ - && dict \ - && dict_get (dict, GLUSTERFS_INTERNAL_FOP_KEY)) \ - goto label; \ - } while (0) - -#define CHANGELOG_COND_GOTO(priv, cond, label) do { \ - if (!priv->active || cond) \ - goto label; \ - } while (0) +#define CHANGELOG_IF_INTERNAL_FOP_THEN_GOTO(frame, dict, label) \ + do { \ + if ((frame->root->pid != GF_CLIENT_PID_SELF_HEALD) && dict && \ + dict_get(dict, GLUSTERFS_INTERNAL_FOP_KEY)) \ + goto label; \ + } while (0) + +#define CHANGELOG_COND_GOTO(priv, cond, label) \ + do { \ + if (!priv->active || cond) \ + goto label; \ + } while (0) /* Begin: Geo-Rep snapshot dependency changes */ -#define DICT_ERROR -1 -#define BARRIER_OFF 0 -#define BARRIER_ON 1 -#define DICT_DEFAULT 2 - -#define CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, label) do { \ - if (!priv->active) { \ - gf_msg (this->name, GF_LOG_WARNING, 0, \ - CHANGELOG_MSG_NOT_ACTIVE, \ - "Changelog is not active, return success"); \ - ret = 0; \ - goto label; \ - } \ - } while (0) +#define DICT_ERROR -1 +#define BARRIER_OFF 0 +#define BARRIER_ON 1 +#define DICT_DEFAULT 2 + +#define CHANGELOG_NOT_ON_THEN_GOTO(priv, ret, label) \ + do { \ + if (!priv->active) { \ + gf_msg(this->name, GF_LOG_WARNING, 0, CHANGELOG_MSG_NOT_ACTIVE, \ + "Changelog is not active, return success"); \ + ret = 0; \ + goto label; \ + } \ + } while (0) /* Log pthread error and goto label */ -#define CHANGELOG_PTHREAD_ERROR_HANDLE_0(ret, label) do { \ - if (ret) { \ - gf_smsg (this->name, GF_LOG_ERROR, \ - 0, CHANGELOG_MSG_PTHREAD_ERROR, \ - "pthread error", "error=%d", ret, NULL); \ - ret = -1; \ - goto label; \ - } \ - } while (0); +#define CHANGELOG_PTHREAD_ERROR_HANDLE_0(ret, label) \ + do { \ + if (ret) { \ + gf_smsg(this->name, GF_LOG_ERROR, 0, CHANGELOG_MSG_PTHREAD_ERROR, \ + "pthread error", "error=%d", ret, NULL); \ + ret = -1; \ + goto label; \ + } \ + } while (0); /* Log pthread error, set flag and goto label */ -#define CHANGELOG_PTHREAD_ERROR_HANDLE_1(ret, label, flag) do { \ - if (ret) { \ - gf_smsg (this->name, GF_LOG_ERROR, 0, \ - CHANGELOG_MSG_PTHREAD_ERROR, \ - "pthread error", "error=%d", ret, NULL); \ - ret = -1; \ - flag = _gf_true; \ - goto label; \ - } \ - } while (0) +#define CHANGELOG_PTHREAD_ERROR_HANDLE_1(ret, label, flag) \ + do { \ + if (ret) { \ + gf_smsg(this->name, GF_LOG_ERROR, 0, CHANGELOG_MSG_PTHREAD_ERROR, \ + "pthread error", "error=%d", ret, NULL); \ + ret = -1; \ + flag = _gf_true; \ + goto label; \ + } \ + } while (0) /* Log pthread error, unlock mutex and goto label */ -#define CHANGELOG_PTHREAD_ERROR_HANDLE_2(ret, label, mutex) do { \ - if (ret) { \ - gf_smsg (this->name, GF_LOG_ERROR, \ - 0, CHANGELOG_MSG_PTHREAD_ERROR, \ - "pthread error", "error=%d", ret, NULL); \ - ret = -1; \ - pthread_mutex_unlock (&mutex); \ - goto label; \ - } \ - } while (0) +#define CHANGELOG_PTHREAD_ERROR_HANDLE_2(ret, label, mutex) \ + do { \ + if (ret) { \ + gf_smsg(this->name, GF_LOG_ERROR, 0, CHANGELOG_MSG_PTHREAD_ERROR, \ + "pthread error", "error=%d", ret, NULL); \ + ret = -1; \ + pthread_mutex_unlock(&mutex); \ + goto label; \ + } \ + } while (0) /* End: Geo-Rep snapshot dependency changes */ diff --git a/xlators/features/changelog/src/changelog-mem-types.h b/xlators/features/changelog/src/changelog-mem-types.h index 33fea31b979..1e3786c6298 100644 --- a/xlators/features/changelog/src/changelog-mem-types.h +++ b/xlators/features/changelog/src/changelog-mem-types.h @@ -14,21 +14,21 @@ #include "mem-types.h" enum gf_changelog_mem_types { - gf_changelog_mt_priv_t = gf_common_mt_end + 1, - gf_changelog_mt_str_t = gf_common_mt_end + 2, - gf_changelog_mt_batch_t = gf_common_mt_end + 3, - gf_changelog_mt_rt_t = gf_common_mt_end + 4, - gf_changelog_mt_inode_ctx_t = gf_common_mt_end + 5, - gf_changelog_mt_rpc_clnt_t = gf_common_mt_end + 6, - gf_changelog_mt_libgfchangelog_t = gf_common_mt_end + 7, - gf_changelog_mt_libgfchangelog_entry_t = gf_common_mt_end + 8, - gf_changelog_mt_libgfchangelog_rl_t = gf_common_mt_end + 9, - gf_changelog_mt_changelog_buffer_t = gf_common_mt_end + 10, - gf_changelog_mt_history_data_t = gf_common_mt_end + 11, - gf_changelog_mt_libgfchangelog_call_pool_t = gf_common_mt_end + 12, - gf_changelog_mt_libgfchangelog_event_t = gf_common_mt_end + 13, - gf_changelog_mt_ev_dispatcher_t = gf_common_mt_end + 14, - gf_changelog_mt_end + gf_changelog_mt_priv_t = gf_common_mt_end + 1, + gf_changelog_mt_str_t = gf_common_mt_end + 2, + gf_changelog_mt_batch_t = gf_common_mt_end + 3, + gf_changelog_mt_rt_t = gf_common_mt_end + 4, + gf_changelog_mt_inode_ctx_t = gf_common_mt_end + 5, + gf_changelog_mt_rpc_clnt_t = gf_common_mt_end + 6, + gf_changelog_mt_libgfchangelog_t = gf_common_mt_end + 7, + gf_changelog_mt_libgfchangelog_entry_t = gf_common_mt_end + 8, + gf_changelog_mt_libgfchangelog_rl_t = gf_common_mt_end + 9, + gf_changelog_mt_changelog_buffer_t = gf_common_mt_end + 10, + gf_changelog_mt_history_data_t = gf_common_mt_end + 11, + gf_changelog_mt_libgfchangelog_call_pool_t = gf_common_mt_end + 12, + gf_changelog_mt_libgfchangelog_event_t = gf_common_mt_end + 13, + gf_changelog_mt_ev_dispatcher_t = gf_common_mt_end + 14, + gf_changelog_mt_end }; #endif diff --git a/xlators/features/changelog/src/changelog-messages.h b/xlators/features/changelog/src/changelog-messages.h index bbef2f2bde5..dbf133ec836 100644 --- a/xlators/features/changelog/src/changelog-messages.h +++ b/xlators/features/changelog/src/changelog-messages.h @@ -23,63 +23,35 @@ * glfs-message-id.h. */ -GLFS_MSGID(CHANGELOG, - CHANGELOG_MSG_OPEN_FAILED, - CHANGELOG_MSG_NO_MEMORY, - CHANGELOG_MSG_VOL_MISCONFIGURED, - CHANGELOG_MSG_RENAME_ERROR, - CHANGELOG_MSG_READ_ERROR, - CHANGELOG_MSG_HTIME_ERROR, - CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED, - CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED, - CHANGELOG_MSG_CHILD_MISCONFIGURED, - CHANGELOG_MSG_DIR_OPTIONS_NOT_SET, - CHANGELOG_MSG_CLOSE_ERROR, - CHANGELOG_MSG_PIPE_CREATION_ERROR, - CHANGELOG_MSG_DICT_GET_FAILED, - CHANGELOG_MSG_BARRIER_INFO, - CHANGELOG_MSG_BARRIER_ERROR, - CHANGELOG_MSG_GET_TIME_OP_FAILED, - CHANGELOG_MSG_WRITE_FAILED, - CHANGELOG_MSG_PTHREAD_ERROR, - CHANGELOG_MSG_INODE_NOT_FOUND, - CHANGELOG_MSG_FSYNC_OP_FAILED, - CHANGELOG_MSG_TOTAL_LOG_INFO, - CHANGELOG_MSG_SNAP_INFO, - CHANGELOG_MSG_SELECT_FAILED, - CHANGELOG_MSG_FCNTL_FAILED, - CHANGELOG_MSG_BNOTIFY_INFO, - CHANGELOG_MSG_ENTRY_BUF_INFO, - CHANGELOG_MSG_NOT_ACTIVE, - CHANGELOG_MSG_LOCAL_INIT_FAILED, - CHANGELOG_MSG_NOTIFY_REGISTER_FAILED, - CHANGELOG_MSG_PROGRAM_NAME_REG_FAILED, - CHANGELOG_MSG_HANDLE_PROBE_ERROR, - CHANGELOG_MSG_SET_FD_CONTEXT, - CHANGELOG_MSG_FREEUP_FAILED, - CHANGELOG_MSG_HTIME_INFO, - CHANGELOG_MSG_RPC_SUBMIT_REPLY_FAILED, - CHANGELOG_MSG_RPC_BUILD_ERROR, - CHANGELOG_MSG_RPC_CONNECT_ERROR, - CHANGELOG_MSG_RPC_START_ERROR, - CHANGELOG_MSG_BUFFER_STARVATION_ERROR, - CHANGELOG_MSG_SCAN_DIR_FAILED, - CHANGELOG_MSG_FSETXATTR_FAILED, - CHANGELOG_MSG_FGETXATTR_FAILED, - CHANGELOG_MSG_CLEANUP_ON_ACTIVE_REF, - CHANGELOG_MSG_DISPATCH_EVENT_FAILED, - CHANGELOG_MSG_PUT_BUFFER_FAILED, - CHANGELOG_MSG_PTHREAD_COND_WAIT_FAILED, - CHANGELOG_MSG_PTHREAD_CANCEL_FAILED, - CHANGELOG_MSG_INJECT_FSYNC_FAILED, - CHANGELOG_MSG_CREATE_FRAME_FAILED, - CHANGELOG_MSG_FSTAT_OP_FAILED, - CHANGELOG_MSG_LSEEK_OP_FAILED, - CHANGELOG_MSG_STRSTR_OP_FAILED, - CHANGELOG_MSG_UNLINK_OP_FAILED, - CHANGELOG_MSG_DETECT_EMPTY_CHANGELOG_FAILED, - CHANGELOG_MSG_READLINK_OP_FAILED, - CHANGELOG_MSG_EXPLICIT_ROLLOVER_FAILED -); +GLFS_MSGID( + CHANGELOG, CHANGELOG_MSG_OPEN_FAILED, CHANGELOG_MSG_NO_MEMORY, + CHANGELOG_MSG_VOL_MISCONFIGURED, CHANGELOG_MSG_RENAME_ERROR, + CHANGELOG_MSG_READ_ERROR, CHANGELOG_MSG_HTIME_ERROR, + CHANGELOG_MSG_PTHREAD_MUTEX_INIT_FAILED, + CHANGELOG_MSG_PTHREAD_COND_INIT_FAILED, CHANGELOG_MSG_CHILD_MISCONFIGURED, + CHANGELOG_MSG_DIR_OPTIONS_NOT_SET, CHANGELOG_MSG_CLOSE_ERROR, + CHANGELOG_MSG_PIPE_CREATION_ERROR, CHANGELOG_MSG_DICT_GET_FAILED, + CHANGELOG_MSG_BARRIER_INFO, CHANGELOG_MSG_BARRIER_ERROR, + CHANGELOG_MSG_GET_TIME_OP_FAILED, CHANGELOG_MSG_WRITE_FAILED, + CHANGELOG_MSG_PTHREAD_ERROR, CHANGELOG_MSG_INODE_NOT_FOUND, + CHANGELOG_MSG_FSYNC_OP_FAILED, CHANGELOG_MSG_TOTAL_LOG_INFO, + CHANGELOG_MSG_SNAP_INFO, CHANGELOG_MSG_SELECT_FAILED, + CHANGELOG_MSG_FCNTL_FAILED, CHANGELOG_MSG_BNOTIFY_INFO, + CHANGELOG_MSG_ENTRY_BUF_INFO, CHANGELOG_MSG_NOT_ACTIVE, + CHANGELOG_MSG_LOCAL_INIT_FAILED, CHANGELOG_MSG_NOTIFY_REGISTER_FAILED, + CHANGELOG_MSG_PROGRAM_NAME_REG_FAILED, CHANGELOG_MSG_HANDLE_PROBE_ERROR, + CHANGELOG_MSG_SET_FD_CONTEXT, CHANGELOG_MSG_FREEUP_FAILED, + CHANGELOG_MSG_HTIME_INFO, CHANGELOG_MSG_RPC_SUBMIT_REPLY_FAILED, + CHANGELOG_MSG_RPC_BUILD_ERROR, CHANGELOG_MSG_RPC_CONNECT_ERROR, + CHANGELOG_MSG_RPC_START_ERROR, CHANGELOG_MSG_BUFFER_STARVATION_ERROR, + CHANGELOG_MSG_SCAN_DIR_FAILED, CHANGELOG_MSG_FSETXATTR_FAILED, + CHANGELOG_MSG_FGETXATTR_FAILED, CHANGELOG_MSG_CLEANUP_ON_ACTIVE_REF, + CHANGELOG_MSG_DISPATCH_EVENT_FAILED, CHANGELOG_MSG_PUT_BUFFER_FAILED, + CHANGELOG_MSG_PTHREAD_COND_WAIT_FAILED, CHANGELOG_MSG_PTHREAD_CANCEL_FAILED, + CHANGELOG_MSG_INJECT_FSYNC_FAILED, CHANGELOG_MSG_CREATE_FRAME_FAILED, + CHANGELOG_MSG_FSTAT_OP_FAILED, CHANGELOG_MSG_LSEEK_OP_FAILED, + CHANGELOG_MSG_STRSTR_OP_FAILED, CHANGELOG_MSG_UNLINK_OP_FAILED, + CHANGELOG_MSG_DETECT_EMPTY_CHANGELOG_FAILED, + CHANGELOG_MSG_READLINK_OP_FAILED, CHANGELOG_MSG_EXPLICIT_ROLLOVER_FAILED); #endif /* !_CHANGELOG_MESSAGES_H_ */ diff --git a/xlators/features/changelog/src/changelog-misc.h b/xlators/features/changelog/src/changelog-misc.h index e96533f7365..04d1bdeba03 100644 --- a/xlators/features/changelog/src/changelog-misc.h +++ b/xlators/features/changelog/src/changelog-misc.h @@ -14,7 +14,7 @@ #include "glusterfs.h" #include "common-utils.h" -#define CHANGELOG_MAX_TYPE 4 +#define CHANGELOG_MAX_TYPE 4 #define CHANGELOG_FILE_NAME "CHANGELOG" #define HTIME_FILE_NAME "HTIME" #define CSNAP_FILE_NAME "CHANGELOG.SNAP" @@ -22,111 +22,110 @@ #define HTIME_CURRENT "trusted.glusterfs.current_htime" #define HTIME_INITIAL_VALUE "0:0" -#define CHANGELOG_VERSION_MAJOR 1 -#define CHANGELOG_VERSION_MINOR 2 +#define CHANGELOG_VERSION_MAJOR 1 +#define CHANGELOG_VERSION_MINOR 2 -#define CHANGELOG_UNIX_SOCK DEFAULT_VAR_RUN_DIRECTORY"/changelog-%s.sock" -#define CHANGELOG_TMP_UNIX_SOCK DEFAULT_VAR_RUN_DIRECTORY"/.%s%lu.sock" +#define CHANGELOG_UNIX_SOCK DEFAULT_VAR_RUN_DIRECTORY "/changelog-%s.sock" +#define CHANGELOG_TMP_UNIX_SOCK DEFAULT_VAR_RUN_DIRECTORY "/.%s%lu.sock" /** * header starts with the version and the format of the changelog. * 'version' not much of a use now. */ -#define CHANGELOG_HEADER \ - "GlusterFS Changelog | version: v%d.%d | encoding : %d\n" - -#define CHANGELOG_MAKE_SOCKET_PATH(brick_path, sockpath, len) do { \ - char xxh64[GF_XXH64_DIGEST_LENGTH*2+1] = {0,}; \ - gf_xxh64_wrapper ((unsigned char *)brick_path, \ - strlen(brick_path), \ - GF_XXHSUM64_DEFAULT_SEED, xxh64); \ - (void) snprintf (sockpath, len, \ - CHANGELOG_UNIX_SOCK, xxh64); \ - } while (0) - -#define CHANGELOG_MAKE_TMP_SOCKET_PATH(brick_path, sockpath, len) do { \ - unsigned long pid = 0; \ - char xxh64[GF_XXH64_DIGEST_LENGTH*2+1] = {0,}; \ - pid = (unsigned long) getpid (); \ - gf_xxh64_wrapper ((unsigned char *)brick_path, \ - strlen(brick_path), \ - GF_XXHSUM64_DEFAULT_SEED, xxh64); \ - (void) snprintf (sockpath, \ - len, CHANGELOG_TMP_UNIX_SOCK, \ - xxh64, pid); \ - } while (0) - +#define CHANGELOG_HEADER \ + "GlusterFS Changelog | version: v%d.%d | encoding : %d\n" + +#define CHANGELOG_MAKE_SOCKET_PATH(brick_path, sockpath, len) \ + do { \ + char xxh64[GF_XXH64_DIGEST_LENGTH * 2 + 1] = { \ + 0, \ + }; \ + gf_xxh64_wrapper((unsigned char *)brick_path, strlen(brick_path), \ + GF_XXHSUM64_DEFAULT_SEED, xxh64); \ + (void)snprintf(sockpath, len, CHANGELOG_UNIX_SOCK, xxh64); \ + } while (0) + +#define CHANGELOG_MAKE_TMP_SOCKET_PATH(brick_path, sockpath, len) \ + do { \ + unsigned long pid = 0; \ + char xxh64[GF_XXH64_DIGEST_LENGTH * 2 + 1] = { \ + 0, \ + }; \ + pid = (unsigned long)getpid(); \ + gf_xxh64_wrapper((unsigned char *)brick_path, strlen(brick_path), \ + GF_XXHSUM64_DEFAULT_SEED, xxh64); \ + (void)snprintf(sockpath, len, CHANGELOG_TMP_UNIX_SOCK, xxh64, pid); \ + } while (0) /** * ... used by libgfchangelog. */ -#define CHANGELOG_GET_HEADER_INFO(fd, buffer, len, enc, maj, min, elen) do { \ - FILE *fp; \ - int fd_dup; \ - \ - enc = -1; \ - maj = -1; \ - min = -1; \ - fd_dup = dup (fd); \ - \ - if (fd_dup != -1) { \ - fp = fdopen (fd_dup, "r"); \ - if (fp) { \ - if (fgets (buffer, len, fp)) { \ - elen = strlen (buffer); \ - sscanf (buffer, \ - CHANGELOG_HEADER, \ - &maj, &min, &enc); \ - } \ - fclose (fp); \ - } else { \ - sys_close (fd_dup); \ - } \ - } \ - } while (0) - -#define CHANGELOG_FILL_HTIME_DIR(changelog_dir, path) do { \ - snprintf (path, sizeof (path), "%s/htime", \ - changelog_dir); \ - } while(0) - -#define CHANGELOG_FILL_CSNAP_DIR(changelog_dir, path) do { \ - snprintf (path, sizeof (path), "%s/csnap", \ - changelog_dir); \ - } while(0) +#define CHANGELOG_GET_HEADER_INFO(fd, buffer, len, enc, maj, min, elen) \ + do { \ + FILE *fp; \ + int fd_dup; \ + \ + enc = -1; \ + maj = -1; \ + min = -1; \ + fd_dup = dup(fd); \ + \ + if (fd_dup != -1) { \ + fp = fdopen(fd_dup, "r"); \ + if (fp) { \ + if (fgets(buffer, len, fp)) { \ + elen = strlen(buffer); \ + sscanf(buffer, CHANGELOG_HEADER, &maj, &min, &enc); \ + } \ + fclose(fp); \ + } else { \ + sys_close(fd_dup); \ + } \ + } \ + } while (0) + +#define CHANGELOG_FILL_HTIME_DIR(changelog_dir, path) \ + do { \ + snprintf(path, sizeof(path), "%s/htime", changelog_dir); \ + } while (0) + +#define CHANGELOG_FILL_CSNAP_DIR(changelog_dir, path) \ + do { \ + snprintf(path, sizeof(path), "%s/csnap", changelog_dir); \ + } while (0) /** * everything after 'CHANGELOG_TYPE_METADATA_XATTR' are internal types * (ie. none of the fops trigger this type of event), hence * CHANGELOG_MAX_TYPE = 4 */ typedef enum { - CHANGELOG_TYPE_DATA = 0, - CHANGELOG_TYPE_METADATA, - CHANGELOG_TYPE_ENTRY, - CHANGELOG_TYPE_METADATA_XATTR, - CHANGELOG_TYPE_ROLLOVER, - CHANGELOG_TYPE_FSYNC, + CHANGELOG_TYPE_DATA = 0, + CHANGELOG_TYPE_METADATA, + CHANGELOG_TYPE_ENTRY, + CHANGELOG_TYPE_METADATA_XATTR, + CHANGELOG_TYPE_ROLLOVER, + CHANGELOG_TYPE_FSYNC, } changelog_log_type; /* operation modes - RT for now */ typedef enum { - CHANGELOG_MODE_RT = 0, + CHANGELOG_MODE_RT = 0, } changelog_mode_t; /* encoder types */ typedef enum { - CHANGELOG_ENCODE_MIN = 0, - CHANGELOG_ENCODE_BINARY, - CHANGELOG_ENCODE_ASCII, - CHANGELOG_ENCODE_MAX, + CHANGELOG_ENCODE_MIN = 0, + CHANGELOG_ENCODE_BINARY, + CHANGELOG_ENCODE_ASCII, + CHANGELOG_ENCODE_MAX, } changelog_encoder_t; -#define CHANGELOG_VALID_ENCODING(enc) \ - (enc > CHANGELOG_ENCODE_MIN && enc < CHANGELOG_ENCODE_MAX) +#define CHANGELOG_VALID_ENCODING(enc) \ + (enc > CHANGELOG_ENCODE_MIN && enc < CHANGELOG_ENCODE_MAX) -#define CHANGELOG_TYPE_IS_ENTRY(type) (type == CHANGELOG_TYPE_ENTRY) -#define CHANGELOG_TYPE_IS_ROLLOVER(type) (type == CHANGELOG_TYPE_ROLLOVER) -#define CHANGELOG_TYPE_IS_FSYNC(type) (type == CHANGELOG_TYPE_FSYNC) +#define CHANGELOG_TYPE_IS_ENTRY(type) (type == CHANGELOG_TYPE_ENTRY) +#define CHANGELOG_TYPE_IS_ROLLOVER(type) (type == CHANGELOG_TYPE_ROLLOVER) +#define CHANGELOG_TYPE_IS_FSYNC(type) (type == CHANGELOG_TYPE_FSYNC) #endif /* _CHANGELOG_MISC_H */ diff --git a/xlators/features/changelog/src/changelog-rpc-common.h b/xlators/features/changelog/src/changelog-rpc-common.h index 1a630536924..2d3f06e60c0 100644 --- a/xlators/features/changelog/src/changelog-rpc-common.h +++ b/xlators/features/changelog/src/changelog-rpc-common.h @@ -24,61 +24,62 @@ /** * Let's keep this non-configurable for now. */ -#define NR_ROTT_BUFFS 4 +#define NR_ROTT_BUFFS 4 #define NR_DISPATCHERS (NR_ROTT_BUFFS - 1) enum changelog_rpc_procnum { - CHANGELOG_RPC_PROC_NULL = 0, - CHANGELOG_RPC_PROBE_FILTER = 1, - CHANGELOG_RPC_PROC_MAX = 2, + CHANGELOG_RPC_PROC_NULL = 0, + CHANGELOG_RPC_PROBE_FILTER = 1, + CHANGELOG_RPC_PROC_MAX = 2, }; -#define CHANGELOG_RPC_PROGNUM 1885957735 -#define CHANGELOG_RPC_PROGVER 1 +#define CHANGELOG_RPC_PROGNUM 1885957735 +#define CHANGELOG_RPC_PROGVER 1 /** * reverse connection: data xfer path */ enum changelog_reverse_rpc_procnum { - CHANGELOG_REV_PROC_NULL = 0, - CHANGELOG_REV_PROC_EVENT = 1, - CHANGELOG_REV_PROC_MAX = 2, + CHANGELOG_REV_PROC_NULL = 0, + CHANGELOG_REV_PROC_EVENT = 1, + CHANGELOG_REV_PROC_MAX = 2, }; -#define CHANGELOG_REV_RPC_PROCNUM 1886350951 -#define CHANGELOG_REV_RPC_PROCVER 1 +#define CHANGELOG_REV_RPC_PROCNUM 1886350951 +#define CHANGELOG_REV_RPC_PROCVER 1 typedef struct changelog_rpc { - rpcsvc_t *svc; - struct rpc_clnt *rpc; - char sock[UNIX_PATH_MAX]; /* tied to server */ + rpcsvc_t *svc; + struct rpc_clnt *rpc; + char sock[UNIX_PATH_MAX]; /* tied to server */ } changelog_rpc_t; /* event poller */ -void *changelog_rpc_poller (void *); +void * +changelog_rpc_poller(void *); /* CLIENT API */ struct rpc_clnt * -changelog_rpc_client_init (xlator_t *, void *, char *, rpc_clnt_notify_t); +changelog_rpc_client_init(xlator_t *, void *, char *, rpc_clnt_notify_t); int -changelog_rpc_sumbit_req (struct rpc_clnt *, void *, call_frame_t *, - rpc_clnt_prog_t *, int , struct iovec *, int, - struct iobref *, xlator_t *, fop_cbk_fn_t, xdrproc_t); +changelog_rpc_sumbit_req(struct rpc_clnt *, void *, call_frame_t *, + rpc_clnt_prog_t *, int, struct iovec *, int, + struct iobref *, xlator_t *, fop_cbk_fn_t, xdrproc_t); int -changelog_invoke_rpc (xlator_t *, struct rpc_clnt *, - rpc_clnt_prog_t *, int , void *); +changelog_invoke_rpc(xlator_t *, struct rpc_clnt *, rpc_clnt_prog_t *, int, + void *); /* SERVER API */ int -changelog_rpc_sumbit_reply (rpcsvc_request_t *, void *, - struct iovec *, int, struct iobref *, xdrproc_t); +changelog_rpc_sumbit_reply(rpcsvc_request_t *, void *, struct iovec *, int, + struct iobref *, xdrproc_t); rpcsvc_t * -changelog_rpc_server_init (xlator_t *, char *, void*, - rpcsvc_notify_t, struct rpcsvc_program **); +changelog_rpc_server_init(xlator_t *, char *, void *, rpcsvc_notify_t, + struct rpcsvc_program **); void -changelog_rpc_server_destroy (xlator_t *, rpcsvc_t *, char *, - rpcsvc_notify_t, struct rpcsvc_program **); +changelog_rpc_server_destroy(xlator_t *, rpcsvc_t *, char *, rpcsvc_notify_t, + struct rpcsvc_program **); #endif diff --git a/xlators/features/changelog/src/changelog-rpc.h b/xlators/features/changelog/src/changelog-rpc.h index 9f1e2d223a3..8002cea5091 100644 --- a/xlators/features/changelog/src/changelog-rpc.h +++ b/xlators/features/changelog/src/changelog-rpc.h @@ -18,14 +18,14 @@ #include "socket.h" #include "changelog-rpc-common.h" -#define CHANGELOG_RPC_PROGNAME "GlusterFS Changelog" +#define CHANGELOG_RPC_PROGNAME "GlusterFS Changelog" rpcsvc_t * -changelog_init_rpc_listener (xlator_t *, changelog_priv_t *, rbuf_t *, int); +changelog_init_rpc_listener(xlator_t *, changelog_priv_t *, rbuf_t *, int); void -changelog_destroy_rpc_listner (xlator_t *, changelog_priv_t *); +changelog_destroy_rpc_listner(xlator_t *, changelog_priv_t *); int -changelog_cleanup_rpc_threads (xlator_t *this, changelog_priv_t *priv); +changelog_cleanup_rpc_threads(xlator_t *this, changelog_priv_t *priv); #endif diff --git a/xlators/features/changelog/src/changelog-rt.h b/xlators/features/changelog/src/changelog-rt.h index 1fc2bbc5bb9..df0d5b03487 100644 --- a/xlators/features/changelog/src/changelog-rt.h +++ b/xlators/features/changelog/src/changelog-rt.h @@ -19,15 +19,15 @@ /* unused as of now - may be you would need it later */ typedef struct changelog_rt { - gf_lock_t lock; + gf_lock_t lock; } changelog_rt_t; int -changelog_rt_init (xlator_t *this, changelog_dispatcher_t *cd); +changelog_rt_init(xlator_t *this, changelog_dispatcher_t *cd); int -changelog_rt_fini (xlator_t *this, changelog_dispatcher_t *cd); +changelog_rt_fini(xlator_t *this, changelog_dispatcher_t *cd); int -changelog_rt_enqueue (xlator_t *this, changelog_priv_t *priv, void *cbatch, - changelog_log_data_t *cld_0, changelog_log_data_t *cld_1); +changelog_rt_enqueue(xlator_t *this, changelog_priv_t *priv, void *cbatch, + changelog_log_data_t *cld_0, changelog_log_data_t *cld_1); #endif /* _CHANGELOG_RT_H */ diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h index f821201d3a5..3268c9d2fb9 100644 --- a/xlators/features/changetimerecorder/src/ctr-helper.h +++ b/xlators/features/changetimerecorder/src/ctr-helper.h @@ -11,7 +11,6 @@ #ifndef __CTR_HELPER_H #define __CTR_HELPER_H - #include "xlator.h" #include "ctr_mem_types.h" #include "iatt.h" @@ -28,37 +27,34 @@ #include "ctr-xlator-ctx.h" #include "ctr-messages.h" -#define CTR_DEFAULT_HARDLINK_EXP_PERIOD 300 /* Five mins */ -#define CTR_DEFAULT_INODE_EXP_PERIOD 300 /* Five mins */ - +#define CTR_DEFAULT_HARDLINK_EXP_PERIOD 300 /* Five mins */ +#define CTR_DEFAULT_INODE_EXP_PERIOD 300 /* Five mins */ typedef struct ctr_query_cbk_args { - int query_fd; - int count; + int query_fd; + int count; } ctr_query_cbk_args_t; - /*CTR Xlator Private structure*/ typedef struct gf_ctr_private { - gf_boolean_t enabled; - char *ctr_db_path; - gf_boolean_t ctr_hot_brick; - gf_boolean_t ctr_record_wind; - gf_boolean_t ctr_record_unwind; - gf_boolean_t ctr_record_counter; - gf_boolean_t ctr_record_metadata_heat; - gf_boolean_t ctr_link_consistency; - gfdb_db_type_t gfdb_db_type; - gfdb_sync_type_t gfdb_sync_type; - gfdb_conn_node_t *_db_conn; - uint64_t ctr_lookupheal_link_timeout; - uint64_t ctr_lookupheal_inode_timeout; - gf_boolean_t compact_active; - gf_boolean_t compact_mode_switched; - pthread_mutex_t compact_lock; + gf_boolean_t enabled; + char *ctr_db_path; + gf_boolean_t ctr_hot_brick; + gf_boolean_t ctr_record_wind; + gf_boolean_t ctr_record_unwind; + gf_boolean_t ctr_record_counter; + gf_boolean_t ctr_record_metadata_heat; + gf_boolean_t ctr_link_consistency; + gfdb_db_type_t gfdb_db_type; + gfdb_sync_type_t gfdb_sync_type; + gfdb_conn_node_t *_db_conn; + uint64_t ctr_lookupheal_link_timeout; + uint64_t ctr_lookupheal_inode_timeout; + gf_boolean_t compact_active; + gf_boolean_t compact_mode_switched; + pthread_mutex_t compact_lock; } gf_ctr_private_t; - /* * gf_ctr_local_t is the ctr xlator local data structure that is stored in * the call_frame of each FOP. @@ -76,67 +72,63 @@ typedef struct gf_ctr_private { * but currently we record only file inode information. * * is_internal_fop in gf_ctr_local will tell us if this is a internal fop and - * take special/no action. We don't record change/access times or increement heat - * counter for internal fops from rebalancer. + * take special/no action. We don't record change/access times or increement + * heat counter for internal fops from rebalancer. * */ typedef struct gf_ctr_local { - gfdb_db_record_t gfdb_db_record; - ia_type_t ia_inode_type; - gf_boolean_t is_internal_fop; - gf_special_pid_t client_pid; + gfdb_db_record_t gfdb_db_record; + ia_type_t ia_inode_type; + gf_boolean_t is_internal_fop; + gf_special_pid_t client_pid; } gf_ctr_local_t; /* * Easy access of gfdb_db_record of ctr_local * */ -#define CTR_DB_REC(ctr_local)\ - (ctr_local->gfdb_db_record) +#define CTR_DB_REC(ctr_local) (ctr_local->gfdb_db_record) /*Clear db record*/ -#define CLEAR_CTR_DB_RECORD(ctr_local)\ -do {\ - ctr_local->gfdb_db_record.gfdb_fop_path = GFDB_FOP_INVALID;\ - memset(&(ctr_local->gfdb_db_record.gfdb_wind_change_time),\ - 0, sizeof(gfdb_time_t));\ - memset(&(ctr_local->gfdb_db_record.gfdb_unwind_change_time),\ - 0, sizeof(gfdb_time_t));\ - gf_uuid_clear (ctr_local->gfdb_db_record.gfid);\ - gf_uuid_clear (ctr_local->gfdb_db_record.pargfid);\ - memset(ctr_local->gfdb_db_record.file_name, 0, GF_NAME_MAX + 1);\ - memset(ctr_local->gfdb_db_record.old_file_name, 0, GF_NAME_MAX + 1);\ - ctr_local->gfdb_db_record.gfdb_fop_type = GFDB_FOP_INVALID_OP;\ - ctr_local->ia_inode_type = IA_INVAL;\ -} while (0) - +#define CLEAR_CTR_DB_RECORD(ctr_local) \ + do { \ + ctr_local->gfdb_db_record.gfdb_fop_path = GFDB_FOP_INVALID; \ + memset(&(ctr_local->gfdb_db_record.gfdb_wind_change_time), 0, \ + sizeof(gfdb_time_t)); \ + memset(&(ctr_local->gfdb_db_record.gfdb_unwind_change_time), 0, \ + sizeof(gfdb_time_t)); \ + gf_uuid_clear(ctr_local->gfdb_db_record.gfid); \ + gf_uuid_clear(ctr_local->gfdb_db_record.pargfid); \ + memset(ctr_local->gfdb_db_record.file_name, 0, GF_NAME_MAX + 1); \ + memset(ctr_local->gfdb_db_record.old_file_name, 0, GF_NAME_MAX + 1); \ + ctr_local->gfdb_db_record.gfdb_fop_type = GFDB_FOP_INVALID_OP; \ + ctr_local->ia_inode_type = IA_INVAL; \ + } while (0) static gf_ctr_local_t * -init_ctr_local_t (xlator_t *this) { +init_ctr_local_t(xlator_t *this) +{ + gf_ctr_local_t *ctr_local = NULL; - gf_ctr_local_t *ctr_local = NULL; + GF_ASSERT(this); - GF_ASSERT(this); + ctr_local = mem_get0(this->local_pool); + if (!ctr_local) { + gf_msg(GFDB_DATA_STORE, GF_LOG_ERROR, 0, + CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, + "Error while creating ctr local"); + goto out; + } - ctr_local = mem_get0 (this->local_pool); - if (!ctr_local) { - gf_msg (GFDB_DATA_STORE, GF_LOG_ERROR, 0, - CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, - "Error while creating ctr local"); - goto out; - } - - CLEAR_CTR_DB_RECORD (ctr_local); + CLEAR_CTR_DB_RECORD(ctr_local); out: - return ctr_local; + return ctr_local; } static void -free_ctr_local (gf_ctr_local_t *ctr_local) +free_ctr_local(gf_ctr_local_t *ctr_local) { - if (ctr_local) - mem_put (ctr_local); + if (ctr_local) + mem_put(ctr_local); } - - /****************************************************************************** * * @@ -159,94 +151,85 @@ free_ctr_local (gf_ctr_local_t *ctr_local) * * */ - /*Context Carrier Structure for hard links*/ +/*Context Carrier Structure for hard links*/ typedef struct gf_ctr_link_context { - uuid_t *pargfid; - const char *basename; + uuid_t *pargfid; + const char *basename; } gf_ctr_link_context_t; - /*Context Carrier Structure for inodes*/ +/*Context Carrier Structure for inodes*/ typedef struct gf_ctr_inode_context { - ia_type_t ia_type; - uuid_t *gfid; - uuid_t *old_gfid; - gf_ctr_link_context_t *new_link_cx; - gf_ctr_link_context_t *old_link_cx; - gfdb_fop_type_t fop_type; - gfdb_fop_path_t fop_path; - gf_boolean_t is_internal_fop; - /* Indicating metadata fops */ - gf_boolean_t is_metadata_fop; + ia_type_t ia_type; + uuid_t *gfid; + uuid_t *old_gfid; + gf_ctr_link_context_t *new_link_cx; + gf_ctr_link_context_t *old_link_cx; + gfdb_fop_type_t fop_type; + gfdb_fop_path_t fop_path; + gf_boolean_t is_internal_fop; + /* Indicating metadata fops */ + gf_boolean_t is_metadata_fop; } gf_ctr_inode_context_t; - /*******************Util Macros for Context Carrier Structures*****************/ /*Checks if ctr_link_cx is sane!*/ -#define IS_CTR_LINK_CX_SANE(ctr_link_cx)\ -do {\ - if (ctr_link_cx) {\ - if (ctr_link_cx->pargfid)\ - GF_ASSERT (*(ctr_link_cx->pargfid));\ - GF_ASSERT (ctr_link_cx->basename);\ - };\ -} while (0) +#define IS_CTR_LINK_CX_SANE(ctr_link_cx) \ + do { \ + if (ctr_link_cx) { \ + if (ctr_link_cx->pargfid) \ + GF_ASSERT(*(ctr_link_cx->pargfid)); \ + GF_ASSERT(ctr_link_cx->basename); \ + }; \ + } while (0) /*Clear and fill the ctr_link_context with values*/ -#define FILL_CTR_LINK_CX(ctr_link_cx, _pargfid, _basename, label)\ -do {\ - GF_VALIDATE_OR_GOTO ("ctr", ctr_link_cx, label);\ - GF_VALIDATE_OR_GOTO ("ctr", _pargfid, label);\ - GF_VALIDATE_OR_GOTO ("ctr", _basename, label);\ - memset (ctr_link_cx, 0, sizeof (*ctr_link_cx));\ - ctr_link_cx->pargfid = &_pargfid;\ - ctr_link_cx->basename = _basename;\ -} while (0) - -#define NEW_LINK_CX(ctr_inode_cx)\ - ctr_inode_cx->new_link_cx\ - -#define OLD_LINK_CX(ctr_inode_cx)\ - ctr_inode_cx->old_link_cx\ +#define FILL_CTR_LINK_CX(ctr_link_cx, _pargfid, _basename, label) \ + do { \ + GF_VALIDATE_OR_GOTO("ctr", ctr_link_cx, label); \ + GF_VALIDATE_OR_GOTO("ctr", _pargfid, label); \ + GF_VALIDATE_OR_GOTO("ctr", _basename, label); \ + memset(ctr_link_cx, 0, sizeof(*ctr_link_cx)); \ + ctr_link_cx->pargfid = &_pargfid; \ + ctr_link_cx->basename = _basename; \ + } while (0) + +#define NEW_LINK_CX(ctr_inode_cx) ctr_inode_cx->new_link_cx + +#define OLD_LINK_CX(ctr_inode_cx) ctr_inode_cx->old_link_cx /*Checks if ctr_inode_cx is sane!*/ -#define IS_CTR_INODE_CX_SANE(ctr_inode_cx)\ -do {\ - GF_ASSERT (ctr_inode_cx);\ - GF_ASSERT (ctr_inode_cx->gfid);\ - GF_ASSERT (*(ctr_inode_cx->gfid));\ - GF_ASSERT (ctr_inode_cx->fop_type != GFDB_FOP_INVALID_OP);\ - GF_ASSERT (ctr_inode_cx->fop_path != GFDB_FOP_INVALID);\ - IS_CTR_LINK_CX_SANE (NEW_LINK_CX(ctr_inode_cx));\ - IS_CTR_LINK_CX_SANE (OLD_LINK_CX(ctr_inode_cx));\ -} while (0) +#define IS_CTR_INODE_CX_SANE(ctr_inode_cx) \ + do { \ + GF_ASSERT(ctr_inode_cx); \ + GF_ASSERT(ctr_inode_cx->gfid); \ + GF_ASSERT(*(ctr_inode_cx->gfid)); \ + GF_ASSERT(ctr_inode_cx->fop_type != GFDB_FOP_INVALID_OP); \ + GF_ASSERT(ctr_inode_cx->fop_path != GFDB_FOP_INVALID); \ + IS_CTR_LINK_CX_SANE(NEW_LINK_CX(ctr_inode_cx)); \ + IS_CTR_LINK_CX_SANE(OLD_LINK_CX(ctr_inode_cx)); \ + } while (0) /*Clear and fill the ctr_inode_context with values*/ -#define FILL_CTR_INODE_CONTEXT(ctr_inode_cx,\ - _ia_type,\ - _gfid,\ - _new_link_cx,\ - _old_link_cx,\ - _fop_type,\ - _fop_path)\ -do {\ - GF_ASSERT (ctr_inode_cx);\ - GF_ASSERT (_gfid);\ - GF_ASSERT (_fop_type != GFDB_FOP_INVALID_OP);\ - GF_ASSERT (_fop_path != GFDB_FOP_INVALID);\ - memset(ctr_inode_cx, 0, sizeof(*ctr_inode_cx));\ - ctr_inode_cx->ia_type = _ia_type;\ - ctr_inode_cx->gfid = &_gfid;\ - IS_CTR_LINK_CX_SANE(NEW_LINK_CX(ctr_inode_cx));\ - if (_new_link_cx)\ - NEW_LINK_CX(ctr_inode_cx) = _new_link_cx;\ - IS_CTR_LINK_CX_SANE(OLD_LINK_CX(ctr_inode_cx));\ - if (_old_link_cx)\ - OLD_LINK_CX(ctr_inode_cx) = _old_link_cx;\ - ctr_inode_cx->fop_type = _fop_type;\ - ctr_inode_cx->fop_path = _fop_path;\ -} while (0) - +#define FILL_CTR_INODE_CONTEXT(ctr_inode_cx, _ia_type, _gfid, _new_link_cx, \ + _old_link_cx, _fop_type, _fop_path) \ + do { \ + GF_ASSERT(ctr_inode_cx); \ + GF_ASSERT(_gfid); \ + GF_ASSERT(_fop_type != GFDB_FOP_INVALID_OP); \ + GF_ASSERT(_fop_path != GFDB_FOP_INVALID); \ + memset(ctr_inode_cx, 0, sizeof(*ctr_inode_cx)); \ + ctr_inode_cx->ia_type = _ia_type; \ + ctr_inode_cx->gfid = &_gfid; \ + IS_CTR_LINK_CX_SANE(NEW_LINK_CX(ctr_inode_cx)); \ + if (_new_link_cx) \ + NEW_LINK_CX(ctr_inode_cx) = _new_link_cx; \ + IS_CTR_LINK_CX_SANE(OLD_LINK_CX(ctr_inode_cx)); \ + if (_old_link_cx) \ + OLD_LINK_CX(ctr_inode_cx) = _old_link_cx; \ + ctr_inode_cx->fop_type = _fop_type; \ + ctr_inode_cx->fop_path = _fop_path; \ + } while (0) /****************************************************************************** * @@ -256,11 +239,12 @@ do {\ * ****************************************************************************/ /* Free ctr frame local */ static inline void -ctr_free_frame_local (call_frame_t *frame) { - if (frame) { - free_ctr_local ((gf_ctr_local_t *) frame->local); - frame->local = NULL; - } +ctr_free_frame_local(call_frame_t *frame) +{ + if (frame) { + free_ctr_local((gf_ctr_local_t *)frame->local); + frame->local = NULL; + } } /* Setting GF_REQUEST_LINK_COUNT_XDATA in dict @@ -271,170 +255,161 @@ ctr_free_frame_local (call_frame_t *frame) { * return -1 for failure. * */ static inline int -set_posix_link_request (xlator_t *this, - dict_t **xdata) +set_posix_link_request(xlator_t *this, dict_t **xdata) { - int ret = -1; - gf_boolean_t is_created = _gf_false; - - GF_VALIDATE_OR_GOTO ("ctr", this, out); - GF_VALIDATE_OR_GOTO (this->name, xdata, out); - - /*create xdata if NULL*/ - if (!*xdata) { - *xdata = dict_new(); - is_created = _gf_true; - ret = 1; - } else { - ret = 0; - } - - if (!*xdata) { - gf_msg (this->name, GF_LOG_ERROR, 0, CTR_MSG_XDATA_NULL, - "xdata is NULL :Cannot send " - "GF_REQUEST_LINK_COUNT_XDATA to posix"); - ret = -1; - goto out; - } - - ret = dict_set_int32 (*xdata, GF_REQUEST_LINK_COUNT_XDATA, 1); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - "Failed setting GF_REQUEST_LINK_COUNT_XDATA"); - ret = -1; - goto out; - } + int ret = -1; + gf_boolean_t is_created = _gf_false; + + GF_VALIDATE_OR_GOTO("ctr", this, out); + GF_VALIDATE_OR_GOTO(this->name, xdata, out); + + /*create xdata if NULL*/ + if (!*xdata) { + *xdata = dict_new(); + is_created = _gf_true; + ret = 1; + } else { ret = 0; + } + + if (!*xdata) { + gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_XDATA_NULL, + "xdata is NULL :Cannot send " + "GF_REQUEST_LINK_COUNT_XDATA to posix"); + ret = -1; + goto out; + } + + ret = dict_set_int32(*xdata, GF_REQUEST_LINK_COUNT_XDATA, 1); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, + "Failed setting GF_REQUEST_LINK_COUNT_XDATA"); + ret = -1; + goto out; + } + ret = 0; out: - if (ret == -1) { - if (*xdata && is_created) { - dict_unref (*xdata); - } + if (ret == -1) { + if (*xdata && is_created) { + dict_unref(*xdata); } - return ret; + } + return ret; } - /* * If a bitrot fop * */ -#define BITROT_FOP(frame)\ - (frame->root->pid == GF_CLIENT_PID_BITD ||\ - frame->root->pid == GF_CLIENT_PID_SCRUB) - +#define BITROT_FOP(frame) \ + (frame->root->pid == GF_CLIENT_PID_BITD || \ + frame->root->pid == GF_CLIENT_PID_SCRUB) /* * If a rebalancer fop * */ -#define REBALANCE_FOP(frame)\ - (frame->root->pid == GF_CLIENT_PID_DEFRAG) +#define REBALANCE_FOP(frame) (frame->root->pid == GF_CLIENT_PID_DEFRAG) /* * If its a tiering rebalancer fop * */ -#define TIER_REBALANCE_FOP(frame)\ - (frame->root->pid == GF_CLIENT_PID_TIER_DEFRAG) +#define TIER_REBALANCE_FOP(frame) \ + (frame->root->pid == GF_CLIENT_PID_TIER_DEFRAG) /* * If its a AFR SELF HEAL * */ - #define AFR_SELF_HEAL_FOP(frame)\ - (frame->root->pid == GF_CLIENT_PID_SELF_HEALD) +#define AFR_SELF_HEAL_FOP(frame) (frame->root->pid == GF_CLIENT_PID_SELF_HEALD) /* * if a rebalancer fop goto * */ -#define CTR_IF_REBALANCE_FOP_THEN_GOTO(frame, label)\ -do {\ - if (REBALANCE_FOP (frame))\ - goto label;\ -} while (0) +#define CTR_IF_REBALANCE_FOP_THEN_GOTO(frame, label) \ + do { \ + if (REBALANCE_FOP(frame)) \ + goto label; \ + } while (0) /* * Internal fop * * */ static inline gf_boolean_t -is_internal_fop (call_frame_t *frame, - dict_t *xdata) +is_internal_fop(call_frame_t *frame, dict_t *xdata) { - gf_boolean_t ret = _gf_false; - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - - if (AFR_SELF_HEAL_FOP (frame)) { - ret = _gf_true; - } - if (BITROT_FOP (frame)) { - ret = _gf_true; - } - if (REBALANCE_FOP (frame) || TIER_REBALANCE_FOP (frame)) { - ret = _gf_true; - if (xdata && dict_get (xdata, CTR_ATTACH_TIER_LOOKUP)) { - ret = _gf_false; - } - } - if (xdata && dict_get (xdata, GLUSTERFS_INTERNAL_FOP_KEY)) { - ret = _gf_true; + gf_boolean_t ret = _gf_false; + + GF_ASSERT(frame); + GF_ASSERT(frame->root); + + if (AFR_SELF_HEAL_FOP(frame)) { + ret = _gf_true; + } + if (BITROT_FOP(frame)) { + ret = _gf_true; + } + if (REBALANCE_FOP(frame) || TIER_REBALANCE_FOP(frame)) { + ret = _gf_true; + if (xdata && dict_get(xdata, CTR_ATTACH_TIER_LOOKUP)) { + ret = _gf_false; } + } + if (xdata && dict_get(xdata, GLUSTERFS_INTERNAL_FOP_KEY)) { + ret = _gf_true; + } - return ret; + return ret; } -#define CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, dict, label)\ -do {\ - if (is_internal_fop (frame, dict)) \ - goto label; \ -} while (0) +#define CTR_IF_INTERNAL_FOP_THEN_GOTO(frame, dict, label) \ + do { \ + if (is_internal_fop(frame, dict)) \ + goto label; \ + } while (0) /* if fop has failed exit */ -#define CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, label)\ -do {\ - if (op_ret == -1) {\ - gf_msg_trace (this->name, 0, "Failed fop with %s",\ - strerror (op_errno));\ - goto label;\ - };\ -} while (0) +#define CTR_IF_FOP_FAILED_THEN_GOTO(this, op_ret, op_errno, label) \ + do { \ + if (op_ret == -1) { \ + gf_msg_trace(this->name, 0, "Failed fop with %s", \ + strerror(op_errno)); \ + goto label; \ + }; \ + } while (0) /* * IS CTR Xlator is disabled then goto to label * */ - #define CTR_IS_DISABLED_THEN_GOTO(this, label)\ - do {\ - gf_ctr_private_t *_priv = NULL;\ - GF_ASSERT (this);\ - GF_ASSERT (this->private);\ - _priv = this->private;\ - if (!_priv->_db_conn)\ - goto label;\ - } while (0) +#define CTR_IS_DISABLED_THEN_GOTO(this, label) \ + do { \ + gf_ctr_private_t *_priv = NULL; \ + GF_ASSERT(this); \ + GF_ASSERT(this->private); \ + _priv = this->private; \ + if (!_priv->_db_conn) \ + goto label; \ + } while (0) /* * IS CTR record metadata heat is disabled then goto to label * */ - #define CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, label)\ - do {\ - gf_ctr_private_t *_priv = NULL;\ - GF_ASSERT (this);\ - GF_ASSERT (this->private);\ - _priv = this->private;\ - if (!_priv->ctr_record_metadata_heat)\ - goto label;\ - } while (0) +#define CTR_RECORD_METADATA_HEAT_IS_DISABLED_THEN_GOTO(this, label) \ + do { \ + gf_ctr_private_t *_priv = NULL; \ + GF_ASSERT(this); \ + GF_ASSERT(this->private); \ + _priv = this->private; \ + if (!_priv->ctr_record_metadata_heat) \ + goto label; \ + } while (0) int -fill_db_record_for_unwind (xlator_t *this, - gf_ctr_local_t *ctr_local, - gfdb_fop_type_t fop_type, - gfdb_fop_path_t fop_path); +fill_db_record_for_unwind(xlator_t *this, gf_ctr_local_t *ctr_local, + gfdb_fop_type_t fop_type, gfdb_fop_path_t fop_path); int -fill_db_record_for_wind (xlator_t *this, - gf_ctr_local_t *ctr_local, - gf_ctr_inode_context_t *ctr_inode_cx); +fill_db_record_for_wind(xlator_t *this, gf_ctr_local_t *ctr_local, + gf_ctr_inode_context_t *ctr_inode_cx); /******************************************************************************* * CTR INSERT WIND @@ -445,116 +420,108 @@ fill_db_record_for_wind (xlator_t *this, * ****************************************************************************/ static inline int -ctr_insert_wind (call_frame_t *frame, - xlator_t *this, - gf_ctr_inode_context_t *ctr_inode_cx) +ctr_insert_wind(call_frame_t *frame, xlator_t *this, + gf_ctr_inode_context_t *ctr_inode_cx) { - int ret = -1; - gf_ctr_private_t *_priv = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(frame); - GF_ASSERT(frame->root); - GF_ASSERT(this); - IS_CTR_INODE_CX_SANE(ctr_inode_cx); - - _priv = this->private; - GF_ASSERT (_priv); - - GF_ASSERT(_priv->_db_conn); - - /*If record_wind option of CTR is on record wind for - * regular files only*/ - if (_priv->ctr_record_wind && ctr_inode_cx->ia_type != IA_IFDIR) { - frame->local = init_ctr_local_t (this); - if (!frame->local) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, - "WIND: Error while creating ctr local"); - goto out; - }; - ctr_local = frame->local; - ctr_local->client_pid = frame->root->pid; - ctr_local->is_internal_fop = ctr_inode_cx->is_internal_fop; - - /* Decide whether to record counters or not */ - CTR_DB_REC(ctr_local).do_record_counters = _gf_false; - /* If record counter is enabled */ - if (_priv->ctr_record_counter) { - /* If not a internal fop */ - if (!(ctr_local->is_internal_fop)) { - /* If its a metadata fop AND - * record metadata heat - * OR - * its NOT a metadata fop */ - if ((ctr_inode_cx->is_metadata_fop - && _priv->ctr_record_metadata_heat) - || - (!ctr_inode_cx->is_metadata_fop)) { - CTR_DB_REC(ctr_local).do_record_counters - = _gf_true; - } - } - } - - /* Decide whether to record times or not - * For non internal FOPS record times as usual*/ - CTR_DB_REC(ctr_local).do_record_times = _gf_false; - if (!ctr_local->is_internal_fop) { - /* If its a metadata fop AND - * record metadata heat - * OR - * its NOT a metadata fop */ - if ((ctr_inode_cx->is_metadata_fop && - _priv->ctr_record_metadata_heat) - || - (!ctr_inode_cx->is_metadata_fop)) { - CTR_DB_REC(ctr_local).do_record_times = - (_priv->ctr_record_wind - || _priv->ctr_record_unwind); - } - } - /* when its a internal FOPS*/ - else { - /* Record times only for create - * i.e when the inode is created */ - CTR_DB_REC(ctr_local).do_record_times = - (isdentrycreatefop(ctr_inode_cx->fop_type)) ? - _gf_true : _gf_false; - } - - /*Fill the db record for insertion*/ - ret = fill_db_record_for_wind (this, ctr_local, ctr_inode_cx); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND, - "WIND: Error filling ctr local"); - goto out; + int ret = -1; + gf_ctr_private_t *_priv = NULL; + gf_ctr_local_t *ctr_local = NULL; + + GF_ASSERT(frame); + GF_ASSERT(frame->root); + GF_ASSERT(this); + IS_CTR_INODE_CX_SANE(ctr_inode_cx); + + _priv = this->private; + GF_ASSERT(_priv); + + GF_ASSERT(_priv->_db_conn); + + /*If record_wind option of CTR is on record wind for + * regular files only*/ + if (_priv->ctr_record_wind && ctr_inode_cx->ia_type != IA_IFDIR) { + frame->local = init_ctr_local_t(this); + if (!frame->local) { + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, + "WIND: Error while creating ctr local"); + goto out; + }; + ctr_local = frame->local; + ctr_local->client_pid = frame->root->pid; + ctr_local->is_internal_fop = ctr_inode_cx->is_internal_fop; + + /* Decide whether to record counters or not */ + CTR_DB_REC(ctr_local).do_record_counters = _gf_false; + /* If record counter is enabled */ + if (_priv->ctr_record_counter) { + /* If not a internal fop */ + if (!(ctr_local->is_internal_fop)) { + /* If its a metadata fop AND + * record metadata heat + * OR + * its NOT a metadata fop */ + if ((ctr_inode_cx->is_metadata_fop && + _priv->ctr_record_metadata_heat) || + (!ctr_inode_cx->is_metadata_fop)) { + CTR_DB_REC(ctr_local).do_record_counters = _gf_true; } + } + } - /*Insert the db record*/ - ret = insert_record (_priv->_db_conn, - &ctr_local->gfdb_db_record); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_RECORD_WIND_FAILED, - "WIND: Inserting of record failed!"); - goto out; - } + /* Decide whether to record times or not + * For non internal FOPS record times as usual*/ + CTR_DB_REC(ctr_local).do_record_times = _gf_false; + if (!ctr_local->is_internal_fop) { + /* If its a metadata fop AND + * record metadata heat + * OR + * its NOT a metadata fop */ + if ((ctr_inode_cx->is_metadata_fop && + _priv->ctr_record_metadata_heat) || + (!ctr_inode_cx->is_metadata_fop)) { + CTR_DB_REC(ctr_local).do_record_times = + (_priv->ctr_record_wind || _priv->ctr_record_unwind); + } + } + /* when its a internal FOPS*/ + else { + /* Record times only for create + * i.e when the inode is created */ + CTR_DB_REC(ctr_local).do_record_times = (isdentrycreatefop( + ctr_inode_cx->fop_type)) + ? _gf_true + : _gf_false; } - ret = 0; -out: + /*Fill the db record for insertion*/ + ret = fill_db_record_for_wind(this, ctr_local, ctr_inode_cx); if (ret) { - free_ctr_local (ctr_local); - frame->local = NULL; + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND, + "WIND: Error filling ctr local"); + goto out; } - return ret; -} - + /*Insert the db record*/ + ret = insert_record(_priv->_db_conn, &ctr_local->gfdb_db_record); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_INSERT_RECORD_WIND_FAILED, + "WIND: Inserting of record failed!"); + goto out; + } + } + ret = 0; +out: + if (ret) { + free_ctr_local(ctr_local); + frame->local = NULL; + } + return ret; +} /******************************************************************************* * CTR INSERT UNWIND @@ -564,168 +531,148 @@ out: * call at the end. * ****************************************************************************/ static inline int -ctr_insert_unwind (call_frame_t *frame, - xlator_t *this, - gfdb_fop_type_t fop_type, - gfdb_fop_path_t fop_path) +ctr_insert_unwind(call_frame_t *frame, xlator_t *this, gfdb_fop_type_t fop_type, + gfdb_fop_path_t fop_path) { - int ret = -1; - gf_ctr_private_t *_priv = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT(frame); - GF_ASSERT(this); + int ret = -1; + gf_ctr_private_t *_priv = NULL; + gf_ctr_local_t *ctr_local = NULL; - _priv = this->private; - GF_ASSERT (_priv); + GF_ASSERT(frame); + GF_ASSERT(this); - GF_ASSERT(_priv->_db_conn); + _priv = this->private; + GF_ASSERT(_priv); - ctr_local = frame->local; + GF_ASSERT(_priv->_db_conn); - if (ctr_local - && (_priv->ctr_record_unwind || isdentryfop(fop_type)) - && (ctr_local->ia_inode_type != IA_IFDIR)) { + ctr_local = frame->local; - CTR_DB_REC(ctr_local).do_record_uwind_time = - _priv->ctr_record_unwind; + if (ctr_local && (_priv->ctr_record_unwind || isdentryfop(fop_type)) && + (ctr_local->ia_inode_type != IA_IFDIR)) { + CTR_DB_REC(ctr_local).do_record_uwind_time = _priv->ctr_record_unwind; - ret = fill_db_record_for_unwind(this, ctr_local, fop_type, - fop_path); - if (ret == -1) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, - "UNWIND: Error filling ctr local"); - goto out; - } + ret = fill_db_record_for_unwind(this, ctr_local, fop_type, fop_path); + if (ret == -1) { + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, + "UNWIND: Error filling ctr local"); + goto out; + } - ret = insert_record(_priv->_db_conn, - &ctr_local->gfdb_db_record); - if (ret == -1) { - gf_msg(this->name, GF_LOG_ERROR, 0, - CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, - "UNWIND: Error filling ctr local"); - goto out; - } + ret = insert_record(_priv->_db_conn, &ctr_local->gfdb_db_record); + if (ret == -1) { + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, + "UNWIND: Error filling ctr local"); + goto out; } - ret = 0; + } + ret = 0; out: - return ret; + return ret; } /****************************************************************************** * Delete file/flink record/s from db * ****************************************************************************/ static inline int -ctr_delete_hard_link_from_db (xlator_t *this, - uuid_t gfid, - uuid_t pargfid, - char *basename, - gfdb_fop_type_t fop_type, - gfdb_fop_path_t fop_path) +ctr_delete_hard_link_from_db(xlator_t *this, uuid_t gfid, uuid_t pargfid, + char *basename, gfdb_fop_type_t fop_type, + gfdb_fop_path_t fop_path) { - int ret = -1; - gfdb_db_record_t gfdb_db_record; - gf_ctr_private_t *_priv = NULL; - - _priv = this->private; - GF_VALIDATE_OR_GOTO (this->name, _priv, out); - GF_VALIDATE_OR_GOTO (this->name, (!gf_uuid_is_null (gfid)), out); - GF_VALIDATE_OR_GOTO (this->name, (!gf_uuid_is_null (pargfid)), out); - GF_VALIDATE_OR_GOTO (this->name, (fop_type == GFDB_FOP_DENTRY_WRITE), - out); - GF_VALIDATE_OR_GOTO (this->name, - (fop_path == GFDB_FOP_UNDEL || GFDB_FOP_UNDEL_ALL), - out); - - /* Set gfdb_db_record to 0 */ - memset (&gfdb_db_record, 0, sizeof(gfdb_db_record)); - - /* Copy basename */ - if (snprintf (gfdb_db_record.file_name, GF_NAME_MAX, "%s", - basename) >= GF_NAME_MAX) - goto out; - - /* Copy gfid into db record */ - gf_uuid_copy (gfdb_db_record.gfid, gfid); - - /* Copy pargid into db record */ - gf_uuid_copy (gfdb_db_record.pargfid, pargfid); - - gfdb_db_record.gfdb_fop_path = fop_path; - gfdb_db_record.gfdb_fop_type = fop_type; - - /*send delete request to db*/ - ret = insert_record (_priv->_db_conn, &gfdb_db_record); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_INSERT_RECORD_WIND_FAILED, - "Failed to delete record. %s", basename); - goto out; - } - - ret = 0; + int ret = -1; + gfdb_db_record_t gfdb_db_record; + gf_ctr_private_t *_priv = NULL; + + _priv = this->private; + GF_VALIDATE_OR_GOTO(this->name, _priv, out); + GF_VALIDATE_OR_GOTO(this->name, (!gf_uuid_is_null(gfid)), out); + GF_VALIDATE_OR_GOTO(this->name, (!gf_uuid_is_null(pargfid)), out); + GF_VALIDATE_OR_GOTO(this->name, (fop_type == GFDB_FOP_DENTRY_WRITE), out); + GF_VALIDATE_OR_GOTO( + this->name, (fop_path == GFDB_FOP_UNDEL || GFDB_FOP_UNDEL_ALL), out); + + /* Set gfdb_db_record to 0 */ + memset(&gfdb_db_record, 0, sizeof(gfdb_db_record)); + + /* Copy basename */ + if (snprintf(gfdb_db_record.file_name, GF_NAME_MAX, "%s", basename) >= + GF_NAME_MAX) + goto out; + + /* Copy gfid into db record */ + gf_uuid_copy(gfdb_db_record.gfid, gfid); + + /* Copy pargid into db record */ + gf_uuid_copy(gfdb_db_record.pargfid, pargfid); + + gfdb_db_record.gfdb_fop_path = fop_path; + gfdb_db_record.gfdb_fop_type = fop_type; + + /*send delete request to db*/ + ret = insert_record(_priv->_db_conn, &gfdb_db_record); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_INSERT_RECORD_WIND_FAILED, + "Failed to delete record. %s", basename); + goto out; + } + + ret = 0; out: - return ret; + return ret; } /******************************* Hard link function ***************************/ static inline gf_boolean_t -__is_inode_expired (ctr_xlator_ctx_t *ctr_xlator_ctx, - gf_ctr_private_t *_priv, - gfdb_time_t *current_time) +__is_inode_expired(ctr_xlator_ctx_t *ctr_xlator_ctx, gf_ctr_private_t *_priv, + gfdb_time_t *current_time) { - gf_boolean_t ret = _gf_false; - uint64_t time_diff = 0; + gf_boolean_t ret = _gf_false; + uint64_t time_diff = 0; - GF_ASSERT (ctr_xlator_ctx); - GF_ASSERT (_priv); - GF_ASSERT (current_time); + GF_ASSERT(ctr_xlator_ctx); + GF_ASSERT(_priv); + GF_ASSERT(current_time); - time_diff = current_time->tv_sec - - ctr_xlator_ctx->inode_heal_period; + time_diff = current_time->tv_sec - ctr_xlator_ctx->inode_heal_period; - ret = (time_diff >= _priv->ctr_lookupheal_inode_timeout) ? - _gf_true : _gf_false; - return ret; + ret = (time_diff >= _priv->ctr_lookupheal_inode_timeout) ? _gf_true + : _gf_false; + return ret; } static inline gf_boolean_t -__is_hardlink_expired (ctr_hard_link_t *ctr_hard_link, - gf_ctr_private_t *_priv, - gfdb_time_t *current_time) +__is_hardlink_expired(ctr_hard_link_t *ctr_hard_link, gf_ctr_private_t *_priv, + gfdb_time_t *current_time) { - gf_boolean_t ret = _gf_false; - uint64_t time_diff = 0; + gf_boolean_t ret = _gf_false; + uint64_t time_diff = 0; - GF_ASSERT (ctr_hard_link); - GF_ASSERT (_priv); - GF_ASSERT (current_time); + GF_ASSERT(ctr_hard_link); + GF_ASSERT(_priv); + GF_ASSERT(current_time); - time_diff = current_time->tv_sec - - ctr_hard_link->hardlink_heal_period; + time_diff = current_time->tv_sec - ctr_hard_link->hardlink_heal_period; - ret = ret || (time_diff >= _priv->ctr_lookupheal_link_timeout) ? - _gf_true : _gf_false; + ret = ret || (time_diff >= _priv->ctr_lookupheal_link_timeout) ? _gf_true + : _gf_false; - return ret; + return ret; } - /* Return values of heal*/ typedef enum ctr_heal_ret_val { - CTR_CTX_ERROR = -1, - /* No healing required */ - CTR_TRY_NO_HEAL = 0, - /* Try healing hard link */ - CTR_TRY_HARDLINK_HEAL = 1, - /* Try healing inode */ - CTR_TRY_INODE_HEAL = 2, + CTR_CTX_ERROR = -1, + /* No healing required */ + CTR_TRY_NO_HEAL = 0, + /* Try healing hard link */ + CTR_TRY_HARDLINK_HEAL = 1, + /* Try healing inode */ + CTR_TRY_INODE_HEAL = 2, } ctr_heal_ret_val_t; - - /** * @brief Function to add hard link to the inode context variable. * The inode context maintainences a in-memory list. This is used @@ -737,180 +684,161 @@ typedef enum ctr_heal_ret_val { */ static inline ctr_heal_ret_val_t -add_hard_link_ctx (call_frame_t *frame, - xlator_t *this, - inode_t *inode) +add_hard_link_ctx(call_frame_t *frame, xlator_t *this, inode_t *inode) { - ctr_heal_ret_val_t ret_val = CTR_TRY_NO_HEAL; - int ret = -1; - gf_ctr_local_t *ctr_local = NULL; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - ctr_hard_link_t *ctr_hard_link = NULL; - gf_ctr_private_t *_priv = NULL; - gfdb_time_t current_time = {0}; - - - GF_ASSERT (frame); - GF_ASSERT (this); - GF_ASSERT (inode); - GF_ASSERT (this->private); - - _priv = this->private; - - ctr_local = frame->local; - if (!ctr_local) { - goto out; - } - - ctr_xlator_ctx = init_ctr_xlator_ctx (this, inode); - if (!ctr_xlator_ctx) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, - "Failed accessing ctr inode context"); - goto out; + ctr_heal_ret_val_t ret_val = CTR_TRY_NO_HEAL; + int ret = -1; + gf_ctr_local_t *ctr_local = NULL; + ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; + ctr_hard_link_t *ctr_hard_link = NULL; + gf_ctr_private_t *_priv = NULL; + gfdb_time_t current_time = {0}; + + GF_ASSERT(frame); + GF_ASSERT(this); + GF_ASSERT(inode); + GF_ASSERT(this->private); + + _priv = this->private; + + ctr_local = frame->local; + if (!ctr_local) { + goto out; + } + + ctr_xlator_ctx = init_ctr_xlator_ctx(this, inode); + if (!ctr_xlator_ctx) { + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, + "Failed accessing ctr inode context"); + goto out; + } + + LOCK(&ctr_xlator_ctx->lock); + + /* Check if the hard link already exists + * in the ctr inode context*/ + ctr_hard_link = ctr_search_hard_link_ctx(this, ctr_xlator_ctx, + CTR_DB_REC(ctr_local).pargfid, + CTR_DB_REC(ctr_local).file_name); + /* if there then ignore */ + if (ctr_hard_link) { + ret = gettimeofday(¤t_time, NULL); + if (ret == -1) { + gf_log(this->name, GF_LOG_ERROR, "Failed to get current time"); + ret_val = CTR_CTX_ERROR; + goto unlock; } - LOCK (&ctr_xlator_ctx->lock); - - /* Check if the hard link already exists - * in the ctr inode context*/ - ctr_hard_link = ctr_search_hard_link_ctx (this, - ctr_xlator_ctx, - CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name); - /* if there then ignore */ - if (ctr_hard_link) { - - ret = gettimeofday (¤t_time, NULL); - if (ret == -1) { - gf_log (this->name, GF_LOG_ERROR, - "Failed to get current time"); - ret_val = CTR_CTX_ERROR; - goto unlock; - } - - if (__is_hardlink_expired (ctr_hard_link, - _priv, ¤t_time)) { - ctr_hard_link->hardlink_heal_period = - current_time.tv_sec; - ret_val = ret_val | CTR_TRY_HARDLINK_HEAL; - } - - if (__is_inode_expired (ctr_xlator_ctx, - _priv, ¤t_time)) { - ctr_xlator_ctx->inode_heal_period = - current_time.tv_sec; - ret_val = ret_val | CTR_TRY_INODE_HEAL; - } - - goto unlock; + if (__is_hardlink_expired(ctr_hard_link, _priv, ¤t_time)) { + ctr_hard_link->hardlink_heal_period = current_time.tv_sec; + ret_val = ret_val | CTR_TRY_HARDLINK_HEAL; } - /* Add the hard link to the list*/ - ret = ctr_add_hard_link (this, ctr_xlator_ctx, - CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, - "Failed to add hardlink to the ctr inode context"); - ret_val = CTR_CTX_ERROR; - goto unlock; + if (__is_inode_expired(ctr_xlator_ctx, _priv, ¤t_time)) { + ctr_xlator_ctx->inode_heal_period = current_time.tv_sec; + ret_val = ret_val | CTR_TRY_INODE_HEAL; } - ret_val = CTR_TRY_NO_HEAL; + goto unlock; + } + + /* Add the hard link to the list*/ + ret = ctr_add_hard_link(this, ctr_xlator_ctx, CTR_DB_REC(ctr_local).pargfid, + CTR_DB_REC(ctr_local).file_name); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, + "Failed to add hardlink to the ctr inode context"); + ret_val = CTR_CTX_ERROR; + goto unlock; + } + + ret_val = CTR_TRY_NO_HEAL; unlock: - UNLOCK (&ctr_xlator_ctx->lock); + UNLOCK(&ctr_xlator_ctx->lock); out: - return ret_val; + return ret_val; } static inline int -delete_hard_link_ctx (call_frame_t *frame, - xlator_t *this, - inode_t *inode) +delete_hard_link_ctx(call_frame_t *frame, xlator_t *this, inode_t *inode) { - int ret = -1; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT (frame); - GF_ASSERT (this); - GF_ASSERT (inode); - - ctr_local = frame->local; - if (!ctr_local) { - goto out; - } - - ctr_xlator_ctx = get_ctr_xlator_ctx (this, inode); - if (!ctr_xlator_ctx) { - /* Since there is no ctr inode context so nothing more to do */ - ret = 0; - goto out; - } + int ret = -1; + ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; + gf_ctr_local_t *ctr_local = NULL; + + GF_ASSERT(frame); + GF_ASSERT(this); + GF_ASSERT(inode); + + ctr_local = frame->local; + if (!ctr_local) { + goto out; + } + + ctr_xlator_ctx = get_ctr_xlator_ctx(this, inode); + if (!ctr_xlator_ctx) { + /* Since there is no ctr inode context so nothing more to do */ + ret = 0; + goto out; + } - ret = ctr_delete_hard_link (this, ctr_xlator_ctx, - CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_DELETE_HARDLINK_FAILED, - "Failed to delete hard link"); - goto out; - } + ret = ctr_delete_hard_link(this, ctr_xlator_ctx, + CTR_DB_REC(ctr_local).pargfid, + CTR_DB_REC(ctr_local).file_name); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_DELETE_HARDLINK_FAILED, + "Failed to delete hard link"); + goto out; + } - ret = 0; + ret = 0; out: - return ret; + return ret; } static inline int -update_hard_link_ctx (call_frame_t *frame, - xlator_t *this, - inode_t *inode) +update_hard_link_ctx(call_frame_t *frame, xlator_t *this, inode_t *inode) { - int ret = -1; - ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; - gf_ctr_local_t *ctr_local = NULL; - - GF_ASSERT (frame); - GF_ASSERT (this); - GF_ASSERT (inode); - - ctr_local = frame->local; - if (!ctr_local) { - goto out; - } - - ctr_xlator_ctx = init_ctr_xlator_ctx (this, inode); - if (!ctr_xlator_ctx) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, - "Failed accessing ctr inode context"); - goto out; - } - - ret = ctr_update_hard_link (this, ctr_xlator_ctx, - CTR_DB_REC(ctr_local).pargfid, - CTR_DB_REC(ctr_local).file_name, - CTR_DB_REC(ctr_local).old_pargfid, - CTR_DB_REC(ctr_local).old_file_name); - if (ret) { - gf_msg (this->name, GF_LOG_ERROR, 0, - CTR_MSG_DELETE_HARDLINK_FAILED, - "Failed to delete hard link"); - goto out; - } - - ret = 0; + int ret = -1; + ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; + gf_ctr_local_t *ctr_local = NULL; + + GF_ASSERT(frame); + GF_ASSERT(this); + GF_ASSERT(inode); + + ctr_local = frame->local; + if (!ctr_local) { + goto out; + } + + ctr_xlator_ctx = init_ctr_xlator_ctx(this, inode); + if (!ctr_xlator_ctx) { + gf_msg(this->name, GF_LOG_ERROR, 0, + CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, + "Failed accessing ctr inode context"); + goto out; + } + + ret = ctr_update_hard_link( + this, ctr_xlator_ctx, CTR_DB_REC(ctr_local).pargfid, + CTR_DB_REC(ctr_local).file_name, CTR_DB_REC(ctr_local).old_pargfid, + CTR_DB_REC(ctr_local).old_file_name); + if (ret) { + gf_msg(this->name, GF_LOG_ERROR, 0, CTR_MSG_DELETE_HARDLINK_FAILED, + "Failed to delete hard link"); + goto out; + } + + ret = 0; out: - return ret; + return ret; } - /****************************************************************************** * * CTR xlator init related functions @@ -918,12 +846,9 @@ out: * * ****************************************************************************/ int -extract_db_params (xlator_t *this, - dict_t *params_dict, - gfdb_db_type_t db_type); +extract_db_params(xlator_t *this, dict_t *params_dict, gfdb_db_type_t db_type); int -extract_ctr_options (xlator_t *this, - gf_ctr_private_t *_priv); +extract_ctr_options(xlator_t *this, gf_ctr_private_t *_priv); #endif diff --git a/xlators/features/changetimerecorder/src/ctr-messages.h b/xlators/features/changetimerecorder/src/ctr-messages.h index bc9a9e0f3ab..105d2265430 100644 --- a/xlators/features/changetimerecorder/src/ctr-messages.h +++ b/xlators/features/changetimerecorder/src/ctr-messages.h @@ -23,64 +23,39 @@ * glfs-message-id.h. */ -GLFS_MSGID(CTR, - CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, - CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, - CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND, - CTR_MSG_INSERT_LINK_WIND_FAILED, - CTR_MSG_INSERT_WRITEV_WIND_FAILED, - CTR_MSG_INSERT_WRITEV_UNWIND_FAILED, - CTR_MSG_INSERT_SETATTR_WIND_FAILED, - CTR_MSG_INSERT_SETATTR_UNWIND_FAILED, - CTR_MSG_INSERT_FREMOVEXATTR_UNWIND_FAILED, - CTR_MSG_INSERT_FREMOVEXATTR_WIND_FAILED, - CTR_MSG_INSERT_REMOVEXATTR_WIND_FAILED, - CTR_MSG_INSERT_REMOVEXATTR_UNWIND_FAILED, - CTR_MSG_INSERT_TRUNCATE_WIND_FAILED, - CTR_MSG_INSERT_TRUNCATE_UNWIND_FAILED, - CTR_MSG_INSERT_FTRUNCATE_UNWIND_FAILED, - CTR_MSG_INSERT_FTRUNCATE_WIND_FAILED, - CTR_MSG_INSERT_RENAME_WIND_FAILED, - CTR_MSG_INSERT_RENAME_UNWIND_FAILED, - CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, - CTR_MSG_ADD_HARDLINK_FAILED, - CTR_MSG_DELETE_HARDLINK_FAILED, - CTR_MSG_UPDATE_HARDLINK_FAILED, - CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, - CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, - CTR_MSG_INSERT_UNLINK_WIND_FAILED, - CTR_MSG_XDATA_NULL, - CTR_MSG_INSERT_FSYNC_WIND_FAILED, - CTR_MSG_INSERT_FSYNC_UNWIND_FAILED, - CTR_MSG_INSERT_MKNOD_UNWIND_FAILED, - CTR_MSG_INSERT_MKNOD_WIND_FAILED, - CTR_MSG_INSERT_CREATE_WIND_FAILED, - CTR_MSG_INSERT_CREATE_UNWIND_FAILED, - CTR_MSG_INSERT_RECORD_WIND_FAILED, - CTR_MSG_INSERT_READV_WIND_FAILED, - CTR_MSG_GET_GFID_FROM_DICT_FAILED, - CTR_MSG_SET, - CTR_MSG_FATAL_ERROR, - CTR_MSG_DANGLING_VOLUME, - CTR_MSG_CALLOC_FAILED, - CTR_MSG_EXTRACT_CTR_XLATOR_OPTIONS_FAILED, - CTR_MSG_INIT_DB_PARAMS_FAILED, - CTR_MSG_CREATE_LOCAL_MEMORY_POOL_FAILED, - CTR_MSG_MEM_ACC_INIT_FAILED, - CTR_MSG_CLOSE_DB_CONN_FAILED, - CTR_MSG_FILL_UNWIND_TIME_REC_ERROR, - CTR_MSG_WRONG_FOP_PATH, - CTR_MSG_CONSTRUCT_DB_PATH_FAILED, - CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED, - CTR_MSG_XLATOR_DISABLED, - CTR_MSG_HARDLINK_MISSING_IN_LIST, - CTR_MSG_ADD_HARDLINK_TO_LIST_FAILED, - CTR_MSG_INIT_LOCK_FAILED, - CTR_MSG_COPY_FAILED, - CTR_MSG_EXTRACT_DB_PARAM_OPTIONS_FAILED, - CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, - CTR_MSG_NULL_LOCAL -); +GLFS_MSGID( + CTR, CTR_MSG_CREATE_CTR_LOCAL_ERROR_WIND, + CTR_MSG_FILL_CTR_LOCAL_ERROR_UNWIND, CTR_MSG_FILL_CTR_LOCAL_ERROR_WIND, + CTR_MSG_INSERT_LINK_WIND_FAILED, CTR_MSG_INSERT_WRITEV_WIND_FAILED, + CTR_MSG_INSERT_WRITEV_UNWIND_FAILED, CTR_MSG_INSERT_SETATTR_WIND_FAILED, + CTR_MSG_INSERT_SETATTR_UNWIND_FAILED, + CTR_MSG_INSERT_FREMOVEXATTR_UNWIND_FAILED, + CTR_MSG_INSERT_FREMOVEXATTR_WIND_FAILED, + CTR_MSG_INSERT_REMOVEXATTR_WIND_FAILED, + CTR_MSG_INSERT_REMOVEXATTR_UNWIND_FAILED, + CTR_MSG_INSERT_TRUNCATE_WIND_FAILED, CTR_MSG_INSERT_TRUNCATE_UNWIND_FAILED, + CTR_MSG_INSERT_FTRUNCATE_UNWIND_FAILED, + CTR_MSG_INSERT_FTRUNCATE_WIND_FAILED, CTR_MSG_INSERT_RENAME_WIND_FAILED, + CTR_MSG_INSERT_RENAME_UNWIND_FAILED, + CTR_MSG_ACCESS_CTR_INODE_CONTEXT_FAILED, CTR_MSG_ADD_HARDLINK_FAILED, + CTR_MSG_DELETE_HARDLINK_FAILED, CTR_MSG_UPDATE_HARDLINK_FAILED, + CTR_MSG_GET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, + CTR_MSG_SET_CTR_RESPONSE_LINK_COUNT_XDATA_FAILED, + CTR_MSG_INSERT_UNLINK_UNWIND_FAILED, CTR_MSG_INSERT_UNLINK_WIND_FAILED, + CTR_MSG_XDATA_NULL, CTR_MSG_INSERT_FSYNC_WIND_FAILED, + CTR_MSG_INSERT_FSYNC_UNWIND_FAILED, CTR_MSG_INSERT_MKNOD_UNWIND_FAILED, + CTR_MSG_INSERT_MKNOD_WIND_FAILED, CTR_MSG_INSERT_CREATE_WIND_FAILED, + CTR_MSG_INSERT_CREATE_UNWIND_FAILED, CTR_MSG_INSERT_RECORD_WIND_FAILED, + CTR_MSG_INSERT_READV_WIND_FAILED, CTR_MSG_GET_GFID_FROM_DICT_FAILED, + CTR_MSG_SET, CTR_MSG_FATAL_ERROR, CTR_MSG_DANGLING_VOLUME, + CTR_MSG_CALLOC_FAILED, CTR_MSG_EXTRACT_CTR_XLATOR_OPTIONS_FAILED, + CTR_MSG_INIT_DB_PARAMS_FAILED, CTR_MSG_CREATE_LOCAL_MEMORY_POOL_FAILED, + CTR_MSG_MEM_ACC_INIT_FAILED, CTR_MSG_CLOSE_DB_CONN_FAILED, + CTR_MSG_FILL_UNWIND_TIME_REC_ERROR, CTR_MSG_WRONG_FOP_PATH, + CTR_MSG_CONSTRUCT_DB_PATH_FAILED, CTR_MSG_SET_VALUE_TO_SQL_PARAM_FAILED, + CTR_MSG_XLATOR_DISABLED, CTR_MSG_HARDLINK_MISSING_IN_LIST, + CTR_MSG_ADD_HARDLINK_TO_LIST_FAILED, CTR_MSG_INIT_LOCK_FAILED, + CTR_MSG_COPY_FAILED, CTR_MSG_EXTRACT_DB_PARAM_OPTIONS_FAILED, + CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, CTR_MSG_NULL_LOCAL); #endif /* !_CTR_MESSAGES_H_ */ diff --git a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h index 7f1c6cb1712..584d3b79ba4 100644 --- a/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h +++ b/xlators/features/changetimerecorder/src/ctr-xlator-ctx.h @@ -23,68 +23,46 @@ #include <sys/time.h> typedef struct ctr_hard_link { - uuid_t pgfid; - char *base_name; - /* Hardlink expiry : Defines the expiry period after which a - * database heal is attempted. */ - uint64_t hardlink_heal_period; - struct list_head list; + uuid_t pgfid; + char *base_name; + /* Hardlink expiry : Defines the expiry period after which a + * database heal is attempted. */ + uint64_t hardlink_heal_period; + struct list_head list; } ctr_hard_link_t; typedef struct ctr_xlator_ctx { - /* This represents the looked up hardlinks - * NOTE: This doesn't represent all physical hardlinks of the inode*/ - struct list_head hardlink_list; - uint64_t inode_heal_period; - gf_lock_t lock; + /* This represents the looked up hardlinks + * NOTE: This doesn't represent all physical hardlinks of the inode*/ + struct list_head hardlink_list; + uint64_t inode_heal_period; + gf_lock_t lock; } ctr_xlator_ctx_t; - ctr_hard_link_t * -ctr_search_hard_link_ctx (xlator_t *this, - ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, - const char *base_name); - +ctr_search_hard_link_ctx(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, + uuid_t pgfid, const char *base_name); int -ctr_add_hard_link (xlator_t *this, - ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, - const char *base_name); - - +ctr_add_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, + uuid_t pgfid, const char *base_name); int -ctr_delete_hard_link (xlator_t *this, - ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, - const char *base_name); - +ctr_delete_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, + uuid_t pgfid, const char *base_name); int -ctr_update_hard_link (xlator_t *this, - ctr_xlator_ctx_t *ctr_xlator_ctx, - uuid_t pgfid, - const char *base_name, - uuid_t old_pgfid, - const char *old_base_name); - +ctr_update_hard_link(xlator_t *this, ctr_xlator_ctx_t *ctr_xlator_ctx, + uuid_t pgfid, const char *base_name, uuid_t old_pgfid, + const char *old_base_name); ctr_xlator_ctx_t * -get_ctr_xlator_ctx (xlator_t *this, - inode_t *inode); - - - +get_ctr_xlator_ctx(xlator_t *this, inode_t *inode); ctr_xlator_ctx_t * -init_ctr_xlator_ctx (xlator_t *this, - inode_t *inode); - +init_ctr_xlator_ctx(xlator_t *this, inode_t *inode); void -fini_ctr_xlator_ctx (xlator_t *this, - inode_t *inode); +fini_ctr_xlator_ctx(xlator_t *this, inode_t *inode); #endif diff --git a/xlators/features/changetimerecorder/src/ctr_mem_types.h b/xlators/features/changetimerecorder/src/ctr_mem_types.h index f408c028e24..7b8f531ddec 100644 --- a/xlators/features/changetimerecorder/src/ctr_mem_types.h +++ b/xlators/features/changetimerecorder/src/ctr_mem_types.h @@ -8,17 +8,15 @@ cases as published by the Free Software Foundation. */ - #ifndef __CTR_MEM_TYPES_H__ #define __CTR_MEM_TYPES_H__ #include "gfdb_mem-types.h" enum gf_ctr_mem_types_ { - gf_ctr_mt_private_t = gfdb_mt_end + 1, - gf_ctr_mt_xlator_ctx, - gf_ctr_mt_hard_link_t, - gf_ctr_mt_end + gf_ctr_mt_private_t = gfdb_mt_end + 1, + gf_ctr_mt_xlator_ctx, + gf_ctr_mt_hard_link_t, + gf_ctr_mt_end }; #endif - diff --git a/xlators/features/cloudsync/src/cloudsync-common.h b/xlators/features/cloudsync/src/cloudsync-common.h index 3298ab0a6f2..0be6a446456 100644 --- a/xlators/features/cloudsync/src/cloudsync-common.h +++ b/xlators/features/cloudsync/src/cloudsync-common.h @@ -18,80 +18,82 @@ #include "cloudsync-messages.h" typedef struct cs_local { - loc_t loc; - fd_t *fd; - call_stub_t *stub; - call_frame_t *main_frame; - int op_errno; - int op_ret; - fd_t *dlfd; - off_t dloffset; - struct iatt stbuf; - dict_t *xattr_rsp; - dict_t *xattr_req; - glusterfs_fop_t fop; - gf_boolean_t locked; - int call_cnt; - inode_t *inode; - char *remotepath; + loc_t loc; + fd_t *fd; + call_stub_t *stub; + call_frame_t *main_frame; + int op_errno; + int op_ret; + fd_t *dlfd; + off_t dloffset; + struct iatt stbuf; + dict_t *xattr_rsp; + dict_t *xattr_req; + glusterfs_fop_t fop; + gf_boolean_t locked; + int call_cnt; + inode_t *inode; + char *remotepath; } cs_local_t; -typedef int (*fop_download_t) (call_frame_t *frame, void *config); +typedef int (*fop_download_t)(call_frame_t *frame, void *config); -typedef void *(*store_init) (xlator_t *this); +typedef void *(*store_init)(xlator_t *this); -typedef int (*store_reconfigure) (xlator_t *this, dict_t *options); +typedef int (*store_reconfigure)(xlator_t *this, dict_t *options); -typedef void (*store_fini) (void *config); +typedef void (*store_fini)(void *config); struct cs_remote_stores { - char *name; /* store name */ - void *config; /* store related information */ - fop_download_t dlfop; /* store specific download function */ - store_init init; /* store init to initialize store config */ - store_reconfigure reconfigure; /* reconfigure store config */ - store_fini fini; - void *handle; /* shared library handle*/ + char *name; /* store name */ + void *config; /* store related information */ + fop_download_t dlfop; /* store specific download function */ + store_init init; /* store init to initialize store config */ + store_reconfigure reconfigure; /* reconfigure store config */ + store_fini fini; + void *handle; /* shared library handle*/ }; typedef struct cs_private { - xlator_t *this; - struct cs_remote_stores *stores; - gf_boolean_t abortdl; - pthread_spinlock_t lock; + xlator_t *this; + struct cs_remote_stores *stores; + gf_boolean_t abortdl; + pthread_spinlock_t lock; } cs_private_t; void -cs_local_wipe (xlator_t *this, cs_local_t *local); +cs_local_wipe(xlator_t *this, cs_local_t *local); -#define CS_STACK_UNWIND(fop, frame, params ...) do { \ - cs_local_t *__local = NULL; \ - xlator_t *__xl = NULL; \ - if (frame) { \ - __xl = frame->this; \ - __local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - cs_local_wipe (__xl, __local); \ -} while (0) +#define CS_STACK_UNWIND(fop, frame, params...) \ + do { \ + cs_local_t *__local = NULL; \ + xlator_t *__xl = NULL; \ + if (frame) { \ + __xl = frame->this; \ + __local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + cs_local_wipe(__xl, __local); \ + } while (0) -#define CS_STACK_DESTROY(frame) do { \ - cs_local_t *__local = NULL; \ - xlator_t *__xl = NULL; \ - __xl = frame->this; \ - __local = frame->local; \ - frame->local = NULL; \ - STACK_DESTROY (frame->root); \ - cs_local_wipe (__xl, __local); \ -} while (0) +#define CS_STACK_DESTROY(frame) \ + do { \ + cs_local_t *__local = NULL; \ + xlator_t *__xl = NULL; \ + __xl = frame->this; \ + __local = frame->local; \ + frame->local = NULL; \ + STACK_DESTROY(frame->root); \ + cs_local_wipe(__xl, __local); \ + } while (0) typedef struct store_methods { - int (*fop_download) (call_frame_t *frame, void *config); - /* return type should be the store config */ - void *(*fop_init) (xlator_t *this); - int (*fop_reconfigure) (xlator_t *this, dict_t *options); - void (*fop_fini) (void *config); + int (*fop_download)(call_frame_t *frame, void *config); + /* return type should be the store config */ + void *(*fop_init)(xlator_t *this); + int (*fop_reconfigure)(xlator_t *this, dict_t *options); + void (*fop_fini)(void *config); } store_methods_t; #endif /* _CLOUDSYNC_COMMON_H */ diff --git a/xlators/features/cloudsync/src/cloudsync-mem-types.h b/xlators/features/cloudsync/src/cloudsync-mem-types.h index 6ebcb16552b..46d4f3aa2a1 100644 --- a/xlators/features/cloudsync/src/cloudsync-mem-types.h +++ b/xlators/features/cloudsync/src/cloudsync-mem-types.h @@ -8,16 +8,14 @@ * cases as published by the Free Software Foundation. */ - #ifndef __CLOUDSYNC_MEM_TYPES_H__ #define __CLOUDSYNC_MEM_TYPES_H__ #include "mem-types.h" enum cs_mem_types_ { - gf_cs_mt_cs_private_t = gf_common_mt_end + 1, - gf_cs_mt_cs_remote_stores_t, - gf_cs_mt_cs_inode_ctx_t, - gf_cs_mt_end + gf_cs_mt_cs_private_t = gf_common_mt_end + 1, + gf_cs_mt_cs_remote_stores_t, + gf_cs_mt_cs_inode_ctx_t, + gf_cs_mt_end }; #endif /* __CLOUDSYNC_MEM_TYPES_H__ */ - diff --git a/xlators/features/cloudsync/src/cloudsync-messages.h b/xlators/features/cloudsync/src/cloudsync-messages.h index ad4b7d2e0b8..fb08f72de7f 100644 --- a/xlators/features/cloudsync/src/cloudsync-messages.h +++ b/xlators/features/cloudsync/src/cloudsync-messages.h @@ -8,12 +8,9 @@ * cases as published by the Free Software Foundation. */ - #ifndef __CLOUDSYNC_MESSAGES_H__ #define __CLOUDSYNC_MESSAGES_H__ /*TODO: define relevant message ids */ - #endif /* __CLOUDSYNC_MESSAGES_H__ */ - diff --git a/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3-mem-types.h b/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3-mem-types.h index dd9314ec8d8..0aaab1fe955 100644 --- a/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3-mem-types.h +++ b/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3-mem-types.h @@ -8,14 +8,12 @@ * cases as published by the Free Software Foundation. */ - #ifndef __LIBAWS_MEM_TYPES_H__ #define __LIBAWS_MEM_TYPES_H__ #include "mem-types.h" enum libaws_mem_types_ { - gf_libaws_mt_aws_private_t = gf_common_mt_end + 1, - gf_libaws_mt_end + gf_libaws_mt_aws_private_t = gf_common_mt_end + 1, + gf_libaws_mt_end }; #endif /* __CLOUDSYNC_MEM_TYPES_H__ */ - diff --git a/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.h b/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.h index c233e1c96f7..b1a95f8cbf9 100644 --- a/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.h +++ b/xlators/features/cloudsync/src/cloudsync-plugins/src/cloudsyncs3/src/libcloudsyncs3.h @@ -18,34 +18,33 @@ #include "cloudsync-common.h" #include "libcloudsyncs3-mem-types.h" - -char* +char * aws_b64_encode(const unsigned char *input, int length); size_t aws_write_callback(void *dlbuf, size_t size, size_t nitems, void *mainframe); int -aws_download_s3 (call_frame_t *frame, void *config); +aws_download_s3(call_frame_t *frame, void *config); int -aws_dlwritev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +aws_dlwritev_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, + int op_errno, struct iatt *prebuf, struct iatt *postbuf, + dict_t *xdata); void * -aws_init (xlator_t *this); +aws_init(xlator_t *this); int -aws_reconfigure (xlator_t *this, dict_t *options); +aws_reconfigure(xlator_t *this, dict_t *options); char * -aws_form_request (char *resource, char **date, char *reqtype, char *bucketid, - char *filepath); +aws_form_request(char *resource, char **date, char *reqtype, char *bucketid, + char *filepath); char * aws_sign_request(char *const str, char *awssekey); void -aws_fini (void *config); +aws_fini(void *config); #endif diff --git a/xlators/features/cloudsync/src/cloudsync.h b/xlators/features/cloudsync/src/cloudsync.h index 18840a6523d..7c70c744d2b 100644 --- a/xlators/features/cloudsync/src/cloudsync.h +++ b/xlators/features/cloudsync/src/cloudsync.h @@ -8,7 +8,6 @@ * cases as published by the Free Software Foundation. */ - #ifndef __CLOUDSYNC_H__ #define __CLOUDSYNC_H__ @@ -20,87 +19,85 @@ #include "cloudsync-common.h" #include "cloudsync-autogen-fops.h" - #define CS_LOCK_DOMAIN "cs.protect.file.stat" typedef struct cs_dlstore { - off_t off; - struct iovec *vector; - int32_t count; - struct iobref *iobref; - uint32_t flags; + off_t off; + struct iovec *vector; + int32_t count; + struct iobref *iobref; + uint32_t flags; } cs_dlstore; typedef struct cs_inode_ctx { - gf_cs_obj_state state; + gf_cs_obj_state state; } cs_inode_ctx_t; struct cs_plugin { - char *name; /* store name */ - char *library; /* library to load for the given store */ - char *description; /* description about the store */ + char *name; /* store name */ + char *library; /* library to load for the given store */ + char *description; /* description about the store */ }; cs_local_t * -cs_local_init (xlator_t *this, call_frame_t *frame, loc_t *loc, fd_t *fd, - glusterfs_fop_t fop); +cs_local_init(xlator_t *this, call_frame_t *frame, loc_t *loc, fd_t *fd, + glusterfs_fop_t fop); int -locate_and_execute (call_frame_t *frame); - +locate_and_execute(call_frame_t *frame); int32_t -cs_resume_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - dict_t *dict, int32_t flags, dict_t *xdata); +cs_resume_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, + dict_t *dict, int32_t flags, dict_t *xdata); int32_t -cs_inodelk_unlock_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, - int32_t op_errno, dict_t *xdata); +cs_inodelk_unlock_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata); size_t -cs_write_callback (void *lcurlbuf, size_t size, size_t nitems, void *frame); +cs_write_callback(void *lcurlbuf, size_t size, size_t nitems, void *frame); void -cs_common_cbk (call_frame_t *frame); +cs_common_cbk(call_frame_t *frame); gf_boolean_t -cs_is_file_remote (struct iatt *stbuf, dict_t *xattr); +cs_is_file_remote(struct iatt *stbuf, dict_t *xattr); int32_t -cs_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata); +cs_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata); int -cs_build_loc (loc_t *loc, call_frame_t *frame); +cs_build_loc(loc_t *loc, call_frame_t *frame); int -cs_blocking_inodelk_cbk (call_frame_t *lock_frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *xdata); +cs_blocking_inodelk_cbk(call_frame_t *lock_frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata); -int cs_read_authinfo(xlator_t *this); +int +cs_read_authinfo(xlator_t *this); int -__cs_inode_ctx_update (xlator_t *this, inode_t *inode, uint64_t val); +__cs_inode_ctx_update(xlator_t *this, inode_t *inode, uint64_t val); int -cs_inode_ctx_reset (xlator_t *this, inode_t *inode); +cs_inode_ctx_reset(xlator_t *this, inode_t *inode); void -__cs_inode_ctx_get (xlator_t *this, inode_t *inode, cs_inode_ctx_t **ctx); +__cs_inode_ctx_get(xlator_t *this, inode_t *inode, cs_inode_ctx_t **ctx); gf_cs_obj_state -__cs_get_file_state (xlator_t *this, inode_t *inode, cs_inode_ctx_t *ctx); +__cs_get_file_state(xlator_t *this, inode_t *inode, cs_inode_ctx_t *ctx); int -cs_inodelk_unlock (call_frame_t *main_frame); +cs_inodelk_unlock(call_frame_t *main_frame); int -cs_resume_postprocess (xlator_t *this, call_frame_t *frame, inode_t *inode); +cs_resume_postprocess(xlator_t *this, call_frame_t *frame, inode_t *inode); int32_t -cs_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *prebuf, - struct iatt *postbuf, dict_t *xdata); +cs_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata); int32_t -cs_resume_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, - off_t offset, dict_t *xattr_req); +cs_resume_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, + off_t offset, dict_t *xattr_req); #endif /* __CLOUDSYNC_H__ */ - diff --git a/xlators/features/compress/src/cdc-mem-types.h b/xlators/features/compress/src/cdc-mem-types.h index ead2c70ba6e..56a5a05ee8c 100644 --- a/xlators/features/compress/src/cdc-mem-types.h +++ b/xlators/features/compress/src/cdc-mem-types.h @@ -14,10 +14,10 @@ #include "mem-types.h" enum gf_cdc_mem_types { - gf_cdc_mt_priv_t = gf_common_mt_end + 1, - gf_cdc_mt_vec_t = gf_common_mt_end + 2, - gf_cdc_mt_gzip_trailer_t = gf_common_mt_end + 3, - gf_cdc_mt_end = gf_common_mt_end + 4, + gf_cdc_mt_priv_t = gf_common_mt_end + 1, + gf_cdc_mt_vec_t = gf_common_mt_end + 2, + gf_cdc_mt_gzip_trailer_t = gf_common_mt_end + 3, + gf_cdc_mt_end = gf_common_mt_end + 4, }; #endif diff --git a/xlators/features/compress/src/cdc.h b/xlators/features/compress/src/cdc.h index 71f4d2317bb..764f2028c75 100644 --- a/xlators/features/compress/src/cdc.h +++ b/xlators/features/compress/src/cdc.h @@ -22,34 +22,34 @@ #endif typedef struct cdc_priv { - int window_size; - int mem_level; - int cdc_level; - int min_file_size; - int op_mode; - gf_boolean_t debug; - gf_lock_t lock; + int window_size; + int mem_level; + int cdc_level; + int min_file_size; + int op_mode; + gf_boolean_t debug; + gf_lock_t lock; } cdc_priv_t; typedef struct cdc_info { - /* input bits */ - int count; - int32_t ibytes; - struct iovec *vector; - struct iatt *buf; - - /* output bits */ - int ncount; - int nbytes; - int buffer_size; - struct iovec vec[MAX_IOVEC]; - struct iobref *iobref; - - /* zlib bits */ + /* input bits */ + int count; + int32_t ibytes; + struct iovec *vector; + struct iatt *buf; + + /* output bits */ + int ncount; + int nbytes; + int buffer_size; + struct iovec vec[MAX_IOVEC]; + struct iobref *iobref; + + /* zlib bits */ #ifdef HAVE_LIB_Z - z_stream stream; + z_stream stream; #endif - unsigned long crc; + unsigned long crc; } cdc_info_t; #define NVEC(ci) (ci->ncount - 1) @@ -57,8 +57,8 @@ typedef struct cdc_info { #define THIS_VEC(ci, i) ci->vector[i] /* Gzip defaults */ -#define GF_CDC_DEF_WINDOWSIZE -15 /* default value */ -#define GF_CDC_MAX_WINDOWSIZE -8 /* max value */ +#define GF_CDC_DEF_WINDOWSIZE -15 /* default value */ +#define GF_CDC_MAX_WINDOWSIZE -8 /* max value */ #ifdef HAVE_LIB_Z #define GF_CDC_DEF_COMPRESSION Z_DEFAULT_COMPRESSION @@ -66,15 +66,15 @@ typedef struct cdc_info { #define GF_CDC_DEF_COMPRESSION -1 #endif -#define GF_CDC_DEF_MEMLEVEL 8 -#define GF_CDC_DEF_BUFFERSIZE 262144 // 256K - default compression buffer size +#define GF_CDC_DEF_MEMLEVEL 8 +#define GF_CDC_DEF_BUFFERSIZE 262144 // 256K - default compression buffer size /* Operation mode * If xlator is loaded on client, readv decompresses and writev compresses * If xlator is loaded on server, readv compresses and writev decompresses */ -#define GF_CDC_MODE_CLIENT 0 -#define GF_CDC_MODE_SERVER 1 +#define GF_CDC_MODE_CLIENT 0 +#define GF_CDC_MODE_SERVER 1 /* min size of data to do cmpression * 0 == compress even 1byte @@ -87,21 +87,13 @@ typedef struct cdc_info { #define GF_CDC_DEFLATE_CANARY_VAL "deflate" #define GF_CDC_DEBUG_DUMP_FILE "/tmp/cdcdump.gz" -#define GF_CDC_MODE_IS_CLIENT(m) \ - (strcmp (m, "client") == 0) +#define GF_CDC_MODE_IS_CLIENT(m) (strcmp(m, "client") == 0) -#define GF_CDC_MODE_IS_SERVER(m) \ - (strcmp (m, "server") == 0) +#define GF_CDC_MODE_IS_SERVER(m) (strcmp(m, "server") == 0) int32_t -cdc_compress (xlator_t *this, - cdc_priv_t *priv, - cdc_info_t *ci, - dict_t **xdata); +cdc_compress(xlator_t *this, cdc_priv_t *priv, cdc_info_t *ci, dict_t **xdata); int32_t -cdc_decompress (xlator_t *this, - cdc_priv_t *priv, - cdc_info_t *ci, - dict_t *xdata); +cdc_decompress(xlator_t *this, cdc_priv_t *priv, cdc_info_t *ci, dict_t *xdata); #endif diff --git a/xlators/features/gfid-access/src/gfid-access-mem-types.h b/xlators/features/gfid-access/src/gfid-access-mem-types.h index 168d67b431f..ee7fd794da8 100644 --- a/xlators/features/gfid-access/src/gfid-access-mem-types.h +++ b/xlators/features/gfid-access/src/gfid-access-mem-types.h @@ -14,10 +14,9 @@ #include "mem-types.h" enum gf_changelog_mem_types { - gf_gfid_access_mt_priv_t = gf_common_mt_end + 1, - gf_gfid_access_mt_gfid_t, - gf_gfid_access_mt_end + gf_gfid_access_mt_priv_t = gf_common_mt_end + 1, + gf_gfid_access_mt_gfid_t, + gf_gfid_access_mt_end }; #endif - diff --git a/xlators/features/gfid-access/src/gfid-access.h b/xlators/features/gfid-access/src/gfid-access.h index 2b5e4fd4184..68ebe539564 100644 --- a/xlators/features/gfid-access/src/gfid-access.h +++ b/xlators/features/gfid-access/src/gfid-access.h @@ -20,87 +20,87 @@ #define UUID_CANONICAL_FORM_LEN 36 #define GF_FUSE_AUX_GFID_NEWFILE "glusterfs.gfid.newfile" -#define GF_FUSE_AUX_GFID_HEAL "glusterfs.gfid.heal" +#define GF_FUSE_AUX_GFID_HEAL "glusterfs.gfid.heal" #define GF_GFID_KEY "GLUSTERFS_GFID" #define GF_GFID_DIR ".gfid" #define GF_AUX_GFID 0xd -#define GFID_ACCESS_ENTRY_OP_CHECK(loc,err,lbl) do { \ - /* need to check if the lookup is on virtual dir */ \ - if ((loc->name && !strcmp (GF_GFID_DIR, loc->name)) && \ - ((loc->parent && \ - __is_root_gfid (loc->parent->gfid)) || \ - __is_root_gfid (loc->pargfid))) { \ - err = ENOTSUP; \ - goto lbl; \ - } \ - \ - /* now, check if the lookup() is on an existing */ \ - /* entry, but on gfid-path */ \ - if ((loc->parent && \ - __is_gfid_access_dir (loc->parent->gfid)) || \ - __is_gfid_access_dir (loc->pargfid)) { \ - err = EPERM; \ - goto lbl; \ - } \ - } while (0) +#define GFID_ACCESS_ENTRY_OP_CHECK(loc, err, lbl) \ + do { \ + /* need to check if the lookup is on virtual dir */ \ + if ((loc->name && !strcmp(GF_GFID_DIR, loc->name)) && \ + ((loc->parent && __is_root_gfid(loc->parent->gfid)) || \ + __is_root_gfid(loc->pargfid))) { \ + err = ENOTSUP; \ + goto lbl; \ + } \ + \ + /* now, check if the lookup() is on an existing */ \ + /* entry, but on gfid-path */ \ + if ((loc->parent && __is_gfid_access_dir(loc->parent->gfid)) || \ + __is_gfid_access_dir(loc->pargfid)) { \ + err = EPERM; \ + goto lbl; \ + } \ + } while (0) -#define GFID_ACCESS_INODE_OP_CHECK(loc,err,lbl) do { \ - /*Check if it is on .gfid*/ \ - if (__is_gfid_access_dir(loc->gfid)) { \ - err = ENOTSUP; \ - goto lbl; \ - } \ - } while (0) +#define GFID_ACCESS_INODE_OP_CHECK(loc, err, lbl) \ + do { \ + /*Check if it is on .gfid*/ \ + if (__is_gfid_access_dir(loc->gfid)) { \ + err = ENOTSUP; \ + goto lbl; \ + } \ + } while (0) typedef struct { - unsigned int uid; - unsigned int gid; - char gfid[UUID_CANONICAL_FORM_LEN + 1]; - unsigned int st_mode; - char *bname; + unsigned int uid; + unsigned int gid; + char gfid[UUID_CANONICAL_FORM_LEN + 1]; + unsigned int st_mode; + char *bname; - union { - struct _symlink_in { - char *linkpath; - } __attribute__ ((__packed__)) symlink; + union { + struct _symlink_in { + char *linkpath; + } __attribute__((__packed__)) symlink; - struct _mknod_in { - unsigned int mode; - unsigned int rdev; - unsigned int umask; - } __attribute__ ((__packed__)) mknod; + struct _mknod_in { + unsigned int mode; + unsigned int rdev; + unsigned int umask; + } __attribute__((__packed__)) mknod; - struct _mkdir_in { - unsigned int mode; - unsigned int umask; - } __attribute__ ((__packed__)) mkdir; - } __attribute__ ((__packed__)) args; + struct _mkdir_in { + unsigned int mode; + unsigned int umask; + } __attribute__((__packed__)) mkdir; + } __attribute__((__packed__)) args; } __attribute__((__packed__)) ga_newfile_args_t; typedef struct { - char gfid[UUID_CANONICAL_FORM_LEN + 1]; - char *bname; /* a null terminated basename */ + char gfid[UUID_CANONICAL_FORM_LEN + 1]; + char *bname; /* a null terminated basename */ } __attribute__((__packed__)) ga_heal_args_t; struct ga_private { - /* root inode's stbuf */ - struct iatt root_stbuf; - struct iatt gfiddir_stbuf; - struct mem_pool *newfile_args_pool; - struct mem_pool *heal_args_pool; + /* root inode's stbuf */ + struct iatt root_stbuf; + struct iatt gfiddir_stbuf; + struct mem_pool *newfile_args_pool; + struct mem_pool *heal_args_pool; }; typedef struct ga_private ga_private_t; struct __ga_local { - call_frame_t *orig_frame; - unsigned int uid; - unsigned int gid; - loc_t loc; - mode_t mode; - dev_t rdev; - mode_t umask; - dict_t *xdata; + call_frame_t *orig_frame; + unsigned int uid; + unsigned int gid; + loc_t loc; + mode_t mode; + dev_t rdev; + mode_t umask; + dict_t *xdata; }; typedef struct __ga_local ga_local_t; diff --git a/xlators/features/glupy/src/glupy.h b/xlators/features/glupy/src/glupy.h index 1488c55c331..851b02154d2 100644 --- a/xlators/features/glupy/src/glupy.h +++ b/xlators/features/glupy/src/glupy.h @@ -14,43 +14,43 @@ #include "mem-types.h" enum { - GLUPY_LOOKUP = 0, - GLUPY_CREATE, - GLUPY_OPEN, - GLUPY_READV, - GLUPY_WRITEV, - GLUPY_OPENDIR, - GLUPY_READDIR, - GLUPY_READDIRP, - GLUPY_STAT, - GLUPY_FSTAT, - GLUPY_STATFS, - GLUPY_SETXATTR, - GLUPY_GETXATTR, - GLUPY_FSETXATTR, - GLUPY_FGETXATTR, - GLUPY_REMOVEXATTR, - GLUPY_FREMOVEXATTR, - GLUPY_LINK, - GLUPY_UNLINK, - GLUPY_READLINK, - GLUPY_SYMLINK, - GLUPY_MKNOD, - GLUPY_MKDIR, - GLUPY_RMDIR, - GLUPY_N_FUNCS + GLUPY_LOOKUP = 0, + GLUPY_CREATE, + GLUPY_OPEN, + GLUPY_READV, + GLUPY_WRITEV, + GLUPY_OPENDIR, + GLUPY_READDIR, + GLUPY_READDIRP, + GLUPY_STAT, + GLUPY_FSTAT, + GLUPY_STATFS, + GLUPY_SETXATTR, + GLUPY_GETXATTR, + GLUPY_FSETXATTR, + GLUPY_FGETXATTR, + GLUPY_REMOVEXATTR, + GLUPY_FREMOVEXATTR, + GLUPY_LINK, + GLUPY_UNLINK, + GLUPY_READLINK, + GLUPY_SYMLINK, + GLUPY_MKNOD, + GLUPY_MKDIR, + GLUPY_RMDIR, + GLUPY_N_FUNCS }; typedef struct { - PyObject *py_module; - PyObject *py_xlator; - long fops[GLUPY_N_FUNCS]; - long cbks[GLUPY_N_FUNCS]; + PyObject *py_module; + PyObject *py_xlator; + long fops[GLUPY_N_FUNCS]; + long cbks[GLUPY_N_FUNCS]; } glupy_private_t; enum gf_glupy_mem_types_ { - gf_glupy_mt_priv = gf_common_mt_end + 1, - gf_glupy_mt_end + gf_glupy_mt_priv = gf_common_mt_end + 1, + gf_glupy_mt_end }; #endif /* __GLUPY_H__ */ diff --git a/xlators/features/index/src/index-mem-types.h b/xlators/features/index/src/index-mem-types.h index ca291cfba7e..f5d456e84be 100644 --- a/xlators/features/index/src/index-mem-types.h +++ b/xlators/features/index/src/index-mem-types.h @@ -14,10 +14,10 @@ #include "mem-types.h" enum gf_index_mem_types_ { - gf_index_mt_priv_t = gf_common_mt_end + 1, - gf_index_inode_ctx_t = gf_common_mt_end + 2, - gf_index_fd_ctx_t = gf_common_mt_end + 3, - gf_index_mt_local_t = gf_common_mt_end + 4, - gf_index_mt_end + gf_index_mt_priv_t = gf_common_mt_end + 1, + gf_index_inode_ctx_t = gf_common_mt_end + 2, + gf_index_fd_ctx_t = gf_common_mt_end + 3, + gf_index_mt_local_t = gf_common_mt_end + 4, + gf_index_mt_end }; #endif diff --git a/xlators/features/index/src/index-messages.h b/xlators/features/index/src/index-messages.h index 7ab2bb0ad4b..3495fb080f0 100644 --- a/xlators/features/index/src/index-messages.h +++ b/xlators/features/index/src/index-messages.h @@ -23,17 +23,11 @@ * glfs-message-id.h. */ -GLFS_MSGID(INDEX, - INDEX_MSG_INDEX_DIR_CREATE_FAILED, - INDEX_MSG_INDEX_READDIR_FAILED, - INDEX_MSG_INDEX_ADD_FAILED, - INDEX_MSG_INDEX_DEL_FAILED, - INDEX_MSG_DICT_SET_FAILED, - INDEX_MSG_INODE_CTX_GET_SET_FAILED, - INDEX_MSG_INVALID_ARGS, - INDEX_MSG_FD_OP_FAILED, - INDEX_MSG_WORKER_THREAD_CREATE_FAILED, - INDEX_MSG_INVALID_GRAPH -); +GLFS_MSGID(INDEX, INDEX_MSG_INDEX_DIR_CREATE_FAILED, + INDEX_MSG_INDEX_READDIR_FAILED, INDEX_MSG_INDEX_ADD_FAILED, + INDEX_MSG_INDEX_DEL_FAILED, INDEX_MSG_DICT_SET_FAILED, + INDEX_MSG_INODE_CTX_GET_SET_FAILED, INDEX_MSG_INVALID_ARGS, + INDEX_MSG_FD_OP_FAILED, INDEX_MSG_WORKER_THREAD_CREATE_FAILED, + INDEX_MSG_INVALID_GRAPH); #endif /* !_INDEX_MESSAGES_H_ */ diff --git a/xlators/features/index/src/index.h b/xlators/features/index/src/index.h index ae9091d69c9..f1e0293b794 100644 --- a/xlators/features/index/src/index.h +++ b/xlators/features/index/src/index.h @@ -18,71 +18,67 @@ #include "common-utils.h" #include "index-mem-types.h" -#define INDEX_THREAD_STACK_SIZE ((size_t)(1024*1024)) +#define INDEX_THREAD_STACK_SIZE ((size_t)(1024 * 1024)) -typedef enum { - UNKNOWN, - IN, - NOTIN -} index_state_t; +typedef enum { UNKNOWN, IN, NOTIN } index_state_t; typedef enum { - XATTROP_TYPE_UNSET = -1, - XATTROP, - DIRTY, - ENTRY_CHANGES, - XATTROP_TYPE_END + XATTROP_TYPE_UNSET = -1, + XATTROP, + DIRTY, + ENTRY_CHANGES, + XATTROP_TYPE_END } index_xattrop_type_t; typedef struct index_inode_ctx { - gf_boolean_t processing; - struct list_head callstubs; - int state[XATTROP_TYPE_END]; - uuid_t virtual_pargfid; /* virtual gfid of dir under - .glusterfs/indices/entry-changes. */ + gf_boolean_t processing; + struct list_head callstubs; + int state[XATTROP_TYPE_END]; + uuid_t virtual_pargfid; /* virtual gfid of dir under + .glusterfs/indices/entry-changes. */ } index_inode_ctx_t; typedef struct index_fd_ctx { - DIR *dir; - off_t dir_eof; + DIR *dir; + off_t dir_eof; } index_fd_ctx_t; typedef struct index_priv { - char *index_basepath; - char *dirty_basepath; - uuid_t index; - gf_lock_t lock; - uuid_t internal_vgfid[XATTROP_TYPE_END]; - struct list_head callstubs; - pthread_mutex_t mutex; - pthread_cond_t cond; - dict_t *dirty_watchlist; - dict_t *pending_watchlist; - dict_t *complete_watchlist; - int64_t pending_count; - pthread_t thread; - gf_boolean_t down; + char *index_basepath; + char *dirty_basepath; + uuid_t index; + gf_lock_t lock; + uuid_t internal_vgfid[XATTROP_TYPE_END]; + struct list_head callstubs; + pthread_mutex_t mutex; + pthread_cond_t cond; + dict_t *dirty_watchlist; + dict_t *pending_watchlist; + dict_t *complete_watchlist; + int64_t pending_count; + pthread_t thread; + gf_boolean_t down; } index_priv_t; typedef struct index_local { - inode_t *inode; - dict_t *xdata; + inode_t *inode; + dict_t *xdata; } index_local_t; -#define INDEX_STACK_UNWIND(fop, frame, params ...) \ -do { \ - index_local_t *__local = NULL; \ - if (frame) { \ - __local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - if (__local) { \ - inode_unref (__local->inode); \ - if (__local->xdata) \ - dict_unref (__local->xdata); \ - mem_put (__local); \ - } \ -} while (0) +#define INDEX_STACK_UNWIND(fop, frame, params...) \ + do { \ + index_local_t *__local = NULL; \ + if (frame) { \ + __local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + if (__local) { \ + inode_unref(__local->inode); \ + if (__local->xdata) \ + dict_unref(__local->xdata); \ + mem_put(__local); \ + } \ + } while (0) #endif diff --git a/xlators/features/leases/src/leases-mem-types.h b/xlators/features/leases/src/leases-mem-types.h index d1a59c1db2e..59d3cbaf0b3 100644 --- a/xlators/features/leases/src/leases-mem-types.h +++ b/xlators/features/leases/src/leases-mem-types.h @@ -14,15 +14,15 @@ #include "mem-types.h" enum gf_leases_mem_types_ { - gf_leases_mt_conf_t = gf_common_mt_end + 1, - gf_leases_mt_private_t, - gf_leases_mt_lease_client_t, - gf_leases_mt_lease_inode_t, - gf_leases_mt_fd_ctx_t, - gf_leases_mt_lease_inode_ctx_t, - gf_leases_mt_lease_id_entry_t, - gf_leases_mt_fop_stub_t, - gf_leases_mt_timer_data_t, - gf_leases_mt_end + gf_leases_mt_conf_t = gf_common_mt_end + 1, + gf_leases_mt_private_t, + gf_leases_mt_lease_client_t, + gf_leases_mt_lease_inode_t, + gf_leases_mt_fd_ctx_t, + gf_leases_mt_lease_inode_ctx_t, + gf_leases_mt_lease_id_entry_t, + gf_leases_mt_fop_stub_t, + gf_leases_mt_timer_data_t, + gf_leases_mt_end }; #endif diff --git a/xlators/features/leases/src/leases-messages.h b/xlators/features/leases/src/leases-messages.h index f4dc169b8d6..81a517f63cd 100644 --- a/xlators/features/leases/src/leases-messages.h +++ b/xlators/features/leases/src/leases-messages.h @@ -23,18 +23,11 @@ * glfs-message-id.h. */ -GLFS_MSGID(LEASES, - LEASE_MSG_NO_MEM, - LEASE_MSG_RECALL_FAIL, - LEASE_MSG_INVAL_LEASE_ID, - LEASE_MSG_INVAL_UNLK_LEASE, - LEASE_MSG_INVAL_INODE_CTX, - LEASE_MSG_NOT_ENABLED, - LEASE_MSG_NO_TIMER_WHEEL, - LEASE_MSG_CLNT_NOTFOUND, - LEASE_MSG_INODE_NOTFOUND, - LEASE_MSG_INVAL_FD_CTX, - LEASE_MSG_INVAL_LEASE_TYPE -); +GLFS_MSGID(LEASES, LEASE_MSG_NO_MEM, LEASE_MSG_RECALL_FAIL, + LEASE_MSG_INVAL_LEASE_ID, LEASE_MSG_INVAL_UNLK_LEASE, + LEASE_MSG_INVAL_INODE_CTX, LEASE_MSG_NOT_ENABLED, + LEASE_MSG_NO_TIMER_WHEEL, LEASE_MSG_CLNT_NOTFOUND, + LEASE_MSG_INODE_NOTFOUND, LEASE_MSG_INVAL_FD_CTX, + LEASE_MSG_INVAL_LEASE_TYPE); #endif /* !_LEASES_MESSAGES_H_ */ diff --git a/xlators/features/leases/src/leases.h b/xlators/features/leases/src/leases.h index 80dbcbb06b9..d5fc451289d 100644 --- a/xlators/features/leases/src/leases.h +++ b/xlators/features/leases/src/leases.h @@ -39,24 +39,27 @@ #define BLOCK_FOP 0x0001 #define WIND_FOP 0x0002 -#define EXIT_IF_LEASES_OFF(this, label) do { \ +#define EXIT_IF_LEASES_OFF(this, label) \ + do { \ if (!is_leases_enabled(this)) \ - goto label; \ -} while (0) + goto label; \ + } while (0) -#define GET_LEASE_ID(xdata, lease_id, client_uid) do { \ - int ret_val = -1; \ - ret_val = dict_get_bin (xdata, "lease-id", (void **)&lease_id); \ +#define GET_LEASE_ID(xdata, lease_id, client_uid) \ + do { \ + int ret_val = -1; \ + ret_val = dict_get_bin(xdata, "lease-id", (void **)&lease_id); \ if (ret_val) { \ - ret_val = 0; \ - gf_msg_debug ("leases", 0, "Lease id is not set for client:%s", client_uid); \ + ret_val = 0; \ + gf_msg_debug("leases", 0, "Lease id is not set for client:%s", \ + client_uid); \ } \ -} while (0) + } while (0) #define GET_FLAGS(fop, fd_flags) \ -do { \ + do { \ if ((fd_flags & (O_WRONLY | O_RDWR)) && fop == GF_FOP_OPEN) \ - fop_flags = DATA_MODIFY_FOP; \ + fop_flags = DATA_MODIFY_FOP; \ \ if (fop == GF_FOP_UNLINK || fop == GF_FOP_RENAME || \ fop == GF_FOP_TRUNCATE || fop == GF_FOP_FTRUNCATE || \ @@ -65,185 +68,181 @@ do { \ fop == GF_FOP_DISCARD || fop == GF_FOP_ZEROFILL || \ fop == GF_FOP_SETATTR || fop == GF_FOP_FSETATTR || \ fop == GF_FOP_LINK) \ - fop_flags = DATA_MODIFY_FOP; \ + fop_flags = DATA_MODIFY_FOP; \ \ if (!(fd_flags & (O_NONBLOCK | O_NDELAY))) \ - fop_flags |= BLOCKING_FOP; \ + fop_flags |= BLOCKING_FOP; \ \ -} while (0) \ - + } while (0) #define GET_FLAGS_LK(cmd, l_type, fd_flags) \ -do { \ + do { \ /* TODO: handle F_RESLK_LCK and other glusterfs_lk_recovery_cmds_t */ \ - if ((cmd == F_SETLKW || cmd == F_SETLKW64 || \ - cmd == F_SETLK || cmd == F_SETLK64) && \ + if ((cmd == F_SETLKW || cmd == F_SETLKW64 || cmd == F_SETLK || \ + cmd == F_SETLK64) && \ l_type == F_WRLCK) \ - fop_flags = DATA_MODIFY_FOP; \ + fop_flags = DATA_MODIFY_FOP; \ \ if (fd_flags & (O_NONBLOCK | O_NDELAY) && \ (cmd == F_SETLKW || cmd == F_SETLKW64)) \ - fop_flags |= BLOCKING_FOP; \ + fop_flags |= BLOCKING_FOP; \ \ -} while (0) \ + } while (0) -#define LEASE_BLOCK_FOP(inode, fop_name, frame, this, params ...) \ -do { \ - call_stub_t *__stub = NULL; \ - fop_stub_t *blk_fop = NULL; \ - lease_inode_ctx_t *lease_ctx = NULL; \ +#define LEASE_BLOCK_FOP(inode, fop_name, frame, this, params...) \ + do { \ + call_stub_t *__stub = NULL; \ + fop_stub_t *blk_fop = NULL; \ + lease_inode_ctx_t *lease_ctx = NULL; \ \ - __stub = fop_##fop_name##_stub (frame, default_##fop_name##_resume, \ - params); \ + __stub = fop_##fop_name##_stub(frame, default_##fop_name##_resume, \ + params); \ if (!__stub) { \ - gf_msg (this->name, GF_LOG_WARNING, ENOMEM, \ - LEASE_MSG_NO_MEM, \ - "Unable to create stub"); \ - ret = -ENOMEM; \ - goto __out; \ + gf_msg(this->name, GF_LOG_WARNING, ENOMEM, LEASE_MSG_NO_MEM, \ + "Unable to create stub"); \ + ret = -ENOMEM; \ + goto __out; \ } \ \ - blk_fop = GF_CALLOC (1, sizeof (*blk_fop), \ - gf_leases_mt_fop_stub_t); \ + blk_fop = GF_CALLOC(1, sizeof(*blk_fop), gf_leases_mt_fop_stub_t); \ if (!blk_fop) { \ - gf_msg (this->name, GF_LOG_WARNING, ENOMEM, \ - LEASE_MSG_NO_MEM, \ - "Unable to create lease fop stub"); \ - ret = -ENOMEM; \ - goto __out; \ + gf_msg(this->name, GF_LOG_WARNING, ENOMEM, LEASE_MSG_NO_MEM, \ + "Unable to create lease fop stub"); \ + ret = -ENOMEM; \ + goto __out; \ } \ \ - lease_ctx = lease_ctx_get (inode, this); \ + lease_ctx = lease_ctx_get(inode, this); \ if (!lease_ctx) { \ - gf_msg (this->name, GF_LOG_WARNING, ENOMEM, \ - LEASE_MSG_NO_MEM, \ - "Unable to create/get inode ctx"); \ - ret = -ENOMEM; \ - goto __out; \ + gf_msg(this->name, GF_LOG_WARNING, ENOMEM, LEASE_MSG_NO_MEM, \ + "Unable to create/get inode ctx"); \ + ret = -ENOMEM; \ + goto __out; \ } \ \ blk_fop->stub = __stub; \ - pthread_mutex_lock (&lease_ctx->lock); \ + pthread_mutex_lock(&lease_ctx->lock); \ { \ - /*TODO: If the lease is unlocked btw check lease conflict and \ - * by now, then this fop shouldn't be add to the blocked fop \ - * list, can use generation number for the same?*/ \ - list_add_tail (&blk_fop->list, &lease_ctx->blocked_list); \ + /*TODO: If the lease is unlocked btw check lease conflict and \ + * by now, then this fop shouldn't be add to the blocked fop \ + * list, can use generation number for the same?*/ \ + list_add_tail(&blk_fop->list, &lease_ctx->blocked_list); \ } \ - pthread_mutex_unlock (&lease_ctx->lock); \ + pthread_mutex_unlock(&lease_ctx->lock); \ \ -__out: \ + __out: \ if (ret < 0) { \ - gf_msg (this->name, GF_LOG_WARNING, ENOMEM, LEASE_MSG_NO_MEM, \ - "Unable to create stub for blocking the fop:%s (%s)", \ - gf_fop_list[frame->root->op], strerror(ENOMEM)); \ - if (__stub != NULL) { \ - call_stub_destroy (__stub); \ - } \ - GF_FREE (blk_fop); \ - goto err; \ + gf_msg(this->name, GF_LOG_WARNING, ENOMEM, LEASE_MSG_NO_MEM, \ + "Unable to create stub for blocking the fop:%s (%s)", \ + gf_fop_list[frame->root->op], strerror(ENOMEM)); \ + if (__stub != NULL) { \ + call_stub_destroy(__stub); \ + } \ + GF_FREE(blk_fop); \ + goto err; \ } \ -} while (0) \ + } while (0) struct _leases_private { - gf_boolean_t leases_enabled; - int32_t recall_lease_timeout; - struct list_head client_list; - struct list_head recall_list; - struct tvec_base *timer_wheel; /* timer wheel where the recall request - is qued and waits for unlock/expiry */ - gf_boolean_t fini; - pthread_t recall_thr; - gf_boolean_t inited_recall_thr; - pthread_mutex_t mutex; - pthread_cond_t cond; + gf_boolean_t leases_enabled; + int32_t recall_lease_timeout; + struct list_head client_list; + struct list_head recall_list; + struct tvec_base *timer_wheel; /* timer wheel where the recall request + is qued and waits for unlock/expiry */ + gf_boolean_t fini; + pthread_t recall_thr; + gf_boolean_t inited_recall_thr; + pthread_mutex_t mutex; + pthread_cond_t cond; }; typedef struct _leases_private leases_private_t; struct _lease_client { - char *client_uid; - struct list_head client_list; - struct list_head inode_list; + char *client_uid; + struct list_head client_list; + struct list_head inode_list; }; typedef struct _lease_client lease_client_t; struct _lease_inode { - inode_t *inode; - struct list_head list; /* This can be part of both inode_list and recall_list */ + inode_t *inode; + struct list_head + list; /* This can be part of both inode_list and recall_list */ }; typedef struct _lease_inode lease_inode_t; struct _lease_fd_ctx { - char *client_uid; - char lease_id[LEASE_ID_SIZE]; + char *client_uid; + char lease_id[LEASE_ID_SIZE]; }; typedef struct _lease_fd_ctx lease_fd_ctx_t; struct _lease_inode_ctx { - struct list_head lease_id_list; /* clients that have taken leases */ - int lease_type_cnt[GF_LEASE_MAX_TYPE+1]; - int lease_type; /* Types of leases acquired */ - uint64_t lease_cnt; /* Total number of leases on this inode */ - uint64_t openfd_cnt; /* number of fds open */ - gf_boolean_t recall_in_progress; /* if lease recall is sent on this inode */ - struct list_head blocked_list; /* List of fops blocked until the - lease recall is complete */ - inode_t *inode; /* this represents the inode on which the - lock was taken, required mainly during - disconnect cleanup */ - struct gf_tw_timer_list *timer; - pthread_mutex_t lock; + struct list_head lease_id_list; /* clients that have taken leases */ + int lease_type_cnt[GF_LEASE_MAX_TYPE + 1]; + int lease_type; /* Types of leases acquired */ + uint64_t lease_cnt; /* Total number of leases on this inode */ + uint64_t openfd_cnt; /* number of fds open */ + gf_boolean_t recall_in_progress; /* if lease recall is sent on this inode */ + struct list_head blocked_list; /* List of fops blocked until the + lease recall is complete */ + inode_t *inode; /* this represents the inode on which the + lock was taken, required mainly during + disconnect cleanup */ + struct gf_tw_timer_list *timer; + pthread_mutex_t lock; }; typedef struct _lease_inode_ctx lease_inode_ctx_t; struct _lease_id_entry { - struct list_head lease_id_list; - char lease_id[LEASE_ID_SIZE]; - char *client_uid; /* uid of the client that has - taken the lease */ - int lease_type_cnt[GF_LEASE_MAX_TYPE+1]; /* count of each lease type */ - int lease_type; /* Union of all the leases taken - under the given lease id */ - uint64_t lease_cnt; /* Number of leases taken under the - given lease id */ - time_t recall_time; /* time @ which recall was sent */ + struct list_head lease_id_list; + char lease_id[LEASE_ID_SIZE]; + char *client_uid; /* uid of the client that has + taken the lease */ + int lease_type_cnt[GF_LEASE_MAX_TYPE + 1]; /* count of each lease type */ + int lease_type; /* Union of all the leases taken + under the given lease id */ + uint64_t lease_cnt; /* Number of leases taken under the + given lease id */ + time_t recall_time; /* time @ which recall was sent */ }; typedef struct _lease_id_entry lease_id_entry_t; /* Required? as stub itself will have list */ struct __fop_stub { - struct list_head list; - call_stub_t *stub; + struct list_head list; + call_stub_t *stub; }; typedef struct __fop_stub fop_stub_t; struct __lease_timer_data { - inode_t *inode; - xlator_t *this; + inode_t *inode; + xlator_t *this; }; typedef struct __lease_timer_data lease_timer_data_t; gf_boolean_t -is_leases_enabled (xlator_t *this); +is_leases_enabled(xlator_t *this); int32_t -get_recall_lease_timeout (xlator_t *this); +get_recall_lease_timeout(xlator_t *this); lease_inode_ctx_t * -lease_ctx_get (inode_t *inode, xlator_t *this); +lease_ctx_get(inode_t *inode, xlator_t *this); int -process_lease_req (call_frame_t *frame, xlator_t *this, - inode_t *inode, struct gf_lease *lease); +process_lease_req(call_frame_t *frame, xlator_t *this, inode_t *inode, + struct gf_lease *lease); int -check_lease_conflict (call_frame_t *frame, inode_t *inode, - const char *lease_id, uint32_t fop_flags); +check_lease_conflict(call_frame_t *frame, inode_t *inode, const char *lease_id, + uint32_t fop_flags); int -cleanup_client_leases (xlator_t *this, const char *client_uid); +cleanup_client_leases(xlator_t *this, const char *client_uid); void * -expired_recall_cleanup (void *data); +expired_recall_cleanup(void *data); #endif /* _LEASES_H */ diff --git a/xlators/features/locks/src/clear.h b/xlators/features/locks/src/clear.h index 78fc5ae3398..08662746f98 100644 --- a/xlators/features/locks/src/clear.h +++ b/xlators/features/locks/src/clear.h @@ -16,56 +16,56 @@ #include "locks.h" typedef enum { - CLRLK_INODE, - CLRLK_ENTRY, - CLRLK_POSIX, - CLRLK_TYPE_MAX + CLRLK_INODE, + CLRLK_ENTRY, + CLRLK_POSIX, + CLRLK_TYPE_MAX } clrlk_type; typedef enum { - CLRLK_BLOCKED = 1, - CLRLK_GRANTED, - CLRLK_ALL, - CLRLK_KIND_MAX + CLRLK_BLOCKED = 1, + CLRLK_GRANTED, + CLRLK_ALL, + CLRLK_KIND_MAX } clrlk_kind; typedef enum { - KW_TYPE, - KW_KIND, - /*add new keywords here*/ - KW_MAX + KW_TYPE, + KW_KIND, + /*add new keywords here*/ + KW_MAX } clrlk_opts; struct _clrlk_args; typedef struct _clrlk_args clrlk_args; struct _clrlk_args { - int type; - int kind; - char *opts; + int type; + int kind; + char *opts; }; int -clrlk_get__kind (char *kind); +clrlk_get__kind(char *kind); int -clrlk_get_type (char *type); +clrlk_get_type(char *type); int -clrlk_get_lock_range (char *range_str, struct gf_flock *ulock, - gf_boolean_t *chk_range); +clrlk_get_lock_range(char *range_str, struct gf_flock *ulock, + gf_boolean_t *chk_range); int -clrlk_parse_args (const char* cmd, clrlk_args *args); +clrlk_parse_args(const char *cmd, clrlk_args *args); int -clrlk_clear_posixlk (xlator_t *this, pl_inode_t *pl_inode, clrlk_args *args, - int *blkd, int *granted, int *op_errno); +clrlk_clear_posixlk(xlator_t *this, pl_inode_t *pl_inode, clrlk_args *args, + int *blkd, int *granted, int *op_errno); int -clrlk_clear_inodelk (xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *dom, - clrlk_args *args, int *blkd, int *granted, int *op_errno); +clrlk_clear_inodelk(xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *dom, + clrlk_args *args, int *blkd, int *granted, int *op_errno); int -clrlk_clear_entrylk (xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *dom, - clrlk_args *args, int *blkd, int *granted, int *op_errno); +clrlk_clear_entrylk(xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *dom, + clrlk_args *args, int *blkd, int *granted, int *op_errno); int -clrlk_clear_lks_in_all_domains (xlator_t *this, pl_inode_t *pl_inode, - clrlk_args *args, int *blkd, int *granted, - int *op_errno); +clrlk_clear_lks_in_all_domains(xlator_t *this, pl_inode_t *pl_inode, + clrlk_args *args, int *blkd, int *granted, + int *op_errno); #endif /* __CLEAR_H__ */ diff --git a/xlators/features/locks/src/common.h b/xlators/features/locks/src/common.h index 50c156feb38..c3d0e361933 100644 --- a/xlators/features/locks/src/common.h +++ b/xlators/features/locks/src/common.h @@ -12,163 +12,173 @@ #include "lkowner.h" /*dump locks format strings */ -#define RANGE_FMT "type=%s, whence=%hd, start=%llu, len=%llu" -#define ENTRY_FMT "type=%s on basename=%s" -#define DUMP_GEN_FMT "pid = %llu, owner=%s, client=%p" -#define GRNTD_AT "granted at %s" -#define BLKD_AT "blocked at %s" -#define CONN_ID "connection-id=%s" -#define DUMP_BLKD_FMT DUMP_GEN_FMT", "CONN_ID", "BLKD_AT -#define DUMP_GRNTD_FMT DUMP_GEN_FMT", "CONN_ID", "GRNTD_AT -#define DUMP_BLKD_GRNTD_FMT DUMP_GEN_FMT", "CONN_ID", "BLKD_AT", "GRNTD_AT - -#define ENTRY_BLKD_FMT ENTRY_FMT", "DUMP_BLKD_FMT -#define ENTRY_GRNTD_FMT ENTRY_FMT", "DUMP_GRNTD_FMT -#define ENTRY_BLKD_GRNTD_FMT ENTRY_FMT", "DUMP_BLKD_GRNTD_FMT - -#define RANGE_BLKD_FMT RANGE_FMT", "DUMP_BLKD_FMT -#define RANGE_GRNTD_FMT RANGE_FMT", "DUMP_GRNTD_FMT -#define RANGE_BLKD_GRNTD_FMT RANGE_FMT", "DUMP_BLKD_GRNTD_FMT +#define RANGE_FMT "type=%s, whence=%hd, start=%llu, len=%llu" +#define ENTRY_FMT "type=%s on basename=%s" +#define DUMP_GEN_FMT "pid = %llu, owner=%s, client=%p" +#define GRNTD_AT "granted at %s" +#define BLKD_AT "blocked at %s" +#define CONN_ID "connection-id=%s" +#define DUMP_BLKD_FMT DUMP_GEN_FMT ", " CONN_ID ", " BLKD_AT +#define DUMP_GRNTD_FMT DUMP_GEN_FMT ", " CONN_ID ", " GRNTD_AT +#define DUMP_BLKD_GRNTD_FMT DUMP_GEN_FMT ", " CONN_ID ", " BLKD_AT ", " GRNTD_AT + +#define ENTRY_BLKD_FMT ENTRY_FMT ", " DUMP_BLKD_FMT +#define ENTRY_GRNTD_FMT ENTRY_FMT ", " DUMP_GRNTD_FMT +#define ENTRY_BLKD_GRNTD_FMT ENTRY_FMT ", " DUMP_BLKD_GRNTD_FMT + +#define RANGE_BLKD_FMT RANGE_FMT ", " DUMP_BLKD_FMT +#define RANGE_GRNTD_FMT RANGE_FMT ", " DUMP_GRNTD_FMT +#define RANGE_BLKD_GRNTD_FMT RANGE_FMT ", " DUMP_BLKD_GRNTD_FMT #define SET_FLOCK_PID(flock, lock) ((flock)->l_pid = lock->client_pid) - posix_lock_t * -new_posix_lock (struct gf_flock *flock, client_t *client, pid_t client_pid, - gf_lkowner_t *owner, fd_t *fd, uint32_t lk_flags, - int can_block); +new_posix_lock(struct gf_flock *flock, client_t *client, pid_t client_pid, + gf_lkowner_t *owner, fd_t *fd, uint32_t lk_flags, int can_block); pl_inode_t * -pl_inode_get (xlator_t *this, inode_t *inode); +pl_inode_get(xlator_t *this, inode_t *inode); posix_lock_t * -pl_getlk (pl_inode_t *inode, posix_lock_t *lock); +pl_getlk(pl_inode_t *inode, posix_lock_t *lock); int -pl_setlk (xlator_t *this, pl_inode_t *inode, posix_lock_t *lock, - int can_block); +pl_setlk(xlator_t *this, pl_inode_t *inode, posix_lock_t *lock, int can_block); void -grant_blocked_locks (xlator_t *this, pl_inode_t *inode); +grant_blocked_locks(xlator_t *this, pl_inode_t *inode); void -posix_lock_to_flock (posix_lock_t *lock, struct gf_flock *flock); +posix_lock_to_flock(posix_lock_t *lock, struct gf_flock *flock); int -locks_overlap (posix_lock_t *l1, posix_lock_t *l2); +locks_overlap(posix_lock_t *l1, posix_lock_t *l2); int -same_owner (posix_lock_t *l1, posix_lock_t *l2); +same_owner(posix_lock_t *l1, posix_lock_t *l2); -void __delete_lock (posix_lock_t *); +void +__delete_lock(posix_lock_t *); -void __destroy_lock (posix_lock_t *); +void +__destroy_lock(posix_lock_t *); pl_dom_list_t * -get_domain (pl_inode_t *pl_inode, const char *volume); +get_domain(pl_inode_t *pl_inode, const char *volume); void -grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode, - pl_dom_list_t *dom, struct timespec *now, - struct list_head *contend); +grant_blocked_inode_locks(xlator_t *this, pl_inode_t *pl_inode, + pl_dom_list_t *dom, struct timespec *now, + struct list_head *contend); void -inodelk_contention_notify (xlator_t *this, struct list_head *contend); +inodelk_contention_notify(xlator_t *this, struct list_head *contend); void -__delete_inode_lock (pl_inode_lock_t *lock); +__delete_inode_lock(pl_inode_lock_t *lock); void -__pl_inodelk_unref (pl_inode_lock_t *lock); +__pl_inodelk_unref(pl_inode_lock_t *lock); void -grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode, - pl_dom_list_t *dom, struct timespec *now, - struct list_head *contend); +grant_blocked_entry_locks(xlator_t *this, pl_inode_t *pl_inode, + pl_dom_list_t *dom, struct timespec *now, + struct list_head *contend); void -entrylk_contention_notify (xlator_t *this, struct list_head *contend); +entrylk_contention_notify(xlator_t *this, struct list_head *contend); -void pl_update_refkeeper (xlator_t *this, inode_t *inode); +void +pl_update_refkeeper(xlator_t *this, inode_t *inode); int32_t -__get_inodelk_count (xlator_t *this, pl_inode_t *pl_inode, char *domname); +__get_inodelk_count(xlator_t *this, pl_inode_t *pl_inode, char *domname); int32_t -get_inodelk_count (xlator_t *this, inode_t *inode, char *domname); +get_inodelk_count(xlator_t *this, inode_t *inode, char *domname); int32_t -__get_entrylk_count (xlator_t *this, pl_inode_t *pl_inode); +__get_entrylk_count(xlator_t *this, pl_inode_t *pl_inode); int32_t -get_entrylk_count (xlator_t *this, inode_t *inode); +get_entrylk_count(xlator_t *this, inode_t *inode); -void pl_trace_in (xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc, - int cmd, struct gf_flock *flock, const char *domain); +void +pl_trace_in(xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc, int cmd, + struct gf_flock *flock, const char *domain); -void pl_trace_out (xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc, - int cmd, struct gf_flock *flock, int op_ret, int op_errno, const char *domain); +void +pl_trace_out(xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc, int cmd, + struct gf_flock *flock, int op_ret, int op_errno, + const char *domain); -void pl_trace_block (xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc, - int cmd, struct gf_flock *flock, const char *domain); +void +pl_trace_block(xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc, + int cmd, struct gf_flock *flock, const char *domain); -void pl_trace_flush (xlator_t *this, call_frame_t *frame, fd_t *fd); +void +pl_trace_flush(xlator_t *this, call_frame_t *frame, fd_t *fd); -void entrylk_trace_in (xlator_t *this, call_frame_t *frame, const char *volume, - fd_t *fd, loc_t *loc, const char *basename, - entrylk_cmd cmd, entrylk_type type); +void +entrylk_trace_in(xlator_t *this, call_frame_t *frame, const char *volume, + fd_t *fd, loc_t *loc, const char *basename, entrylk_cmd cmd, + entrylk_type type); -void entrylk_trace_out (xlator_t *this, call_frame_t *frame, const char *volume, - fd_t *fd, loc_t *loc, const char *basename, - entrylk_cmd cmd, entrylk_type type, - int op_ret, int op_errno); +void +entrylk_trace_out(xlator_t *this, call_frame_t *frame, const char *volume, + fd_t *fd, loc_t *loc, const char *basename, entrylk_cmd cmd, + entrylk_type type, int op_ret, int op_errno); -void entrylk_trace_block (xlator_t *this, call_frame_t *frame, const char *volume, - fd_t *fd, loc_t *loc, const char *basename, - entrylk_cmd cmd, entrylk_type type); +void +entrylk_trace_block(xlator_t *this, call_frame_t *frame, const char *volume, + fd_t *fd, loc_t *loc, const char *basename, entrylk_cmd cmd, + entrylk_type type); void -pl_print_verdict (char *str, int size, int op_ret, int op_errno); +pl_print_verdict(char *str, int size, int op_ret, int op_errno); void -pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc); +pl_print_lockee(char *str, int size, fd_t *fd, loc_t *loc); void -pl_print_locker (char *str, int size, xlator_t *this, call_frame_t *frame); +pl_print_locker(char *str, int size, xlator_t *this, call_frame_t *frame); void -pl_print_inodelk (char *str, int size, int cmd, struct gf_flock *flock, const char *domain); +pl_print_inodelk(char *str, int size, int cmd, struct gf_flock *flock, + const char *domain); void -pl_trace_release (xlator_t *this, fd_t *fd); +pl_trace_release(xlator_t *this, fd_t *fd); unsigned long -fd_to_fdnum (fd_t *fd); +fd_to_fdnum(fd_t *fd); fd_t * -fd_from_fdnum (posix_lock_t *lock); +fd_from_fdnum(posix_lock_t *lock); int -pl_reserve_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock, - int can_block); +pl_reserve_setlk(xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock, + int can_block); int -reservelks_equal (posix_lock_t *l1, posix_lock_t *l2); +reservelks_equal(posix_lock_t *l1, posix_lock_t *l2); int -pl_verify_reservelk (xlator_t *this, pl_inode_t *pl_inode, - posix_lock_t *lock, int can_block); +pl_verify_reservelk(xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock, + int can_block); int -pl_reserve_unlock (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *reqlock); +pl_reserve_unlock(xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *reqlock); int32_t -check_entrylk_on_basename (xlator_t *this, inode_t *parent, char *basename); +check_entrylk_on_basename(xlator_t *this, inode_t *parent, char *basename); -void __pl_inodelk_unref (pl_inode_lock_t *lock); -void __pl_entrylk_unref (pl_entry_lock_t *lock); +void +__pl_inodelk_unref(pl_inode_lock_t *lock); +void +__pl_entrylk_unref(pl_entry_lock_t *lock); int -pl_metalock_is_active (pl_inode_t *pl_inode); +pl_metalock_is_active(pl_inode_t *pl_inode); int -__pl_queue_lock (pl_inode_t *pl_inode, posix_lock_t *reqlock, int can_block); +__pl_queue_lock(pl_inode_t *pl_inode, posix_lock_t *reqlock, int can_block); gf_boolean_t pl_does_monkey_want_stuck_lock(); diff --git a/xlators/features/locks/src/locks-mem-types.h b/xlators/features/locks/src/locks-mem-types.h index a48b35c2044..240c1957a42 100644 --- a/xlators/features/locks/src/locks-mem-types.h +++ b/xlators/features/locks/src/locks-mem-types.h @@ -14,17 +14,16 @@ #include "mem-types.h" enum gf_locks_mem_types_ { - gf_locks_mt_pl_dom_list_t = gf_common_mt_end + 1, - gf_locks_mt_pl_inode_t, - gf_locks_mt_posix_lock_t, - gf_locks_mt_pl_entry_lock_t, - gf_locks_mt_pl_inode_lock_t, - gf_locks_mt_truncate_ops, - gf_locks_mt_pl_rw_req_t, - gf_locks_mt_posix_locks_private_t, - gf_locks_mt_pl_fdctx_t, - gf_locks_mt_pl_meta_lock_t, - gf_locks_mt_end + gf_locks_mt_pl_dom_list_t = gf_common_mt_end + 1, + gf_locks_mt_pl_inode_t, + gf_locks_mt_posix_lock_t, + gf_locks_mt_pl_entry_lock_t, + gf_locks_mt_pl_inode_lock_t, + gf_locks_mt_truncate_ops, + gf_locks_mt_pl_rw_req_t, + gf_locks_mt_posix_locks_private_t, + gf_locks_mt_pl_fdctx_t, + gf_locks_mt_pl_meta_lock_t, + gf_locks_mt_end }; #endif - diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h index e9b75fb3f13..cf2849fc251 100644 --- a/xlators/features/locks/src/locks.h +++ b/xlators/features/locks/src/locks.h @@ -19,234 +19,233 @@ #include "lkowner.h" typedef enum { - MLK_NONE, - MLK_FILE_BASED, - MLK_FORCED, - MLK_OPTIMAL + MLK_NONE, + MLK_FILE_BASED, + MLK_FORCED, + MLK_OPTIMAL } mlk_mode_t; /* defines different mandatory locking modes*/ struct __pl_fd; struct __posix_lock { - struct list_head list; + struct list_head list; - short fl_type; - off_t fl_start; - off_t fl_end; - uint32_t lk_flags; + short fl_type; + off_t fl_start; + off_t fl_end; + uint32_t lk_flags; - short blocked; /* waiting to acquire */ - struct gf_flock user_flock; /* the flock supplied by the user */ - xlator_t *this; /* required for blocked locks */ - unsigned long fd_num; + short blocked; /* waiting to acquire */ + struct gf_flock user_flock; /* the flock supplied by the user */ + xlator_t *this; /* required for blocked locks */ + unsigned long fd_num; - fd_t *fd; - call_frame_t *frame; + fd_t *fd; + call_frame_t *frame; - struct timeval blkd_time; /*time at which lock was queued into blkd list*/ - struct timeval granted_time; /*time at which lock was queued into active list*/ + struct timeval blkd_time; /*time at which lock was queued into blkd list*/ + struct timeval + granted_time; /*time at which lock was queued into active list*/ - /* These two together serve to uniquely identify each process - across nodes */ + /* These two together serve to uniquely identify each process + across nodes */ - void *client; /* to identify client node */ + void *client; /* to identify client node */ - /* This field uniquely identifies the client the lock belongs to. As - * lock migration is handled by rebalance, the client_t object will be - * overwritten by rebalance and can't be deemed as the owner of the - * lock on destination. Hence, the below field is migrated from - * source to destination by lock_migration_info_t and updated on the - * destination. So that on client-server disconnection, server can - * cleanup the locks proper;y. */ + /* This field uniquely identifies the client the lock belongs to. As + * lock migration is handled by rebalance, the client_t object will be + * overwritten by rebalance and can't be deemed as the owner of the + * lock on destination. Hence, the below field is migrated from + * source to destination by lock_migration_info_t and updated on the + * destination. So that on client-server disconnection, server can + * cleanup the locks proper;y. */ - char *client_uid; - gf_lkowner_t owner; - pid_t client_pid; /* pid of client process */ + char *client_uid; + gf_lkowner_t owner; + pid_t client_pid; /* pid of client process */ - int blocking; + int blocking; }; typedef struct __posix_lock posix_lock_t; struct __pl_inode_lock { - struct list_head list; - struct list_head blocked_locks; /* list_head pointing to blocked_inodelks */ - struct list_head contend; /* list of contending locks */ - int ref; + struct list_head list; + struct list_head blocked_locks; /* list_head pointing to blocked_inodelks */ + struct list_head contend; /* list of contending locks */ + int ref; - short fl_type; - off_t fl_start; - off_t fl_end; + short fl_type; + off_t fl_start; + off_t fl_end; - const char *volume; + const char *volume; - struct gf_flock user_flock; /* the flock supplied by the user */ - xlator_t *this; /* required for blocked locks */ - struct __pl_inode *pl_inode; + struct gf_flock user_flock; /* the flock supplied by the user */ + xlator_t *this; /* required for blocked locks */ + struct __pl_inode *pl_inode; - call_frame_t *frame; + call_frame_t *frame; - struct timeval blkd_time; /*time at which lock was queued into blkd list*/ - struct timeval granted_time; /*time at which lock was queued into active list*/ - /*last time at which lock contention was detected and notified*/ - struct timespec contention_time; + struct timeval blkd_time; /*time at which lock was queued into blkd list*/ + struct timeval + granted_time; /*time at which lock was queued into active list*/ + /*last time at which lock contention was detected and notified*/ + struct timespec contention_time; - /* These two together serve to uniquely identify each process - across nodes */ + /* These two together serve to uniquely identify each process + across nodes */ - void *client; /* to identify client node */ - gf_lkowner_t owner; - pid_t client_pid; /* pid of client process */ + void *client; /* to identify client node */ + gf_lkowner_t owner; + pid_t client_pid; /* pid of client process */ - char *connection_id; /* stores the client connection id */ + char *connection_id; /* stores the client connection id */ - struct list_head client_list; /* list of all locks from a client */ + struct list_head client_list; /* list of all locks from a client */ }; typedef struct __pl_inode_lock pl_inode_lock_t; struct _pl_rw_req { - struct list_head list; - call_stub_t *stub; - posix_lock_t region; + struct list_head list; + call_stub_t *stub; + posix_lock_t region; }; typedef struct _pl_rw_req pl_rw_req_t; struct _pl_dom_list { - struct list_head inode_list; /* list_head back to pl_inode_t */ - const char *domain; - struct list_head entrylk_list; /* List of entry locks */ - struct list_head blocked_entrylks; /* List of all blocked entrylks */ - struct list_head inodelk_list; /* List of inode locks */ - struct list_head blocked_inodelks; /* List of all blocked inodelks */ + struct list_head inode_list; /* list_head back to pl_inode_t */ + const char *domain; + struct list_head entrylk_list; /* List of entry locks */ + struct list_head blocked_entrylks; /* List of all blocked entrylks */ + struct list_head inodelk_list; /* List of inode locks */ + struct list_head blocked_inodelks; /* List of all blocked inodelks */ }; typedef struct _pl_dom_list pl_dom_list_t; struct __entry_lock { - struct list_head domain_list; /* list_head back to pl_dom_list_t */ - struct list_head blocked_locks; /* list_head back to blocked_entrylks */ - struct list_head contend; /* list of contending locks */ - int ref; + struct list_head domain_list; /* list_head back to pl_dom_list_t */ + struct list_head blocked_locks; /* list_head back to blocked_entrylks */ + struct list_head contend; /* list of contending locks */ + int ref; - call_frame_t *frame; - xlator_t *this; - struct __pl_inode *pinode; + call_frame_t *frame; + xlator_t *this; + struct __pl_inode *pinode; - const char *volume; + const char *volume; - const char *basename; - entrylk_type type; + const char *basename; + entrylk_type type; - struct timeval blkd_time; /*time at which lock was queued into blkd list*/ - struct timeval granted_time; /*time at which lock was queued into active list*/ - /*last time at which lock contention was detected and notified*/ - struct timespec contention_time; + struct timeval blkd_time; /*time at which lock was queued into blkd list*/ + struct timeval + granted_time; /*time at which lock was queued into active list*/ + /*last time at which lock contention was detected and notified*/ + struct timespec contention_time; - void *client; - gf_lkowner_t owner; - pid_t client_pid; /* pid of client process */ + void *client; + gf_lkowner_t owner; + pid_t client_pid; /* pid of client process */ - char *connection_id; /* stores the client connection id */ + char *connection_id; /* stores the client connection id */ - struct list_head client_list; /* list of all locks from a client */ + struct list_head client_list; /* list of all locks from a client */ }; typedef struct __entry_lock pl_entry_lock_t; - /* The "simulated" inode. This contains a list of all the locks associated with this file */ struct __pl_inode { - pthread_mutex_t mutex; - - struct list_head dom_list; /* list of domains */ - struct list_head ext_list; /* list of fcntl locks */ - struct list_head rw_list; /* list of waiting r/w requests */ - struct list_head reservelk_list; /* list of reservelks */ - struct list_head blocked_reservelks; /* list of blocked reservelks */ - struct list_head blocked_calls; /* List of blocked lock calls while a reserve is held*/ - struct list_head metalk_list; /* Meta lock list */ - /* This is to store the incoming lock - requests while meta lock is enabled */ - struct list_head queued_locks; - int mandatory; /* if mandatory locking is enabled */ - - inode_t *refkeeper; /* hold refs on an inode while locks are - held to prevent pruning */ - uuid_t gfid; /* placeholder for gfid of the inode */ - inode_t *inode; /* pointer to be used for ref and unref - of inode_t as long as there are - locks on it */ - gf_boolean_t migrated; + pthread_mutex_t mutex; + + struct list_head dom_list; /* list of domains */ + struct list_head ext_list; /* list of fcntl locks */ + struct list_head rw_list; /* list of waiting r/w requests */ + struct list_head reservelk_list; /* list of reservelks */ + struct list_head blocked_reservelks; /* list of blocked reservelks */ + struct list_head + blocked_calls; /* List of blocked lock calls while a reserve is held*/ + struct list_head metalk_list; /* Meta lock list */ + /* This is to store the incoming lock + requests while meta lock is enabled */ + struct list_head queued_locks; + int mandatory; /* if mandatory locking is enabled */ + + inode_t *refkeeper; /* hold refs on an inode while locks are + held to prevent pruning */ + uuid_t gfid; /* placeholder for gfid of the inode */ + inode_t *inode; /* pointer to be used for ref and unref + of inode_t as long as there are + locks on it */ + gf_boolean_t migrated; }; typedef struct __pl_inode pl_inode_t; struct __pl_metalk { - pthread_mutex_t mutex; - /* For pl_inode meta lock list */ - struct list_head list; - /* For pl_ctx_t list */ - struct list_head client_list; - char *client_uid; - - pl_inode_t *pl_inode; - int ref; + pthread_mutex_t mutex; + /* For pl_inode meta lock list */ + struct list_head list; + /* For pl_ctx_t list */ + struct list_head client_list; + char *client_uid; + + pl_inode_t *pl_inode; + int ref; }; typedef struct __pl_metalk pl_meta_lock_t; typedef struct { - mlk_mode_t mandatory_mode; /* holds current mandatory locking mode */ - gf_boolean_t trace; /* trace lock requests in and out */ - char *brickname; - gf_boolean_t monkey_unlocking; - uint32_t revocation_secs; - gf_boolean_t revocation_clear_all; - uint32_t revocation_max_blocked; - gf_boolean_t notify_contention; - uint32_t notify_contention_delay; + mlk_mode_t mandatory_mode; /* holds current mandatory locking mode */ + gf_boolean_t trace; /* trace lock requests in and out */ + char *brickname; + gf_boolean_t monkey_unlocking; + uint32_t revocation_secs; + gf_boolean_t revocation_clear_all; + uint32_t revocation_max_blocked; + gf_boolean_t notify_contention; + uint32_t notify_contention_delay; } posix_locks_private_t; - typedef struct { - gf_boolean_t entrylk_count_req; - gf_boolean_t inodelk_count_req; - gf_boolean_t posixlk_count_req; - gf_boolean_t parent_entrylk_req; - data_t *inodelk_dom_count_req; - - dict_t *xdata; - loc_t loc[2]; - fd_t *fd; - off_t offset; - glusterfs_fop_t op; + gf_boolean_t entrylk_count_req; + gf_boolean_t inodelk_count_req; + gf_boolean_t posixlk_count_req; + gf_boolean_t parent_entrylk_req; + data_t *inodelk_dom_count_req; + + dict_t *xdata; + loc_t loc[2]; + fd_t *fd; + off_t offset; + glusterfs_fop_t op; } pl_local_t; - typedef struct { - struct list_head locks_list; + struct list_head locks_list; } pl_fdctx_t; - struct _locker { - struct list_head lockers; - char *volume; - inode_t *inode; - gf_lkowner_t owner; + struct list_head lockers; + char *volume; + inode_t *inode; + gf_lkowner_t owner; }; typedef struct _locks_ctx { - pthread_mutex_t lock; - struct list_head inodelk_lockers; - struct list_head entrylk_lockers; - struct list_head metalk_list; + pthread_mutex_t lock; + struct list_head inodelk_lockers; + struct list_head entrylk_lockers; + struct list_head metalk_list; } pl_ctx_t; - pl_ctx_t * -pl_ctx_get (client_t *client, xlator_t *xlator); +pl_ctx_get(client_t *client, xlator_t *xlator); int -pl_inodelk_client_cleanup (xlator_t *this, pl_ctx_t *ctx); +pl_inodelk_client_cleanup(xlator_t *this, pl_ctx_t *ctx); int -pl_entrylk_client_cleanup (xlator_t *this, pl_ctx_t *ctx); +pl_entrylk_client_cleanup(xlator_t *this, pl_ctx_t *ctx); #endif /* __POSIX_LOCKS_H__ */ diff --git a/xlators/features/locks/src/pl-messages.h b/xlators/features/locks/src/pl-messages.h index e5a276f35b5..a99e1bbce43 100644 --- a/xlators/features/locks/src/pl-messages.h +++ b/xlators/features/locks/src/pl-messages.h @@ -23,10 +23,7 @@ * glfs-message-id.h. */ -GLFS_MSGID(PL, - PL_MSG_LOCK_NUMBER, - PL_MSG_INODELK_CONTENTION_FAILED, - PL_MSG_ENTRYLK_CONTENTION_FAILED -); +GLFS_MSGID(PL, PL_MSG_LOCK_NUMBER, PL_MSG_INODELK_CONTENTION_FAILED, + PL_MSG_ENTRYLK_CONTENTION_FAILED); #endif /* !_PL_MESSAGES_H_ */ diff --git a/xlators/features/marker/src/marker-common.h b/xlators/features/marker/src/marker-common.h index fbe9a2ce4b0..449d55b5ef0 100644 --- a/xlators/features/marker/src/marker-common.h +++ b/xlators/features/marker/src/marker-common.h @@ -14,8 +14,8 @@ #include "marker.h" int32_t -marker_force_inode_ctx_get (inode_t *, xlator_t *, marker_inode_ctx_t **); +marker_force_inode_ctx_get(inode_t *, xlator_t *, marker_inode_ctx_t **); int -marker_filter_quota_xattr (dict_t *, char *, data_t *, void *); +marker_filter_quota_xattr(dict_t *, char *, data_t *, void *); #endif diff --git a/xlators/features/marker/src/marker-mem-types.h b/xlators/features/marker/src/marker-mem-types.h index dc5ad16ed76..7d590d7ec84 100644 --- a/xlators/features/marker/src/marker-mem-types.h +++ b/xlators/features/marker/src/marker-mem-types.h @@ -13,15 +13,15 @@ #include "mem-types.h" enum gf_marker_mem_types_ { - gf_marker_mt_marker_conf_t = gf_common_mt_end + 1, - gf_marker_mt_loc_t, - gf_marker_mt_volume_mark, - gf_marker_mt_int64_t, - gf_marker_mt_quota_inode_ctx_t, - gf_marker_mt_marker_inode_ctx_t, - gf_marker_mt_inode_contribution_t, - gf_marker_mt_quota_meta_t, - gf_marker_mt_quota_synctask_t, - gf_marker_mt_end + gf_marker_mt_marker_conf_t = gf_common_mt_end + 1, + gf_marker_mt_loc_t, + gf_marker_mt_volume_mark, + gf_marker_mt_int64_t, + gf_marker_mt_quota_inode_ctx_t, + gf_marker_mt_marker_inode_ctx_t, + gf_marker_mt_inode_contribution_t, + gf_marker_mt_quota_meta_t, + gf_marker_mt_quota_synctask_t, + gf_marker_mt_end }; #endif diff --git a/xlators/features/marker/src/marker-quota-helper.h b/xlators/features/marker/src/marker-quota-helper.h index 444ba7ca71e..99723def1b9 100644 --- a/xlators/features/marker/src/marker-quota-helper.h +++ b/xlators/features/marker/src/marker-quota-helper.h @@ -13,66 +13,66 @@ #include "marker.h" -#define QUOTA_FREE_CONTRIBUTION_NODE(ctx, _contribution) \ - do { \ - LOCK (&ctx->lock); \ - { \ - list_del_init (&_contribution->contri_list); \ - GF_REF_PUT (_contribution); \ - } \ - UNLOCK (&ctx->lock); \ - } while (0) - -#define QUOTA_SAFE_INCREMENT(lock, var) \ - do { \ - LOCK (lock); \ - var ++; \ - UNLOCK (lock); \ - } while (0) - -#define QUOTA_SAFE_DECREMENT(lock, var, value) \ - do { \ - LOCK (lock); \ - { \ - value = --var; \ - } \ - UNLOCK (lock); \ - } while (0) +#define QUOTA_FREE_CONTRIBUTION_NODE(ctx, _contribution) \ + do { \ + LOCK(&ctx->lock); \ + { \ + list_del_init(&_contribution->contri_list); \ + GF_REF_PUT(_contribution); \ + } \ + UNLOCK(&ctx->lock); \ + } while (0) + +#define QUOTA_SAFE_INCREMENT(lock, var) \ + do { \ + LOCK(lock); \ + var++; \ + UNLOCK(lock); \ + } while (0) + +#define QUOTA_SAFE_DECREMENT(lock, var, value) \ + do { \ + LOCK(lock); \ + { \ + value = --var; \ + } \ + UNLOCK(lock); \ + } while (0) inode_contribution_t * -mq_add_new_contribution_node (xlator_t *, quota_inode_ctx_t *, loc_t *); +mq_add_new_contribution_node(xlator_t *, quota_inode_ctx_t *, loc_t *); int32_t -mq_dict_set_contribution (xlator_t *, dict_t *, loc_t *, uuid_t, char *); +mq_dict_set_contribution(xlator_t *, dict_t *, loc_t *, uuid_t, char *); quota_inode_ctx_t * -mq_inode_ctx_new (inode_t *, xlator_t *); +mq_inode_ctx_new(inode_t *, xlator_t *); int32_t -mq_inode_ctx_get (inode_t *, xlator_t *, quota_inode_ctx_t **); +mq_inode_ctx_get(inode_t *, xlator_t *, quota_inode_ctx_t **); int32_t -mq_delete_contribution_node (dict_t *, char *, inode_contribution_t *); +mq_delete_contribution_node(dict_t *, char *, inode_contribution_t *); int32_t -mq_inode_loc_fill (const char *, inode_t *, loc_t *); +mq_inode_loc_fill(const char *, inode_t *, loc_t *); quota_local_t * -mq_local_new (); +mq_local_new(); quota_local_t * -mq_local_ref (quota_local_t *); +mq_local_ref(quota_local_t *); int32_t -mq_local_unref (xlator_t *, quota_local_t *); +mq_local_unref(xlator_t *, quota_local_t *); -inode_contribution_t* -mq_contri_init (inode_t *inode); +inode_contribution_t * +mq_contri_init(inode_t *inode); inode_contribution_t * -mq_get_contribution_node (inode_t *, quota_inode_ctx_t *); +mq_get_contribution_node(inode_t *, quota_inode_ctx_t *); inode_contribution_t * -mq_get_contribution_from_loc (xlator_t *this, loc_t *loc); +mq_get_contribution_from_loc(xlator_t *this, loc_t *loc); #endif diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h index 51e062537b8..7f63e268203 100644 --- a/xlators/features/marker/src/marker-quota.h +++ b/xlators/features/marker/src/marker-quota.h @@ -19,138 +19,131 @@ #define QUOTA_XATTR_PREFIX "trusted.glusterfs" #define QUOTA_DIRTY_KEY "trusted.glusterfs.quota.dirty" -#define CONTRIBUTION "contri" +#define CONTRIBUTION "contri" #define QUOTA_KEY_MAX 512 #define READDIR_BUF 4096 - -#define QUOTA_STACK_DESTROY(_frame, _this) \ - do { \ - quota_local_t *_local = NULL; \ - _local = _frame->local; \ - _frame->local = NULL; \ - STACK_DESTROY (_frame->root); \ - mq_local_unref (_this, _local); \ - } while (0) - - -#define QUOTA_ALLOC(var, type, ret) \ - do { \ - ret = 0; \ - var = GF_CALLOC (sizeof (type), 1, \ - gf_marker_mt_##type); \ - if (!var) { \ - ret = -1; \ - } \ - } while (0); - -#define QUOTA_ALLOC_OR_GOTO(var, type, ret, label) \ - do { \ - var = GF_CALLOC (sizeof (type), 1, \ - gf_marker_mt_##type); \ - if (!var) { \ - gf_log ("", GF_LOG_ERROR, \ - "out of memory"); \ - ret = -1; \ - goto label; \ - } \ - ret = 0; \ - } while (0); - -#define GET_QUOTA_KEY(_this, var, key, _ret) \ - do { \ - marker_conf_t *_priv = _this->private; \ - if (_priv->version > 0) \ - _ret = snprintf (var, QUOTA_KEY_MAX, "%s.%d", \ - key, _priv->version); \ - else \ - _ret = snprintf (var, QUOTA_KEY_MAX, "%s", key); \ - } while (0) - -#define GET_CONTRI_KEY(_this, var, _gfid, _ret) \ - do { \ - char _tmp_var[QUOTA_KEY_MAX] = {0, }; \ - if (_gfid != NULL) { \ - char _gfid_unparsed[40]; \ - gf_uuid_unparse (_gfid, _gfid_unparsed); \ - _ret = snprintf (_tmp_var, QUOTA_KEY_MAX, \ - QUOTA_XATTR_PREFIX \ - ".%s.%s." CONTRIBUTION, \ - "quota", _gfid_unparsed); \ - } else { \ - _ret = snprintf (_tmp_var, QUOTA_KEY_MAX, \ - QUOTA_XATTR_PREFIX \ - ".%s.." CONTRIBUTION, \ - "quota"); \ - } \ - GET_QUOTA_KEY (_this, var, _tmp_var, _ret); \ - } while (0) - -#define GET_SIZE_KEY(_this, var, _ret) \ - { \ - GET_QUOTA_KEY (_this, var, QUOTA_SIZE_KEY, _ret); \ - } - -#define QUOTA_SAFE_INCREMENT(lock, var) \ - do { \ - LOCK (lock); \ - var ++; \ - UNLOCK (lock); \ - } while (0) +#define QUOTA_STACK_DESTROY(_frame, _this) \ + do { \ + quota_local_t *_local = NULL; \ + _local = _frame->local; \ + _frame->local = NULL; \ + STACK_DESTROY(_frame->root); \ + mq_local_unref(_this, _local); \ + } while (0) + +#define QUOTA_ALLOC(var, type, ret) \ + do { \ + ret = 0; \ + var = GF_CALLOC(sizeof(type), 1, gf_marker_mt_##type); \ + if (!var) { \ + ret = -1; \ + } \ + } while (0); + +#define QUOTA_ALLOC_OR_GOTO(var, type, ret, label) \ + do { \ + var = GF_CALLOC(sizeof(type), 1, gf_marker_mt_##type); \ + if (!var) { \ + gf_log("", GF_LOG_ERROR, "out of memory"); \ + ret = -1; \ + goto label; \ + } \ + ret = 0; \ + } while (0); + +#define GET_QUOTA_KEY(_this, var, key, _ret) \ + do { \ + marker_conf_t *_priv = _this->private; \ + if (_priv->version > 0) \ + _ret = snprintf(var, QUOTA_KEY_MAX, "%s.%d", key, _priv->version); \ + else \ + _ret = snprintf(var, QUOTA_KEY_MAX, "%s", key); \ + } while (0) + +#define GET_CONTRI_KEY(_this, var, _gfid, _ret) \ + do { \ + char _tmp_var[QUOTA_KEY_MAX] = { \ + 0, \ + }; \ + if (_gfid != NULL) { \ + char _gfid_unparsed[40]; \ + gf_uuid_unparse(_gfid, _gfid_unparsed); \ + _ret = snprintf(_tmp_var, QUOTA_KEY_MAX, \ + QUOTA_XATTR_PREFIX ".%s.%s." CONTRIBUTION, \ + "quota", _gfid_unparsed); \ + } else { \ + _ret = snprintf(_tmp_var, QUOTA_KEY_MAX, \ + QUOTA_XATTR_PREFIX ".%s.." CONTRIBUTION, "quota"); \ + } \ + GET_QUOTA_KEY(_this, var, _tmp_var, _ret); \ + } while (0) + +#define GET_SIZE_KEY(_this, var, _ret) \ + { \ + GET_QUOTA_KEY(_this, var, QUOTA_SIZE_KEY, _ret); \ + } + +#define QUOTA_SAFE_INCREMENT(lock, var) \ + do { \ + LOCK(lock); \ + var++; \ + UNLOCK(lock); \ + } while (0) struct quota_inode_ctx { - int64_t size; - int64_t file_count; - int64_t dir_count; - int8_t dirty; - gf_boolean_t create_status; - gf_boolean_t updation_status; - gf_boolean_t dirty_status; - gf_lock_t lock; - struct list_head contribution_head; + int64_t size; + int64_t file_count; + int64_t dir_count; + int8_t dirty; + gf_boolean_t create_status; + gf_boolean_t updation_status; + gf_boolean_t dirty_status; + gf_lock_t lock; + struct list_head contribution_head; }; typedef struct quota_inode_ctx quota_inode_ctx_t; struct quota_synctask { - xlator_t *this; - loc_t loc; - quota_meta_t contri; - gf_boolean_t is_static; - uint32_t ia_nlink; - call_stub_t *stub; + xlator_t *this; + loc_t loc; + quota_meta_t contri; + gf_boolean_t is_static; + uint32_t ia_nlink; + call_stub_t *stub; }; typedef struct quota_synctask quota_synctask_t; struct inode_contribution { - struct list_head contri_list; - int64_t contribution; - int64_t file_count; - int64_t dir_count; - uuid_t gfid; - gf_lock_t lock; - GF_REF_DECL; + struct list_head contri_list; + int64_t contribution; + int64_t file_count; + int64_t dir_count; + uuid_t gfid; + gf_lock_t lock; + GF_REF_DECL; }; typedef struct inode_contribution inode_contribution_t; int32_t -mq_req_xattr (xlator_t *, loc_t *, dict_t *, char *, char *); +mq_req_xattr(xlator_t *, loc_t *, dict_t *, char *, char *); int32_t -mq_xattr_state (xlator_t *, loc_t *, dict_t *, struct iatt); +mq_xattr_state(xlator_t *, loc_t *, dict_t *, struct iatt); int -mq_initiate_quota_txn (xlator_t *, loc_t *, struct iatt *); +mq_initiate_quota_txn(xlator_t *, loc_t *, struct iatt *); int -mq_initiate_quota_blocking_txn (xlator_t *, loc_t *, struct iatt *); +mq_initiate_quota_blocking_txn(xlator_t *, loc_t *, struct iatt *); int -mq_create_xattrs_txn (xlator_t *this, loc_t *loc, struct iatt *buf); +mq_create_xattrs_txn(xlator_t *this, loc_t *loc, struct iatt *buf); int32_t -mq_reduce_parent_size_txn (xlator_t *, loc_t *, quota_meta_t *, - uint32_t nlink, call_stub_t *stub); +mq_reduce_parent_size_txn(xlator_t *, loc_t *, quota_meta_t *, uint32_t nlink, + call_stub_t *stub); int32_t -mq_forget (xlator_t *, quota_inode_ctx_t *); +mq_forget(xlator_t *, quota_inode_ctx_t *); #endif diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h index 4726880b82f..3b6f4ec8b72 100644 --- a/xlators/features/marker/src/marker.h +++ b/xlators/features/marker/src/marker.h @@ -17,132 +17,131 @@ #include "call-stub.h" #define MARKER_XATTR_PREFIX "trusted.glusterfs" -#define XTIME "xtime" -#define VOLUME_MARK "volume-mark" -#define VOLUME_UUID "volume-uuid" -#define TIMESTAMP_FILE "timestamp-file" +#define XTIME "xtime" +#define VOLUME_MARK "volume-mark" +#define VOLUME_UUID "volume-uuid" +#define TIMESTAMP_FILE "timestamp-file" enum { - GF_QUOTA = 1, - GF_XTIME = 2, - GF_XTIME_GSYNC_FORCE = 4, - GF_INODE_QUOTA = 8, + GF_QUOTA = 1, + GF_XTIME = 2, + GF_XTIME_GSYNC_FORCE = 4, + GF_INODE_QUOTA = 8, }; /*initialize the local variable*/ -#define MARKER_INIT_LOCAL(_frame,_local) do { \ - _frame->local = _local; \ - _local->pid = _frame->root->pid; \ - memset (&_local->loc, 0, sizeof (loc_t)); \ - _local->ref = 1; \ - _local->uid = -1; \ - _local->gid = -1; \ - LOCK_INIT (&_local->lock); \ - _local->oplocal = NULL; \ - } while (0) +#define MARKER_INIT_LOCAL(_frame, _local) \ + do { \ + _frame->local = _local; \ + _local->pid = _frame->root->pid; \ + memset(&_local->loc, 0, sizeof(loc_t)); \ + _local->ref = 1; \ + _local->uid = -1; \ + _local->gid = -1; \ + LOCK_INIT(&_local->lock); \ + _local->oplocal = NULL; \ + } while (0) /* try alloc and if it fails, goto label */ -#define ALLOCATE_OR_GOTO(var, type, label) do { \ - var = GF_CALLOC (sizeof (type), 1, \ - gf_marker_mt_##type); \ - if (!var) { \ - gf_log (this->name, GF_LOG_ERROR, \ - "out of memory :("); \ - goto label; \ - } \ - } while (0) - -#define _MARKER_SET_UID_GID(dest, src) \ - do { \ - if (src->uid != -1 && \ - src->gid != -1) { \ - dest->uid = src->uid; \ - dest->gid = src->gid; \ - } \ - } while (0) - -#define MARKER_SET_UID_GID(frame, dest, src) \ - do { \ - _MARKER_SET_UID_GID (dest, src); \ - frame->root->uid = 0; \ - frame->root->gid = 0; \ - frame->cookie = (void *) _GF_UID_GID_CHANGED; \ - } while (0) - -#define MARKER_RESET_UID_GID(frame, dest, src) \ - do { \ - _MARKER_SET_UID_GID (dest, src); \ - frame->cookie = NULL; \ - } while (0) - -#define MARKER_STACK_UNWIND(fop, frame, params...) \ - do { \ - quota_local_t *_local = NULL; \ - if (frame) { \ - _local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - if (_local) \ - marker_local_unref (_local); \ - } while (0) - -struct marker_local{ - uint32_t timebuf[2]; - pid_t pid; - loc_t loc; - loc_t parent_loc; - uid_t uid; - gid_t gid; - int32_t ref; - uint32_t ia_nlink; - struct iatt buf; - gf_lock_t lock; - mode_t mode; - int32_t err; - call_stub_t *stub; - call_frame_t *lk_frame; - quota_meta_t contribution; - struct marker_local *oplocal; - - /* marker quota specific */ - int64_t delta; - int64_t d_off; - int64_t sum; - int64_t size; - int32_t hl_count; - int32_t dentry_child_count; - - fd_t *fd; - call_frame_t *frame; - - quota_inode_ctx_t *ctx; - inode_contribution_t *contri; - - int xflag; - dict_t *xdata; - gf_boolean_t skip_txn; +#define ALLOCATE_OR_GOTO(var, type, label) \ + do { \ + var = GF_CALLOC(sizeof(type), 1, gf_marker_mt_##type); \ + if (!var) { \ + gf_log(this->name, GF_LOG_ERROR, "out of memory :("); \ + goto label; \ + } \ + } while (0) + +#define _MARKER_SET_UID_GID(dest, src) \ + do { \ + if (src->uid != -1 && src->gid != -1) { \ + dest->uid = src->uid; \ + dest->gid = src->gid; \ + } \ + } while (0) + +#define MARKER_SET_UID_GID(frame, dest, src) \ + do { \ + _MARKER_SET_UID_GID(dest, src); \ + frame->root->uid = 0; \ + frame->root->gid = 0; \ + frame->cookie = (void *)_GF_UID_GID_CHANGED; \ + } while (0) + +#define MARKER_RESET_UID_GID(frame, dest, src) \ + do { \ + _MARKER_SET_UID_GID(dest, src); \ + frame->cookie = NULL; \ + } while (0) + +#define MARKER_STACK_UNWIND(fop, frame, params...) \ + do { \ + quota_local_t *_local = NULL; \ + if (frame) { \ + _local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + if (_local) \ + marker_local_unref(_local); \ + } while (0) + +struct marker_local { + uint32_t timebuf[2]; + pid_t pid; + loc_t loc; + loc_t parent_loc; + uid_t uid; + gid_t gid; + int32_t ref; + uint32_t ia_nlink; + struct iatt buf; + gf_lock_t lock; + mode_t mode; + int32_t err; + call_stub_t *stub; + call_frame_t *lk_frame; + quota_meta_t contribution; + struct marker_local *oplocal; + + /* marker quota specific */ + int64_t delta; + int64_t d_off; + int64_t sum; + int64_t size; + int32_t hl_count; + int32_t dentry_child_count; + + fd_t *fd; + call_frame_t *frame; + + quota_inode_ctx_t *ctx; + inode_contribution_t *contri; + + int xflag; + dict_t *xdata; + gf_boolean_t skip_txn; }; typedef struct marker_local marker_local_t; #define quota_local_t marker_local_t struct marker_inode_ctx { - struct quota_inode_ctx *quota_ctx; + struct quota_inode_ctx *quota_ctx; }; typedef struct marker_inode_ctx marker_inode_ctx_t; -struct marker_conf{ - char feature_enabled; - char *size_key; - char *dirty_key; - char *volume_uuid; - uuid_t volume_uuid_bin; - char *timestamp_file; - char *marker_xattr; - uint64_t quota_lk_owner; - gf_lock_t lock; - int32_t version; +struct marker_conf { + char feature_enabled; + char *size_key; + char *dirty_key; + char *volume_uuid; + uuid_t volume_uuid_bin; + char *timestamp_file; + char *marker_xattr; + uint64_t quota_lk_owner; + gf_lock_t lock; + int32_t version; }; typedef struct marker_conf marker_conf_t; diff --git a/xlators/features/namespace/src/namespace.h b/xlators/features/namespace/src/namespace.h index 1dbec50e024..4c04cb3f471 100644 --- a/xlators/features/namespace/src/namespace.h +++ b/xlators/features/namespace/src/namespace.h @@ -12,12 +12,12 @@ #define GF_NAMESPACE "namespace" typedef struct { - gf_boolean_t tag_namespaces; + gf_boolean_t tag_namespaces; } ns_private_t; typedef struct { - loc_t loc; /* We store a "fake" loc_t for the getxattr wind. */ - call_stub_t *stub; /* A stub back to the function we're resuming. */ + loc_t loc; /* We store a "fake" loc_t for the getxattr wind. */ + call_stub_t *stub; /* A stub back to the function we're resuming. */ } ns_local_t; #endif /* __NAMESPACE_H__ */ diff --git a/xlators/features/quiesce/src/quiesce-mem-types.h b/xlators/features/quiesce/src/quiesce-mem-types.h index 31346c1a794..914bfb22ed0 100644 --- a/xlators/features/quiesce/src/quiesce-mem-types.h +++ b/xlators/features/quiesce/src/quiesce-mem-types.h @@ -14,8 +14,8 @@ #include "mem-types.h" enum gf_quiesce_mem_types_ { - gf_quiesce_mt_priv_t = gf_common_mt_end + 1, - gf_quiesce_mt_failover_hosts, - gf_quiesce_mt_end + gf_quiesce_mt_priv_t = gf_common_mt_end + 1, + gf_quiesce_mt_failover_hosts, + gf_quiesce_mt_end }; #endif diff --git a/xlators/features/quiesce/src/quiesce-messages.h b/xlators/features/quiesce/src/quiesce-messages.h index 8af3b10b06e..864a18147dc 100644 --- a/xlators/features/quiesce/src/quiesce-messages.h +++ b/xlators/features/quiesce/src/quiesce-messages.h @@ -23,9 +23,6 @@ * glfs-message-id.h. */ -GLFS_MSGID(QUIESCE, - QUIESCE_MSG_INVAL_HOST, - QUIESCE_MSG_FAILOVER_FAILED -); +GLFS_MSGID(QUIESCE, QUIESCE_MSG_INVAL_HOST, QUIESCE_MSG_FAILOVER_FAILED); #endif /* __NL_CACHE_MESSAGES_H__ */ diff --git a/xlators/features/quiesce/src/quiesce.h b/xlators/features/quiesce/src/quiesce.h index c084801c6c6..ed8f8fa2934 100644 --- a/xlators/features/quiesce/src/quiesce.h +++ b/xlators/features/quiesce/src/quiesce.h @@ -19,47 +19,47 @@ #define GF_FOPS_EXPECTED_IN_PARALLEL 512 typedef struct { - struct list_head list; - char *addr; - gf_boolean_t tried; /* indicates attempted connecting */ + struct list_head list; + char *addr; + gf_boolean_t tried; /* indicates attempted connecting */ } quiesce_failover_hosts_t; typedef struct { - gf_timer_t *timer; - gf_boolean_t pass_through; - gf_lock_t lock; - struct list_head req; - int queue_size; - pthread_t thr; - struct mem_pool *local_pool; - uint32_t timeout; - char *failover_hosts; - struct list_head failover_list; + gf_timer_t *timer; + gf_boolean_t pass_through; + gf_lock_t lock; + struct list_head req; + int queue_size; + pthread_t thr; + struct mem_pool *local_pool; + uint32_t timeout; + char *failover_hosts; + struct list_head failover_list; } quiesce_priv_t; typedef struct { - fd_t *fd; - char *name; - char *volname; - loc_t loc; - off_t size; - off_t offset; - mode_t mode; - int32_t flag; - struct iatt stbuf; - struct iovec *vector; - struct iobref *iobref; - dict_t *dict; - struct gf_flock flock; - entrylk_cmd cmd; - entrylk_type type; - gf_xattrop_flags_t xattrop_flags; - int32_t wbflags; - uint32_t io_flag; - /* for fallocate */ - size_t len; - /* for lseek */ - gf_seek_what_t what; + fd_t *fd; + char *name; + char *volname; + loc_t loc; + off_t size; + off_t offset; + mode_t mode; + int32_t flag; + struct iatt stbuf; + struct iovec *vector; + struct iobref *iobref; + dict_t *dict; + struct gf_flock flock; + entrylk_cmd cmd; + entrylk_type type; + gf_xattrop_flags_t xattrop_flags; + int32_t wbflags; + uint32_t io_flag; + /* for fallocate */ + size_t len; + /* for lseek */ + gf_seek_what_t what; } quiesce_local_t; #endif diff --git a/xlators/features/quota/src/quota-mem-types.h b/xlators/features/quota/src/quota-mem-types.h index 97d9165681f..e04d2e846cd 100644 --- a/xlators/features/quota/src/quota-mem-types.h +++ b/xlators/features/quota/src/quota-mem-types.h @@ -13,18 +13,17 @@ #include "mem-types.h" enum gf_quota_mem_types_ { - gf_quota_mt_quota_priv_t = gf_common_mt_end + 1, - gf_quota_mt_quota_inode_ctx_t, - gf_quota_mt_loc_t, - gf_quota_mt_char, - gf_quota_mt_int64_t, - gf_quota_mt_int32_t, - gf_quota_mt_limits_t, - gf_quota_mt_quota_dentry_t, - gf_quota_mt_quota_limits_level_t, - gf_quota_mt_qd_vols_conf_t, - gf_quota_mt_aggregator_state_t, - gf_quota_mt_end + gf_quota_mt_quota_priv_t = gf_common_mt_end + 1, + gf_quota_mt_quota_inode_ctx_t, + gf_quota_mt_loc_t, + gf_quota_mt_char, + gf_quota_mt_int64_t, + gf_quota_mt_int32_t, + gf_quota_mt_limits_t, + gf_quota_mt_quota_dentry_t, + gf_quota_mt_quota_limits_level_t, + gf_quota_mt_qd_vols_conf_t, + gf_quota_mt_aggregator_state_t, + gf_quota_mt_end }; #endif - diff --git a/xlators/features/quota/src/quota-messages.h b/xlators/features/quota/src/quota-messages.h index 85f5abf7b29..5129d2ee9ad 100644 --- a/xlators/features/quota/src/quota-messages.h +++ b/xlators/features/quota/src/quota-messages.h @@ -23,33 +23,17 @@ * glfs-message-id.h. */ -GLFS_MSGID(QUOTA, - Q_MSG_ENFORCEMENT_FAILED, - Q_MSG_ENOMEM, - Q_MSG_PARENT_NULL, - Q_MSG_CROSSED_SOFT_LIMIT, - Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED, - Q_MSG_REMOTE_OPERATION_FAILED, - Q_MSG_FAILED_TO_SEND_FOP, - Q_MSG_INVALID_VOLFILE, - Q_MSG_INODE_PARENT_NOT_FOUND, - Q_MSG_XDR_DECODE_ERROR, - Q_MSG_DICT_UNSERIALIZE_FAIL, - Q_MSG_DICT_SERIALIZE_FAIL, - Q_MSG_RPCSVC_INIT_FAILED, - Q_MSG_RPCSVC_LISTENER_CREATION_FAILED, - Q_MSG_RPCSVC_REGISTER_FAILED, - Q_MSG_XDR_DECODING_FAILED, - Q_MSG_RPCCLNT_REGISTER_NOTIFY_FAILED, - Q_MSG_ANCESTRY_BUILD_FAILED, - Q_MSG_SIZE_KEY_MISSING, - Q_MSG_INODE_CTX_GET_FAILED, - Q_MSG_INODE_CTX_SET_FAILED, - Q_MSG_LOOKUP_FAILED, - Q_MSG_RPC_SUBMIT_FAILED, - Q_MSG_ENFORCEMENT_SKIPPED, - Q_MSG_INTERNAL_FOP_KEY_MISSING -); +GLFS_MSGID(QUOTA, Q_MSG_ENFORCEMENT_FAILED, Q_MSG_ENOMEM, Q_MSG_PARENT_NULL, + Q_MSG_CROSSED_SOFT_LIMIT, Q_MSG_QUOTA_ENFORCER_RPC_INIT_FAILED, + Q_MSG_REMOTE_OPERATION_FAILED, Q_MSG_FAILED_TO_SEND_FOP, + Q_MSG_INVALID_VOLFILE, Q_MSG_INODE_PARENT_NOT_FOUND, + Q_MSG_XDR_DECODE_ERROR, Q_MSG_DICT_UNSERIALIZE_FAIL, + Q_MSG_DICT_SERIALIZE_FAIL, Q_MSG_RPCSVC_INIT_FAILED, + Q_MSG_RPCSVC_LISTENER_CREATION_FAILED, Q_MSG_RPCSVC_REGISTER_FAILED, + Q_MSG_XDR_DECODING_FAILED, Q_MSG_RPCCLNT_REGISTER_NOTIFY_FAILED, + Q_MSG_ANCESTRY_BUILD_FAILED, Q_MSG_SIZE_KEY_MISSING, + Q_MSG_INODE_CTX_GET_FAILED, Q_MSG_INODE_CTX_SET_FAILED, + Q_MSG_LOOKUP_FAILED, Q_MSG_RPC_SUBMIT_FAILED, + Q_MSG_ENFORCEMENT_SKIPPED, Q_MSG_INTERNAL_FOP_KEY_MISSING); #endif /* !_QUOTA_MESSAGES_H_ */ - diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h index 9fe0e3e0a51..7ced27a6188 100644 --- a/xlators/features/quota/src/quota.h +++ b/xlators/features/quota/src/quota.h @@ -31,246 +31,235 @@ #include "quota-common-utils.h" #include "quota-messages.h" -#define DIRTY "dirty" -#define SIZE "size" -#define CONTRIBUTION "contri" -#define VAL_LENGTH 8 -#define READDIR_BUF 4096 +#define DIRTY "dirty" +#define SIZE "size" +#define CONTRIBUTION "contri" +#define VAL_LENGTH 8 +#define READDIR_BUF 4096 #ifndef UUID_CANONICAL_FORM_LEN #define UUID_CANONICAL_FORM_LEN 36 #endif -#define WIND_IF_QUOTAOFF(is_quota_on, label) \ - if (!is_quota_on) \ - goto label; - -#define QUOTA_WIND_FOR_INTERNAL_FOP(xdata, label) \ - do { \ - if (xdata && dict_get (xdata, GLUSTERFS_INTERNAL_FOP_KEY)) \ - goto label; \ - } while (0) - -#define DID_REACH_LIMIT(lim, prev_size, cur_size) \ - ((cur_size) >= (lim) && (prev_size) < (lim)) - -#define QUOTA_SAFE_INCREMENT(lock, var) \ - do { \ - LOCK (lock); \ - var ++; \ - UNLOCK (lock); \ - } while (0) - -#define QUOTA_SAFE_DECREMENT(lock, var) \ - do { \ - LOCK (lock); \ - var --; \ - UNLOCK (lock); \ - } while (0) - -#define QUOTA_ALLOC_OR_GOTO(var, type, label) \ - do { \ - var = GF_CALLOC (sizeof (type), 1, \ - gf_quota_mt_##type); \ - if (!var) { \ - gf_msg ("", GF_LOG_ERROR, \ - ENOMEM, Q_MSG_ENOMEM, \ - "out of memory"); \ - ret = -1; \ - goto label; \ - } \ - } while (0); - -#define QUOTA_STACK_WIND_TAIL(frame, params...) \ - do { \ - quota_local_t *_local = NULL; \ - \ - if (frame) { \ - _local = frame->local; \ - frame->local = NULL; \ - } \ - \ - STACK_WIND_TAIL (frame, params); \ - \ - if (_local) \ - quota_local_cleanup (_local); \ - } while (0) - -#define QUOTA_STACK_UNWIND(fop, frame, params...) \ - do { \ - quota_local_t *_local = NULL; \ - if (frame) { \ - _local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - quota_local_cleanup (_local); \ - } while (0) - -#define QUOTA_FREE_CONTRIBUTION_NODE(_contribution) \ - do { \ - list_del (&_contribution->contri_list); \ - GF_FREE (_contribution); \ - } while (0) - -#define GET_CONTRI_KEY(var, _vol_name, _gfid, _ret) \ - do { \ - char _gfid_unparsed[40]; \ - if (_gfid != NULL) { \ - gf_uuid_unparse (_gfid, _gfid_unparsed);\ - _ret = gf_asprintf (var, QUOTA_XATTR_PREFIX \ - "%s.%s." CONTRIBUTION, \ - _vol_name, _gfid_unparsed); \ - } else { \ - _ret = gf_asprintf (var, QUOTA_XATTR_PREFIX \ - "%s.." CONTRIBUTION, \ - _vol_name); \ - } \ - } while (0) - - -#define GET_CONTRI_KEY_OR_GOTO(var, _vol_name, _gfid, label) \ - do { \ - GET_CONTRI_KEY(var, _vol_name, _gfid, ret); \ - if (ret == -1) \ - goto label; \ - } while (0) - -#define GET_DIRTY_KEY_OR_GOTO(var, _vol_name, label) \ - do { \ - ret = gf_asprintf (var, QUOTA_XATTR_PREFIX \ - "%s." DIRTY, _vol_name); \ - if (ret == -1) \ - goto label; \ - } while (0) - -#define QUOTA_REG_OR_LNK_FILE(ia_type) \ - (IA_ISREG (ia_type) || IA_ISLNK (ia_type)) - - +#define WIND_IF_QUOTAOFF(is_quota_on, label) \ + if (!is_quota_on) \ + goto label; + +#define QUOTA_WIND_FOR_INTERNAL_FOP(xdata, label) \ + do { \ + if (xdata && dict_get(xdata, GLUSTERFS_INTERNAL_FOP_KEY)) \ + goto label; \ + } while (0) + +#define DID_REACH_LIMIT(lim, prev_size, cur_size) \ + ((cur_size) >= (lim) && (prev_size) < (lim)) + +#define QUOTA_SAFE_INCREMENT(lock, var) \ + do { \ + LOCK(lock); \ + var++; \ + UNLOCK(lock); \ + } while (0) + +#define QUOTA_SAFE_DECREMENT(lock, var) \ + do { \ + LOCK(lock); \ + var--; \ + UNLOCK(lock); \ + } while (0) + +#define QUOTA_ALLOC_OR_GOTO(var, type, label) \ + do { \ + var = GF_CALLOC(sizeof(type), 1, gf_quota_mt_##type); \ + if (!var) { \ + gf_msg("", GF_LOG_ERROR, ENOMEM, Q_MSG_ENOMEM, "out of memory"); \ + ret = -1; \ + goto label; \ + } \ + } while (0); + +#define QUOTA_STACK_WIND_TAIL(frame, params...) \ + do { \ + quota_local_t *_local = NULL; \ + \ + if (frame) { \ + _local = frame->local; \ + frame->local = NULL; \ + } \ + \ + STACK_WIND_TAIL(frame, params); \ + \ + if (_local) \ + quota_local_cleanup(_local); \ + } while (0) + +#define QUOTA_STACK_UNWIND(fop, frame, params...) \ + do { \ + quota_local_t *_local = NULL; \ + if (frame) { \ + _local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + quota_local_cleanup(_local); \ + } while (0) + +#define QUOTA_FREE_CONTRIBUTION_NODE(_contribution) \ + do { \ + list_del(&_contribution->contri_list); \ + GF_FREE(_contribution); \ + } while (0) + +#define GET_CONTRI_KEY(var, _vol_name, _gfid, _ret) \ + do { \ + char _gfid_unparsed[40]; \ + if (_gfid != NULL) { \ + gf_uuid_unparse(_gfid, _gfid_unparsed); \ + _ret = gf_asprintf(var, QUOTA_XATTR_PREFIX "%s.%s." CONTRIBUTION, \ + _vol_name, _gfid_unparsed); \ + } else { \ + _ret = gf_asprintf(var, QUOTA_XATTR_PREFIX "%s.." CONTRIBUTION, \ + _vol_name); \ + } \ + } while (0) + +#define GET_CONTRI_KEY_OR_GOTO(var, _vol_name, _gfid, label) \ + do { \ + GET_CONTRI_KEY(var, _vol_name, _gfid, ret); \ + if (ret == -1) \ + goto label; \ + } while (0) + +#define GET_DIRTY_KEY_OR_GOTO(var, _vol_name, label) \ + do { \ + ret = gf_asprintf(var, QUOTA_XATTR_PREFIX "%s." DIRTY, _vol_name); \ + if (ret == -1) \ + goto label; \ + } while (0) + +#define QUOTA_REG_OR_LNK_FILE(ia_type) (IA_ISREG(ia_type) || IA_ISLNK(ia_type)) struct quota_dentry { - char *name; - uuid_t par; - struct list_head next; + char *name; + uuid_t par; + struct list_head next; }; typedef struct quota_dentry quota_dentry_t; struct quota_inode_ctx { - int64_t size; - int64_t hard_lim; - int64_t soft_lim; - int64_t file_count; - int64_t dir_count; - int64_t object_hard_lim; - int64_t object_soft_lim; - struct iatt buf; - struct list_head parents; - struct timeval tv; - struct timeval prev_log; - gf_boolean_t ancestry_built; - gf_lock_t lock; + int64_t size; + int64_t hard_lim; + int64_t soft_lim; + int64_t file_count; + int64_t dir_count; + int64_t object_hard_lim; + int64_t object_soft_lim; + struct iatt buf; + struct list_head parents; + struct timeval tv; + struct timeval prev_log; + gf_boolean_t ancestry_built; + gf_lock_t lock; }; typedef struct quota_inode_ctx quota_inode_ctx_t; -typedef void -(*quota_ancestry_built_t) (struct list_head *parents, inode_t *inode, - int32_t op_ret, int32_t op_errno, void *data); +typedef void (*quota_ancestry_built_t)(struct list_head *parents, + inode_t *inode, int32_t op_ret, + int32_t op_errno, void *data); -typedef void -(*quota_fop_continue_t) (call_frame_t *frame); +typedef void (*quota_fop_continue_t)(call_frame_t *frame); struct quota_local { - gf_lock_t lock; - uint32_t link_count; - loc_t loc; - loc_t oldloc; - loc_t newloc; - loc_t validate_loc; - int64_t delta; - int8_t object_delta; - int32_t op_ret; - int32_t op_errno; - int64_t size; - char just_validated; - fop_lookup_cbk_t validate_cbk; - quota_fop_continue_t fop_continue_cbk; - inode_t *inode; - uuid_t common_ancestor; /* Used by quota_rename */ - call_stub_t *stub; - struct iobref *iobref; - quota_limits_t limit; - quota_limits_t object_limit; - int64_t space_available; - quota_ancestry_built_t ancestry_cbk; - void *ancestry_data; - dict_t *xdata; - dict_t *validate_xdata; - int32_t quotad_conn_retry; - xlator_t *this; - call_frame_t *par_frame; + gf_lock_t lock; + uint32_t link_count; + loc_t loc; + loc_t oldloc; + loc_t newloc; + loc_t validate_loc; + int64_t delta; + int8_t object_delta; + int32_t op_ret; + int32_t op_errno; + int64_t size; + char just_validated; + fop_lookup_cbk_t validate_cbk; + quota_fop_continue_t fop_continue_cbk; + inode_t *inode; + uuid_t common_ancestor; /* Used by quota_rename */ + call_stub_t *stub; + struct iobref *iobref; + quota_limits_t limit; + quota_limits_t object_limit; + int64_t space_available; + quota_ancestry_built_t ancestry_cbk; + void *ancestry_data; + dict_t *xdata; + dict_t *validate_xdata; + int32_t quotad_conn_retry; + xlator_t *this; + call_frame_t *par_frame; }; -typedef struct quota_local quota_local_t; +typedef struct quota_local quota_local_t; struct quota_priv { - uint32_t soft_timeout; - uint32_t hard_timeout; - uint32_t log_timeout; - double default_soft_lim; - gf_boolean_t is_quota_on; - gf_boolean_t consider_statfs; - gf_lock_t lock; - rpc_clnt_prog_t *quota_enforcer; - struct rpcsvc_program *quotad_aggregator; - struct rpc_clnt *rpc_clnt; - rpcsvc_t *rpcsvc; - inode_table_t *itable; - char *volume_uuid; - uint64_t validation_count; - int32_t quotad_conn_status; + uint32_t soft_timeout; + uint32_t hard_timeout; + uint32_t log_timeout; + double default_soft_lim; + gf_boolean_t is_quota_on; + gf_boolean_t consider_statfs; + gf_lock_t lock; + rpc_clnt_prog_t *quota_enforcer; + struct rpcsvc_program *quotad_aggregator; + struct rpc_clnt *rpc_clnt; + rpcsvc_t *rpcsvc; + inode_table_t *itable; + char *volume_uuid; + uint64_t validation_count; + int32_t quotad_conn_status; }; -typedef struct quota_priv quota_priv_t; +typedef struct quota_priv quota_priv_t; int -quota_enforcer_lookup (call_frame_t *frame, xlator_t *this, dict_t *xdata, - fop_lookup_cbk_t cbk); +quota_enforcer_lookup(call_frame_t *frame, xlator_t *this, dict_t *xdata, + fop_lookup_cbk_t cbk); void -_quota_enforcer_lookup (void *data); +_quota_enforcer_lookup(void *data); struct rpc_clnt * -quota_enforcer_init (xlator_t *this, dict_t *options); +quota_enforcer_init(xlator_t *this, dict_t *options); void -quota_log_usage (xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode, - int64_t delta); +quota_log_usage(xlator_t *this, quota_inode_ctx_t *ctx, inode_t *inode, + int64_t delta); int -quota_build_ancestry (inode_t *inode, quota_ancestry_built_t ancestry_cbk, - void *data); +quota_build_ancestry(inode_t *inode, quota_ancestry_built_t ancestry_cbk, + void *data); void -quota_get_limit_dir (call_frame_t *frame, inode_t *cur_inode, xlator_t *this); +quota_get_limit_dir(call_frame_t *frame, inode_t *cur_inode, xlator_t *this); int32_t -quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this); +quota_check_limit(call_frame_t *frame, inode_t *inode, xlator_t *this); inode_t * -do_quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this, - quota_dentry_t *dentry, gf_boolean_t force); +do_quota_check_limit(call_frame_t *frame, inode_t *inode, xlator_t *this, + quota_dentry_t *dentry, gf_boolean_t force); int -quota_fill_inodectx (xlator_t *this, inode_t *inode, dict_t *dict, - loc_t *loc, struct iatt *buf, int32_t *op_errno); +quota_fill_inodectx(xlator_t *this, inode_t *inode, dict_t *dict, loc_t *loc, + struct iatt *buf, int32_t *op_errno); int32_t -quota_check_size_limit (call_frame_t *frame, quota_inode_ctx_t *ctx, - quota_priv_t *priv, inode_t *_inode, xlator_t *this, - int32_t *op_errno, int just_validated, int64_t delta, - quota_local_t *local, gf_boolean_t *skip_check); +quota_check_size_limit(call_frame_t *frame, quota_inode_ctx_t *ctx, + quota_priv_t *priv, inode_t *_inode, xlator_t *this, + int32_t *op_errno, int just_validated, int64_t delta, + quota_local_t *local, gf_boolean_t *skip_check); int32_t -quota_check_object_limit (call_frame_t *frame, quota_inode_ctx_t *ctx, - quota_priv_t *priv, inode_t *_inode, xlator_t *this, - int32_t *op_errno, int just_validated, - quota_local_t *local, gf_boolean_t *skip_check); +quota_check_object_limit(call_frame_t *frame, quota_inode_ctx_t *ctx, + quota_priv_t *priv, inode_t *_inode, xlator_t *this, + int32_t *op_errno, int just_validated, + quota_local_t *local, gf_boolean_t *skip_check); #endif diff --git a/xlators/features/quota/src/quotad-aggregator.h b/xlators/features/quota/src/quotad-aggregator.h index 5ddea5b3c46..02a0094102f 100644 --- a/xlators/features/quota/src/quotad-aggregator.h +++ b/xlators/features/quota/src/quotad-aggregator.h @@ -17,21 +17,20 @@ #include "inode.h" typedef struct { - void *pool; - xlator_t *this; - xlator_t *active_subvol; - inode_table_t *itable; - loc_t loc; - dict_t *xdata; + void *pool; + xlator_t *this; + xlator_t *active_subvol; + inode_table_t *itable; + loc_t loc; + dict_t *xdata; } quotad_aggregator_state_t; -typedef int (*quotad_aggregator_lookup_cbk_t) (xlator_t *this, - call_frame_t *frame, - void *rsp); +typedef int (*quotad_aggregator_lookup_cbk_t)(xlator_t *this, + call_frame_t *frame, void *rsp); int -qd_nameless_lookup (xlator_t *this, call_frame_t *frame, gfs3_lookup_req *req, - dict_t *xdata, quotad_aggregator_lookup_cbk_t lookup_cbk); +qd_nameless_lookup(xlator_t *this, call_frame_t *frame, gfs3_lookup_req *req, + dict_t *xdata, quotad_aggregator_lookup_cbk_t lookup_cbk); int -quotad_aggregator_init (xlator_t *this); +quotad_aggregator_init(xlator_t *this); #endif diff --git a/xlators/features/quota/src/quotad-helpers.h b/xlators/features/quota/src/quotad-helpers.h index a10fb7fa82a..bcb39fe845e 100644 --- a/xlators/features/quota/src/quotad-helpers.h +++ b/xlators/features/quota/src/quotad-helpers.h @@ -16,9 +16,9 @@ #include "quotad-aggregator.h" void -quotad_aggregator_free_state (quotad_aggregator_state_t *state); +quotad_aggregator_free_state(quotad_aggregator_state_t *state); call_frame_t * -quotad_aggregator_get_frame_from_req (rpcsvc_request_t *req); +quotad_aggregator_get_frame_from_req(rpcsvc_request_t *req); #endif diff --git a/xlators/features/read-only/src/read-only-common.h b/xlators/features/read-only/src/read-only-common.h index ec629bd5660..32719da28f1 100644 --- a/xlators/features/read-only/src/read-only-common.h +++ b/xlators/features/read-only/src/read-only-common.h @@ -11,107 +11,111 @@ #include "defaults.h" gf_boolean_t -is_readonly_or_worm_enabled (call_frame_t *frame, xlator_t *this); +is_readonly_or_worm_enabled(call_frame_t *frame, xlator_t *this); int32_t -ro_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, - gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata); +ro_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata); int32_t -ro_fxattrop (call_frame_t *frame, xlator_t *this, - fd_t *fd, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata); +ro_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata); int32_t -ro_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, - loc_t *loc, const char *basename, entrylk_cmd cmd, - entrylk_type type, dict_t *xdata); +ro_entrylk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, + const char *basename, entrylk_cmd cmd, entrylk_type type, + dict_t *xdata); int32_t -ro_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, - fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type - type, dict_t *xdata); +ro_fentrylk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, + const char *basename, entrylk_cmd cmd, entrylk_type type, + dict_t *xdata); int32_t -ro_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, - loc_t *loc, int32_t cmd, struct gf_flock *lock, dict_t *xdata); +ro_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, + int32_t cmd, struct gf_flock *lock, dict_t *xdata); int32_t -ro_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, - fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata); +ro_finodelk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, + int32_t cmd, struct gf_flock *lock, dict_t *xdata); int32_t -ro_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int cmd, - struct gf_flock *flock, dict_t *xdata); +ro_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int cmd, + struct gf_flock *flock, dict_t *xdata); int32_t -ro_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - struct iatt *stbuf, int32_t valid, dict_t *xdata); +ro_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf, + int32_t valid, dict_t *xdata); int32_t -ro_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - struct iatt *stbuf, int32_t valid, dict_t *xdata); - +ro_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf, + int32_t valid, dict_t *xdata); int32_t -ro_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, dict_t *xdata); +ro_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, + dict_t *xdata); int32_t -ro_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, dict_t *xdata); +ro_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + dict_t *xdata); int -ro_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, - dev_t rdev, mode_t umask, dict_t *xdata); +ro_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + dev_t rdev, mode_t umask, dict_t *xdata); int -ro_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, - mode_t umask, dict_t *xdata); +ro_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, + mode_t umask, dict_t *xdata); int32_t -ro_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, - dict_t *xdata); - -int -ro_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, +ro_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, dict_t *xdata); +int +ro_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata); int -ro_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, - loc_t *loc, mode_t umask, dict_t *xdata); +ro_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, + loc_t *loc, mode_t umask, dict_t *xdata); int32_t -ro_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata); +ro_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); int32_t -ro_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata); +ro_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, + dict_t *xdata); int32_t -ro_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); +ro_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 -ro_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, - fd_t *fd, dict_t *xdata); +ro_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, + fd_t *fd, dict_t *xdata); int32_t -ro_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, - int32_t flags, dict_t *xdata); +ro_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, + int32_t flags, dict_t *xdata); int32_t -ro_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, dict_t *xdata); +ro_fsyncdir(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, + dict_t *xdata); int32_t -ro_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, - int32_t count, off_t off, uint32_t flags, struct iobref *iobref, dict_t *xdata); +ro_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, + int32_t count, off_t off, uint32_t flags, struct iobref *iobref, + dict_t *xdata); int32_t -ro_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, - int32_t flags, dict_t *xdata); +ro_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, + int32_t flags, dict_t *xdata); int32_t -ro_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - const char *name, dict_t *xdata); +ro_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, + const char *name, dict_t *xdata); int32_t -ro_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, - off_t offset, size_t len, dict_t *xdata); +ro_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata); diff --git a/xlators/features/read-only/src/read-only-mem-types.h b/xlators/features/read-only/src/read-only-mem-types.h index 940700a017d..4baaeb41216 100644 --- a/xlators/features/read-only/src/read-only-mem-types.h +++ b/xlators/features/read-only/src/read-only-mem-types.h @@ -14,7 +14,7 @@ #include "mem-types.h" enum gf_read_only_mem_types_ { - gf_read_only_mt_priv_t = gf_common_mt_end + 1, - gf_read_only_mt_end + gf_read_only_mt_priv_t = gf_common_mt_end + 1, + gf_read_only_mt_end }; #endif diff --git a/xlators/features/read-only/src/read-only.h b/xlators/features/read-only/src/read-only.h index aae625f5eaf..d74053a2a8f 100644 --- a/xlators/features/read-only/src/read-only.h +++ b/xlators/features/read-only/src/read-only.h @@ -14,25 +14,23 @@ #include "read-only-mem-types.h" #include "xlator.h" - typedef struct { - uint8_t worm : 1; - uint8_t retain : 1; - uint8_t legal_hold :1; - uint8_t ret_mode : 1; - uint64_t ret_period; - uint64_t auto_commit_period; + uint8_t worm : 1; + uint8_t retain : 1; + uint8_t legal_hold : 1; + uint8_t ret_mode : 1; + uint64_t ret_period; + uint64_t auto_commit_period; } worm_reten_state_t; - typedef struct { - gf_boolean_t readonly_or_worm_enabled; - gf_boolean_t worm_file; - gf_boolean_t worm_files_deletable; - uint64_t reten_period; - uint64_t com_period; - char *reten_mode; - time_t start_time; + gf_boolean_t readonly_or_worm_enabled; + gf_boolean_t worm_file; + gf_boolean_t worm_files_deletable; + uint64_t reten_period; + uint64_t com_period; + char *reten_mode; + time_t start_time; } read_only_priv_t; #endif diff --git a/xlators/features/read-only/src/worm-helper.h b/xlators/features/read-only/src/worm-helper.h index 745df8294c3..b42f8d2b40c 100644 --- a/xlators/features/read-only/src/worm-helper.h +++ b/xlators/features/read-only/src/worm-helper.h @@ -8,30 +8,37 @@ cases as published by the Free Software Foundation. */ -gf_boolean_t gf_worm_write_disabled (struct iatt *stbuf); +gf_boolean_t +gf_worm_write_disabled(struct iatt *stbuf); -int32_t worm_init_state (xlator_t *this, gf_boolean_t fop_with_fd, - void *file_ptr); +int32_t +worm_init_state(xlator_t *this, gf_boolean_t fop_with_fd, void *file_ptr); -int32_t worm_set_state (xlator_t *this, gf_boolean_t fop_with_fd, - void *file_ptr, worm_reten_state_t *retention_state, - struct iatt *stbuf); +int32_t +worm_set_state(xlator_t *this, gf_boolean_t fop_with_fd, void *file_ptr, + worm_reten_state_t *retention_state, struct iatt *stbuf); -int32_t worm_get_state (xlator_t *this, gf_boolean_t fop_with_fd, - void *file_ptr, worm_reten_state_t *reten_state); +int32_t +worm_get_state(xlator_t *this, gf_boolean_t fop_with_fd, void *file_ptr, + worm_reten_state_t *reten_state); -void gf_worm_state_lookup (xlator_t *this, gf_boolean_t fop_with_fd, - void *file_ptr, worm_reten_state_t *reten_state, - struct iatt *stbuf); +void +gf_worm_state_lookup(xlator_t *this, gf_boolean_t fop_with_fd, void *file_ptr, + worm_reten_state_t *reten_state, struct iatt *stbuf); -void gf_worm_serialize_state (worm_reten_state_t *reten_state, char *val); +void +gf_worm_serialize_state(worm_reten_state_t *reten_state, char *val); -void gf_worm_deserialize_state (char *val, worm_reten_state_t *reten_state); +void +gf_worm_deserialize_state(char *val, worm_reten_state_t *reten_state); -int32_t gf_worm_set_xattr (xlator_t *this, worm_reten_state_t *reten_state, - gf_boolean_t fop_with_fd, void *file_ptr); +int32_t +gf_worm_set_xattr(xlator_t *this, worm_reten_state_t *reten_state, + gf_boolean_t fop_with_fd, void *file_ptr); -int gf_worm_state_transition (xlator_t *this, gf_boolean_t fop_with_fd, - void *file_ptr, glusterfs_fop_t op); +int +gf_worm_state_transition(xlator_t *this, gf_boolean_t fop_with_fd, + void *file_ptr, glusterfs_fop_t op); -int32_t is_wormfile (xlator_t *this, gf_boolean_t fop_with_fd, void *file_ptr); +int32_t +is_wormfile(xlator_t *this, gf_boolean_t fop_with_fd, void *file_ptr); diff --git a/xlators/features/sdfs/src/sdfs-messages.h b/xlators/features/sdfs/src/sdfs-messages.h index 6c7a9d90667..cf866c8512a 100644 --- a/xlators/features/sdfs/src/sdfs-messages.h +++ b/xlators/features/sdfs/src/sdfs-messages.h @@ -39,16 +39,14 @@ * holes. */ -#define GLFS_SDFS_BASE GLFS_MSGID_COMP_SDFS -#define GLFS_SDFS_NUM_MESSAGES 2 -#define GLFS_MSGID_END (GLFS_SDFS_BASE + \ - GLFS_SDFS_NUM_MESSAGES + 1) +#define GLFS_SDFS_BASE GLFS_MSGID_COMP_SDFS +#define GLFS_SDFS_NUM_MESSAGES 2 +#define GLFS_MSGID_END (GLFS_SDFS_BASE + GLFS_SDFS_NUM_MESSAGES + 1) /* Messaged with message IDs */ -#define glfs_msg_start_x GLFS_DFS_BASE, "Invalid: Start of messages" +#define glfs_msg_start_x GLFS_DFS_BASE, "Invalid: Start of messages" /*------------*/ - -#define SDFS_MSG_ENTRYLK_ERROR (GLFS_SDFS_BASE + 1) +#define SDFS_MSG_ENTRYLK_ERROR (GLFS_SDFS_BASE + 1) /*! * @messageid * @diagnosis @@ -56,7 +54,7 @@ * */ -#define SDFS_MSG_MKDIR_ERROR (GLFS_SDFS_BASE + 2) +#define SDFS_MSG_MKDIR_ERROR (GLFS_SDFS_BASE + 2) /*! * @messageid * @diagnosis diff --git a/xlators/features/sdfs/src/sdfs.h b/xlators/features/sdfs/src/sdfs.h index d28257eda5e..986d7c2731c 100644 --- a/xlators/features/sdfs/src/sdfs.h +++ b/xlators/features/sdfs/src/sdfs.h @@ -13,37 +13,37 @@ #include "sdfs-messages.h" #include "atomic.h" -#define SDFS_LOCK_COUNT_MAX 2 +#define SDFS_LOCK_COUNT_MAX 2 -typedef struct{ - loc_t parent_loc; - char *basename; - int locked[SDFS_LOCK_COUNT_MAX]; +typedef struct { + loc_t parent_loc; + char *basename; + int locked[SDFS_LOCK_COUNT_MAX]; } sdfs_entry_lock_t; typedef struct { - sdfs_entry_lock_t entrylk[SDFS_LOCK_COUNT_MAX]; - int lock_count; + sdfs_entry_lock_t entrylk[SDFS_LOCK_COUNT_MAX]; + int lock_count; } sdfs_lock_t; struct sdfs_local { - call_frame_t *main_frame; - loc_t loc; - loc_t parent_loc; - call_stub_t *stub; - sdfs_lock_t *lock; - int op_ret; - int op_errno; - gf_atomic_t call_cnt; + call_frame_t *main_frame; + loc_t loc; + loc_t parent_loc; + call_stub_t *stub; + sdfs_lock_t *lock; + int op_ret; + int op_errno; + gf_atomic_t call_cnt; }; typedef struct sdfs_local sdfs_local_t; -#define SDFS_STACK_DESTROY(frame) do { \ - sdfs_local_t *__local = NULL; \ - __local = frame->local; \ - frame->local = NULL; \ - gf_client_unref (frame->root->client); \ - STACK_DESTROY (frame->root); \ - sdfs_local_cleanup (__local); \ - } while (0) - +#define SDFS_STACK_DESTROY(frame) \ + do { \ + sdfs_local_t *__local = NULL; \ + __local = frame->local; \ + frame->local = NULL; \ + gf_client_unref(frame->root->client); \ + STACK_DESTROY(frame->root); \ + sdfs_local_cleanup(__local); \ + } while (0) diff --git a/xlators/features/selinux/src/selinux-mem-types.h b/xlators/features/selinux/src/selinux-mem-types.h index f9f356dd39a..a8c544fba52 100644 --- a/xlators/features/selinux/src/selinux-mem-types.h +++ b/xlators/features/selinux/src/selinux-mem-types.h @@ -13,8 +13,7 @@ #include "mem-types.h" enum gf_selinux_mem_types_ { - gf_selinux_mt_selinux_priv_t = gf_common_mt_end + 1, - gf_selinux_mt_end + gf_selinux_mt_selinux_priv_t = gf_common_mt_end + 1, + gf_selinux_mt_end }; #endif - diff --git a/xlators/features/selinux/src/selinux-messages.h b/xlators/features/selinux/src/selinux-messages.h index 3a1663433ab..1f5739d8dc7 100644 --- a/xlators/features/selinux/src/selinux-messages.h +++ b/xlators/features/selinux/src/selinux-messages.h @@ -23,13 +23,8 @@ * glfs-message-id.h. */ -GLFS_MSGID(SL, - SL_MSG_INVALID_VOLFILE, - SL_MSG_ENOMEM, - SL_MSG_MEM_ACCT_INIT_FAILED, - SL_MSG_SELINUX_GLUSTER_XATTR_MISSING, - SL_MSG_SELINUX_XATTR_MISSING -); +GLFS_MSGID(SL, SL_MSG_INVALID_VOLFILE, SL_MSG_ENOMEM, + SL_MSG_MEM_ACCT_INIT_FAILED, SL_MSG_SELINUX_GLUSTER_XATTR_MISSING, + SL_MSG_SELINUX_XATTR_MISSING); #endif /*_SELINUX_MESSAGES_H */ - diff --git a/xlators/features/selinux/src/selinux.h b/xlators/features/selinux/src/selinux.h index 2ff57b5080a..787bff348f0 100644 --- a/xlators/features/selinux/src/selinux.h +++ b/xlators/features/selinux/src/selinux.h @@ -16,7 +16,7 @@ #define SELINUX_GLUSTER_XATTR "trusted.glusterfs.selinux" struct selinux_priv { - gf_boolean_t selinux_enabled; + gf_boolean_t selinux_enabled; }; typedef struct selinux_priv selinux_priv_t; diff --git a/xlators/features/shard/src/shard-mem-types.h b/xlators/features/shard/src/shard-mem-types.h index fea66aa7dcb..39a57ba6fd0 100644 --- a/xlators/features/shard/src/shard-mem-types.h +++ b/xlators/features/shard/src/shard-mem-types.h @@ -13,12 +13,12 @@ #include "mem-types.h" enum gf_shard_mem_types_ { - gf_shard_mt_priv_t = gf_common_mt_end + 1, - gf_shard_mt_inode_list, - gf_shard_mt_inode_ctx_t, - gf_shard_mt_iovec, - gf_shard_mt_int64_t, - gf_shard_mt_uint64_t, - gf_shard_mt_end + gf_shard_mt_priv_t = gf_common_mt_end + 1, + gf_shard_mt_inode_list, + gf_shard_mt_inode_ctx_t, + gf_shard_mt_iovec, + gf_shard_mt_int64_t, + gf_shard_mt_uint64_t, + gf_shard_mt_end }; #endif diff --git a/xlators/features/shard/src/shard-messages.h b/xlators/features/shard/src/shard-messages.h index 1f0378b20df..89a96709219 100644 --- a/xlators/features/shard/src/shard-messages.h +++ b/xlators/features/shard/src/shard-messages.h @@ -23,29 +23,17 @@ * glfs-message-id.h. */ -GLFS_MSGID(SHARD, - SHARD_MSG_BASE_FILE_LOOKUP_FAILED, - SHARD_MSG_DICT_OP_FAILED, - SHARD_MSG_DOT_SHARD_NODIR, - SHARD_MSG_FD_CTX_SET_FAILED, - SHARD_MSG_INODE_CTX_GET_FAILED, - SHARD_MSG_INODE_CTX_SET_FAILED, - SHARD_MSG_INODE_PATH_FAILED, - SHARD_MSG_INTERNAL_XATTR_MISSING, - SHARD_MSG_INVALID_VOLFILE, - SHARD_MSG_LOOKUP_SHARD_FAILED, - SHARD_MSG_MEM_ACCT_INIT_FAILED, - SHARD_MSG_NULL_THIS, - SHARD_MSG_SIZE_SET_FAILED, - SHARD_MSG_STAT_FAILED, - SHARD_MSG_TRUNCATE_LAST_SHARD_FAILED, - SHARD_MSG_UPDATE_FILE_SIZE_FAILED, - SHARD_MSG_FOP_NOT_SUPPORTED, - SHARD_MSG_INVALID_FOP, - SHARD_MSG_MEMALLOC_FAILED, - SHARD_MSG_FOP_FAILED, - SHARD_MSG_SHARDS_DELETION_FAILED, - SHARD_MSG_SHARD_DELETION_COMPLETED -); +GLFS_MSGID(SHARD, SHARD_MSG_BASE_FILE_LOOKUP_FAILED, SHARD_MSG_DICT_OP_FAILED, + SHARD_MSG_DOT_SHARD_NODIR, SHARD_MSG_FD_CTX_SET_FAILED, + SHARD_MSG_INODE_CTX_GET_FAILED, SHARD_MSG_INODE_CTX_SET_FAILED, + SHARD_MSG_INODE_PATH_FAILED, SHARD_MSG_INTERNAL_XATTR_MISSING, + SHARD_MSG_INVALID_VOLFILE, SHARD_MSG_LOOKUP_SHARD_FAILED, + SHARD_MSG_MEM_ACCT_INIT_FAILED, SHARD_MSG_NULL_THIS, + SHARD_MSG_SIZE_SET_FAILED, SHARD_MSG_STAT_FAILED, + SHARD_MSG_TRUNCATE_LAST_SHARD_FAILED, + SHARD_MSG_UPDATE_FILE_SIZE_FAILED, SHARD_MSG_FOP_NOT_SUPPORTED, + SHARD_MSG_INVALID_FOP, SHARD_MSG_MEMALLOC_FAILED, + SHARD_MSG_FOP_FAILED, SHARD_MSG_SHARDS_DELETION_FAILED, + SHARD_MSG_SHARD_DELETION_COMPLETED); #endif /* !_SHARD_MESSAGES_H_ */ diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h index 7a263f4c37b..f877591faee 100644 --- a/xlators/features/shard/src/shard.h +++ b/xlators/features/shard/src/shard.h @@ -8,7 +8,6 @@ cases as published by the Free Software Foundation. */ - #ifndef __SHARD_H__ #define __SHARD_H__ @@ -19,324 +18,329 @@ #define GF_SHARD_DIR ".shard" #define GF_SHARD_REMOVE_ME_DIR ".remove_me" -#define SHARD_MIN_BLOCK_SIZE (4 * GF_UNIT_MB) -#define SHARD_MAX_BLOCK_SIZE (4 * GF_UNIT_TB) +#define SHARD_MIN_BLOCK_SIZE (4 * GF_UNIT_MB) +#define SHARD_MAX_BLOCK_SIZE (4 * GF_UNIT_TB) #define SHARD_XATTR_PREFIX "trusted.glusterfs.shard." #define GF_XATTR_SHARD_BLOCK_SIZE "trusted.glusterfs.shard.block-size" /** * Bit masks for the valid flag, which is used while updating ctx -**/ -#define SHARD_MASK_BLOCK_SIZE (1 << 0) -#define SHARD_MASK_PROT (1 << 1) -#define SHARD_MASK_NLINK (1 << 2) -#define SHARD_MASK_UID (1 << 3) -#define SHARD_MASK_GID (1 << 4) -#define SHARD_MASK_SIZE (1 << 6) -#define SHARD_MASK_BLOCKS (1 << 7) -#define SHARD_MASK_TIMES (1 << 8) -#define SHARD_MASK_OTHERS (1 << 9) -#define SHARD_MASK_REFRESH_RESET (1 << 10) - -#define SHARD_INODE_WRITE_MASK (SHARD_MASK_SIZE | SHARD_MASK_BLOCKS \ - | SHARD_MASK_TIMES) - -#define SHARD_LOOKUP_MASK (SHARD_MASK_PROT | SHARD_MASK_NLINK | SHARD_MASK_UID \ - | SHARD_MASK_GID | SHARD_MASK_TIMES \ - | SHARD_MASK_OTHERS) - -#define SHARD_ALL_MASK (SHARD_MASK_BLOCK_SIZE | SHARD_MASK_PROT \ - | SHARD_MASK_NLINK | SHARD_MASK_UID | SHARD_MASK_GID \ - | SHARD_MASK_SIZE | SHARD_MASK_BLOCKS \ - | SHARD_MASK_TIMES | SHARD_MASK_OTHERS) - + **/ +#define SHARD_MASK_BLOCK_SIZE (1 << 0) +#define SHARD_MASK_PROT (1 << 1) +#define SHARD_MASK_NLINK (1 << 2) +#define SHARD_MASK_UID (1 << 3) +#define SHARD_MASK_GID (1 << 4) +#define SHARD_MASK_SIZE (1 << 6) +#define SHARD_MASK_BLOCKS (1 << 7) +#define SHARD_MASK_TIMES (1 << 8) +#define SHARD_MASK_OTHERS (1 << 9) +#define SHARD_MASK_REFRESH_RESET (1 << 10) + +#define SHARD_INODE_WRITE_MASK \ + (SHARD_MASK_SIZE | SHARD_MASK_BLOCKS | SHARD_MASK_TIMES) + +#define SHARD_LOOKUP_MASK \ + (SHARD_MASK_PROT | SHARD_MASK_NLINK | SHARD_MASK_UID | SHARD_MASK_GID | \ + SHARD_MASK_TIMES | SHARD_MASK_OTHERS) + +#define SHARD_ALL_MASK \ + (SHARD_MASK_BLOCK_SIZE | SHARD_MASK_PROT | SHARD_MASK_NLINK | \ + SHARD_MASK_UID | SHARD_MASK_GID | SHARD_MASK_SIZE | SHARD_MASK_BLOCKS | \ + SHARD_MASK_TIMES | SHARD_MASK_OTHERS) #define get_lowest_block(off, shard_size) ((off) / (shard_size)) -#define get_highest_block(off, len, shard_size) \ - (((((off)+(len)) == 0)?0:((off)+(len)-1)) / (shard_size)) +#define get_highest_block(off, len, shard_size) \ + (((((off) + (len)) == 0) ? 0 : ((off) + (len)-1)) / (shard_size)) int -shard_unlock_inodelk (call_frame_t *frame, xlator_t *this); +shard_unlock_inodelk(call_frame_t *frame, xlator_t *this); int -shard_unlock_entrylk (call_frame_t *frame, xlator_t *this); - -#define SHARD_ENTRY_FOP_CHECK(loc, op_errno, label) do { \ - if ((loc->name && !strcmp (GF_SHARD_DIR, loc->name)) && \ - (((loc->parent) && \ - __is_root_gfid (loc->parent->gfid)) || \ - __is_root_gfid (loc->pargfid))) { \ - op_errno = EPERM; \ - goto label; \ - } \ - \ - if ((loc->parent && \ - __is_shard_dir (loc->parent->gfid)) || \ - __is_shard_dir (loc->pargfid)) { \ - op_errno = EPERM; \ - goto label; \ - } \ -} while (0) - -#define SHARD_INODE_OP_CHECK(gfid, err, label) do { \ - if (__is_shard_dir(gfid)) { \ - err = EPERM; \ - goto label; \ - } \ -} while (0) - -#define SHARD_STACK_UNWIND(fop, frame, params ...) do { \ - shard_local_t *__local = NULL; \ - if (frame) { \ - __local = frame->local; \ - if (__local && __local->int_inodelk.acquired_lock) \ - shard_unlock_inodelk (frame, frame->this); \ - if (__local && __local->int_entrylk.acquired_lock) \ - shard_unlock_entrylk (frame, frame->this); \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - if (__local) { \ - shard_local_wipe (__local); \ - mem_put (__local); \ - } \ -} while (0) - -#define SHARD_STACK_DESTROY(frame) \ - do { \ - shard_local_t *__local = NULL; \ - __local = frame->local; \ - frame->local = NULL; \ - STACK_DESTROY (frame->root); \ - if (__local) { \ - shard_local_wipe (__local); \ - mem_put (__local); \ - } \ - } while (0); - - -#define SHARD_INODE_CREATE_INIT(this, block_size, xattr_req, loc, size, \ - block_count, label) do { \ - int __ret = -1; \ - int64_t *__size_attr = NULL; \ - uint64_t *__bs = 0; \ - \ - __bs = GF_MALLOC (sizeof (uint64_t), gf_shard_mt_uint64_t); \ - if (!__bs) \ - goto label; \ - *__bs = hton64 (block_size); \ - __ret = dict_set_bin (xattr_req, GF_XATTR_SHARD_BLOCK_SIZE, __bs, \ - sizeof (*__bs)); \ - if (__ret) { \ - gf_msg (this->name, GF_LOG_WARNING, 0, \ - SHARD_MSG_DICT_OP_FAILED, "Failed to set key: %s " \ - "on path %s", GF_XATTR_SHARD_BLOCK_SIZE, (loc)->path);\ - GF_FREE (__bs); \ - goto label; \ - } \ - \ - __ret = shard_set_size_attrs (size, block_count, &__size_attr); \ - if (__ret) \ - goto label; \ - \ - __ret = dict_set_bin (xattr_req, GF_XATTR_SHARD_FILE_SIZE, \ - __size_attr, 8 * 4); \ - if (__ret) { \ - gf_msg (this->name, GF_LOG_WARNING, 0, \ - SHARD_MSG_DICT_OP_FAILED, "Failed to set key: %s " \ - "on path %s", GF_XATTR_SHARD_FILE_SIZE, (loc)->path); \ - GF_FREE (__size_attr); \ - goto label; \ - } \ -} while (0) - - -#define SHARD_MD_READ_FOP_INIT_REQ_DICT(this, dict, gfid, local, label) do { \ - int __ret = -1; \ - \ - __ret = dict_set_uint64 (dict, GF_XATTR_SHARD_FILE_SIZE, 8 * 4); \ - if (__ret) { \ - local->op_ret = -1; \ - local->op_errno = ENOMEM; \ - gf_msg (this->name, GF_LOG_WARNING, 0, \ - SHARD_MSG_DICT_OP_FAILED, "Failed to set dict value:"\ - " key:%s for %s.", GF_XATTR_SHARD_FILE_SIZE, \ - uuid_utoa (gfid)); \ - goto label; \ - } \ -} while (0) - -#define SHARD_SET_ROOT_FS_ID(frame, local) do { \ - if (!local->is_set_fsid) { \ - local->uid = frame->root->uid; \ - local->gid = frame->root->gid; \ - frame->root->uid = 0; \ - frame->root->gid = 0; \ - local->is_set_fsid = _gf_true; \ - } \ -} while (0) - -#define SHARD_UNSET_ROOT_FS_ID(frame, local) do { \ - if (local->is_set_fsid) { \ - frame->root->uid = local->uid; \ - frame->root->gid = local->gid; \ - local->is_set_fsid = _gf_false; \ - } \ -} while (0) - -#define SHARD_TIME_UPDATE(ctx_sec, ctx_nsec, new_sec, new_nsec) do { \ - if (ctx_sec == new_sec) \ - ctx_nsec = new_nsec = max (new_nsec, ctx_nsec); \ - else if (ctx_sec > new_sec) { \ - new_sec = ctx_sec; \ - new_nsec = ctx_nsec; \ - } else { \ - ctx_sec = new_sec; \ - ctx_nsec = new_nsec; \ - } \ - } while (0) +shard_unlock_entrylk(call_frame_t *frame, xlator_t *this); + +#define SHARD_ENTRY_FOP_CHECK(loc, op_errno, label) \ + do { \ + if ((loc->name && !strcmp(GF_SHARD_DIR, loc->name)) && \ + (((loc->parent) && __is_root_gfid(loc->parent->gfid)) || \ + __is_root_gfid(loc->pargfid))) { \ + op_errno = EPERM; \ + goto label; \ + } \ + \ + if ((loc->parent && __is_shard_dir(loc->parent->gfid)) || \ + __is_shard_dir(loc->pargfid)) { \ + op_errno = EPERM; \ + goto label; \ + } \ + } while (0) + +#define SHARD_INODE_OP_CHECK(gfid, err, label) \ + do { \ + if (__is_shard_dir(gfid)) { \ + err = EPERM; \ + goto label; \ + } \ + } while (0) + +#define SHARD_STACK_UNWIND(fop, frame, params...) \ + do { \ + shard_local_t *__local = NULL; \ + if (frame) { \ + __local = frame->local; \ + if (__local && __local->int_inodelk.acquired_lock) \ + shard_unlock_inodelk(frame, frame->this); \ + if (__local && __local->int_entrylk.acquired_lock) \ + shard_unlock_entrylk(frame, frame->this); \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + if (__local) { \ + shard_local_wipe(__local); \ + mem_put(__local); \ + } \ + } while (0) + +#define SHARD_STACK_DESTROY(frame) \ + do { \ + shard_local_t *__local = NULL; \ + __local = frame->local; \ + frame->local = NULL; \ + STACK_DESTROY(frame->root); \ + if (__local) { \ + shard_local_wipe(__local); \ + mem_put(__local); \ + } \ + } while (0); + +#define SHARD_INODE_CREATE_INIT(this, block_size, xattr_req, loc, size, \ + block_count, label) \ + do { \ + int __ret = -1; \ + int64_t *__size_attr = NULL; \ + uint64_t *__bs = 0; \ + \ + __bs = GF_MALLOC(sizeof(uint64_t), gf_shard_mt_uint64_t); \ + if (!__bs) \ + goto label; \ + *__bs = hton64(block_size); \ + __ret = dict_set_bin(xattr_req, GF_XATTR_SHARD_BLOCK_SIZE, __bs, \ + sizeof(*__bs)); \ + if (__ret) { \ + gf_msg(this->name, GF_LOG_WARNING, 0, SHARD_MSG_DICT_OP_FAILED, \ + "Failed to set key: %s " \ + "on path %s", \ + GF_XATTR_SHARD_BLOCK_SIZE, (loc)->path); \ + GF_FREE(__bs); \ + goto label; \ + } \ + \ + __ret = shard_set_size_attrs(size, block_count, &__size_attr); \ + if (__ret) \ + goto label; \ + \ + __ret = dict_set_bin(xattr_req, GF_XATTR_SHARD_FILE_SIZE, __size_attr, \ + 8 * 4); \ + if (__ret) { \ + gf_msg(this->name, GF_LOG_WARNING, 0, SHARD_MSG_DICT_OP_FAILED, \ + "Failed to set key: %s " \ + "on path %s", \ + GF_XATTR_SHARD_FILE_SIZE, (loc)->path); \ + GF_FREE(__size_attr); \ + goto label; \ + } \ + } while (0) + +#define SHARD_MD_READ_FOP_INIT_REQ_DICT(this, dict, gfid, local, label) \ + do { \ + int __ret = -1; \ + \ + __ret = dict_set_uint64(dict, GF_XATTR_SHARD_FILE_SIZE, 8 * 4); \ + if (__ret) { \ + local->op_ret = -1; \ + local->op_errno = ENOMEM; \ + gf_msg(this->name, GF_LOG_WARNING, 0, SHARD_MSG_DICT_OP_FAILED, \ + "Failed to set dict value:" \ + " key:%s for %s.", \ + GF_XATTR_SHARD_FILE_SIZE, uuid_utoa(gfid)); \ + goto label; \ + } \ + } while (0) + +#define SHARD_SET_ROOT_FS_ID(frame, local) \ + do { \ + if (!local->is_set_fsid) { \ + local->uid = frame->root->uid; \ + local->gid = frame->root->gid; \ + frame->root->uid = 0; \ + frame->root->gid = 0; \ + local->is_set_fsid = _gf_true; \ + } \ + } while (0) + +#define SHARD_UNSET_ROOT_FS_ID(frame, local) \ + do { \ + if (local->is_set_fsid) { \ + frame->root->uid = local->uid; \ + frame->root->gid = local->gid; \ + local->is_set_fsid = _gf_false; \ + } \ + } while (0) + +#define SHARD_TIME_UPDATE(ctx_sec, ctx_nsec, new_sec, new_nsec) \ + do { \ + if (ctx_sec == new_sec) \ + ctx_nsec = new_nsec = max(new_nsec, ctx_nsec); \ + else if (ctx_sec > new_sec) { \ + new_sec = ctx_sec; \ + new_nsec = ctx_nsec; \ + } else { \ + ctx_sec = new_sec; \ + ctx_nsec = new_nsec; \ + } \ + } while (0) typedef enum { - SHARD_FIRST_LOOKUP_PENDING = 0, - SHARD_FIRST_LOOKUP_IN_PROGRESS, - SHARD_FIRST_LOOKUP_DONE, + SHARD_FIRST_LOOKUP_PENDING = 0, + SHARD_FIRST_LOOKUP_IN_PROGRESS, + SHARD_FIRST_LOOKUP_DONE, } shard_first_lookup_state_t; /* rm = "remove me" */ typedef struct shard_priv { - uint64_t block_size; - uuid_t dot_shard_gfid; - uuid_t dot_shard_rm_gfid; - inode_t *dot_shard_inode; - inode_t *dot_shard_rm_inode; - gf_lock_t lock; - int inode_count; - struct list_head ilist_head; - uint32_t deletion_rate; - shard_first_lookup_state_t first_lookup; - uint64_t lru_limit; + uint64_t block_size; + uuid_t dot_shard_gfid; + uuid_t dot_shard_rm_gfid; + inode_t *dot_shard_inode; + inode_t *dot_shard_rm_inode; + gf_lock_t lock; + int inode_count; + struct list_head ilist_head; + uint32_t deletion_rate; + shard_first_lookup_state_t first_lookup; + uint64_t lru_limit; } shard_priv_t; typedef struct { - loc_t loc; - char *domain; - struct gf_flock flock; - gf_boolean_t acquired_lock; + loc_t loc; + char *domain; + struct gf_flock flock; + gf_boolean_t acquired_lock; } shard_inodelk_t; typedef struct { - loc_t loc; - char *domain; - char *basename; - entrylk_cmd cmd; - entrylk_type type; - gf_boolean_t acquired_lock; + loc_t loc; + char *domain; + char *basename; + entrylk_cmd cmd; + entrylk_type type; + gf_boolean_t acquired_lock; } shard_entrylk_t; -typedef int32_t (*shard_post_fop_handler_t) (call_frame_t *frame, - xlator_t *this); -typedef int32_t (*shard_post_resolve_fop_handler_t) (call_frame_t *frame, - xlator_t *this); -typedef int32_t (*shard_post_lookup_shards_fop_handler_t) (call_frame_t *frame, - xlator_t *this); +typedef int32_t (*shard_post_fop_handler_t)(call_frame_t *frame, + xlator_t *this); +typedef int32_t (*shard_post_resolve_fop_handler_t)(call_frame_t *frame, + xlator_t *this); +typedef int32_t (*shard_post_lookup_shards_fop_handler_t)(call_frame_t *frame, + xlator_t *this); -typedef int32_t (*shard_post_mknod_fop_handler_t) (call_frame_t *frame, - xlator_t *this); +typedef int32_t (*shard_post_mknod_fop_handler_t)(call_frame_t *frame, + xlator_t *this); -typedef int32_t (*shard_post_update_size_fop_handler_t) (call_frame_t *frame, - xlator_t *this); +typedef int32_t (*shard_post_update_size_fop_handler_t)(call_frame_t *frame, + xlator_t *this); typedef struct shard_local { - int op_ret; - int op_errno; - int first_block; - int last_block; - int num_blocks; - int call_count; - int eexist_count; - int create_count; - int xflag; - int count; - uint32_t flags; - uint32_t uid; - uint32_t gid; - uint64_t block_size; - uint64_t dst_block_size; - int32_t datasync; - off_t offset; - size_t total_size; - size_t written_size; - size_t hole_size; - size_t req_size; - size_t readdir_size; - int64_t delta_size; - int delta_blocks; - loc_t loc; - loc_t dot_shard_loc; - loc_t dot_shard_rm_loc; - loc_t loc2; - loc_t tmp_loc; - fd_t *fd; - dict_t *xattr_req; - dict_t *xattr_rsp; - inode_t **inode_list; - glusterfs_fop_t fop; - struct iatt prebuf; - struct iatt postbuf; - struct iatt preoldparent; - struct iatt postoldparent; - struct iatt prenewparent; - struct iatt postnewparent; - struct iovec *vector; - struct iobref *iobref; - struct iobuf *iobuf; - gf_dirent_t entries_head; - gf_boolean_t is_set_fsid; - gf_boolean_t list_inited; - shard_post_fop_handler_t handler; - shard_post_lookup_shards_fop_handler_t pls_fop_handler; - shard_post_resolve_fop_handler_t post_res_handler; - shard_post_mknod_fop_handler_t post_mknod_handler; - shard_post_update_size_fop_handler_t post_update_size_handler; - shard_inodelk_t int_inodelk; - shard_entrylk_t int_entrylk; - inode_t *resolver_base_inode; - gf_boolean_t first_lookup_done; - syncbarrier_t barrier; - gf_boolean_t lookup_shards_barriered; - gf_boolean_t unlink_shards_barriered; - gf_boolean_t resolve_not; - loc_t newloc; - call_frame_t *main_frame; - call_frame_t *inodelk_frame; - call_frame_t *entrylk_frame; - uint32_t deletion_rate; - gf_boolean_t cleanup_required; - uuid_t base_gfid; + int op_ret; + int op_errno; + int first_block; + int last_block; + int num_blocks; + int call_count; + int eexist_count; + int create_count; + int xflag; + int count; + uint32_t flags; + uint32_t uid; + uint32_t gid; + uint64_t block_size; + uint64_t dst_block_size; + int32_t datasync; + off_t offset; + size_t total_size; + size_t written_size; + size_t hole_size; + size_t req_size; + size_t readdir_size; + int64_t delta_size; + int delta_blocks; + loc_t loc; + loc_t dot_shard_loc; + loc_t dot_shard_rm_loc; + loc_t loc2; + loc_t tmp_loc; + fd_t *fd; + dict_t *xattr_req; + dict_t *xattr_rsp; + inode_t **inode_list; + glusterfs_fop_t fop; + struct iatt prebuf; + struct iatt postbuf; + struct iatt preoldparent; + struct iatt postoldparent; + struct iatt prenewparent; + struct iatt postnewparent; + struct iovec *vector; + struct iobref *iobref; + struct iobuf *iobuf; + gf_dirent_t entries_head; + gf_boolean_t is_set_fsid; + gf_boolean_t list_inited; + shard_post_fop_handler_t handler; + shard_post_lookup_shards_fop_handler_t pls_fop_handler; + shard_post_resolve_fop_handler_t post_res_handler; + shard_post_mknod_fop_handler_t post_mknod_handler; + shard_post_update_size_fop_handler_t post_update_size_handler; + shard_inodelk_t int_inodelk; + shard_entrylk_t int_entrylk; + inode_t *resolver_base_inode; + gf_boolean_t first_lookup_done; + syncbarrier_t barrier; + gf_boolean_t lookup_shards_barriered; + gf_boolean_t unlink_shards_barriered; + gf_boolean_t resolve_not; + loc_t newloc; + call_frame_t *main_frame; + call_frame_t *inodelk_frame; + call_frame_t *entrylk_frame; + uint32_t deletion_rate; + gf_boolean_t cleanup_required; + uuid_t base_gfid; } shard_local_t; typedef struct shard_inode_ctx { - uint64_t block_size; /* The block size with which this inode is - sharded */ - struct iatt stat; - gf_boolean_t refresh; - /* The following members of inode ctx will be applicable only to the - * individual shards' ctx and never the base file ctx. - */ - struct list_head ilist; - uuid_t base_gfid; - int block_num; - gf_boolean_t refreshed; - struct list_head to_fsync_list; - int fsync_needed; - inode_t *inode; - int fsync_count; - inode_t *base_inode; + uint64_t block_size; /* The block size with which this inode is + sharded */ + struct iatt stat; + gf_boolean_t refresh; + /* The following members of inode ctx will be applicable only to the + * individual shards' ctx and never the base file ctx. + */ + struct list_head ilist; + uuid_t base_gfid; + int block_num; + gf_boolean_t refreshed; + struct list_head to_fsync_list; + int fsync_needed; + inode_t *inode; + int fsync_count; + inode_t *base_inode; } shard_inode_ctx_t; typedef enum { - SHARD_INTERNAL_DIR_DOT_SHARD = 1, - SHARD_INTERNAL_DIR_DOT_SHARD_REMOVE_ME, + SHARD_INTERNAL_DIR_DOT_SHARD = 1, + SHARD_INTERNAL_DIR_DOT_SHARD_REMOVE_ME, } shard_internal_dir_type_t; #endif /* __SHARD_H__ */ diff --git a/xlators/features/snapview-client/src/snapview-client-mem-types.h b/xlators/features/snapview-client/src/snapview-client-mem-types.h index 1a0158d950e..aac0d571c41 100644 --- a/xlators/features/snapview-client/src/snapview-client-mem-types.h +++ b/xlators/features/snapview-client/src/snapview-client-mem-types.h @@ -14,11 +14,11 @@ #include "mem-types.h" enum svc_mem_types { - gf_svc_mt_svc_private_t = gf_common_mt_end + 1, - gf_svc_mt_svc_local_t, - gf_svc_mt_svc_inode_t, - gf_svc_mt_svc_fd_t, - gf_svc_mt_end + gf_svc_mt_svc_private_t = gf_common_mt_end + 1, + gf_svc_mt_svc_local_t, + gf_svc_mt_svc_inode_t, + gf_svc_mt_svc_fd_t, + gf_svc_mt_end }; #endif diff --git a/xlators/features/snapview-client/src/snapview-client.h b/xlators/features/snapview-client/src/snapview-client.h index 169974af532..ccce7bebca6 100644 --- a/xlators/features/snapview-client/src/snapview-client.h +++ b/xlators/features/snapview-client/src/snapview-client.h @@ -1,11 +1,11 @@ - /* - Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com> - This file is part of GlusterFS. +/* + Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef __SNAP_VIEW_CLIENT_H__ #define __SNAP_VIEW_CLIENT_H__ @@ -18,85 +18,82 @@ #include "snapview-client-mem-types.h" struct __svc_local { - loc_t loc; - xlator_t *subvolume; - fd_t *fd; - void *cookie; - dict_t *xdata; - uint16_t revalidate; + loc_t loc; + xlator_t *subvolume; + fd_t *fd; + void *cookie; + dict_t *xdata; + uint16_t revalidate; }; typedef struct __svc_local svc_local_t; -#define SVC_STACK_UNWIND(fop, frame, params ...) do { \ - svc_local_t *__local = NULL; \ - if (frame) { \ - __local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - svc_local_free (__local); \ - } while (0) +#define SVC_STACK_UNWIND(fop, frame, params...) \ + do { \ + svc_local_t *__local = NULL; \ + if (frame) { \ + __local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + svc_local_free(__local); \ + } while (0) -#define SVC_ENTRY_POINT_SET(this, xdata, op_ret, op_errno, new_xdata, \ - priv, ret, label) \ - do { \ - if (!xdata) { \ - xdata = new_xdata = dict_new (); \ - if (!new_xdata) { \ - gf_log (this->name, GF_LOG_ERROR, \ - "failed to allocate new dict"); \ - op_ret = -1; \ - op_errno = ENOMEM; \ - goto label; \ - } \ - } \ - ret = dict_set_str (xdata, "entry-point", "true"); \ - if (ret) { \ - gf_log (this->name, GF_LOG_ERROR, \ - "failed to set dict"); \ - op_ret = -1; \ - op_errno = ENOMEM; \ - goto label; \ - } \ - } while (0); +#define SVC_ENTRY_POINT_SET(this, xdata, op_ret, op_errno, new_xdata, priv, \ + ret, label) \ + do { \ + if (!xdata) { \ + xdata = new_xdata = dict_new(); \ + if (!new_xdata) { \ + gf_log(this->name, GF_LOG_ERROR, \ + "failed to allocate new dict"); \ + op_ret = -1; \ + op_errno = ENOMEM; \ + goto label; \ + } \ + } \ + ret = dict_set_str(xdata, "entry-point", "true"); \ + if (ret) { \ + gf_log(this->name, GF_LOG_ERROR, "failed to set dict"); \ + op_ret = -1; \ + op_errno = ENOMEM; \ + goto label; \ + } \ + } while (0); -#define SVC_GET_SUBVOL_FROM_CTX(this, op_ret, op_errno, inode_type, ret, \ - inode, subvolume, label) \ - do { \ - ret = svc_inode_ctx_get (this, inode, &inode_type); \ - if (ret < 0) { \ - gf_log (this->name, GF_LOG_ERROR, \ - "inode context not found for gfid %s", \ - uuid_utoa (inode->gfid)); \ - op_ret = -1; \ - op_errno = EINVAL; \ - goto label; \ - } \ - \ - subvolume = svc_get_subvolume (this, inode_type); \ - } while (0); +#define SVC_GET_SUBVOL_FROM_CTX(this, op_ret, op_errno, inode_type, ret, \ + inode, subvolume, label) \ + do { \ + ret = svc_inode_ctx_get(this, inode, &inode_type); \ + if (ret < 0) { \ + gf_log(this->name, GF_LOG_ERROR, \ + "inode context not found for gfid %s", \ + uuid_utoa(inode->gfid)); \ + op_ret = -1; \ + op_errno = EINVAL; \ + goto label; \ + } \ + \ + subvolume = svc_get_subvolume(this, inode_type); \ + } while (0); struct svc_private { - char *path; - char *special_dir; /* needed for samba */ - gf_boolean_t show_entry_point; + char *path; + char *special_dir; /* needed for samba */ + gf_boolean_t show_entry_point; }; typedef struct svc_private svc_private_t; struct svc_fd { - off_t last_offset; - gf_boolean_t entry_point_handled; - gf_boolean_t special_dir; + off_t last_offset; + gf_boolean_t entry_point_handled; + gf_boolean_t special_dir; }; typedef struct svc_fd svc_fd_t; -typedef enum { - NORMAL_INODE = 1, - VIRTUAL_INODE -} inode_type_t; +typedef enum { NORMAL_INODE = 1, VIRTUAL_INODE } inode_type_t; int -gf_svc_special_dir_revalidate_lookup (call_frame_t *frame, xlator_t *this, - dict_t *xdata); +gf_svc_special_dir_revalidate_lookup(call_frame_t *frame, xlator_t *this, + dict_t *xdata); #endif /* __SNAP_VIEW_CLIENT_H__ */ diff --git a/xlators/features/snapview-server/src/snapview-server-mem-types.h b/xlators/features/snapview-server/src/snapview-server-mem-types.h index a8035165000..504c7969bdc 100644 --- a/xlators/features/snapview-server/src/snapview-server-mem-types.h +++ b/xlators/features/snapview-server/src/snapview-server-mem-types.h @@ -14,13 +14,12 @@ #include "mem-types.h" enum snapview_mem_types { - gf_svs_mt_priv_t = gf_common_mt_end + 1, - gf_svs_mt_svs_inode_t, - gf_svs_mt_dirents_t, - gf_svs_mt_svs_fd_t, - gf_svs_mt_snaplist_t, - gf_svs_mt_end + gf_svs_mt_priv_t = gf_common_mt_end + 1, + gf_svs_mt_svs_inode_t, + gf_svs_mt_dirents_t, + gf_svs_mt_svs_fd_t, + gf_svs_mt_snaplist_t, + gf_svs_mt_end }; #endif - diff --git a/xlators/features/snapview-server/src/snapview-server.h b/xlators/features/snapview-server/src/snapview-server.h index d024a77011b..e07d3bcad0c 100644 --- a/xlators/features/snapview-server/src/snapview-server.h +++ b/xlators/features/snapview-server/src/snapview-server.h @@ -34,219 +34,216 @@ #include "protocol-common.h" #include "xdr-generic.h" - #define DEFAULT_SVD_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" -#define SNAP_VIEW_MAX_GLFS_T 256 -#define SNAP_VIEW_MAX_GLFS_FDS 1024 -#define SNAP_VIEW_MAX_GLFS_OBJ_HANDLES 1024 - -#define SVS_STACK_DESTROY(_frame) \ - do { \ - ((call_frame_t *)_frame)->local = NULL; \ - STACK_DESTROY (((call_frame_t *)_frame)->root); \ - } while (0) - -#define SVS_CHECK_VALID_SNAPSHOT_HANDLE(fs, this) \ - do { \ - svs_private_t *_private = NULL; \ - _private = this->private; \ - int i = 0; \ - gf_boolean_t found = _gf_false; \ - glfs_t *tmp_fs = NULL; \ - LOCK (&_private->snaplist_lock); \ - { \ - for (i = 0; i < _private->num_snaps; i++) { \ - tmp_fs = _private->dirents[i].fs; \ - gf_log (this->name, GF_LOG_DEBUG, \ - "dirent->fs: %p", tmp_fs); \ - if (tmp_fs && fs && (tmp_fs == fs)) { \ - found = _gf_true; \ - break; \ - } \ - } \ - } \ - UNLOCK (&_private->snaplist_lock); \ - \ - if (!found) { \ - gf_log (this->name, GF_LOG_WARNING, "failed to" \ - " find the fs instance %p", fs); \ - fs = NULL; \ - } \ - } while (0) - -#define SVS_GET_INODE_CTX_INFO(inode_ctx, fs, object, this, loc, ret, \ - op_errno, label) \ - do { \ - fs = inode_ctx->fs; \ - object = inode_ctx->object; \ - SVS_CHECK_VALID_SNAPSHOT_HANDLE (fs, this); \ - if (!fs) \ - object = NULL; \ - \ - if (!fs || !object) { \ - int32_t tmp = -1; \ - char tmp_uuid[64]; \ - \ - tmp = svs_get_handle (this, loc, inode_ctx, \ - &op_errno); \ - if (tmp) { \ - gf_log (this->name, GF_LOG_ERROR, \ - "failed to get the handle for %s " \ - "(gfid: %s)", loc->path, \ - uuid_utoa_r (loc->inode->gfid, \ - tmp_uuid)); \ - ret = -1; \ - goto label; \ - } \ - \ - fs = inode_ctx->fs; \ - object = inode_ctx->object; \ - } \ - } while(0); - -#define SVS_STRDUP(dst, src) \ - do { \ - if (dst && strcmp (src, dst)) { \ - GF_FREE (dst); \ - dst = NULL; \ - } \ - \ - if (!dst) \ - dst = gf_strdup (src); \ - } while (0) +#define SNAP_VIEW_MAX_GLFS_T 256 +#define SNAP_VIEW_MAX_GLFS_FDS 1024 +#define SNAP_VIEW_MAX_GLFS_OBJ_HANDLES 1024 + +#define SVS_STACK_DESTROY(_frame) \ + do { \ + ((call_frame_t *)_frame)->local = NULL; \ + STACK_DESTROY(((call_frame_t *)_frame)->root); \ + } while (0) + +#define SVS_CHECK_VALID_SNAPSHOT_HANDLE(fs, this) \ + do { \ + svs_private_t *_private = NULL; \ + _private = this->private; \ + int i = 0; \ + gf_boolean_t found = _gf_false; \ + glfs_t *tmp_fs = NULL; \ + LOCK(&_private->snaplist_lock); \ + { \ + for (i = 0; i < _private->num_snaps; i++) { \ + tmp_fs = _private->dirents[i].fs; \ + gf_log(this->name, GF_LOG_DEBUG, "dirent->fs: %p", tmp_fs); \ + if (tmp_fs && fs && (tmp_fs == fs)) { \ + found = _gf_true; \ + break; \ + } \ + } \ + } \ + UNLOCK(&_private->snaplist_lock); \ + \ + if (!found) { \ + gf_log(this->name, GF_LOG_WARNING, \ + "failed to" \ + " find the fs instance %p", \ + fs); \ + fs = NULL; \ + } \ + } while (0) + +#define SVS_GET_INODE_CTX_INFO(inode_ctx, fs, object, this, loc, ret, \ + op_errno, label) \ + do { \ + fs = inode_ctx->fs; \ + object = inode_ctx->object; \ + SVS_CHECK_VALID_SNAPSHOT_HANDLE(fs, this); \ + if (!fs) \ + object = NULL; \ + \ + if (!fs || !object) { \ + int32_t tmp = -1; \ + char tmp_uuid[64]; \ + \ + tmp = svs_get_handle(this, loc, inode_ctx, &op_errno); \ + if (tmp) { \ + gf_log(this->name, GF_LOG_ERROR, \ + "failed to get the handle for %s " \ + "(gfid: %s)", \ + loc->path, uuid_utoa_r(loc->inode->gfid, tmp_uuid)); \ + ret = -1; \ + goto label; \ + } \ + \ + fs = inode_ctx->fs; \ + object = inode_ctx->object; \ + } \ + } while (0); + +#define SVS_STRDUP(dst, src) \ + do { \ + if (dst && strcmp(src, dst)) { \ + GF_FREE(dst); \ + dst = NULL; \ + } \ + \ + if (!dst) \ + dst = gf_strdup(src); \ + } while (0) int -svs_mgmt_submit_request (void *req, call_frame_t *frame, - glusterfs_ctx_t *ctx, - rpc_clnt_prog_t *prog, int procnum, - fop_cbk_fn_t cbkfn, xdrproc_t xdrproc); +svs_mgmt_submit_request(void *req, call_frame_t *frame, glusterfs_ctx_t *ctx, + rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbkfn, + xdrproc_t xdrproc); int -svs_get_snapshot_list (xlator_t *this); +svs_get_snapshot_list(xlator_t *this); int -mgmt_get_snapinfo_cbk (struct rpc_req *req, struct iovec *iov, - int count, void *myframe); +mgmt_get_snapinfo_cbk(struct rpc_req *req, struct iovec *iov, int count, + void *myframe); typedef enum { - SNAP_VIEW_ENTRY_POINT_INODE = 0, - SNAP_VIEW_SNAPSHOT_INODE, - SNAP_VIEW_VIRTUAL_INODE + SNAP_VIEW_ENTRY_POINT_INODE = 0, + SNAP_VIEW_SNAPSHOT_INODE, + SNAP_VIEW_VIRTUAL_INODE } inode_type_t; struct svs_inode { - glfs_t *fs; - glfs_object_t *object; - inode_type_t type; - - /* used only for entry point directory where gfid of the directory - from where the entry point was entered is saved. - */ - uuid_t pargfid; - - /* This is used to generate gfid for all sub files/dirs under this - * snapshot - */ - char *snapname; - struct iatt buf; + glfs_t *fs; + glfs_object_t *object; + inode_type_t type; + + /* used only for entry point directory where gfid of the directory + from where the entry point was entered is saved. + */ + uuid_t pargfid; + + /* This is used to generate gfid for all sub files/dirs under this + * snapshot + */ + char *snapname; + struct iatt buf; }; typedef struct svs_inode svs_inode_t; struct svs_fd { - glfs_fd_t *fd; + glfs_fd_t *fd; }; typedef struct svs_fd svs_fd_t; struct snap_dirent { - char name[NAME_MAX]; - char uuid[UUID_CANONICAL_FORM_LEN + 1]; - char snap_volname[NAME_MAX]; - glfs_t *fs; + char name[NAME_MAX]; + char uuid[UUID_CANONICAL_FORM_LEN + 1]; + char snap_volname[NAME_MAX]; + glfs_t *fs; }; typedef struct snap_dirent snap_dirent_t; struct svs_private { - snap_dirent_t *dirents; - int num_snaps; - char *volname; - struct list_head snaplist; - gf_lock_t snaplist_lock; - struct rpc_clnt *rpc; + snap_dirent_t *dirents; + int num_snaps; + char *volname; + struct list_head snaplist; + gf_lock_t snaplist_lock; + struct rpc_clnt *rpc; }; typedef struct svs_private svs_private_t; int -__svs_inode_ctx_set (xlator_t *this, inode_t *inode, svs_inode_t *svs_inode); +__svs_inode_ctx_set(xlator_t *this, inode_t *inode, svs_inode_t *svs_inode); svs_inode_t * -__svs_inode_ctx_get (xlator_t *this, inode_t *inode); +__svs_inode_ctx_get(xlator_t *this, inode_t *inode); svs_inode_t * -svs_inode_ctx_get (xlator_t *this, inode_t *inode); +svs_inode_ctx_get(xlator_t *this, inode_t *inode); int32_t -svs_inode_ctx_set (xlator_t *this, inode_t *inode, svs_inode_t *svs_inode); +svs_inode_ctx_set(xlator_t *this, inode_t *inode, svs_inode_t *svs_inode); svs_inode_t * -svs_inode_ctx_get_or_new (xlator_t *this, inode_t *inode); +svs_inode_ctx_get_or_new(xlator_t *this, inode_t *inode); int -__svs_fd_ctx_set (xlator_t *this, fd_t *fd, svs_fd_t *svs_fd); +__svs_fd_ctx_set(xlator_t *this, fd_t *fd, svs_fd_t *svs_fd); svs_fd_t * -__svs_fd_ctx_get (xlator_t *this, fd_t *fd); +__svs_fd_ctx_get(xlator_t *this, fd_t *fd); svs_fd_t * -svs_fd_ctx_get (xlator_t *this, fd_t *fd); +svs_fd_ctx_get(xlator_t *this, fd_t *fd); int32_t -svs_fd_ctx_set (xlator_t *this, fd_t *fd, svs_fd_t *svs_fd); +svs_fd_ctx_set(xlator_t *this, fd_t *fd, svs_fd_t *svs_fd); svs_fd_t * -__svs_fd_ctx_get_or_new (xlator_t *this, fd_t *fd); +__svs_fd_ctx_get_or_new(xlator_t *this, fd_t *fd); svs_fd_t * -svs_fd_ctx_get_or_new (xlator_t *this, fd_t *fd); +svs_fd_ctx_get_or_new(xlator_t *this, fd_t *fd); int -svs_uuid_generate (xlator_t *this, uuid_t gfid, char *snapname, - uuid_t origin_gfid); +svs_uuid_generate(xlator_t *this, uuid_t gfid, char *snapname, + uuid_t origin_gfid); void -svs_fill_ino_from_gfid (struct iatt *buf); +svs_fill_ino_from_gfid(struct iatt *buf); void -svs_iatt_fill (uuid_t gfid, struct iatt *buf); +svs_iatt_fill(uuid_t gfid, struct iatt *buf); snap_dirent_t * -svs_get_latest_snap_entry (xlator_t *this); +svs_get_latest_snap_entry(xlator_t *this); glfs_t * -svs_get_latest_snapshot (xlator_t *this); +svs_get_latest_snapshot(xlator_t *this); glfs_t * -svs_initialise_snapshot_volume (xlator_t *this, const char *name, - int32_t *op_errno); +svs_initialise_snapshot_volume(xlator_t *this, const char *name, + int32_t *op_errno); glfs_t * -__svs_initialise_snapshot_volume (xlator_t *this, const char *name, - int32_t *op_errno); +__svs_initialise_snapshot_volume(xlator_t *this, const char *name, + int32_t *op_errno); snap_dirent_t * -__svs_get_snap_dirent (xlator_t *this, const char *name); +__svs_get_snap_dirent(xlator_t *this, const char *name); int -svs_mgmt_init (xlator_t *this); +svs_mgmt_init(xlator_t *this); int32_t -svs_get_handle (xlator_t *this, loc_t *loc, svs_inode_t *inode_ctx, - int32_t *op_errno); +svs_get_handle(xlator_t *this, loc_t *loc, svs_inode_t *inode_ctx, + int32_t *op_errno); glfs_t * -svs_inode_glfs_mapping (xlator_t *this, inode_t *inode); +svs_inode_glfs_mapping(xlator_t *this, inode_t *inode); glfs_t * -svs_inode_ctx_glfs_mapping (xlator_t *this, svs_inode_t *inode_ctx); +svs_inode_ctx_glfs_mapping(xlator_t *this, svs_inode_t *inode_ctx); #endif /* __SNAP_VIEW_H__ */ diff --git a/xlators/features/thin-arbiter/src/thin-arbiter-mem-types.h b/xlators/features/thin-arbiter/src/thin-arbiter-mem-types.h index d7288192d32..79b5ce0eee3 100644 --- a/xlators/features/thin-arbiter/src/thin-arbiter-mem-types.h +++ b/xlators/features/thin-arbiter/src/thin-arbiter-mem-types.h @@ -12,8 +12,8 @@ #include "mem-types.h" typedef enum gf_ta_mem_types_ { - gf_ta_mt_local_t = gf_common_mt_end + 1, - gf_ta_mt_char, - gf_ta_mt_end + gf_ta_mt_local_t = gf_common_mt_end + 1, + gf_ta_mt_char, + gf_ta_mt_end } gf_ta_mem_types_t; #endif diff --git a/xlators/features/thin-arbiter/src/thin-arbiter-messages.h b/xlators/features/thin-arbiter/src/thin-arbiter-messages.h index 524e4d3aef8..f49b3eedadf 100644 --- a/xlators/features/thin-arbiter/src/thin-arbiter-messages.h +++ b/xlators/features/thin-arbiter/src/thin-arbiter-messages.h @@ -23,8 +23,6 @@ * glfs-message-id.h. */ -GLFS_MSGID(TA, - TA_MSG_INVALID_FOP -); +GLFS_MSGID(TA, TA_MSG_INVALID_FOP); #endif /* !_TA_MESSAGES_H_ */ diff --git a/xlators/features/thin-arbiter/src/thin-arbiter.h b/xlators/features/thin-arbiter/src/thin-arbiter.h index 996f4441fdd..af3d4b1af92 100644 --- a/xlators/features/thin-arbiter/src/thin-arbiter.h +++ b/xlators/features/thin-arbiter/src/thin-arbiter.h @@ -21,43 +21,39 @@ #define THIN_ARBITER_SOURCE_XATTR "trusted.ta.source" #define THIN_ARBITER_SOURCE_SIZE 2 -#define TA_FAILED_FOP(fop, frame, op_errno) \ - do { \ - default_##fop##_failure_cbk(frame, op_errno); \ +#define TA_FAILED_FOP(fop, frame, op_errno) \ + do { \ + default_##fop##_failure_cbk(frame, op_errno); \ } while (0) -#define TA_STACK_UNWIND(fop, frame, op_ret, op_errno, params ...)\ - do { \ - ta_fop_t *__local = NULL; \ - int32_t __op_ret = 0; \ - int32_t __op_errno = 0; \ - \ - __local = frame->local; \ - __op_ret = op_ret; \ - __op_errno = op_errno; \ - if (__local) { \ - ta_release_fop (__local); \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, __op_ret, \ - __op_errno, params); \ - \ +#define TA_STACK_UNWIND(fop, frame, op_ret, op_errno, params...) \ + do { \ + ta_fop_t *__local = NULL; \ + int32_t __op_ret = 0; \ + int32_t __op_errno = 0; \ + \ + __local = frame->local; \ + __op_ret = op_ret; \ + __op_errno = op_errno; \ + if (__local) { \ + ta_release_fop(__local); \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, __op_ret, __op_errno, params); \ + \ } while (0) struct _ta_fop; typedef struct _ta_fop ta_fop_t; struct _ta_fop { - gf_xattrop_flags_t xattrop_flags; - loc_t loc; - fd_t *fd; - dict_t *dict; - dict_t *brick_xattr; - int32_t on_disk[2]; - int32_t idx; + gf_xattrop_flags_t xattrop_flags; + loc_t loc; + fd_t *fd; + dict_t *dict; + dict_t *brick_xattr; + int32_t on_disk[2]; + int32_t idx; }; - - - #endif /* _THIN_ARBITER_H */ diff --git a/xlators/features/trash/src/trash-mem-types.h b/xlators/features/trash/src/trash-mem-types.h index b7cad3ce3a9..133f2edf99b 100644 --- a/xlators/features/trash/src/trash-mem-types.h +++ b/xlators/features/trash/src/trash-mem-types.h @@ -13,11 +13,10 @@ #include "mem-types.h" enum gf_trash_mem_types_ { - gf_trash_mt_trash_private_t = gf_common_mt_end + 1, - gf_trash_mt_char, - gf_trash_mt_uuid, - gf_trash_mt_trash_elim_path, - gf_trash_mt_end + gf_trash_mt_trash_private_t = gf_common_mt_end + 1, + gf_trash_mt_char, + gf_trash_mt_uuid, + gf_trash_mt_trash_elim_path, + gf_trash_mt_end }; #endif - diff --git a/xlators/features/trash/src/trash.h b/xlators/features/trash/src/trash.h index 7dd83afc09a..675f9f97350 100644 --- a/xlators/features/trash/src/trash.h +++ b/xlators/features/trash/src/trash.h @@ -21,7 +21,7 @@ #include <libgen.h> #ifndef GF_BLOCK_READV_SIZE -#define GF_BLOCK_READV_SIZE (128 * GF_UNIT_KB) +#define GF_BLOCK_READV_SIZE (128 * GF_UNIT_KB) #endif #ifndef GF_DEFAULT_MAX_FILE_SIZE @@ -29,66 +29,69 @@ #endif struct trash_struct { - fd_t *fd; /* for the fd of existing file */ - fd_t *newfd; /* for the newly created file */ - loc_t loc; /* to store the location of the existing file */ - loc_t newloc; /* to store the location for the new file */ - size_t fsize; /* for keeping the size of existing file */ - off_t cur_offset; /* current offset for read and write ops */ - off_t fop_offset; /* original offset received with the fop */ - pid_t pid; - char origpath[PATH_MAX]; - char newpath[PATH_MAX]; - int32_t loop_count; - gf_boolean_t is_set_pid; - struct iatt preparent; - struct iatt postparent; - gf_boolean_t ctr_link_count_req; + fd_t *fd; /* for the fd of existing file */ + fd_t *newfd; /* for the newly created file */ + loc_t loc; /* to store the location of the existing file */ + loc_t newloc; /* to store the location for the new file */ + size_t fsize; /* for keeping the size of existing file */ + off_t cur_offset; /* current offset for read and write ops */ + off_t fop_offset; /* original offset received with the fop */ + pid_t pid; + char origpath[PATH_MAX]; + char newpath[PATH_MAX]; + int32_t loop_count; + gf_boolean_t is_set_pid; + struct iatt preparent; + struct iatt postparent; + gf_boolean_t ctr_link_count_req; }; typedef struct trash_struct trash_local_t; struct _trash_elim_path { - struct _trash_elim_path *next; - char *path; + struct _trash_elim_path *next; + char *path; }; typedef struct _trash_elim_path trash_elim_path; struct trash_priv { - char *oldtrash_dir; - char *newtrash_dir; - char *brick_path; - trash_elim_path *eliminate; - size_t max_trash_file_size; - gf_boolean_t state; - gf_boolean_t internal; - inode_t *trash_inode; - inode_table_t *trash_itable; + char *oldtrash_dir; + char *newtrash_dir; + char *brick_path; + trash_elim_path *eliminate; + size_t max_trash_file_size; + gf_boolean_t state; + gf_boolean_t internal; + inode_t *trash_inode; + inode_table_t *trash_itable; }; typedef struct trash_priv trash_private_t; -#define TRASH_SET_PID(frame, local) do { \ - GF_ASSERT (!local->is_set_pid); \ - if (!local->is_set_pid) { \ - local->pid = frame->root->pid; \ - frame->root->pid = GF_SERVER_PID_TRASH; \ - local->is_set_pid = _gf_true; \ - } \ -} while (0) +#define TRASH_SET_PID(frame, local) \ + do { \ + GF_ASSERT(!local->is_set_pid); \ + if (!local->is_set_pid) { \ + local->pid = frame->root->pid; \ + frame->root->pid = GF_SERVER_PID_TRASH; \ + local->is_set_pid = _gf_true; \ + } \ + } while (0) -#define TRASH_UNSET_PID(frame, local) do { \ - GF_ASSERT (local->is_set_pid); \ - if (local->is_set_pid) { \ - frame->root->pid = local->pid; \ - local->is_set_pid = _gf_false; \ - } \ -} while (0) +#define TRASH_UNSET_PID(frame, local) \ + do { \ + GF_ASSERT(local->is_set_pid); \ + if (local->is_set_pid) { \ + frame->root->pid = local->pid; \ + local->is_set_pid = _gf_false; \ + } \ + } while (0) -#define TRASH_STACK_UNWIND(op, frame, params ...) do { \ - trash_local_t *__local = NULL; \ - __local = frame->local; \ - frame->local = NULL; \ - STACK_UNWIND_STRICT (op, frame, params); \ - trash_local_wipe (__local); \ - } while (0) +#define TRASH_STACK_UNWIND(op, frame, params...) \ + do { \ + trash_local_t *__local = NULL; \ + __local = frame->local; \ + frame->local = NULL; \ + STACK_UNWIND_STRICT(op, frame, params); \ + trash_local_wipe(__local); \ + } while (0) #endif /* __TRASH_H__ */ diff --git a/xlators/features/upcall/src/upcall-cache-invalidation.h b/xlators/features/upcall/src/upcall-cache-invalidation.h index 62b458fa295..e509a89acd5 100644 --- a/xlators/features/upcall/src/upcall-cache-invalidation.h +++ b/xlators/features/upcall/src/upcall-cache-invalidation.h @@ -16,7 +16,9 @@ #define CACHE_INVALIDATION_TIMEOUT "60" /* xlator options */ -gf_boolean_t is_cache_invalidation_enabled(xlator_t *this); -int32_t get_cache_invalidation_timeout(xlator_t *this); +gf_boolean_t +is_cache_invalidation_enabled(xlator_t *this); +int32_t +get_cache_invalidation_timeout(xlator_t *this); #endif /* __UPCALL_CACHE_INVALIDATION_H__ */ diff --git a/xlators/features/upcall/src/upcall-mem-types.h b/xlators/features/upcall/src/upcall-mem-types.h index 55793ec65ca..079677ff79c 100644 --- a/xlators/features/upcall/src/upcall-mem-types.h +++ b/xlators/features/upcall/src/upcall-mem-types.h @@ -14,11 +14,10 @@ #include "mem-types.h" enum gf_upcall_mem_types_ { - gf_upcall_mt_conf_t = gf_common_mt_end + 1, - gf_upcall_mt_private_t, - gf_upcall_mt_upcall_inode_ctx_t, - gf_upcall_mt_upcall_client_entry_t, - gf_upcall_mt_end + gf_upcall_mt_conf_t = gf_common_mt_end + 1, + gf_upcall_mt_private_t, + gf_upcall_mt_upcall_inode_ctx_t, + gf_upcall_mt_upcall_client_entry_t, + gf_upcall_mt_end }; #endif - diff --git a/xlators/features/upcall/src/upcall-messages.h b/xlators/features/upcall/src/upcall-messages.h index b60a3ed7371..db5cac1e07d 100644 --- a/xlators/features/upcall/src/upcall-messages.h +++ b/xlators/features/upcall/src/upcall-messages.h @@ -23,10 +23,7 @@ * glfs-message-id.h. */ -GLFS_MSGID(UPCALL, - UPCALL_MSG_NO_MEMORY, - UPCALL_MSG_INTERNAL_ERROR, - UPCALL_MSG_NOTIFY_FAILED -); +GLFS_MSGID(UPCALL, UPCALL_MSG_NO_MEMORY, UPCALL_MSG_INTERNAL_ERROR, + UPCALL_MSG_NOTIFY_FAILED); #endif /* !_UPCALL_MESSAGES_H_ */ diff --git a/xlators/features/upcall/src/upcall.h b/xlators/features/upcall/src/upcall.h index 3e0d96cd001..3797e62aac3 100644 --- a/xlators/features/upcall/src/upcall.h +++ b/xlators/features/upcall/src/upcall.h @@ -17,123 +17,143 @@ #include "upcall-cache-invalidation.h" #include "upcall-utils.h" -#define EXIT_IF_UPCALL_OFF(this, label) do { \ - if (!is_upcall_enabled(this)) \ - goto label; \ -} while (0) - -#define UPCALL_STACK_UNWIND(fop, frame, params ...) do { \ - upcall_local_t *__local = NULL; \ - xlator_t *__xl = NULL; \ - if (frame) { \ - __xl = frame->this; \ - __local = frame->local; \ - frame->local = NULL; \ - } \ - STACK_UNWIND_STRICT (fop, frame, params); \ - upcall_local_wipe (__xl, __local); \ -} while (0) - -#define UPCALL_STACK_DESTROY(frame) do { \ - upcall_local_t *__local = NULL; \ - xlator_t *__xl = NULL; \ - __xl = frame->this; \ - __local = frame->local; \ - frame->local = NULL; \ - STACK_DESTROY (frame->root); \ - upcall_local_wipe (__xl, __local); \ -} while (0) +#define EXIT_IF_UPCALL_OFF(this, label) \ + do { \ + if (!is_upcall_enabled(this)) \ + goto label; \ + } while (0) + +#define UPCALL_STACK_UNWIND(fop, frame, params...) \ + do { \ + upcall_local_t *__local = NULL; \ + xlator_t *__xl = NULL; \ + if (frame) { \ + __xl = frame->this; \ + __local = frame->local; \ + frame->local = NULL; \ + } \ + STACK_UNWIND_STRICT(fop, frame, params); \ + upcall_local_wipe(__xl, __local); \ + } while (0) + +#define UPCALL_STACK_DESTROY(frame) \ + do { \ + upcall_local_t *__local = NULL; \ + xlator_t *__xl = NULL; \ + __xl = frame->this; \ + __local = frame->local; \ + frame->local = NULL; \ + STACK_DESTROY(frame->root); \ + upcall_local_wipe(__xl, __local); \ + } while (0) struct _upcall_private { - gf_boolean_t cache_invalidation_enabled; - int32_t cache_invalidation_timeout; - struct list_head inode_ctx_list; - gf_lock_t inode_ctx_lk; - gf_boolean_t reaper_init_done; - pthread_t reaper_thr; - int32_t fini; - dict_t *xattrs; /* list of xattrs registered by clients - for receiving invalidation */ + gf_boolean_t cache_invalidation_enabled; + int32_t cache_invalidation_timeout; + struct list_head inode_ctx_list; + gf_lock_t inode_ctx_lk; + gf_boolean_t reaper_init_done; + pthread_t reaper_thr; + int32_t fini; + dict_t *xattrs; /* list of xattrs registered by clients + for receiving invalidation */ }; typedef struct _upcall_private upcall_private_t; struct _upcall_client { - struct list_head client_list; - /* strdup to store client_uid, strdup. Free it explicitly */ - char *client_uid; - time_t access_time; /* time last accessed */ - /* the amount of time which client can cache this entry */ - uint32_t expire_time_attr; + struct list_head client_list; + /* strdup to store client_uid, strdup. Free it explicitly */ + char *client_uid; + time_t access_time; /* time last accessed */ + /* the amount of time which client can cache this entry */ + uint32_t expire_time_attr; }; typedef struct _upcall_client upcall_client_t; /* Upcall entries are maintained in inode_ctx */ struct _upcall_inode_ctx { - struct list_head inode_ctx_list; - struct list_head client_list; - pthread_mutex_t client_list_lock; /* mutex for clients list - of this upcall entry */ - int destroy; - uuid_t gfid; /* gfid of the entry */ + struct list_head inode_ctx_list; + struct list_head client_list; + pthread_mutex_t client_list_lock; /* mutex for clients list + of this upcall entry */ + int destroy; + uuid_t gfid; /* gfid of the entry */ }; typedef struct _upcall_inode_ctx upcall_inode_ctx_t; struct upcall_local { - /* XXX: need to check if we can store - * pointers in 'local' which may get freed - * in future by other thread - */ - inode_t *inode; - loc_t rename_oldloc; - loc_t loc; /* required for stat in *xattr_cbk */ - fd_t *fd; /* required for fstat in *xattr_cbk */ - dict_t *xattr; + /* XXX: need to check if we can store + * pointers in 'local' which may get freed + * in future by other thread + */ + inode_t *inode; + loc_t rename_oldloc; + loc_t loc; /* required for stat in *xattr_cbk */ + fd_t *fd; /* required for fstat in *xattr_cbk */ + dict_t *xattr; }; typedef struct upcall_local upcall_local_t; -void upcall_local_wipe (xlator_t *this, upcall_local_t *local); -upcall_local_t *upcall_local_init (call_frame_t *frame, xlator_t *this, - loc_t *loc, fd_t *fd, inode_t *inode, - dict_t *xattr); - -upcall_client_t *add_upcall_client (call_frame_t *frame, client_t *client, - upcall_inode_ctx_t *up_inode_ctx); -upcall_client_t *__add_upcall_client (call_frame_t *frame, client_t *client, - upcall_inode_ctx_t *up_inode_ctx); -upcall_client_t *__get_upcall_client (call_frame_t *frame, client_t *client, - upcall_inode_ctx_t *up_inode_ctx); -int __upcall_cleanup_client_entry (upcall_client_t *up_client); -int upcall_cleanup_expired_clients (xlator_t *this, - upcall_inode_ctx_t *up_inode_ctx); - -int __upcall_inode_ctx_set (inode_t *inode, xlator_t *this); -upcall_inode_ctx_t *__upcall_inode_ctx_get (inode_t *inode, xlator_t *this); -upcall_inode_ctx_t *upcall_inode_ctx_get (inode_t *inode, xlator_t *this); -int upcall_cleanup_inode_ctx (xlator_t *this, inode_t *inode); -void upcall_cache_forget (xlator_t *this, inode_t *inode, - upcall_inode_ctx_t *up_inode_ctx); - -void *upcall_reaper_thread (void *data); -int upcall_reaper_thread_init (xlator_t *this); +void +upcall_local_wipe(xlator_t *this, upcall_local_t *local); +upcall_local_t * +upcall_local_init(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + inode_t *inode, dict_t *xattr); + +upcall_client_t * +add_upcall_client(call_frame_t *frame, client_t *client, + upcall_inode_ctx_t *up_inode_ctx); +upcall_client_t * +__add_upcall_client(call_frame_t *frame, client_t *client, + upcall_inode_ctx_t *up_inode_ctx); +upcall_client_t * +__get_upcall_client(call_frame_t *frame, client_t *client, + upcall_inode_ctx_t *up_inode_ctx); +int +__upcall_cleanup_client_entry(upcall_client_t *up_client); +int +upcall_cleanup_expired_clients(xlator_t *this, + upcall_inode_ctx_t *up_inode_ctx); + +int +__upcall_inode_ctx_set(inode_t *inode, xlator_t *this); +upcall_inode_ctx_t * +__upcall_inode_ctx_get(inode_t *inode, xlator_t *this); +upcall_inode_ctx_t * +upcall_inode_ctx_get(inode_t *inode, xlator_t *this); +int +upcall_cleanup_inode_ctx(xlator_t *this, inode_t *inode); +void +upcall_cache_forget(xlator_t *this, inode_t *inode, + upcall_inode_ctx_t *up_inode_ctx); + +void * +upcall_reaper_thread(void *data); +int +upcall_reaper_thread_init(xlator_t *this); /* Xlator options */ -gf_boolean_t is_upcall_enabled (xlator_t *this); +gf_boolean_t +is_upcall_enabled(xlator_t *this); /* Cache invalidation specific */ -void upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, - client_t *client, inode_t *inode, - uint32_t flags, struct iatt *stbuf, - struct iatt *p_stbuf, - struct iatt *oldp_stbuf, dict_t *xattr); -void upcall_client_cache_invalidate (xlator_t *xl, uuid_t gfid, - upcall_client_t *up_client_entry, - uint32_t flags, struct iatt *stbuf, - struct iatt *p_stbuf, - struct iatt *oldp_stbuf, dict_t *xattr); - -int up_filter_xattr (dict_t *xattr, dict_t *regd_xattrs); - -int up_compare_afr_xattr (dict_t *d, char *k, data_t *v, void *tmp); - -gf_boolean_t up_invalidate_needed (dict_t *xattrs); +void +upcall_cache_invalidate(call_frame_t *frame, xlator_t *this, client_t *client, + inode_t *inode, uint32_t flags, struct iatt *stbuf, + struct iatt *p_stbuf, struct iatt *oldp_stbuf, + dict_t *xattr); +void +upcall_client_cache_invalidate(xlator_t *xl, uuid_t gfid, + upcall_client_t *up_client_entry, uint32_t flags, + struct iatt *stbuf, struct iatt *p_stbuf, + struct iatt *oldp_stbuf, dict_t *xattr); + +int +up_filter_xattr(dict_t *xattr, dict_t *regd_xattrs); + +int +up_compare_afr_xattr(dict_t *d, char *k, data_t *v, void *tmp); + +gf_boolean_t +up_invalidate_needed(dict_t *xattrs); #endif /* __UPCALL_H__ */ diff --git a/xlators/features/utime/src/utime-helpers.h b/xlators/features/utime/src/utime-helpers.h index f526aecb063..4efe75619eb 100644 --- a/xlators/features/utime/src/utime-helpers.h +++ b/xlators/features/utime/src/utime-helpers.h @@ -17,7 +17,7 @@ #include <time.h> void -gl_timespec_get (struct timespec *ts); +gl_timespec_get(struct timespec *ts); void utime_update_attribute_flags(call_frame_t *frame, glusterfs_fop_t fop); |