Skip to content

Commit

Permalink
dm cache policy smq: allocate cache blocks in order
Browse files Browse the repository at this point in the history
Previously, cache blocks were being allocated in reverse order.  Fix
this by pulling the block off the head of the free list.

Shouldn't have any impact on performance or latency but it is more
correct to have the cache blocks allocated/mapped in ascending order.
This fix will slightly increase the chances of two adjacent oblocks
being in adjacent cblocks.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
jthornber authored and snitm committed Nov 10, 2017
1 parent 8ee18ed commit 9768a10
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion drivers/md/dm-cache-policy-smq.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,19 @@ static void l_del(struct entry_space *es, struct ilist *l, struct entry *e)
l->nr_elts--;
}

static struct entry *l_pop_head(struct entry_space *es, struct ilist *l)
{
struct entry *e;

for (e = l_head(es, l); e; e = l_next(es, e))
if (!e->sentinel) {
l_del(es, l, e);
return e;
}

return NULL;
}

static struct entry *l_pop_tail(struct entry_space *es, struct ilist *l)
{
struct entry *e;
Expand Down Expand Up @@ -719,7 +732,7 @@ static struct entry *alloc_entry(struct entry_alloc *ea)
if (l_empty(&ea->free))
return NULL;

e = l_pop_tail(ea->es, &ea->free);
e = l_pop_head(ea->es, &ea->free);
init_entry(e);
ea->nr_allocated++;

Expand Down

0 comments on commit 9768a10

Please sign in to comment.