From efa58397a991864ca8564f194e0414cf6ef4bed9 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 4 Jun 2010 12:37:14 +0000 Subject: [PATCH] Minor max_transfer fixes git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1741 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index ef8026911..b62fba203 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1363,16 +1363,18 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) } else if ((0xB0 == cmd->cdb[2]) && (virt_dev->dev->type == TYPE_DISK)) { /* block limits */ + int max_transfer; buf[1] = 0xB0; buf[3] = 0x1C; /* Optimal transfer granuality is PAGE_SIZE */ put_unaligned(cpu_to_be16(max_t(int, PAGE_SIZE/virt_dev->block_size, 1)), - (uint16_t *)&buf[6]); + (uint16_t *)&buf[6]); /* Max transfer len is min of sg limit and 8M */ - put_unaligned(cpu_to_be32(min_t(int, + max_transfer = min_t(int, cmd->tgt_dev->max_sg_cnt << PAGE_SHIFT, - 8*1024*1024) / virt_dev->block_size), + 8*1024*1024) / virt_dev->block_size; + put_unaligned(cpu_to_be32(max_transfer), (uint32_t *)&buf[8]); /* * Let's have optimal transfer len 1MB. Better to not @@ -1381,9 +1383,10 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) * From other side, too big transfers are not optimal, * because SGV cache supports only <4M buffers. */ - put_unaligned(cpu_to_be32( - 1*1024*1024 / virt_dev->block_size), - (uint32_t *)&buf[12]); + put_unaligned(cpu_to_be32(min_t(int, + max_transfer, + 1*1024*1024 / virt_dev->block_size)), + (uint32_t *)&buf[12]); resp_len = buf[3] + 4; } else { TRACE_DBG("INQUIRY: Unsupported EVPD page %x",