All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: "Matias Bjørling" <m@bjorling.me>
Cc: axboe@fb.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes
Date: Wed, 2 Sep 2015 12:42:33 -0600	[thread overview]
Message-ID: <20150902184233.GB32255@linux.intel.com> (raw)
In-Reply-To: <1441023451-17049-1-git-send-email-m@bjorling.me>

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>

  reply	other threads:[~2015-09-02 18:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-07-28 12:00 Matias Bjørling
2015-06-22 11:28 Matias Bjørling
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=20150902184233.GB32255@linux.intel.com \
    --to=ross.zwisler@linux.intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.