diff options
author | Joe Thornber <ejt@redhat.com> | 2013-10-24 14:10:28 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2013-11-09 18:20:17 -0500 |
commit | 0184b44e321dda893d4d4be33499d404718c3a86 (patch) | |
tree | 064e79ebdb9e19c8f07617e80a810a9603506323 /drivers/md/dm-cache-policy-mq.c | |
parent | 3351937e4a6054a925d306e36c4cddc7723b1579 (diff) |
dm cache policy mq: a few small fixes
Rename takeout_queue to concat_queue.
Fix a harmless bug in mq policies pop() function. Currently pop()
always succeeds, with up coming changes this wont be the case.
Fix typo in comment above pre_cache_to_cache prototype.
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-cache-policy-mq.c')
-rw-r--r-- | drivers/md/dm-cache-policy-mq.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/md/dm-cache-policy-mq.c b/drivers/md/dm-cache-policy-mq.c index db490f74c7f8..a9a25de5b011 100644 --- a/drivers/md/dm-cache-policy-mq.c +++ b/drivers/md/dm-cache-policy-mq.c | |||
@@ -311,7 +311,7 @@ struct mq_policy { | |||
311 | 311 | ||
312 | /*----------------------------------------------------------------*/ | 312 | /*----------------------------------------------------------------*/ |
313 | /* Free/alloc mq cache entry structures. */ | 313 | /* Free/alloc mq cache entry structures. */ |
314 | static void takeout_queue(struct list_head *lh, struct queue *q) | 314 | static void concat_queue(struct list_head *lh, struct queue *q) |
315 | { | 315 | { |
316 | unsigned level; | 316 | unsigned level; |
317 | 317 | ||
@@ -323,8 +323,8 @@ static void free_entries(struct mq_policy *mq) | |||
323 | { | 323 | { |
324 | struct entry *e, *tmp; | 324 | struct entry *e, *tmp; |
325 | 325 | ||
326 | takeout_queue(&mq->free, &mq->pre_cache); | 326 | concat_queue(&mq->free, &mq->pre_cache); |
327 | takeout_queue(&mq->free, &mq->cache); | 327 | concat_queue(&mq->free, &mq->cache); |
328 | 328 | ||
329 | list_for_each_entry_safe(e, tmp, &mq->free, list) | 329 | list_for_each_entry_safe(e, tmp, &mq->free, list) |
330 | kmem_cache_free(mq_entry_cache, e); | 330 | kmem_cache_free(mq_entry_cache, e); |
@@ -531,14 +531,16 @@ static void del(struct mq_policy *mq, struct entry *e) | |||
531 | */ | 531 | */ |
532 | static struct entry *pop(struct mq_policy *mq, struct queue *q) | 532 | static struct entry *pop(struct mq_policy *mq, struct queue *q) |
533 | { | 533 | { |
534 | struct entry *e = container_of(queue_pop(q), struct entry, list); | 534 | struct entry *e; |
535 | struct list_head *h = queue_pop(q); | ||
535 | 536 | ||
536 | if (e) { | 537 | if (!h) |
537 | hash_remove(e); | 538 | return NULL; |
538 | 539 | ||
539 | if (e->in_cache) | 540 | e = container_of(h, struct entry, list); |
540 | free_cblock(mq, e->cblock); | 541 | hash_remove(e); |
541 | } | 542 | if (e->in_cache) |
543 | free_cblock(mq, e->cblock); | ||
542 | 544 | ||
543 | return e; | 545 | return e; |
544 | } | 546 | } |
@@ -697,7 +699,7 @@ static int cache_entry_found(struct mq_policy *mq, | |||
697 | } | 699 | } |
698 | 700 | ||
699 | /* | 701 | /* |
700 | * Moves and entry from the pre_cache to the cache. The main work is | 702 | * Moves an entry from the pre_cache to the cache. The main work is |
701 | * finding which cache block to use. | 703 | * finding which cache block to use. |
702 | */ | 704 | */ |
703 | static int pre_cache_to_cache(struct mq_policy *mq, struct entry *e, | 705 | static int pre_cache_to_cache(struct mq_policy *mq, struct entry *e, |