From: Keith Busch <kbusch@kernel.org>
To: Chris S <coshi036@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Weidong Zhu <weizhu@fiu.edu>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] nvme: refuse an unsolicited format change on a namespace that is in use
Date: Tue, 11 Aug 2026 14:42:54 -0600 [thread overview]
Message-ID: <anuJTi4sZiCBuMzb@kbusch-mbp> (raw)
In-Reply-To: <CACd_6n1=oS_Jdq6s=u2jNmtP9n0Yc13BkKqJHSpsjbWHy=X5cA@mail.gmail.com>
On Tue, Aug 11, 2026 at 04:29:51PM -0400, Chris S wrote:
> On Tue, Aug 11, 2026 at 01:30:54PM -0600, Keith Busch wrote:
> > Refusing to acknowledge the new format doesn't mean you get to continue
> > using the old format. You're going to corrupt memory and data this way.
>
> You're right - the teardown is the problem, not the refusal.
>
> nvme_ns_remove() never sets GD_DEAD, so del_gendisk() takes the
> non-surprise path and asks the filesystem to write back. Those bios
> go through nvme_setup_rw() with the stale lba_shift. set_capacity(0)
> doesn't catch them on a partition, which keeps its own bd_nr_sectors.
>
> So it should mark the disk dead first and drop the cache instead:
>
> blk_mark_disk_dead(ns->disk);
> ret = NVME_SC_INVALID_NS | NVME_STATUS_DNR;
>
> Multipath needs more than that - the openers are on head->disk, and
> only the path gets removed.
>
> Is that the direction, or is refuse-and-remove wrong here to begin
> with?
You need a nvme spec level change for this to work. There's nothing we
can do today to close every race where the driver attempts to use a
stale LBA shift when the format was changed externally.
What I proposed in the past was that the device has to return a new
error code for all new IO until the host queries the appropriate
Namespace identification to acknowledge the new LBA format. Kind of like
a SCSI "Check Condition Parameters Changed". An enlightend host could
trigger a queue freeze and namespace rescan after seeing this status,
clearing the device's latch and resume IO after setting up the new queue
limits.
prev parent reply other threads:[~2026-08-11 20:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 19:21 [RFC PATCH] nvme: refuse an unsolicited format change on a namespace that is in use Chao Shi
2026-08-11 19:30 ` Keith Busch
2026-08-11 20:29 ` Chris S
2026-08-11 20:42 ` Keith Busch [this message]
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=anuJTi4sZiCBuMzb@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=axboe@kernel.dk \
--cc=coshi036@gmail.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=martin.petersen@oracle.com \
--cc=sagi@grimberg.me \
--cc=weizhu@fiu.edu \
/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