Task the logwatcher thread with updating the gauges

They also get updated during resurrection when the checkpoint
logs are output.

Implements #6
parent aa35f2b3
......@@ -602,6 +602,30 @@ struct fellow_fd {
unsigned open_cbs_n;
};
void
fellow_fd_update_space_stats(struct fellow_fd *ffd)
{
buddy_t *buddy;
size_t sz;
CHECK_OBJ_NOTNULL(ffd, FELLOW_FD_MAGIC);
if (ffd->stats == NULL)
return;
/* we get the exact values (which implies lock acquisition)
* because this function is only to be called infrequently
*/
buddy = ffd->dskbuddy;
sz = buddy_space(buddy, 1);
ffd->stats->g_dsk_space = sz;
ffd->stats->g_dsk_bytes = buddy_size(buddy) - sz;
buddy = ffd->membuddy;
sz = buddy_space(buddy, 1);
ffd->stats->g_mem_space = sz;
ffd->stats->g_mem_bytes = buddy_size(buddy) - sz;
}
static void
fellow_fd_ioctx_get(struct fellow_fd *ffd, struct fellow_fd_ioctx_lease *fdil)
{
......@@ -5373,6 +5397,7 @@ fellow_logwatcher_thread(void *priv)
AZ(pthread_mutex_lock(&ffd->logmtx));
fellow_logwatcher_new_log_alloc(ffd, new_log_req, &new_log_fdr);
while (ffd->watcher_running) {
fellow_fd_update_space_stats(ffd);
if (ffd->logbuf->ff.inuse) {
AZ(pthread_mutex_unlock(&ffd->logmtx));
logbuffer_wait_flush_fini(ffd->logbuf);
......
......@@ -263,3 +263,4 @@ size_t fellow_minsize(void);
typedef void fellow_log_diag_f(const char *fmt, ...);
void fellow_log_set_diag(struct fellow_fd *ffd, fellow_log_diag_f *diag);
void fellow_fd_update_space_stats(struct fellow_fd *ffd);
......@@ -1687,6 +1687,7 @@ sfe_keep(struct sfe_resurrect_priv *sfer)
SFE_DIAG(sfer->stvfe->memstv->ident,
"resurrected %u ", sfer->n_resurrected);
Pool_Sumstat(sfer->wrk);
fellow_fd_update_space_stats(sfer->stvfe->ffd);
}
return (1);
}
......@@ -2747,30 +2748,12 @@ sfe_panic(struct vsb *vsb, const struct objcore *oc)
}
#endif
static void
sfe_update_space(struct stvfe *stvfe)
{
buddy_t *buddy;
size_t sz;
buddy = fellow_dskbuddy(stvfe->ffd);
sz = buddy_space(buddy, 0);
stvfe->stats->g_dsk_space = sz;
stvfe->stats->g_dsk_bytes = buddy_size(buddy) - sz;
buddy = stvfe->membuddy;
sz = buddy_space(buddy, 0);
stvfe->stats->g_mem_space = sz;
stvfe->stats->g_mem_bytes = buddy_size(buddy) - sz;
}
static VCL_BYTES v_matchproto_(stv_var_free_space)
sfe_free_space(const struct stevedore *stv)
{
struct stvfe *stvfe;
CAST_OBJ_NOTNULL(stvfe, stv->priv, STVFE_MAGIC);
sfe_update_space(stvfe);
return ((VCL_BYTES)stvfe->stats->g_dsk_space);
}
......@@ -2781,7 +2764,6 @@ sfe_used_space(const struct stevedore *stv)
struct stvfe *stvfe;
CAST_OBJ_NOTNULL(stvfe, stv->priv, STVFE_MAGIC);
sfe_update_space(stvfe);
return ((VCL_BYTES)stvfe->stats->g_dsk_bytes);
}
......
......@@ -812,6 +812,9 @@ observed with VSC clients like :ref:`varnishstat(1)`.
The counter documentation is available through :ref:`varnishstat(1)`
and the :ref:`slash-counters(7)` man page.
The ``g_dsk_*`` and ``g_mem_*`` gauges are updated at regular
intervals of *logbuffer_flush_interval*.
FELLOW DIAGNOSTICS
==================
......
......@@ -733,6 +733,9 @@ observed with VSC clients like :ref:`varnishstat(1)`.
The counter documentation is available through :ref:`varnishstat(1)`
and the :ref:`slash-counters(7)` man page.
The ``g_dsk_*`` and ``g_mem_*`` gauges are updated at regular
intervals of *logbuffer_flush_interval*.
FELLOW DIAGNOSTICS
==================
......
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