fellow_cache_test: wake up logwatcher when disk buddy is waiting

because for fellow_cache_test there is no disk LRU, there is no instance to
trigger a log flush besides the periodic wake up of the logwatcher thread.

So when the disk buddy ran out of space, but the log buffer still had regions to
free, those would only be freed after two seconds, drastically slowing down
fellow_cache_test execution.

To avoid special casing just for tests, we now run a thread to care about this
issue specifically, to some extent emulating what otherwise the lru thread would
do.
parent a07fbf19
......@@ -7367,6 +7367,28 @@ struct t_fc {
pthread_t thr;
};
static void *
t_logwatcher_kicker(void *priv)
{
struct fellow_cache *fc;
struct fellow_fd *ffd;
struct t_fc *tfc;
buddy_t *buddy;
CAST_OBJ_NOTNULL(tfc, priv, TFC_MAGIC);
fc = tfc->fc;
CHECK_OBJ_NOTNULL(fc, FELLOW_CACHE_MAGIC);
ffd = fc->ffd;
buddy = fellow_dskbuddy(ffd);
while (! tfc->shutdown) {
buddy_wait_needspace(buddy);
fellow_logwatcher_kick(ffd);
}
return (NULL);
}
static struct t_fc *
t_fc_init(struct fellow_fd *ffd, buddy_t *membuddy, struct stvfe_tune *tune)
{
......@@ -7378,6 +7400,7 @@ t_fc_init(struct fellow_fd *ffd, buddy_t *membuddy, struct stvfe_tune *tune)
tfc->fc = fellow_cache_init(ffd, membuddy, tune, fellow_simple_task_run,
&tfc->g_mem_obj);
AN(tfc->fc);
AZ(pthread_create(&tfc->thr, NULL, t_logwatcher_kicker, tfc));
return (tfc);
}
......@@ -7388,6 +7411,10 @@ t_fc_fini(struct t_fc **tfcp)
struct t_fc *tfc;
TAKE_OBJ_NOTNULL(tfc, tfcp, TFC_MAGIC);
AZ(tfc->shutdown);
tfc->shutdown = 1;
buddy_wait_kick(fellow_dskbuddy(tfc->fc->ffd));
AZ(pthread_join(tfc->thr, NULL));
fellow_cache_fini(&tfc->fc);
AZ(tfc->fc);
AZ(tfc->g_mem_obj);
......
......@@ -6330,6 +6330,16 @@ fellow_logwatcher_kick_locked(struct fellow_fd *ffd)
AZ(pthread_cond_signal(&ffd->watcher_cond));
}
void
fellow_logwatcher_kick(struct fellow_fd *ffd)
{
CHECK_OBJ_NOTNULL(ffd, FELLOW_FD_MAGIC);
AZ(pthread_mutex_lock(&ffd->logmtx));
fellow_logwatcher_kick_locked(ffd);
AZ(pthread_mutex_unlock(&ffd->logmtx));
}
// not unter logmtx
static void
fellow_logwatcher_init(struct fellow_fd *ffd)
......
......@@ -55,3 +55,4 @@ unsigned fellow_io_ring_size(const char *envvar);
// XXX restructure code, this should not be needed
int fellow_fd(const struct fellow_fd *ffd);
void fellow_logwatcher_kick(struct fellow_fd *ffd);
......@@ -158,6 +158,11 @@
-esym(769, *_LIM)
-esym(528, assert_*)
// only used for TEST_DRIVER
-esym(759, fellow_logwatcher_kick)
-esym(765, fellow_logwatcher_kick)
-esym(714, fellow_logwatcher_kick)
// vcc_slash_if.h because of common struct
-esym(18, vmod_*)
-esym(516, vmod_*)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment