[master] 1d95c79 Add a debug.persistent command so we can fondle persistent storage for testing and debugging.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Feb 7 12:51:16 CET 2011
commit 1d95c792bee73dead4e5a11cd85b5b4c8f0e6737
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Feb 7 11:50:56 2011 +0000
Add a debug.persistent command so we can fondle persistent storage for
testing and debugging.
diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index fdd0308..32c6e45 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -849,6 +849,7 @@ struct vsb *SMS_Makesynth(struct object *obj);
void SMS_Finish(struct object *obj);
/* storage_persistent.c */
+void SMP_Init(void);
void SMP_Ready(void);
void SMP_NewBan(double t0, const char *ban);
diff --git a/bin/varnishd/cache_main.c b/bin/varnishd/cache_main.c
index 6a2fc41..d874a98 100644
--- a/bin/varnishd/cache_main.c
+++ b/bin/varnishd/cache_main.c
@@ -127,6 +127,7 @@ child_main(void)
VCA_Init();
SMS_Init();
+ SMP_Init();
STV_open();
VMOD_Init();
diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c
index 8b1df91..94db92b 100644
--- a/bin/varnishd/storage_persistent.c
+++ b/bin/varnishd/storage_persistent.c
@@ -52,6 +52,8 @@ SVNID("$Id$")
#include "stevedore.h"
#include "hash_slinger.h"
#include "vsha256.h"
+#include "cli.h"
+#include "cli_priv.h"
#include "persistent.h"
@@ -124,6 +126,7 @@ struct smp_sc {
unsigned flags;
#define SMP_F_LOADED (1 << 0)
+ const struct stevedore *stevedore;
int fd;
const char *filename;
off_t mediasize;
@@ -1292,6 +1295,8 @@ smp_open(const struct stevedore *st)
Lck_New(&sc->mtx, lck_smp);
Lck_Lock(&sc->mtx);
+ sc->stevedore = st;
+
/* We trust the parent to give us a valid silo, for good measure: */
AZ(smp_valid_silo(sc));
@@ -1569,3 +1574,40 @@ const struct stevedore smp_stevedore = {
.free = smp_free,
.trim = smp_trim,
};
+
+/*--------------------------------------------------------------------*/
+
+static void
+debug_persistent(struct cli *cli, const char * const * av, void *priv)
+{
+ struct smp_sc *sc;
+ struct smp_seg *sg;
+
+ (void)priv;
+
+ if (av[2] == NULL || av[3] == NULL) {
+ VTAILQ_FOREACH(sc, &silos, list) {
+ if (av[2] != NULL &&
+ strcmp(av[2], sc->stevedore->ident))
+ continue;
+ cli_out(cli, "Silo: %s (%s)\n",
+ sc->stevedore->ident, sc->filename);
+ VTAILQ_FOREACH(sg, &sc->segments, list) {
+ cli_out(cli, " Seg: %p\n", sg);
+ }
+ }
+ return;
+ }
+}
+
+static struct cli_proto debug_cmds[] = {
+ { "debug.persistent", "debug.persistent",
+ "Persistent debugging magic\n", 0, 2, "d", debug_persistent },
+ { NULL }
+};
+
+void
+SMP_Init(void)
+{
+ CLI_AddFuncs(debug_cmds);
+}
More information about the varnish-commit
mailing list