aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/null_blk.c
diff options
context:
space:
mode:
authorMatias Bjørling <m@bjorling.me>2015-08-31 14:17:31 +0200
committerJens Axboe <axboe@fb.com>2015-09-02 16:49:42 -0600
commit5fdb7e1b976dc9d18aff8c711e51d17c4c324a0e (patch)
tree599f29381b2aa817a069adbe1c5d84ef0e6c2995 /drivers/block/null_blk.c
parentnull_blk: fix memory leak on cleanup (diff)
downloadlinux-dev-5fdb7e1b976dc9d18aff8c711e51d17c4c324a0e.tar.xz
linux-dev-5fdb7e1b976dc9d18aff8c711e51d17c4c324a0e.zip
null_blk: fix wrong capacity when bs is not 512 bytes
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> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block/null_blk.c')
-rw-r--r--drivers/block/null_blk.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index d394a85aa92e..a295b98c6bae 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -589,8 +589,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;