Commit bc421898 authored by Pål Hermunn Johansen's avatar Pål Hermunn Johansen

Optimize ban lurker and dying objects

When an object is dying, we would rather not have the ban
lurker evalueate it against any existing bans. Now it will,
when a dying object is found, simply remove the oc off the
ban list completely. This is very cheap since we are already
holding the oh and ban mutexes.
parent b3a14937
......@@ -266,6 +266,8 @@ BAN_DestroyObj(struct objcore *oc)
{
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
if (oc->ban == NULL)
return;
Lck_Lock(&ban_mtx);
CHECK_OBJ_ORNULL(oc->ban, BAN_MAGIC);
if (oc->ban != NULL) {
......
......@@ -167,8 +167,23 @@ ban_lurker_getfirst(struct vsl_log *vsl, struct ban *bt)
oh = oc->objhead;
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
if (!Lck_Trylock(&oh->mtx)) {
if (oc->refcnt == 0 || oc->flags & OC_F_BUSY) {
if (oc->flags & OC_F_BUSY) {
Lck_Unlock(&oh->mtx);
} else if (oc->refcnt == 0 ||
oc->flags & (OC_F_DYING | OC_F_FAILED)) {
/*
* We seize the opportunity to remove
* the object completely off the ban
* list, now that we have both the oh
* and ban mutexes.
*/
noc = VTAILQ_NEXT(oc, ban_list);
VTAILQ_REMOVE(&bt->objcore, oc, ban_list);
oc->ban = NULL;
bt->refcount--;
Lck_Unlock(&oh->mtx);
oc = noc;
continue;
} else {
/*
* We got the lock, and the oc is not being
......
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