All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Wouter Verhelst <w@uter.be>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, nbd@other.debian.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] nbd: correct the maximum value for discard sectors
Date: Wed, 7 Aug 2024 09:56:25 -0400	[thread overview]
Message-ID: <20240807135625.GA242945@perftesting> (raw)
In-Reply-To: <20240806133058.268058-3-w@uter.be>

On Tue, Aug 06, 2024 at 03:30:56PM +0200, Wouter Verhelst wrote:
> The version of the NBD protocol implemented by the kernel driver
> currently has a 32 bit field for length values. As the NBD protocol uses
> bytes as a unit of length, length values larger than 2^32 bytes cannot
> be expressed.
> 
> Update the max_hw_discard_sectors field to match that.
> 
> Signed-off-by: Wouter Verhelst <w@uter.be>
> Fixes: 268283244c0f018dec8bf4a9c69ce50684561f46
> ---
>  drivers/block/nbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 20e9f9fdeaae..1457f0c8a4a4 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -339,7 +339,7 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
>  
>  	lim = queue_limits_start_update(nbd->disk->queue);
>  	if (nbd->config->flags & NBD_FLAG_SEND_TRIM)
> -		lim.max_hw_discard_sectors = UINT_MAX;
> +		lim.max_hw_discard_sectors = UINT_MAX / blksize;

We use 512 as the "sectors" measurement throughout the block layer, so our limit
is actually

UINT32_MAX >> 9

since we can only send at most UINT32_MAX as our length.  Fix it to be that for
both patches and you should be good.  Thanks,

Josef

  reply	other threads:[~2024-08-07 13:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-03 13:04 [PATCH 1/2] nbd: implement the WRITE_ZEROES command Wouter Verhelst
2024-08-03 13:04 ` [PATCH 2/2] nbd: nbd_bg_flags_show: add NBD_FLAG_ROTATIONAL Wouter Verhelst
2024-08-05 12:52 ` [PATCH 1/2] nbd: implement the WRITE_ZEROES command Eric Blake
2024-08-06  7:49   ` Wouter Verhelst
2024-08-06 13:30 ` [PATCH v2 1/3] " Wouter Verhelst
2024-08-06 13:30   ` [PATCH v2 2/3] nbd: nbd_bg_flags_show: add NBD_FLAG_ROTATIONAL Wouter Verhelst
2024-08-06 13:30   ` [PATCH v2 3/3] nbd: correct the maximum value for discard sectors Wouter Verhelst
2024-08-07 13:56     ` Josef Bacik [this message]
2024-08-07 17:20       ` Damien Le Moal
2024-08-08  6:55       ` Wouter Verhelst
2024-08-08  7:06 ` [PATCH v3 1/3] nbd: implement the WRITE_ZEROES command Wouter Verhelst
2024-08-08  7:06   ` [PATCH v3 2/3] nbd: nbd_bg_flags_show: add NBD_FLAG_ROTATIONAL Wouter Verhelst
2024-08-08  7:06   ` [PATCH v3 3/3] nbd: correct the maximum value for discard sectors Wouter Verhelst
2024-08-09 15:22     ` Damien Le Moal
2024-08-09 15:34     ` Jens Axboe
2024-08-12 13:20       ` Wouter Verhelst

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=20240807135625.GA242945@perftesting \
    --to=josef@toxicpanda.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nbd@other.debian.org \
    --cc=w@uter.be \
    /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.