* [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes
@ 2015-06-22 11:28 Matias Bjørling
0 siblings, 0 replies; 4+ messages in thread
From: Matias Bjørling @ 2015-06-22 11:28 UTC (permalink / raw)
To: axboe, linux-fsdevel, linux-kernel; +Cc: Matias Bjørling
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
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes
@ 2015-07-28 12:00 Matias Bjørling
0 siblings, 0 replies; 4+ messages in thread
From: Matias Bjørling @ 2015-07-28 12:00 UTC (permalink / raw)
To: axboe, linux-fsdevel, linux-kernel; +Cc: Matias Bjørling
From: Matias Bjørling <m@bjorling.me>
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes
@ 2015-08-31 12:17 Matias Bjørling
2015-09-02 18:42 ` Ross Zwisler
0 siblings, 1 reply; 4+ messages in thread
From: Matias Bjørling @ 2015-08-31 12:17 UTC (permalink / raw)
To: axboe, linux-fsdevel, linux-kernel; +Cc: Matias Bjørling
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes
2015-08-31 12:17 Matias Bjørling
@ 2015-09-02 18:42 ` Ross Zwisler
0 siblings, 0 replies; 4+ messages in thread
From: Ross Zwisler @ 2015-09-02 18:42 UTC (permalink / raw)
To: Matias Bjørling; +Cc: axboe, linux-fsdevel, linux-kernel
On Mon, Aug 31, 2015 at 02:17:31PM +0200, Matias Bjørling wrote:
> 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;
Looks correct.
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-02 18:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28 12:00 [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes Matias Bjørling
-- strict thread matches above, loose matches on Subject: below --
2015-08-31 12:17 Matias Bjørling
2015-09-02 18:42 ` Ross Zwisler
2015-06-22 11:28 Matias Bjørling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).