Commit 03661b5f authored by Hans Holmberg's avatar Hans Holmberg Committed by Jens Axboe

lightnvm: pblk: start gc if needed during init

Start GC if needed, directly after init, as we might
need to garbage collect in order to make room for user writes.

Create a helper function that allows to kick GC without exposing the
internals of the GC/rate-limiter interaction.
Signed-off-by: default avatarHans Holmberg <hans.holmberg@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <m@bjorling.me>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 37ce33d5
...@@ -510,6 +510,11 @@ void pblk_gc_should_stop(struct pblk *pblk) ...@@ -510,6 +510,11 @@ void pblk_gc_should_stop(struct pblk *pblk)
pblk_gc_stop(pblk, 0); pblk_gc_stop(pblk, 0);
} }
void pblk_gc_should_kick(struct pblk *pblk)
{
pblk_rl_update_rates(&pblk->rl);
}
void pblk_gc_sysfs_state_show(struct pblk *pblk, int *gc_enabled, void pblk_gc_sysfs_state_show(struct pblk *pblk, int *gc_enabled,
int *gc_active) int *gc_active)
{ {
......
...@@ -1025,6 +1025,10 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, ...@@ -1025,6 +1025,10 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
pblk->rwb.nr_entries); pblk->rwb.nr_entries);
wake_up_process(pblk->writer_ts); wake_up_process(pblk->writer_ts);
/* Check if we need to start GC */
pblk_gc_should_kick(pblk);
return pblk; return pblk;
fail_stop_writer: fail_stop_writer:
......
...@@ -96,7 +96,7 @@ unsigned long pblk_rl_nr_free_blks(struct pblk_rl *rl) ...@@ -96,7 +96,7 @@ unsigned long pblk_rl_nr_free_blks(struct pblk_rl *rl)
* *
* Only the total number of free blocks is used to configure the rate limiter. * Only the total number of free blocks is used to configure the rate limiter.
*/ */
static void pblk_rl_update_rates(struct pblk_rl *rl) void pblk_rl_update_rates(struct pblk_rl *rl)
{ {
struct pblk *pblk = container_of(rl, struct pblk, rl); struct pblk *pblk = container_of(rl, struct pblk, rl);
unsigned long free_blocks = pblk_rl_nr_free_blks(rl); unsigned long free_blocks = pblk_rl_nr_free_blks(rl);
......
...@@ -830,6 +830,7 @@ int pblk_gc_init(struct pblk *pblk); ...@@ -830,6 +830,7 @@ int pblk_gc_init(struct pblk *pblk);
void pblk_gc_exit(struct pblk *pblk); void pblk_gc_exit(struct pblk *pblk);
void pblk_gc_should_start(struct pblk *pblk); void pblk_gc_should_start(struct pblk *pblk);
void pblk_gc_should_stop(struct pblk *pblk); void pblk_gc_should_stop(struct pblk *pblk);
void pblk_gc_should_kick(struct pblk *pblk);
void pblk_gc_kick(struct pblk *pblk); void pblk_gc_kick(struct pblk *pblk);
void pblk_gc_free_full_lines(struct pblk *pblk); void pblk_gc_free_full_lines(struct pblk *pblk);
void pblk_gc_sysfs_state_show(struct pblk *pblk, int *gc_enabled, void pblk_gc_sysfs_state_show(struct pblk *pblk, int *gc_enabled,
...@@ -841,6 +842,7 @@ int pblk_gc_sysfs_force(struct pblk *pblk, int force); ...@@ -841,6 +842,7 @@ int pblk_gc_sysfs_force(struct pblk *pblk, int force);
*/ */
void pblk_rl_init(struct pblk_rl *rl, int budget); void pblk_rl_init(struct pblk_rl *rl, int budget);
void pblk_rl_free(struct pblk_rl *rl); void pblk_rl_free(struct pblk_rl *rl);
void pblk_rl_update_rates(struct pblk_rl *rl);
int pblk_rl_high_thrs(struct pblk_rl *rl); int pblk_rl_high_thrs(struct pblk_rl *rl);
int pblk_rl_low_thrs(struct pblk_rl *rl); int pblk_rl_low_thrs(struct pblk_rl *rl);
unsigned long pblk_rl_nr_free_blks(struct pblk_rl *rl); unsigned long pblk_rl_nr_free_blks(struct pblk_rl *rl);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment