Commit a6bf9db0 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Lasse Karstensen

Cache a checkpoint when we iterate over busy objects, so we don't

have to walk the full list all the time.

This is a minimal fix for backporting to 4.1.x

Fixes:	#1798
Fixes:	#1788
parent 9f6dd2b1
...@@ -93,6 +93,8 @@ struct objiter { ...@@ -93,6 +93,8 @@ struct objiter {
struct storage *st; struct storage *st;
struct worker *wrk; struct worker *wrk;
ssize_t len; ssize_t len;
struct storage *checkpoint;
ssize_t checkpoint_len;
}; };
void * void *
...@@ -126,6 +128,7 @@ ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l) ...@@ -126,6 +128,7 @@ ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l)
struct objiter *oi; struct objiter *oi;
ssize_t ol; ssize_t ol;
ssize_t nl; ssize_t nl;
ssize_t sl;
const struct storeobj_methods *om = obj_getmethods(oc); const struct storeobj_methods *om = obj_getmethods(oc);
AN(oix); AN(oix);
...@@ -167,7 +170,15 @@ ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l) ...@@ -167,7 +170,15 @@ ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l)
} }
Lck_Lock(&oi->bo->mtx); Lck_Lock(&oi->bo->mtx);
AZ(VTAILQ_EMPTY(&oi->obj->list)); AZ(VTAILQ_EMPTY(&oi->obj->list));
VTAILQ_FOREACH(oi->st, &oi->obj->list, list) { if (oi->checkpoint == NULL) {
oi->st = VTAILQ_FIRST(&oi->obj->list);
sl = 0;
} else {
oi->st = oi->checkpoint;
sl = oi->checkpoint_len;
ol -= oi->checkpoint_len;
}
while (oi->st != NULL) {
if (oi->st->len > ol) { if (oi->st->len > ol) {
*p = oi->st->ptr + ol; *p = oi->st->ptr + ol;
*l = oi->st->len - ol; *l = oi->st->len - ol;
...@@ -178,6 +189,12 @@ ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l) ...@@ -178,6 +189,12 @@ ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l)
assert(ol >= 0); assert(ol >= 0);
nl -= oi->st->len; nl -= oi->st->len;
assert(nl > 0); assert(nl > 0);
sl += oi->st->len;
oi->st = VTAILQ_NEXT(oi->st, list);
if (VTAILQ_NEXT(oi->st, list) != NULL) {
oi->checkpoint = oi->st;
oi->checkpoint_len = sl;
}
} }
CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(oi->st, STORAGE_MAGIC); CHECK_OBJ_NOTNULL(oi->st, STORAGE_MAGIC);
......
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