Skip to content

Commit

Permalink
zram: Prevent overflow in logical block size
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Robert Jennings authored and Greg Kroah-Hartman committed Feb 4, 2011
1 parent f3bc232 commit 7b19b8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/staging/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions drivers/staging/zram/zram_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7b19b8d

Please sign in to comment.