[master] 849fcd3 Add argument to tell which vsm_cluster a VSC goes into.

Poul-Henning Kamp phk at FreeBSD.org
Fri Jan 5 10:36:09 UTC 2018


commit 849fcd3b659ec70359fd1a5c469fc6790bd08280
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 5 09:23:00 2018 +0000

    Add argument to tell which vsm_cluster a VSC goes into.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 3b67257..601beaf 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -342,7 +342,8 @@ vbe_dir_event(const struct director *d, enum vcl_event_e ev)
 	if (ev == VCL_EVENT_WARM) {
 		AZ(bp->vsc);
 		bp->vsc =
-		    VSC_vbe_New(&bp->vsc_seg, bp->director->display_name);
+		    VSC_vbe_New(NULL, &bp->vsc_seg,
+			bp->director->display_name);
 		AN(bp->vsc);
 	}
 
diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c
index 9f122e9..6fa816a 100644
--- a/bin/varnishd/cache/cache_lck.c
+++ b/bin/varnishd/cache/cache_lck.c
@@ -247,7 +247,7 @@ Lck_Delete(struct lock *lck)
 struct VSC_lck *
 Lck_CreateClass(struct vsc_seg **sg, const char *name)
 {
-	return(VSC_lck_New(sg, name));
+	return(VSC_lck_New(NULL, sg, name));
 }
 
 void
diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c
index 1a9f040..62407f6 100644
--- a/bin/varnishd/cache/cache_mempool.c
+++ b/bin/varnishd/cache/cache_mempool.c
@@ -239,7 +239,7 @@ MPL_New(const char *name,
 	VTAILQ_INIT(&mpl->surplus);
 	Lck_New(&mpl->mtx, lck_mempool);
 	/* XXX: prealloc min_pool */
-	mpl->vsc = VSC_mempool_New(&mpl->vsc_seg, mpl->name + 4);
+	mpl->vsc = VSC_mempool_New(NULL, &mpl->vsc_seg, mpl->name + 4);
 	AN(mpl->vsc);
 	AZ(pthread_create(&mpl->thread, NULL, mpl_guard, mpl));
 	AZ(pthread_detach(mpl->thread));
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index c01e01e..01c8c36 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -505,7 +505,7 @@ VSM_Init(void)
 	vsc_lock = vsm_vsc_lock;
 	vsc_unlock = vsm_vsc_unlock;
 
-	VSC_C_main = VSC_main_New(NULL, "");
+	VSC_C_main = VSC_main_New(NULL, NULL, "");
 	AN(VSC_C_main);
 
 	AN(heritage.proc_vsmw);
diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c
index 6b8c0c5..fa361b9 100644
--- a/bin/varnishd/common/common_vsc.c
+++ b/bin/varnishd/common/common_vsc.c
@@ -106,13 +106,15 @@ vrt_vsc_mksegf(const char *class, size_t payload, const char *fmt, ...)
 }
 
 void *
-VRT_VSC_Alloc(struct vsc_seg **sg, const char *nm, size_t sd,
+VRT_VSC_Alloc(struct vsm_cluster *vc, struct vsc_seg **sg,
+    const char *nm, size_t sd,
     const unsigned char *jp, size_t sj, const char *fmt, va_list va)
 {
 	struct vsc_seg *vsg, *dvsg;
 	char buf[1024];
 	uintptr_t jjp;
 
+	AZ(vc);
 	if (vsc_lock != NULL)
 		vsc_lock();
 
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 46595d2..646b19c 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -49,6 +49,7 @@
 #include "common/common_param.h"
 
 struct vsc_seg;
+struct vsm_cluster;
 #include "VSC_mgt.h"
 
 struct cli;
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index da963b5..f23bc75 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -808,7 +808,7 @@ main(int argc, char * const *argv)
 	mgt_SHM_Init();
 
 	mgt_SHM_static_alloc(i_arg, strlen(i_arg) + 1L, "Arg", "-i");
-	VSC_C_mgt = VSC_mgt_New(NULL, "");
+	VSC_C_mgt = VSC_mgt_New(NULL, NULL, "");
 
 	if (M_arg != NULL)
 		mgt_cli_master(M_arg);
diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c
index af2817f..c2cb479 100644
--- a/bin/varnishd/storage/storage_file.c
+++ b/bin/varnishd/storage/storage_file.c
@@ -413,7 +413,7 @@ smf_open(struct stevedore *st)
 	if (lck_smf == NULL)
 		lck_smf = Lck_CreateClass(NULL, "smf");
 	CAST_OBJ_NOTNULL(sc, st->priv, SMF_SC_MAGIC);
-	sc->stats = VSC_smf_New(NULL, st->ident);
+	sc->stats = VSC_smf_New(NULL, NULL, st->ident);
 	Lck_New(&sc->mtx, lck_smf);
 	Lck_Lock(&sc->mtx);
 	smf_open_chunk(sc, sc->filesize, 0, &fail, &sum);
diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c
index 4ea548b..b8a168a 100644
--- a/bin/varnishd/storage/storage_malloc.c
+++ b/bin/varnishd/storage/storage_malloc.c
@@ -213,7 +213,7 @@ sma_open(struct stevedore *st)
 		lck_sma = Lck_CreateClass(NULL, "sma");
 	CAST_OBJ_NOTNULL(sma_sc, st->priv, SMA_SC_MAGIC);
 	Lck_New(&sma_sc->sma_mtx, lck_sma);
-	sma_sc->stats = VSC_sma_New(NULL, st->ident);
+	sma_sc->stats = VSC_sma_New(NULL, NULL, st->ident);
 	if (sma_sc->sma_max != SIZE_MAX)
 		sma_sc->stats->g_space = sma_sc->sma_max;
 }
diff --git a/include/vrt.h b/include/vrt.h
index ee440aa..9a01feb 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -113,6 +113,7 @@ struct vmod_priv;
 struct vrt_acl;
 struct vsb;
 struct vsc_seg;
+struct vsm_cluster;
 struct vsl_log;
 struct ws;
 
@@ -444,7 +445,7 @@ VCL_STRING VRT_STRANDS_string(VCL_STRANDS);
 VCL_STRING VRT_TIME_string(VRT_CTX, VCL_TIME);
 
 #ifdef va_start	// XXX: hackish
-void *VRT_VSC_Alloc(struct vsc_seg **, const char *, size_t,
-    const unsigned char *, size_t, const char *, va_list);
+void *VRT_VSC_Alloc(struct vsm_cluster *, struct vsc_seg **,
+    const char *, size_t, const unsigned char *, size_t, const char *, va_list);
 void VRT_VSC_Destroy(const char *, struct vsc_seg *);
 #endif
diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py
index 4afeb73..c0c6d80 100644
--- a/lib/libvcc/vsctool.py
+++ b/lib/libvcc/vsctool.py
@@ -144,7 +144,8 @@ class vscset(object):
 		fo.write("\n")
 
 		fo.write(self.struct + " *VSC_" + self.name + "_New")
-		fo.write("(struct vsc_seg **, const char *fmt, ...);\n")
+		fo.write("(struct vsm_cluster *,\n")
+		fo.write("    struct vsc_seg **, const char *fmt, ...);\n")
 
 		fo.write("void VSC_" + self.name + "_Destroy")
 		fo.write("(struct vsc_seg **);\n")
@@ -186,14 +187,15 @@ class vscset(object):
 		fo.write("\n")
 		fo.write(self.struct + "*\n")
 		fo.write("VSC_" + self.name + "_New")
-		fo.write("(struct vsc_seg **sg, const char *fmt, ...)\n")
+		fo.write("(struct vsm_cluster *vc,\n")
+		fo.write("    struct vsc_seg **sg, const char *fmt, ...)\n")
 		fo.write("{\n")
 		fo.write("\tva_list ap;\n")
 		fo.write("\t" + self.struct + " *retval;\n")
 		fo.write("\n")
 		fo.write("\tva_start(ap, fmt);\n")
 		fo.write("\tretval = VRT_VSC_Alloc")
-		fo.write("(sg, vsc_" + self.name + "_name, ")
+		fo.write("(vc, sg, vsc_" + self.name + "_name, ")
 		fo.write("sizeof(" + self.struct + "),\n\t    ")
 		fo.write("vsc_" + self.name + "_json, ")
 		fo.write("sizeof vsc_" + self.name + "_json, fmt, ap);\n")
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 2298d10..8e730dc 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -585,7 +585,7 @@ xyzzy_vsc_new(VRT_CTX)
 	(void)ctx;
 	AZ(pthread_mutex_lock(&vsc_mtx));
 	if (vsc == NULL)
-		vsc = VSC_debug_New(&vsc_seg, "");
+		vsc = VSC_debug_New(NULL, &vsc_seg, "");
 	AN(vsc);
 	AZ(pthread_mutex_unlock(&vsc_mtx));
 }


More information about the varnish-commit mailing list