From: "Matias Bjørling" <mb@lightnvm.io>
To: axboe@fb.com, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: "Matias Bjørling" <m@bjorling.me>
Subject: [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes
Date: Tue, 28 Jul 2015 14:00:24 +0200 [thread overview]
Message-ID: <1438084824-29730-1-git-send-email-mb@lightnvm.io> (raw)
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
next reply other threads:[~2015-07-28 12:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 12:00 Matias Bjørling [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-08-31 12:17 [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes Matias Bjørling
2015-09-02 18:42 ` Ross Zwisler
2015-06-22 11:28 Matias Bjørling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438084824-29730-1-git-send-email-mb@lightnvm.io \
--to=mb@lightnvm.io \
--cc=axboe@fb.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m@bjorling.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).