diff options
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r-- | drivers/md/bcache/alloc.c | 17 | ||||
-rw-r--r-- | drivers/md/bcache/bcache.h | 2 |
2 files changed, 16 insertions, 3 deletions
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index bcfd96e2121b..c0d37d082443 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c | |||
@@ -168,8 +168,21 @@ static void invalidate_one_bucket(struct cache *ca, struct bucket *b) | |||
168 | fifo_push(&ca->free_inc, b - ca->buckets); | 168 | fifo_push(&ca->free_inc, b - ca->buckets); |
169 | } | 169 | } |
170 | 170 | ||
171 | #define bucket_prio(b) \ | 171 | /* |
172 | (((unsigned) (b->prio - ca->set->min_prio)) * GC_SECTORS_USED(b)) | 172 | * Determines what order we're going to reuse buckets, smallest bucket_prio() |
173 | * first: we also take into account the number of sectors of live data in that | ||
174 | * bucket, and in order for that multiply to make sense we have to scale bucket | ||
175 | * | ||
176 | * Thus, we scale the bucket priorities so that the bucket with the smallest | ||
177 | * prio is worth 1/8th of what INITIAL_PRIO is worth. | ||
178 | */ | ||
179 | |||
180 | #define bucket_prio(b) \ | ||
181 | ({ \ | ||
182 | unsigned min_prio = (INITIAL_PRIO - ca->set->min_prio) / 8; \ | ||
183 | \ | ||
184 | (b->prio - ca->set->min_prio + min_prio) * GC_SECTORS_USED(b); \ | ||
185 | }) | ||
173 | 186 | ||
174 | #define bucket_max_cmp(l, r) (bucket_prio(l) < bucket_prio(r)) | 187 | #define bucket_max_cmp(l, r) (bucket_prio(l) < bucket_prio(r)) |
175 | #define bucket_min_cmp(l, r) (bucket_prio(l) > bucket_prio(r)) | 188 | #define bucket_min_cmp(l, r) (bucket_prio(l) > bucket_prio(r)) |
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 93b848419665..0c707e4f4eaf 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h | |||
@@ -704,7 +704,7 @@ struct bbio { | |||
704 | }; | 704 | }; |
705 | 705 | ||
706 | #define BTREE_PRIO USHRT_MAX | 706 | #define BTREE_PRIO USHRT_MAX |
707 | #define INITIAL_PRIO 32768 | 707 | #define INITIAL_PRIO 32768U |
708 | 708 | ||
709 | #define btree_bytes(c) ((c)->btree_pages * PAGE_SIZE) | 709 | #define btree_bytes(c) ((c)->btree_pages * PAGE_SIZE) |
710 | #define btree_blocks(b) \ | 710 | #define btree_blocks(b) \ |