max_discard_sectors can not be larger than UINT_MAX>>9,
otherwise, there is a risk that discard requests would be merged
into a request larger than 4GB.

Signed-off-by: Gwendal Grignou <gwen...@chromium.org>
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 2dc3b51..f30128b 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -859,7 +859,7 @@ static int __init nbd_init(void)
                 */
                queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue);
                disk->queue->limits.discard_granularity = 512;
-               disk->queue->limits.max_discard_sectors = UINT_MAX;
+               disk->queue->limits.max_discard_sectors = UINT_MAX >> 9;
                disk->queue->limits.discard_zeroes_data = 0;
                blk_queue_max_hw_sectors(disk->queue, 65536);
                disk->queue->limits.max_sectors = 256;
-- 
1.9.1.423.g4596e3a

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

Reply via email to