Commit ecd7f92a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move STV_Freestore() to ObjSlim()

parent 78045920
......@@ -1066,6 +1066,7 @@ uint64_t ObjGetLen(struct objcore *oc, struct dstat *ds);
struct object *ObjGetObj(struct objcore *, struct dstat *);
void ObjUpdateMeta(struct objcore *, struct dstat *);
void ObjFreeObj(struct objcore *, struct dstat *);
void ObjSlim(struct objcore *oc, struct dstat *ds);
struct lru *ObjGetLRU(const struct objcore *);
void *ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr,
ssize_t *len);
......@@ -1248,7 +1249,6 @@ void STV_trim(struct storage *st, size_t size, int move_ok);
void STV_free(struct storage *st);
void STV_open(void);
void STV_close(void);
void STV_Freestore(struct object *o);
int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len);
void STV_BanExport(const uint8_t *bans, unsigned len);
struct storage *STV_alloc_transient(size_t size);
......
......@@ -290,7 +290,6 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru)
{
struct objcore *oc, *oc2;
struct objhead *oh;
struct object *o;
/* Find the first currently unused object on the LRU. */
Lck_Lock(&lru->mtx);
......@@ -334,9 +333,7 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru)
}
/* XXX: We could grab and return one storage segment to our caller */
o = ObjGetObj(oc, bo->stats);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
STV_Freestore(o);
ObjSlim(oc, bo->stats);
exp_mail_it(oc);
......
......@@ -176,6 +176,32 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds)
}
}
/*--------------------------------------------------------------------
* Early disposal of storage from soon to be killed object.
*/
void
ObjSlim(struct objcore *oc, struct dstat *ds)
{
struct object *o;
struct storage *st, *stn;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(ds);
o = ObjGetObj(oc, ds);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
if (o->esidata != NULL) {
STV_free(o->esidata);
o->esidata = NULL;
}
VTAILQ_FOREACH_SAFE(st, &o->body->list, list, stn) {
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
VTAILQ_REMOVE(&o->body->list, st, list);
STV_free(st);
}
}
struct object *
ObjGetObj(struct objcore *oc, struct dstat *ds)
{
......
......@@ -175,7 +175,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
bo = HSH_RefBusy(req->objcore);
V1D_Deliver(req, bo);
if (bo != NULL)
VBO_DerefBusyObj(req->wrk, &bo);
VBO_DerefBusyObj(wrk, &bo);
VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
......@@ -190,7 +190,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
*/
while (req->objcore->busyobj != NULL)
(void)usleep(100000);
STV_Freestore(req->obj);
ObjSlim(req->objcore, &wrk->stats);
}
assert(WRW_IsReleased(wrk));
......
......@@ -65,13 +65,14 @@ default_oc_freeobj(struct dstat *ds, struct objcore *oc)
{
struct object *o;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(ds);
ObjSlim(oc, ds);
CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC);
oc->priv = NULL;
oc->stevedore = NULL;
o->magic = 0;
STV_Freestore(o);
STV_free(o->objstore);
ds->n_object--;
......@@ -379,24 +380,6 @@ STV_NewObject(struct busyobj *bo, const char *hint,
/*-------------------------------------------------------------------*/
void
STV_Freestore(struct object *o)
{
struct storage *st, *stn;
if (o->esidata != NULL) {
STV_free(o->esidata);
o->esidata = NULL;
}
VTAILQ_FOREACH_SAFE(st, &o->body->list, list, stn) {
CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC);
VTAILQ_REMOVE(&o->body->list, st, list);
STV_free(st);
}
}
/*-------------------------------------------------------------------*/
struct storage *
STV_alloc(const struct vfp_ctx *vc, size_t size)
{
......
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