zram: Prevent overflow in logical block size
authorRobert Jennings <rcj@linux.vnet.ibm.com>
Fri, 28 Jan 2011 14:58:17 +0000 (08:58 -0600)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 4 Feb 2011 21:29:11 +0000 (13:29 -0800)
On a 64K page kernel, the value PAGE_SIZE passed to
blk_queue_logical_block_size would overflow the logical block size
argument (resulting in setting it to 0).

This patch sets the logical block size to 4096, using a new
ZRAM_LOGICAL_BLOCK_SIZE constant.

Signed-off-by: Robert Jennings <rcj@linux.vnet.ibm.com>
Reviewed-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/zram/zram_drv.c
drivers/staging/zram/zram_drv.h

index 5ed4e75dc21890d167dd38692d740f78a8836e5f..3c8ecab70e97b6ae6322808f0cd63a8dd7454751 100644 (file)
@@ -616,7 +616,8 @@ static int create_device(struct zram *zram, int device_id)
         * and n*PAGE_SIZED sized I/O requests.
         */
        blk_queue_physical_block_size(zram->disk->queue, PAGE_SIZE);
-       blk_queue_logical_block_size(zram->disk->queue, PAGE_SIZE);
+       blk_queue_logical_block_size(zram->disk->queue,
+                                       ZRAM_LOGICAL_BLOCK_SIZE);
        blk_queue_io_min(zram->disk->queue, PAGE_SIZE);
        blk_queue_io_opt(zram->disk->queue, PAGE_SIZE);
 
index a48155112b1e68a736cd8018f0b504860e20b8c3..408b2c067fc9c2532f4ac2de7cdae0ba1cd616ee 100644 (file)
@@ -61,6 +61,7 @@ static const unsigned max_zpage_size = PAGE_SIZE / 4 * 3;
 #define SECTOR_SIZE            (1 << SECTOR_SHIFT)
 #define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
 #define SECTORS_PER_PAGE       (1 << SECTORS_PER_PAGE_SHIFT)
+#define ZRAM_LOGICAL_BLOCK_SIZE        4096
 
 /* Flags for zram pages (table[page_no].flags) */
 enum zram_pageflags {