From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH v2 02/10] wal: simplify watcher API
Date: Sat, 8 Dec 2018 18:48:06 +0300 [thread overview]
Message-ID: <7f779b579a827154d130d2072bc86c53ae4ec8a1.1544282224.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1544282224.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1544282224.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 f864d308..a01c2a2e 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 0775dbae..644f58c8 100644
--- a/src/box/wal.c
+++ b/src/box/wal.c
@@ -1169,13 +1169,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,
@@ -1195,7 +1188,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
@@ -1248,9 +1244,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));
@@ -1260,7 +1255,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)
@@ -1281,15 +1275,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 6e5a5458..3d616353 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-12-08 15:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-08 15:48 [PATCH v2 00/10] Allow to limit size of WAL files Vladimir Davydov
2018-12-08 15:48 ` [PATCH v2 01/10] gc: do not use WAL watcher API for deactivating stale consumers Vladimir Davydov
2018-12-08 21:41 ` Konstantin Osipov
2018-12-08 15:48 ` Vladimir Davydov [this message]
2018-12-08 21:41 ` [PATCH v2 02/10] wal: simplify watcher API Konstantin Osipov
2018-12-08 15:48 ` [PATCH v2 03/10] box: fix certain cfg options initialized twice on recovery Vladimir Davydov
2018-12-08 21:42 ` Konstantin Osipov
2018-12-08 15:48 ` [PATCH v2 04/10] box: don't use box_checkpoint_is_in_progress outside box.cc Vladimir Davydov
2018-12-08 21:43 ` Konstantin Osipov
2018-12-08 15:48 ` [PATCH v2 05/10] box: move checkpointing to gc module Vladimir Davydov
2018-12-08 21:44 ` Konstantin Osipov
2018-12-08 15:48 ` [PATCH v2 06/10] gc: some renames Vladimir Davydov
2018-12-08 21:44 ` Konstantin Osipov
2018-12-08 15:48 ` [PATCH v2 07/10] Introduce checkpoint schedule module Vladimir Davydov
2018-12-08 21:45 ` Konstantin Osipov
2018-12-08 15:48 ` [PATCH v2 08/10] Rewrite checkpoint daemon in C Vladimir Davydov
2018-12-08 21:45 ` Konstantin Osipov
2018-12-08 15:48 ` [PATCH v2 09/10] wal: pass struct instead of vclock to checkpoint methods Vladimir Davydov
2018-12-08 21:46 ` Konstantin Osipov
2018-12-08 15:48 ` [PATCH v2 10/10] wal: trigger checkpoint if there are too many WALs Vladimir Davydov
2018-12-08 21:48 ` Konstantin Osipov
2018-12-09 11:20 ` [PATCH v2 00/10] Allow to limit size of WAL files Vladimir Davydov
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=7f779b579a827154d130d2072bc86c53ae4ec8a1.1544282224.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH v2 02/10] 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