Commit 9d2e59f2 authored by Quinn Tran's avatar Quinn Tran Committed by Nicholas Bellinger

target/rd: T10-Dif: RAM disk is allocating more space than required.

Ram disk is allocating 8x more space than required for diff data.
For large RAM disk test, there is small potential for memory
starvation.

(Use block_size when calculating total_sg_needed - sagi + nab)
Signed-off-by: default avatarGiridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: default avatarQuinn Tran <quinn.tran@qlogic.com>
Cc: <stable@vger.kernel.org> #3.14+
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent d444edc6
...@@ -242,7 +242,7 @@ static void rd_release_prot_space(struct rd_dev *rd_dev) ...@@ -242,7 +242,7 @@ static void rd_release_prot_space(struct rd_dev *rd_dev)
rd_dev->sg_prot_count = 0; rd_dev->sg_prot_count = 0;
} }
static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length) static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length, int block_size)
{ {
struct rd_dev_sg_table *sg_table; struct rd_dev_sg_table *sg_table;
u32 total_sg_needed, sg_tables; u32 total_sg_needed, sg_tables;
...@@ -252,8 +252,13 @@ static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length) ...@@ -252,8 +252,13 @@ static int rd_build_prot_space(struct rd_dev *rd_dev, int prot_length)
if (rd_dev->rd_flags & RDF_NULLIO) if (rd_dev->rd_flags & RDF_NULLIO)
return 0; return 0;
/*
total_sg_needed = rd_dev->rd_page_count / prot_length; * prot_length=8byte dif data
* tot sg needed = rd_page_count * (PGSZ/block_size) *
* (prot_length/block_size) + pad
* PGSZ canceled each other.
*/
total_sg_needed = (rd_dev->rd_page_count * prot_length / block_size) + 1;
sg_tables = (total_sg_needed / max_sg_per_table) + 1; sg_tables = (total_sg_needed / max_sg_per_table) + 1;
...@@ -606,7 +611,8 @@ static int rd_init_prot(struct se_device *dev) ...@@ -606,7 +611,8 @@ static int rd_init_prot(struct se_device *dev)
if (!dev->dev_attrib.pi_prot_type) if (!dev->dev_attrib.pi_prot_type)
return 0; return 0;
return rd_build_prot_space(rd_dev, dev->prot_length); return rd_build_prot_space(rd_dev, dev->prot_length,
dev->dev_attrib.block_size);
} }
static void rd_free_prot(struct se_device *dev) static void rd_free_prot(struct se_device *dev)
......
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