All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-block@vger.kernel.org, linux-nvme@lists.infradead.org
Subject: [PATCH 3/3] nvme: don't set io_opt if NOWS is zero
Date: Mon,  1 Jul 2024 07:17:52 +0200	[thread overview]
Message-ID: <20240701051800.1245240-4-hch@lst.de> (raw)
In-Reply-To: <20240701051800.1245240-1-hch@lst.de>

NOWS is one of the annoying "0's based values" in NVMe, where 0 means one
and we thus can't detect if it isn't set.  Thus a NOWS value of 0 means
that the Namespace Optimal Write Size is a single LBA, which is clearly
bogus.  Ignore the value in that case and don't propagate an io_opt
value to the block layer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ab0429644fe378..6784fc6e95625e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2025,7 +2025,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id,
 		/* NPWG = Namespace Preferred Write Granularity */
 		phys_bs = bs * (1 + le16_to_cpu(id->npwg));
 		/* NOWS = Namespace Optimal Write Size */
-		io_opt = bs * (1 + le16_to_cpu(id->nows));
+		if (id->nows)
+			io_opt = bs * (1 + le16_to_cpu(id->nows));
 	}
 
 	/*
-- 
2.43.0


  parent reply	other threads:[~2024-07-01  5:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240701073115epcas5p3e2758375e272cba80281fe0ac37394d0@epcas5p3.samsung.com>
2024-07-01  5:17 ` io_opt fixups Christoph Hellwig
2024-07-01  5:17   ` [PATCH 1/3] block: remove a duplicate io_min check in blk_validate_limits Christoph Hellwig
2024-07-01  6:37     ` Chaitanya Kulkarni
2024-07-01  7:06     ` Sagi Grimberg
2024-07-01  5:17   ` [PATCH 2/3] block: don't reduce max_sectors based on io_opt Christoph Hellwig
2024-07-01  6:42     ` Chaitanya Kulkarni
2024-07-01  7:08     ` Sagi Grimberg
2024-07-01  5:17   ` Christoph Hellwig [this message]
2024-07-01  7:02     ` [PATCH 3/3] nvme: don't set io_opt if NOWS is zero Chaitanya Kulkarni
2024-07-01  7:08     ` Sagi Grimberg
2024-07-01 13:55     ` Keith Busch
2024-07-01 15:11       ` Christoph Hellwig
2024-07-01  7:24   ` io_opt fixups Nitesh Shetty
2024-07-01 10:22   ` Johannes Thumshirn
2024-07-01 12:53   ` Jens Axboe

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=20240701051800.1245240-4-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    --cc=sagi@grimberg.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.