On 3/29/2014 2:05 AM, Quinn Tran wrote:
Ram disk is allocating 8x more space than required for diff data.
For large RAM disk test, there is small potential for memory
starvation.

Signed-off-by: Nicholas Bellinger <n...@linux-iscsi.org>
Signed-off-by: Giridhar Malavali <giridhar.malav...@qlogic.com>
---
  drivers/target/target_core_rd.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index 01dda0b..6df177a 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -253,7 +253,11 @@ static int rd_build_prot_space(struct rd_dev *rd_dev, int 
prot_length)
        if (rd_dev->rd_flags & RDF_NULLIO)
                return 0;
- total_sg_needed = rd_dev->rd_page_count / prot_length;
+       /* prot_length=8byte dif data
+        * tot sg needed = rd_page_count * (PGSZ/512) * (prot_length/PGSZ) + pad
+        * PGSZ canceled each other.
+        */
+       total_sg_needed = (rd_dev->rd_page_count * prot_length / 512) +1;

You probably will want to use block_size instead of hard-coding 512.
Other then that this makes sense.

sg_tables = (total_sg_needed / max_sg_per_table) + 1;

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to