From: Mike Christie <[email protected]>

max_discard_sectors and block_size are 32 bits, so we can
overflow when trying to convert between the linux block
layer max discard sectors and the LIO value.

This fixes a regression caused by this patch:

commit 8a9ebe717a133ba7bc90b06047f43cc6b8bcb8b3
Author: Mike Christie <[email protected]>
Date:   Mon Jan 18 14:09:27 2016 -0600

    target: Fix WRITE_SAME/DISCARD conversion to linux 512b sectors

where you will get smaller and extra discards due to the max size
being shortened.


Signed-off-by: Mike Christie <[email protected]>
Cc: [email protected]

---
 drivers/target/target_core_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_device.c 
b/drivers/target/target_core_device.c
index a4046ca..3f9f304 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -826,8 +826,8 @@ bool target_configure_unmap_from_queue(struct se_dev_attrib 
*attrib,
        if (!blk_queue_discard(q))
                return false;
 
-       attrib->max_unmap_lba_count = (q->limits.max_discard_sectors << 9) /
-                                                               block_size;
+       attrib->max_unmap_lba_count =
+                       ((u64)q->limits.max_discard_sectors << 9) / block_size;
        /*
         * Currently hardcoded to 1 in Linux/SCSI code..
         */
-- 
2.7.2

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

Reply via email to