Commit b6279f82 authored by Mike Snitzer's avatar Mike Snitzer

dm bio prison v1: intelligently size dm_bio_prison's prison_regions

Size the dm_bio_prison's number of prison_region structs using
dm_num_hash_locks().
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent c6273411
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
#define NR_LOCKS 64
#define MIN_CELLS 1024 #define MIN_CELLS 1024
struct prison_region { struct prison_region {
...@@ -27,7 +26,7 @@ struct prison_region { ...@@ -27,7 +26,7 @@ struct prison_region {
struct dm_bio_prison { struct dm_bio_prison {
mempool_t cell_pool; mempool_t cell_pool;
unsigned int num_locks; unsigned int num_locks;
struct prison_region regions[NR_LOCKS]; struct prison_region regions[];
}; };
static struct kmem_cache *_cell_cache; static struct kmem_cache *_cell_cache;
...@@ -41,12 +40,14 @@ static struct kmem_cache *_cell_cache; ...@@ -41,12 +40,14 @@ static struct kmem_cache *_cell_cache;
struct dm_bio_prison *dm_bio_prison_create(void) struct dm_bio_prison *dm_bio_prison_create(void)
{ {
int ret; int ret;
unsigned i; unsigned int i, num_locks;
struct dm_bio_prison *prison = kzalloc(sizeof(*prison), GFP_KERNEL); struct dm_bio_prison *prison;
num_locks = dm_num_hash_locks();
prison = kzalloc(struct_size(prison, regions, num_locks), GFP_KERNEL);
if (!prison) if (!prison)
return NULL; return NULL;
prison->num_locks = NR_LOCKS; prison->num_locks = num_locks;
for (i = 0; i < prison->num_locks; i++) { for (i = 0; i < prison->num_locks; i++) {
spin_lock_init(&prison->regions[i].lock); spin_lock_init(&prison->regions[i].lock);
......
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