• Home
  • Raw
  • Download

Lines Matching full:gc

16  * pblk-gc.c - pblk's garbage collector
33 struct pblk_gc *gc = &pblk->gc; in pblk_gc_write() local
37 spin_lock(&gc->w_lock); in pblk_gc_write()
38 if (list_empty(&gc->w_list)) { in pblk_gc_write()
39 spin_unlock(&gc->w_lock); in pblk_gc_write()
43 list_cut_position(&w_list, &gc->w_list, gc->w_list.prev); in pblk_gc_write()
44 gc->w_entries = 0; in pblk_gc_write()
45 spin_unlock(&gc->w_lock); in pblk_gc_write()
57 static void pblk_gc_writer_kick(struct pblk_gc *gc) in pblk_gc_writer_kick() argument
59 wake_up_process(gc->gc_writer_ts); in pblk_gc_writer_kick()
77 * gc lists. in pblk_put_line_back()
91 struct pblk_gc *gc = &pblk->gc; in pblk_gc_line_ws() local
96 up(&gc->gc_sem); in pblk_gc_line_ws()
98 /* Read from GC victim block */ in pblk_gc_line_ws()
109 spin_lock(&gc->w_lock); in pblk_gc_line_ws()
110 if (gc->w_entries >= PBLK_GC_RQ_QD) { in pblk_gc_line_ws()
111 spin_unlock(&gc->w_lock); in pblk_gc_line_ws()
112 pblk_gc_writer_kick(&pblk->gc); in pblk_gc_line_ws()
116 gc->w_entries++; in pblk_gc_line_ws()
117 list_add_tail(&gc_rq->list, &gc->w_list); in pblk_gc_line_ws()
118 spin_unlock(&gc->w_lock); in pblk_gc_line_ws()
120 pblk_gc_writer_kick(&pblk->gc); in pblk_gc_line_ws()
185 struct pblk_gc *gc = &pblk->gc; in pblk_gc_line_prepare_ws() local
214 pblk_err(pblk, "corrupted GC line (%d)\n", line->id); in pblk_gc_line_prepare_ws()
255 /* The write GC path can be much slower than the read GC one due to in pblk_gc_line_prepare_ws()
257 * back pressure from the write GC path. in pblk_gc_line_prepare_ws()
259 while (down_timeout(&gc->gc_sem, msecs_to_jiffies(30000))) in pblk_gc_line_prepare_ws()
265 queue_work(gc->gc_line_reader_wq, &gc_rq_ws->ws); in pblk_gc_line_prepare_ws()
277 atomic_dec(&gc->read_inflight_gc); in pblk_gc_line_prepare_ws()
294 * gc to free line state transition. in pblk_gc_line_prepare_ws()
297 atomic_dec(&gc->read_inflight_gc); in pblk_gc_line_prepare_ws()
299 pblk_err(pblk, "failed to GC line %d\n", line->id); in pblk_gc_line_prepare_ws()
304 struct pblk_gc *gc = &pblk->gc; in pblk_gc_line() local
307 pblk_debug(pblk, "line '%d' being reclaimed for GC\n", line->id); in pblk_gc_line()
316 atomic_inc(&gc->pipeline_gc); in pblk_gc_line()
318 queue_work(gc->gc_reader_wq, &line_ws->ws); in pblk_gc_line()
323 static void pblk_gc_reader_kick(struct pblk_gc *gc) in pblk_gc_reader_kick() argument
325 wake_up_process(gc->gc_reader_ts); in pblk_gc_reader_kick()
330 struct pblk_gc *gc = &pblk->gc; in pblk_gc_kick() local
332 pblk_gc_writer_kick(gc); in pblk_gc_kick()
333 pblk_gc_reader_kick(gc); in pblk_gc_kick()
335 /* If we're shutting down GC, let's not start it up again */ in pblk_gc_kick()
336 if (gc->gc_enabled) { in pblk_gc_kick()
337 wake_up_process(gc->gc_ts); in pblk_gc_kick()
338 mod_timer(&gc->gc_timer, in pblk_gc_kick()
345 struct pblk_gc *gc = &pblk->gc; in pblk_gc_read() local
348 spin_lock(&gc->r_lock); in pblk_gc_read()
349 if (list_empty(&gc->r_list)) { in pblk_gc_read()
350 spin_unlock(&gc->r_lock); in pblk_gc_read()
354 line = list_first_entry(&gc->r_list, struct pblk_line, list); in pblk_gc_read()
356 spin_unlock(&gc->r_lock); in pblk_gc_read()
361 pblk_err(pblk, "failed to GC line %d\n", line->id); in pblk_gc_read()
363 spin_lock(&gc->r_lock); in pblk_gc_read()
364 list_add_tail(&line->list, &gc->r_list); in pblk_gc_read()
365 spin_unlock(&gc->r_lock); in pblk_gc_read()
394 static bool pblk_gc_should_run(struct pblk_gc *gc, struct pblk_rl *rl) in pblk_gc_should_run() argument
404 ((gc->gc_active) && (nr_blocks_need > nr_blocks_free))); in pblk_gc_should_run()
410 struct pblk_gc *gc = &pblk->gc; in pblk_gc_free_full_lines() local
433 atomic_inc(&gc->pipeline_gc); in pblk_gc_free_full_lines()
440 * GC is activated - either because the free block count is under the determined
447 struct pblk_gc *gc = &pblk->gc; in pblk_gc_run() local
455 run_gc = pblk_gc_should_run(&pblk->gc, &pblk->rl); in pblk_gc_run()
456 if (!run_gc || (atomic_read(&gc->read_inflight_gc) >= PBLK_GC_L_QD)) in pblk_gc_run()
481 spin_lock(&gc->r_lock); in pblk_gc_run()
482 list_add_tail(&line->list, &gc->r_list); in pblk_gc_run()
483 spin_unlock(&gc->r_lock); in pblk_gc_run()
485 read_inflight_gc = atomic_inc_return(&gc->read_inflight_gc); in pblk_gc_run()
486 pblk_gc_reader_kick(gc); in pblk_gc_run()
490 /* No need to queue up more GC lines than we can handle */ in pblk_gc_run()
491 run_gc = pblk_gc_should_run(&pblk->gc, &pblk->rl); in pblk_gc_run()
503 struct pblk *pblk = from_timer(pblk, t, gc.gc_timer); in pblk_gc_timer()
538 struct pblk_gc *gc = &pblk->gc; in pblk_gc_reader_ts() local
548 pblk_info(pblk, "flushing gc pipeline, %d lines left\n", in pblk_gc_reader_ts()
549 atomic_read(&gc->pipeline_gc)); in pblk_gc_reader_ts()
553 if (!atomic_read(&gc->pipeline_gc)) in pblk_gc_reader_ts()
564 pblk->gc.gc_active = 1; in pblk_gc_start()
565 pblk_debug(pblk, "gc start\n"); in pblk_gc_start()
570 struct pblk_gc *gc = &pblk->gc; in pblk_gc_should_start() local
572 if (gc->gc_enabled && !gc->gc_active) { in pblk_gc_should_start()
580 struct pblk_gc *gc = &pblk->gc; in pblk_gc_should_stop() local
582 if (gc->gc_active && !gc->gc_forced) in pblk_gc_should_stop()
583 gc->gc_active = 0; in pblk_gc_should_stop()
594 struct pblk_gc *gc = &pblk->gc; in pblk_gc_sysfs_state_show() local
596 spin_lock(&gc->lock); in pblk_gc_sysfs_state_show()
597 *gc_enabled = gc->gc_enabled; in pblk_gc_sysfs_state_show()
598 *gc_active = gc->gc_active; in pblk_gc_sysfs_state_show()
599 spin_unlock(&gc->lock); in pblk_gc_sysfs_state_show()
604 struct pblk_gc *gc = &pblk->gc; in pblk_gc_sysfs_force() local
609 spin_lock(&gc->lock); in pblk_gc_sysfs_force()
610 gc->gc_forced = force; in pblk_gc_sysfs_force()
613 gc->gc_enabled = 1; in pblk_gc_sysfs_force()
615 gc->gc_enabled = 0; in pblk_gc_sysfs_force()
616 spin_unlock(&gc->lock); in pblk_gc_sysfs_force()
625 struct pblk_gc *gc = &pblk->gc; in pblk_gc_init() local
628 gc->gc_ts = kthread_create(pblk_gc_ts, pblk, "pblk-gc-ts"); in pblk_gc_init()
629 if (IS_ERR(gc->gc_ts)) { in pblk_gc_init()
630 pblk_err(pblk, "could not allocate GC main kthread\n"); in pblk_gc_init()
631 return PTR_ERR(gc->gc_ts); in pblk_gc_init()
634 gc->gc_writer_ts = kthread_create(pblk_gc_writer_ts, pblk, in pblk_gc_init()
635 "pblk-gc-writer-ts"); in pblk_gc_init()
636 if (IS_ERR(gc->gc_writer_ts)) { in pblk_gc_init()
637 pblk_err(pblk, "could not allocate GC writer kthread\n"); in pblk_gc_init()
638 ret = PTR_ERR(gc->gc_writer_ts); in pblk_gc_init()
642 gc->gc_reader_ts = kthread_create(pblk_gc_reader_ts, pblk, in pblk_gc_init()
643 "pblk-gc-reader-ts"); in pblk_gc_init()
644 if (IS_ERR(gc->gc_reader_ts)) { in pblk_gc_init()
645 pblk_err(pblk, "could not allocate GC reader kthread\n"); in pblk_gc_init()
646 ret = PTR_ERR(gc->gc_reader_ts); in pblk_gc_init()
650 timer_setup(&gc->gc_timer, pblk_gc_timer, 0); in pblk_gc_init()
651 mod_timer(&gc->gc_timer, jiffies + msecs_to_jiffies(GC_TIME_MSECS)); in pblk_gc_init()
653 gc->gc_active = 0; in pblk_gc_init()
654 gc->gc_forced = 0; in pblk_gc_init()
655 gc->gc_enabled = 1; in pblk_gc_init()
656 gc->w_entries = 0; in pblk_gc_init()
657 atomic_set(&gc->read_inflight_gc, 0); in pblk_gc_init()
658 atomic_set(&gc->pipeline_gc, 0); in pblk_gc_init()
661 * GC writer to be recycled. in pblk_gc_init()
663 gc->gc_line_reader_wq = alloc_workqueue("pblk-gc-line-reader-wq", in pblk_gc_init()
665 if (!gc->gc_line_reader_wq) { in pblk_gc_init()
666 pblk_err(pblk, "could not allocate GC line reader workqueue\n"); in pblk_gc_init()
671 /* Workqueue that prepare lines for GC */ in pblk_gc_init()
672 gc->gc_reader_wq = alloc_workqueue("pblk-gc-line_wq", in pblk_gc_init()
674 if (!gc->gc_reader_wq) { in pblk_gc_init()
675 pblk_err(pblk, "could not allocate GC reader workqueue\n"); in pblk_gc_init()
680 spin_lock_init(&gc->lock); in pblk_gc_init()
681 spin_lock_init(&gc->w_lock); in pblk_gc_init()
682 spin_lock_init(&gc->r_lock); in pblk_gc_init()
684 sema_init(&gc->gc_sem, PBLK_GC_RQ_QD); in pblk_gc_init()
686 INIT_LIST_HEAD(&gc->w_list); in pblk_gc_init()
687 INIT_LIST_HEAD(&gc->r_list); in pblk_gc_init()
692 destroy_workqueue(gc->gc_line_reader_wq); in pblk_gc_init()
694 kthread_stop(gc->gc_reader_ts); in pblk_gc_init()
696 kthread_stop(gc->gc_writer_ts); in pblk_gc_init()
698 kthread_stop(gc->gc_ts); in pblk_gc_init()
705 struct pblk_gc *gc = &pblk->gc; in pblk_gc_exit() local
707 gc->gc_enabled = 0; in pblk_gc_exit()
708 del_timer_sync(&gc->gc_timer); in pblk_gc_exit()
709 gc->gc_active = 0; in pblk_gc_exit()
711 if (gc->gc_ts) in pblk_gc_exit()
712 kthread_stop(gc->gc_ts); in pblk_gc_exit()
714 if (gc->gc_reader_ts) in pblk_gc_exit()
715 kthread_stop(gc->gc_reader_ts); in pblk_gc_exit()
718 flush_workqueue(gc->gc_reader_wq); in pblk_gc_exit()
719 flush_workqueue(gc->gc_line_reader_wq); in pblk_gc_exit()
722 destroy_workqueue(gc->gc_reader_wq); in pblk_gc_exit()
723 destroy_workqueue(gc->gc_line_reader_wq); in pblk_gc_exit()
725 if (gc->gc_writer_ts) in pblk_gc_exit()
726 kthread_stop(gc->gc_writer_ts); in pblk_gc_exit()