[master] 8697257 Send EXP_NukeOne() over to storage_simple where it belongs (more)
Poul-Henning Kamp
phk at FreeBSD.org
Wed Feb 3 23:45:28 CET 2016
commit 8697257d18eaa4d5f3d0c1d066a9565c0242a7c5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Feb 3 15:09:57 2016 +0000
Send EXP_NukeOne() over to storage_simple where it belongs (more)
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 4d832a7..b6961ae 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -695,6 +695,7 @@ void EXP_Insert(struct worker *wrk, struct objcore *oc);
void EXP_Inject(struct worker *wrk, struct objcore *oc, struct lru *lru);
void EXP_Rearm(struct objcore *, double now, double ttl, double grace,
double keep);
+void EXP_Poke(struct objcore *);
int EXP_NukeOne(struct worker *wrk, struct lru *lru);
enum exp_event_e {
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index fd0b67a..1df0fa0 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -156,6 +156,18 @@ exp_mail_it(struct objcore *oc, uint8_t cmds)
}
/*--------------------------------------------------------------------
+ * Call EXP's attention to a an oc
+ */
+
+void
+EXP_Poke(struct objcore *oc)
+{
+
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+ exp_mail_it(oc, 0);
+}
+
+/*--------------------------------------------------------------------
* Inject an object with a reference into the lru/binheap.
*
* This can either come from a stevedore (persistent) during startup
@@ -266,53 +278,6 @@ EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep)
exp_mail_it(oc, OC_EF_MOVE);
}
-/*--------------------------------------------------------------------
- * Attempt to make space by nuking the oldest object on the LRU list
- * which isn't in use.
- * Returns: 1: did, 0: didn't, -1: can't
- */
-
-int
-EXP_NukeOne(struct worker *wrk, struct lru *lru)
-{
- struct objcore *oc, *oc2;
-
- CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
- /* Find the first currently unused object on the LRU. */
- Lck_Lock(&lru->mtx);
- VTAILQ_FOREACH_SAFE(oc, &lru->lru_head, lru_list, oc2) {
- CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-
- VSLb(wrk->vsl, SLT_ExpKill, "LRU_Cand p=%p f=0x%x r=%d",
- oc, oc->flags, oc->refcnt);
-
- AZ(isnan(oc->last_lru));
-
- if (ObjSnipe(wrk, oc)) {
- VSC_C_main->n_lru_nuked++; // XXX per lru ?
- VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
- oc->last_lru = NAN;
- break;
- }
- }
- Lck_Unlock(&lru->mtx);
-
- if (oc == NULL) {
- VSLb(wrk->vsl, SLT_ExpKill, "LRU_Fail");
- return (-1);
- }
-
- /* XXX: We could grab and return one storage segment to our caller */
- ObjSlim(wrk, oc);
-
- exp_mail_it(oc, 0);
-
- VSLb(wrk->vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(wrk, oc));
- (void)HSH_DerefObjCore(wrk, &oc);
- return (1);
-}
-
/*--------------------------------------------------------------------*/
uintptr_t
diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 605cd58..20d20a4 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -39,6 +39,54 @@
#include "storage/storage.h"
#include "storage/storage_simple.h"
+/*--------------------------------------------------------------------
+ * Attempt to make space by nuking the oldest object on the LRU list
+ * which isn't in use.
+ * Returns: 1: did, 0: didn't, -1: can't
+ */
+
+int
+EXP_NukeOne(struct worker *wrk, struct lru *lru)
+{
+ struct objcore *oc, *oc2;
+
+ CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
+ /* Find the first currently unused object on the LRU. */
+ Lck_Lock(&lru->mtx);
+ VTAILQ_FOREACH_SAFE(oc, &lru->lru_head, lru_list, oc2) {
+ CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+
+ VSLb(wrk->vsl, SLT_ExpKill, "LRU_Cand p=%p f=0x%x r=%d",
+ oc, oc->flags, oc->refcnt);
+
+ AZ(isnan(oc->last_lru));
+
+ if (ObjSnipe(wrk, oc)) {
+ VSC_C_main->n_lru_nuked++; // XXX per lru ?
+ VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
+ oc->last_lru = NAN;
+ break;
+ }
+ }
+ Lck_Unlock(&lru->mtx);
+
+ if (oc == NULL) {
+ VSLb(wrk->vsl, SLT_ExpKill, "LRU_Fail");
+ return (-1);
+ }
+
+ /* XXX: We could grab and return one storage segment to our caller */
+ ObjSlim(wrk, oc);
+
+ EXP_Poke(oc);
+
+ VSLb(wrk->vsl, SLT_ExpKill, "LRU x=%u", ObjGetXID(wrk, oc));
+ (void)HSH_DerefObjCore(wrk, &oc);
+ return (1);
+}
+
+
/*-------------------------------------------------------------------*/
static struct storage *
More information about the varnish-commit
mailing list