[experimental-ims] b40bdeb Convert the -l argument into two params. For now setting them any other way than -l does you no good.

Geoff Simmons geoff at varnish-cache.org
Mon Jan 9 21:52:40 CET 2012


commit b40bdeb066636492b43eb863a002d191aeac557f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Nov 18 19:33:02 2011 +0000

    Convert the -l argument into two params.  For now setting them any
    other way than -l does you no good.

diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h
index 51721b1..95258fb 100644
--- a/bin/varnishd/common/params.h
+++ b/bin/varnishd/common/params.h
@@ -186,6 +186,10 @@ struct params {
 	double			shortlived;
 
 	struct vre_limits	vre_limits;
+
+	/* VSM dimensions */
+	ssize_t			vsm_space;
+	ssize_t			vsl_space;
 };
 
 /*
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 1eabe10..0650413 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -81,7 +81,7 @@ void mgt_sandbox_solaris_privsep(void);
 #endif
 
 /* mgt_shmem.c */
-void mgt_SHM_Init(const char *arg);
+void mgt_SHM_Init(void);
 void mgt_SHM_Pid(void);
 
 /* stevedore_mgt.c */
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 8a9e1fc..ff8992e 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -336,7 +336,6 @@ main(int argc, char * const *argv)
 	const char *b_arg = NULL;
 	const char *f_arg = NULL;
 	const char *i_arg = NULL;
-	const char *l_arg = NULL;	/* default in mgt_shmem.c */
 	const char *h_arg = "critbit";
 	const char *M_arg = NULL;
 	const char *n_arg = NULL;
@@ -349,6 +348,7 @@ main(int argc, char * const *argv)
 	struct cli cli[1];
 	struct vpf_fh *pfh = NULL;
 	char *dirname;
+	char **av;
 	unsigned clilim;
 
 	/*
@@ -459,7 +459,19 @@ main(int argc, char * const *argv)
 			i_arg = optarg;
 			break;
 		case 'l':
-			l_arg = optarg;
+			av = VAV_Parse(optarg, NULL, ARGV_COMMA);
+			AN(av);
+			if (av[0] != NULL)
+				ARGV_ERR("\t-l ...: %s", av[0]);
+			if (av[1] != NULL) {
+				MCF_ParamSet(cli, "vsl_space", av[1]);
+				cli_check(cli);
+			}
+			if (av[1] != NULL && av[2] != NULL) {
+				MCF_ParamSet(cli, "vsm_space", av[2]);
+				cli_check(cli);
+			}
+			VAV_Free(av);
 			break;
 		case 'M':
 			M_arg = optarg;
@@ -611,7 +623,7 @@ main(int argc, char * const *argv)
 
 	HSH_config(h_arg);
 
-	mgt_SHM_Init(l_arg);
+	mgt_SHM_Init();
 
 	AZ(VSB_finish(vident));
 
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 10e64b5..f6de562 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -1085,6 +1085,26 @@ static const struct parspec input_parspec[] = {
 		0,
 		"10000", ""},
 
+	{ "vsl_space", tweak_bytes,
+		&mgt_param.vsl_space, 1024*1024, HUGE_VAL,
+		"The amount of space to allocate for the VSL fifo buffer"
+		" in the VSM memory segment."
+		"  If you make this too small, varnish{ncsa|log} etc will"
+		" not be able to keep up."
+		"  Making it too large just costs memory resources.",
+		MUST_RESTART,
+		"80M", "bytes"},
+
+	{ "vsm_space", tweak_bytes,
+		&mgt_param.vsm_space, 1024*1024, HUGE_VAL,
+		"The amount of space to allocate for stats counters"
+		" in the VSM memory segment."
+		"  If you make this too small, some counters will be"
+		" invisible."
+		"  Making it too large just costs memory resources.",
+		MUST_RESTART,
+		"1M", "bytes"},
+
 	{ NULL, NULL, NULL }
 };
 
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index 24bc396..d1bf18e 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -105,9 +105,7 @@
 #include "vapi/vsc_int.h"
 #include "vapi/vsl_int.h"
 #include "vapi/vsm_int.h"
-#include "vav.h"
 #include "vmb.h"
-#include "vnum.h"
 
 #ifndef MAP_HASSEMAPHORE
 #define MAP_HASSEMAPHORE 0 /* XXX Linux */
@@ -227,67 +225,15 @@ mgt_shm_atexit(void)
 }
 
 void
-mgt_SHM_Init(const char *l_arg)
+mgt_SHM_Init(void)
 {
 	int i, fill;
-	const char *q;
-	uintmax_t size, s1, s2, ps;
-	char **av, **ap;
+	uintmax_t size, ps;
 	uint32_t *vsl_log_start;
 
-	if (l_arg == NULL)
-		l_arg = "";
+	fill = 1;
 
-	av = VAV_Parse(l_arg, NULL, ARGV_COMMA);
-	AN(av);
-	if (av[0] != NULL)
-		ARGV_ERR("\t-l ...: %s", av[0]);
-
-	ap = av + 1;
-
-	/* Size of SHMLOG */
-	if (*ap != NULL && **ap != '\0') {
-		q = VNUM_2bytes(*ap, &s1, 0);
-		if (q != NULL)
-			ARGV_ERR("\t-l[1] ...:  %s\n", q);
-	} else {
-		s1 = 80 * 1024 * 1024;
-	}
-	if (*ap != NULL)
-		ap++;
-
-	/* Size of space for other stuff */
-	if (*ap != NULL && **ap != '\0') {
-		q = VNUM_2bytes(*ap, &s2, 0);
-		if (q != NULL)
-			ARGV_ERR("\t-l[2] ...:  %s\n", q);
-	} else {
-		s2 = 1024 * 1024;
-	}
-	if (*ap != NULL)
-		ap++;
-
-	/* Fill or not ? */
-	if (*ap != NULL) {
-		if (**ap == '\0')
-			fill = 1;
-		else if (!strcmp(*ap, "-"))
-			fill = 0;
-		else if (!strcmp(*ap, "+"))
-			fill = 1;
-		else
-			ARGV_ERR("\t-l[3] ...:  Must be \"-\" or \"+\"\n");
-		ap++;
-	} else {
-		fill = 1;
-	}
-
-	if (*ap != NULL)
-		ARGV_ERR("\t-l ...:  Too many sub-args\n");
-
-	VAV_Free(av);
-
-	size = s1 + s2;
+	size = mgt_param.vsl_space + mgt_param.vsm_space;
 	ps = getpagesize();
 	size += ps - 1;
 	size &= ~(ps - 1);
@@ -326,7 +272,7 @@ mgt_SHM_Init(const char *l_arg)
 	AN(cache_param);
 	*cache_param = mgt_param;
 
-	vsl_log_start = VSM_Alloc(s1, VSL_CLASS, "", "");
+	vsl_log_start = VSM_Alloc(mgt_param.vsl_space, VSL_CLASS, "", "");
 	AN(vsl_log_start);
 	vsl_log_start[1] = VSL_ENDMARKER;
 	VWMB();



More information about the varnish-commit mailing list