[dm-6.4 PATCH v3 20/20] dm bio prison v1: intelligently size dm_bio_prison's prison_regions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Size the dm_bio_prison's number of prison_region structs using
dm_num_sharded_locks().

Signed-off-by: Mike Snitzer <snitzer@xxxxxxxxxx>
---
 drivers/md/dm-bio-prison-v1.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-bio-prison-v1.c b/drivers/md/dm-bio-prison-v1.c
index a7930ad1878b..1d560a83b144 100644
--- a/drivers/md/dm-bio-prison-v1.c
+++ b/drivers/md/dm-bio-prison-v1.c
@@ -16,7 +16,6 @@
 
 /*----------------------------------------------------------------*/
 
-#define NR_LOCKS 64
 #define MIN_CELLS 1024
 
 struct prison_region {
@@ -27,7 +26,7 @@ struct prison_region {
 struct dm_bio_prison {
 	mempool_t cell_pool;
 	unsigned int num_locks;
-	struct prison_region regions[NR_LOCKS];
+	struct prison_region regions[];
 };
 
 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)
 {
 	int ret;
-	unsigned i;
-	struct dm_bio_prison *prison = kzalloc(sizeof(*prison), GFP_KERNEL);
+	unsigned int i, num_locks;
+	struct dm_bio_prison *prison;
 
+	num_locks = dm_num_sharded_locks();
+	prison = kzalloc(struct_size(prison, regions, num_locks), GFP_KERNEL);
 	if (!prison)
 		return NULL;
-	prison->num_locks = NR_LOCKS;
+	prison->num_locks = num_locks;
 
 	for (i = 0; i < prison->num_locks; i++) {
 		spin_lock_init(&prison->regions[i].lock);
-- 
2.40.0




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux