Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcache: remove discard code from alloc.c

Bcache allocator initially has no free space to allocate. Firstly it
does a garbage collection which is triggered by a cache device write
and fills free space into ca->free[] lists. The discard happens after
the free bucket is handled by garbage collection added into one of the
ca->free[] lists. But normally this bucket will be allocated out very
soon to requester and filled data onto it. The discard hint on this
bucket LBA range doesn't help SSD control to improve internal erasure
performance, and waste extra CPU cycles to issue discard bios.

This patch removes the almost-useless discard code from alloc.c.

Signed-off-by: Coly Li <colyli@fnnas.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Coly Li and committed by
Jens Axboe
b4056afb 0c72e9fc

+4 -17
+4 -17
drivers/md/bcache/alloc.c
··· 24 24 * Since the gens and priorities are all stored contiguously on disk, we can 25 25 * batch this up: We fill up the free_inc list with freshly invalidated buckets, 26 26 * call prio_write(), and when prio_write() finishes we pull buckets off the 27 - * free_inc list and optionally discard them. 27 + * free_inc list. 28 28 * 29 29 * free_inc isn't the only freelist - if it was, we'd often to sleep while 30 30 * priorities and gens were being written before we could allocate. c->free is a 31 31 * smaller freelist, and buckets on that list are always ready to be used. 32 - * 33 - * If we've got discards enabled, that happens when a bucket moves from the 34 - * free_inc list to the free list. 35 32 * 36 33 * There is another freelist, because sometimes we have buckets that we know 37 34 * have nothing pointing into them - these we can reuse without waiting for 38 35 * priorities to be rewritten. These come from freed btree nodes and buckets 39 36 * that garbage collection discovered no longer had valid keys pointing into 40 37 * them (because they were overwritten). That's the unused list - buckets on the 41 - * unused list move to the free list, optionally being discarded in the process. 38 + * unused list move to the free list. 42 39 * 43 40 * It's also important to ensure that gens don't wrap around - with respect to 44 41 * either the oldest gen in the btree or the gen on disk. This is quite ··· 115 118 /* 116 119 * Background allocation thread: scans for buckets to be invalidated, 117 120 * invalidates them, rewrites prios/gens (marking them as invalidated on disk), 118 - * then optionally issues discard commands to the newly free buckets, then puts 119 - * them on the various freelists. 121 + * then puts them on the various freelists. 120 122 */ 121 123 122 124 static inline bool can_inc_bucket_gen(struct bucket *b) ··· 317 321 while (1) { 318 322 /* 319 323 * First, we pull buckets off of the unused and free_inc lists, 320 - * possibly issue discards to them, then we add the bucket to 321 - * the free list: 324 + * then we add the bucket to the free list: 322 325 */ 323 326 while (1) { 324 327 long bucket; 325 328 326 329 if (!fifo_pop(&ca->free_inc, bucket)) 327 330 break; 328 - 329 - if (ca->discard) { 330 - mutex_unlock(&ca->set->bucket_lock); 331 - blkdev_issue_discard(ca->bdev, 332 - bucket_to_sector(ca->set, bucket), 333 - ca->sb.bucket_size, GFP_KERNEL); 334 - mutex_lock(&ca->set->bucket_lock); 335 - } 336 331 337 332 allocator_wait(ca, bch_allocator_push(ca, bucket)); 338 333 wake_up(&ca->set->btree_cache_wait);