lkml.org 
[lkml]   [2015]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] null_blk: fix wrong capacity when bs is not 512 bytes
Date
set_capacity() sets device's capacity using 512 bytes sectors.
null_blk calculates the number of sectors by size / bs, which
set_capacity is called with. This led to null_blk exposing the
wrong number of sectors when bs is not 512 bytes.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
drivers/block/null_blk.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 6f9b753..bf8f764 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -588,8 +588,7 @@ static int null_add_dev(void)
blk_queue_physical_block_size(nullb->q, bs);

size = gb * 1024 * 1024 * 1024ULL;
- sector_div(size, bs);
- set_capacity(disk, size);
+ set_capacity(disk, size >> 9);

disk->flags |= GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO;
disk->major = null_major;
--
2.1.4


\
 
 \ /
  Last update: 2015-08-31 14:41    [W:0.174 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site