From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 6/9] wal: simplify watcher API Date: Wed, 28 Nov 2018 19:14:44 +0300 [thread overview] Message-ID: <bac213ee42277ec0cecba7729b95c9f6058cac7a.1543419109.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1543419109.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1543419109.git.vdavydov.dev@gmail.com> This patch reverts changes done in order to make WAL watcher API suitable for notiying TX about WAL garbage collection triggered on ENOSPC, namely: b073b0176704 wal: add event_mask to wal_watcher 7077341ec5b3 wal: pass wal_watcher_msg to wal_watcher callback We don't need them anymore, because now we piggyback the notification on the WAL request message that triggered ENOSPC. --- src/box/relay.cc | 12 ++++-------- src/box/wal.c | 27 ++++++--------------------- src/box/wal.h | 25 ++++++------------------- 3 files changed, 16 insertions(+), 48 deletions(-) diff --git a/src/box/relay.cc b/src/box/relay.cc index 0034f99a..0a1e95af 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -406,12 +406,9 @@ relay_schedule_pending_gc(struct relay *relay, const struct vclock *vclock) } static void -relay_process_wal_event(struct wal_watcher_msg *msg) +relay_process_wal_event(struct wal_watcher *watcher, unsigned events) { - assert((msg->events & (WAL_EVENT_WRITE | WAL_EVENT_ROTATE)) != 0); - - struct relay *relay = container_of(msg->watcher, struct relay, - wal_watcher); + struct relay *relay = container_of(watcher, struct relay, wal_watcher); if (relay->state != RELAY_FOLLOW) { /* * Do not try to send anything to the replica @@ -421,7 +418,7 @@ relay_process_wal_event(struct wal_watcher_msg *msg) } try { recover_remaining_wals(relay->r, &relay->stream, NULL, - (msg->events & WAL_EVENT_ROTATE) != 0); + (events & WAL_EVENT_ROTATE) != 0); } catch (Exception *e) { e->log(); diag_move(diag_get(), &relay->diag); @@ -507,8 +504,7 @@ relay_subscribe_f(va_list ap) }; trigger_add(&r->on_close_log, &on_close_log); wal_set_watcher(&relay->wal_watcher, cord_name(cord()), - relay_process_wal_event, cbus_process, - WAL_EVENT_WRITE | WAL_EVENT_ROTATE); + relay_process_wal_event, cbus_process); relay_set_cord_name(relay->io.fd); diff --git a/src/box/wal.c b/src/box/wal.c index c47535e4..31385642 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -1137,13 +1137,6 @@ wal_watcher_notify(struct wal_watcher *watcher, unsigned events) assert(!rlist_empty(&watcher->next)); struct wal_watcher_msg *msg = &watcher->msg; - - events &= watcher->event_mask; - if (events == 0) { - /* The watcher isn't interested in this event. */ - return; - } - if (msg->cmsg.route != NULL) { /* * If the notification message is still en route, @@ -1163,7 +1156,10 @@ static void wal_watcher_notify_perform(struct cmsg *cmsg) { struct wal_watcher_msg *msg = (struct wal_watcher_msg *) cmsg; - msg->watcher->cb(msg); + struct wal_watcher *watcher = msg->watcher; + unsigned events = msg->events; + + watcher->cb(watcher, events); } static void @@ -1216,9 +1212,8 @@ wal_watcher_detach(void *arg) void wal_set_watcher(struct wal_watcher *watcher, const char *name, - void (*watcher_cb)(struct wal_watcher_msg *), - void (*process_cb)(struct cbus_endpoint *), - unsigned event_mask) + void (*watcher_cb)(struct wal_watcher *, unsigned events), + void (*process_cb)(struct cbus_endpoint *)) { assert(journal_is_initialized(&wal_writer_singleton.base)); @@ -1228,7 +1223,6 @@ wal_set_watcher(struct wal_watcher *watcher, const char *name, watcher->msg.events = 0; watcher->msg.cmsg.route = NULL; watcher->pending_events = 0; - watcher->event_mask = event_mask; assert(lengthof(watcher->route) == 2); watcher->route[0] = (struct cmsg_hop) @@ -1249,15 +1243,6 @@ wal_clear_watcher(struct wal_watcher *watcher, wal_watcher_detach, watcher, process_cb); } -/** - * Notify all interested watchers about a WAL event. - * - * XXX: Note, this function iterates over all registered watchers, - * including those that are not interested in the given event. - * This is OK only as long as the number of events/watchers is - * small. If this ever changes, we should consider maintaining - * a separate watcher list per each event type. - */ static void wal_notify_watchers(struct wal_writer *writer, unsigned events) { diff --git a/src/box/wal.h b/src/box/wal.h index e5079552..1e070625 100644 --- a/src/box/wal.h +++ b/src/box/wal.h @@ -73,15 +73,9 @@ wal_init(enum wal_mode wal_mode, const char *wal_dirname, int64_t wal_max_rows, void wal_thread_stop(); -/** - * A notification message sent from the WAL to a watcher - * when a WAL event occurs. - */ struct wal_watcher_msg { struct cmsg cmsg; - /** Pointer to the watcher this message is for. */ struct wal_watcher *watcher; - /** Bit mask of events, see wal_event. */ unsigned events; }; @@ -96,7 +90,7 @@ struct wal_watcher { /** Link in wal_writer::watchers. */ struct rlist next; /** The watcher callback function. */ - void (*cb)(struct wal_watcher_msg *); + void (*cb)(struct wal_watcher *, unsigned events); /** Pipe from the watcher to WAL. */ struct cpipe wal_pipe; /** Pipe from WAL to the watcher. */ @@ -106,11 +100,6 @@ struct wal_watcher { /** Message sent to notify the watcher. */ struct wal_watcher_msg msg; /** - * Bit mask of WAL events that this watcher is - * interested in. - */ - unsigned event_mask; - /** * Bit mask of WAL events that happened while * the notification message was en route. * It indicates that the message must be resend @@ -135,19 +124,17 @@ struct wal_watcher { * @param watcher WAL watcher to register. * @param name Name of the cbus endpoint at the caller's cord. * @param watcher_cb Callback to invoke from the caller's cord - * upon receiving a WAL event. It takes an object - * of type wal_watcher_msg that stores a pointer - * to the watcher and information about the event. + * upon receiving a WAL event. Apart from the + * watcher itself, it takes a bit mask of events. + * Events are described in wal_event enum. * @param process_cb Function called to process cbus messages * while the watcher is being attached or NULL * if the cbus loop is running elsewhere. - * @param event_mask Bit mask of events the watcher is interested in. */ void wal_set_watcher(struct wal_watcher *watcher, const char *name, - void (*watcher_cb)(struct wal_watcher_msg *), - void (*process_cb)(struct cbus_endpoint *), - unsigned event_mask); + void (*watcher_cb)(struct wal_watcher *, unsigned events), + void (*process_cb)(struct cbus_endpoint *)); /** * Unsubscribe from WAL events. -- 2.11.0
next prev parent reply other threads:[~2018-11-28 16:14 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-28 16:14 [PATCH 0/9] Allow to limit size of WAL files Vladimir Davydov 2018-11-28 16:14 ` [PATCH 1/9] wal: separate checkpoint and flush paths Vladimir Davydov 2018-11-29 16:24 ` [tarantool-patches] " Konstantin Osipov 2018-11-28 16:14 ` [PATCH 2/9] wal: remove files needed for recovery from backup checkpoints on ENOSPC Vladimir Davydov 2018-11-29 16:31 ` [tarantool-patches] " Konstantin Osipov 2018-11-29 17:42 ` Vladimir Davydov 2018-11-28 16:14 ` [PATCH 3/9] recovery: restore garbage collector vclock after restart Vladimir Davydov 2018-11-29 16:37 ` [tarantool-patches] " Konstantin Osipov 2018-11-29 17:42 ` Vladimir Davydov 2018-11-28 16:14 ` [PATCH 4/9] gc: run garbage collection in background Vladimir Davydov 2018-11-29 16:42 ` [tarantool-patches] " Konstantin Osipov 2018-11-29 17:43 ` Vladimir Davydov 2018-11-28 16:14 ` [PATCH 5/9] gc: do not use WAL watcher API for deactivating stale consumers Vladimir Davydov 2018-11-29 17:02 ` [tarantool-patches] " Konstantin Osipov 2018-11-28 16:14 ` Vladimir Davydov [this message] 2018-11-29 17:33 ` [tarantool-patches] Re: [PATCH 6/9] wal: simplify watcher API Konstantin Osipov 2018-11-28 16:14 ` [PATCH 7/9] box: rewrite checkpoint daemon in C Vladimir Davydov 2018-11-30 8:58 ` [tarantool-patches] " Konstantin Osipov 2018-11-30 9:41 ` Vladimir Davydov 2018-12-05 16:21 ` Vladimir Davydov 2018-11-28 16:14 ` [PATCH 8/9] wal: pass struct instead of vclock to checkpoint methods Vladimir Davydov 2018-11-30 9:00 ` [tarantool-patches] " Konstantin Osipov 2018-11-30 9:43 ` Vladimir Davydov 2018-12-03 20:20 ` Konstantin Osipov 2018-11-28 16:14 ` [PATCH 9/9] wal: trigger checkpoint if there are too many WALs Vladimir Davydov 2018-12-03 20:34 ` [tarantool-patches] " Konstantin Osipov 2018-12-04 11:25 ` Vladimir Davydov 2018-12-04 12:53 ` Konstantin Osipov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bac213ee42277ec0cecba7729b95c9f6058cac7a.1543419109.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 6/9] wal: simplify watcher API' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox