Commit 6f6bf9db authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move LRU-touching behind a oc->touch method.

This makes it easier for -spersistent to avoid LRU touching
parent ea95f53a
......@@ -363,9 +363,6 @@ struct lru {
#define LRU_MAGIC 0x3fec7bb0
VTAILQ_HEAD(,objcore) lru_head;
struct lock mtx;
unsigned flags;
#define LRU_F_DONTMOVE (1<<1)
#define LRU_F_CONDEMMED (1<<2)
unsigned n_objcore;
};
......@@ -850,6 +847,7 @@ int ObjIterate(struct worker *, struct objcore *,
int ObjGetSpace(struct worker *, struct objcore *, ssize_t *sz, uint8_t **ptr);
void ObjExtend(struct worker *, struct objcore *, ssize_t l);
void ObjTrimStore(struct worker *, struct objcore *);
void ObjTouch(struct worker *wrk, struct objcore *oc, double now);
unsigned ObjGetXID(struct worker *, struct objcore *);
uint64_t ObjGetLen(struct worker *, struct objcore *oc);
void ObjUpdateMeta(struct worker *, struct objcore *);
......
......@@ -240,13 +240,6 @@ EXP_Touch(struct objcore *oc, double now)
lru = ObjGetLRU(oc);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
/*
* For -spersistent (and possibly other stevedores, we don't move
* objects on the lru list, since LRU doesn't really help much.
*/
if (lru->flags & LRU_F_DONTMOVE)
return;
if (Lck_Trylock(&lru->mtx))
return;
......
......@@ -36,6 +36,7 @@
* ObjSetAttr Set attr now
* ObjGetAttr Get attr no
* ObjRelease Done with attr ptr
* ObjTouch Object was used
*/
#include "config.h"
......@@ -246,6 +247,20 @@ ObjSetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
return (om->objsetattr(wrk, oc, attr, len, ptr));
}
/*====================================================================
* ObjTouch()
*/
void
ObjTouch(struct worker *wrk, struct objcore *oc, double now)
{
const struct obj_methods *om = obj_getmethods(oc);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
if (om->objtouch != NULL)
om->objtouch(wrk, oc, now);
}
/*====================================================================
* Utility functions which work on top of the previous ones
*/
......
......@@ -49,6 +49,7 @@ typedef void *objgetattr_f(struct worker *, struct objcore *,
typedef void *objsetattr_f(struct worker *, struct objcore *,
enum obj_attr attr, ssize_t len, const void *ptr);
typedef uint64_t objgetlen_f(struct worker *, struct objcore *);
typedef void objtouch_f(struct worker *, struct objcore *, double now);
struct obj_methods {
objfree_f *objfree;
......@@ -65,4 +66,5 @@ struct obj_methods {
objslim_f *objslim;
objgetattr_f *objgetattr;
objsetattr_f *objsetattr;
objtouch_f *objtouch;
};
......@@ -126,7 +126,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
assert(req->objcore->refcnt > 0);
if (req->objcore->exp_flags & OC_EF_EXP)
EXP_Touch(req->objcore, req->t_prev);
ObjTouch(req->wrk, req->objcore, req->t_prev);
HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod);
if (HTTP_Decode(req->resp,
......
......@@ -708,6 +708,7 @@ SMP_Init(void)
smp_oc_realmethods.objupdatemeta = smp_oc_methods.objupdatemeta;
smp_oc_realmethods.objfree = smp_oc_methods.objfree;
smp_oc_realmethods.objgetlru = smp_oc_methods.objgetlru;
smp_oc_realmethods.objtouch = NULL;
}
/*--------------------------------------------------------------------
......
......@@ -225,7 +225,6 @@ smp_new_seg(struct smp_sc *sc)
*sg = tmpsg;
sg->lru = LRU_Alloc();
CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC);
sg->lru->flags |= LRU_F_DONTMOVE;
sg->p.offset = IRNUP(sc, sg->p.offset);
sg->p.length -= sg->p.offset - tmpsg.p.offset;
......
......@@ -557,6 +557,14 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
return (retval);
}
static void __match_proto__(objtouch_f)
sml_touch(struct worker *wrk, struct objcore *oc, double now)
{
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
EXP_Touch(oc, now);
}
const struct obj_methods SML_methods = {
.objfree = sml_objfree,
......@@ -569,4 +577,5 @@ const struct obj_methods SML_methods = {
.objslim = sml_slim,
.objgetattr = sml_getattr,
.objsetattr = sml_setattr,
.objtouch = sml_touch,
};
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