diff options
author | Hans Holmberg <hans.holmberg@cnexlabs.com> | 2018-10-09 07:11:47 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-10-09 10:25:07 -0400 |
commit | 53d82db693fe1fd1926066583fd24285fb5aae16 (patch) | |
tree | bd4d71e87e1168ceeb11d922617119382f534350 /drivers/lightnvm/pblk-init.c | |
parent | d68a9344041b6dd304ff382d0c7805869f09944f (diff) |
lightnvm: pblk: allocate line map bitmaps using a mempool
Line map bitmap allocations are fairly large and can fail. Allocation
failures are fatal to pblk, stopping the write pipeline. To avoid this,
allocate the bitmaps using a mempool instead.
Mempool allocations never fail if called from a process context,
and pblk *should* only allocate map bitmaps in process context,
but keep the failure handling for robustness sake.
Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r-- | drivers/lightnvm/pblk-init.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 8adc8ac8b03c..76a4a271b9cf 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c | |||
@@ -498,6 +498,9 @@ static void pblk_line_mg_free(struct pblk *pblk) | |||
498 | pblk_mfree(l_mg->eline_meta[i]->buf, l_mg->emeta_alloc_type); | 498 | pblk_mfree(l_mg->eline_meta[i]->buf, l_mg->emeta_alloc_type); |
499 | kfree(l_mg->eline_meta[i]); | 499 | kfree(l_mg->eline_meta[i]); |
500 | } | 500 | } |
501 | |||
502 | mempool_destroy(l_mg->bitmap_pool); | ||
503 | kmem_cache_destroy(l_mg->bitmap_cache); | ||
501 | } | 504 | } |
502 | 505 | ||
503 | static void pblk_line_meta_free(struct pblk_line_mgmt *l_mg, | 506 | static void pblk_line_meta_free(struct pblk_line_mgmt *l_mg, |
@@ -797,6 +800,17 @@ static int pblk_line_mg_init(struct pblk *pblk) | |||
797 | goto fail_free_smeta; | 800 | goto fail_free_smeta; |
798 | } | 801 | } |
799 | 802 | ||
803 | l_mg->bitmap_cache = kmem_cache_create("pblk_lm_bitmap", | ||
804 | lm->sec_bitmap_len, 0, 0, NULL); | ||
805 | if (!l_mg->bitmap_cache) | ||
806 | goto fail_free_smeta; | ||
807 | |||
808 | /* the bitmap pool is used for both valid and map bitmaps */ | ||
809 | l_mg->bitmap_pool = mempool_create_slab_pool(PBLK_DATA_LINES * 2, | ||
810 | l_mg->bitmap_cache); | ||
811 | if (!l_mg->bitmap_pool) | ||
812 | goto fail_destroy_bitmap_cache; | ||
813 | |||
800 | /* emeta allocates three different buffers for managing metadata with | 814 | /* emeta allocates three different buffers for managing metadata with |
801 | * in-memory and in-media layouts | 815 | * in-memory and in-media layouts |
802 | */ | 816 | */ |
@@ -849,6 +863,10 @@ fail_free_emeta: | |||
849 | kfree(l_mg->eline_meta[i]->buf); | 863 | kfree(l_mg->eline_meta[i]->buf); |
850 | kfree(l_mg->eline_meta[i]); | 864 | kfree(l_mg->eline_meta[i]); |
851 | } | 865 | } |
866 | |||
867 | mempool_destroy(l_mg->bitmap_pool); | ||
868 | fail_destroy_bitmap_cache: | ||
869 | kmem_cache_destroy(l_mg->bitmap_cache); | ||
852 | fail_free_smeta: | 870 | fail_free_smeta: |
853 | for (i = 0; i < PBLK_DATA_LINES; i++) | 871 | for (i = 0; i < PBLK_DATA_LINES; i++) |
854 | kfree(l_mg->sline_meta[i]); | 872 | kfree(l_mg->sline_meta[i]); |