mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvme: fix write_stream_granularity initialization
@ 2025-05-06 17:54 Caleb Sander Mateos
  2025-05-06 19:09 ` Keith Busch
  2025-05-06 19:47 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Caleb Sander Mateos @ 2025-05-06 17:54 UTC (permalink / raw)
  To: Kanchan Joshi, Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
  Cc: Caleb Sander Mateos, linux-nvme, linux-kernel

write_stream_granularity is set to max(info->runs, U32_MAX), which means
that any RUNS value less than 2 ** 32 becomes U32_MAX, and any larger
value is silently truncated to an unsigned int.

Use min() instead to provide the correct semantics, capping RUNS values
at U32_MAX.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Fixes: 30b5f20bb2dd ("nvme: register fdp parameters with the block layer")
---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 52331a14bce1..a9fb8cd54420 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2390,11 +2390,11 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
 	if (!nvme_init_integrity(ns->head, &lim, info))
 		capacity = 0;
 
 	lim.max_write_streams = ns->head->nr_plids;
 	if (lim.max_write_streams)
-		lim.write_stream_granularity = max(info->runs, U32_MAX);
+		lim.write_stream_granularity = min(info->runs, U32_MAX);
 	else
 		lim.write_stream_granularity = 0;
 
 	ret = queue_limits_commit_update(ns->disk->queue, &lim);
 	if (ret) {
-- 
2.45.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: fix write_stream_granularity initialization
  2025-05-06 17:54 [PATCH] nvme: fix write_stream_granularity initialization Caleb Sander Mateos
@ 2025-05-06 19:09 ` Keith Busch
  2025-05-06 19:47 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2025-05-06 19:09 UTC (permalink / raw)
  To: Caleb Sander Mateos
  Cc: Kanchan Joshi, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	linux-nvme, linux-kernel

On Tue, May 06, 2025 at 11:54:12AM -0600, Caleb Sander Mateos wrote:
> write_stream_granularity is set to max(info->runs, U32_MAX), which means
> that any RUNS value less than 2 ** 32 becomes U32_MAX, and any larger
> value is silently truncated to an unsigned int.
> 
> Use min() instead to provide the correct semantics, capping RUNS values
> at U32_MAX.
> 
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> Fixes: 30b5f20bb2dd ("nvme: register fdp parameters with the block layer")

Looks good

Reviewed-by: Keith Busch <kbusch@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvme: fix write_stream_granularity initialization
  2025-05-06 17:54 [PATCH] nvme: fix write_stream_granularity initialization Caleb Sander Mateos
  2025-05-06 19:09 ` Keith Busch
@ 2025-05-06 19:47 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2025-05-06 19:47 UTC (permalink / raw)
  To: Kanchan Joshi, Keith Busch, Christoph Hellwig, Sagi Grimberg,
	Caleb Sander Mateos
  Cc: linux-nvme, linux-kernel


On Tue, 06 May 2025 11:54:12 -0600, Caleb Sander Mateos wrote:
> write_stream_granularity is set to max(info->runs, U32_MAX), which means
> that any RUNS value less than 2 ** 32 becomes U32_MAX, and any larger
> value is silently truncated to an unsigned int.
> 
> Use min() instead to provide the correct semantics, capping RUNS values
> at U32_MAX.
> 
> [...]

Applied, thanks!

[1/1] nvme: fix write_stream_granularity initialization
      commit: 86b6e0bd1a69efd0ed408997e0adfb85df96a0c7

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-06 19:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-06 17:54 [PATCH] nvme: fix write_stream_granularity initialization Caleb Sander Mateos
2025-05-06 19:09 ` Keith Busch
2025-05-06 19:47 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®