aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-gc.c
diff options
context:
space:
mode:
authorJavier González <jg@lightnvm.io>2017-06-26 05:57:23 -0400
committerJens Axboe <axboe@kernel.dk>2017-06-26 18:27:39 -0400
commitd45ebd470bb6d41eb5294733bdba78a7ad69f1d0 (patch)
tree895ebef437c4325bdcf61011f14bc961ce1bc78e /drivers/lightnvm/pblk-gc.c
parentdffdd960ee16d0515d32701301760a817a25d52b (diff)
lightnvm: pblk: choose optimal victim GC line
At the moment, we separate the closed lines on three different list based on their number of valid sectors. GC recycles lines from each list based on capacity. Lines from each list are taken in a FIFO fashion. Since the number of lines is limited (it corresponds to the number of blocks in a LUN, which is somewhere between 1000-2000), we can afford scanning the lists to choose the optimal line to be recycled. This helps specially in lines with a high number of valid sectors. If the number of blocks per LUN increases, we will consider a more efficient policy. Signed-off-by: Javier González <javier@cnexlabs.com> Signed-off-by: Matias Bjørling <matias@cnexlabs.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-gc.c')
-rw-r--r--drivers/lightnvm/pblk-gc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c
index 2e7fb7a51854..f811e4ca63f4 100644
--- a/drivers/lightnvm/pblk-gc.c
+++ b/drivers/lightnvm/pblk-gc.c
@@ -287,6 +287,20 @@ static void pblk_gc_lines(struct pblk *pblk, struct list_head *gc_list)
287 } 287 }
288} 288}
289 289
290static struct pblk_line *pblk_gc_get_victim_line(struct pblk *pblk,
291 struct list_head *group_list)
292{
293 struct pblk_line *line, *victim;
294
295 victim = list_first_entry(group_list, struct pblk_line, list);
296 list_for_each_entry(line, group_list, list) {
297 if (*line->vsc < *victim->vsc)
298 victim = line;
299 }
300
301 return victim;
302}
303
290/* 304/*
291 * Lines with no valid sectors will be returned to the free list immediately. If 305 * Lines with no valid sectors will be returned to the free list immediately. If
292 * GC is activated - either because the free block count is under the determined 306 * GC is activated - either because the free block count is under the determined
@@ -332,7 +346,7 @@ next_gc_group:
332 return; 346 return;
333 } 347 }
334 348
335 line = list_first_entry(group_list, struct pblk_line, list); 349 line = pblk_gc_get_victim_line(pblk, group_list);
336 nr_blocks_free += atomic_read(&line->blk_in_line); 350 nr_blocks_free += atomic_read(&line->blk_in_line);
337 351
338 spin_lock(&line->lock); 352 spin_lock(&line->lock);