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/changelog | |
parent | be77dbbda692792335a8e9e7c02e0c281f003c40 (diff) |
Land clang-format changes
Change-Id: I6f5d8140a06f3c1b2d196849299f8d483028d33b
Diffstat (limited to 'xlators/features/changelog')
-rw-r--r-- | xlators/features/changelog/lib/src/changelog-lib-messages.h | 55 | ||||
-rw-r--r-- | xlators/features/changelog/lib/src/gf-changelog-helpers.h | 239 | ||||
-rw-r--r-- | xlators/features/changelog/lib/src/gf-changelog-journal.h | 94 | ||||
-rw-r--r-- | xlators/features/changelog/lib/src/gf-changelog-rpc.h | 8 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-encoders.h | 40 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-ev-handle.h | 90 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-helpers.h | 876 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-mem-types.h | 30 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-messages.h | 88 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-misc.h | 157 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-rpc-common.h | 55 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-rpc.h | 8 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-rt.h | 10 |
13 files changed, 859 insertions, 891 deletions
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 */ |