public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Gilles BULOZ <gilles.buloz@kontron.com>
Cc: Chao Leng <lengchao@huawei.com>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: Re: NVMe write protection support
Date: Mon, 1 Aug 2022 10:39:28 -0600	[thread overview]
Message-ID: <YugBv1bYQMj4A9+m@kbusch-mbp> (raw)
In-Reply-To: <1070fdd5-c1bb-92bd-c5f0-9efd9d88d518@kontron.com>

On Mon, Aug 01, 2022 at 02:41:45PM +0200, Gilles BULOZ wrote:
> Thanks Chao for your suggestion : "Suggest: set the NSATTR of namespace to 1 when identify namespace."
> Also thanks to Andrey Kuzmin for his private reply : "It sounds like the
> kernel nvme subsystem is either ignoring or misinterpreting the status code
> returned by the controller in the write completion. Per spec, an attempt to
> write to a write-protected namespace must be declined with 'Namespace is
> Write Protected' status code (see Nvme Command Set Spec. Fig. 67 for
> details) which, apparently, isn't critical wrt the device itself."
> I'll check all this with our NVMe manufacturer

The driver doesn't do anything special with the "Namespace is Write Protected",
status so that should get a generic IO Error if the device was returning that.

The driver will currently return a Medium error block status if we get a
"Attempted Write to Read Only Range" nvme status, though. Maybe that would make
more sense as a target error.

 
> Le 01/08/2022 à 12:01, Chao Leng a écrit :
> > 
> > On 2022/8/1 16:36, Gilles Buloz wrote:
> > > Dear developers,
> > > In case an NVMe module has a write protection feature, what is the
> > > best  method for the NVMe to tell the kernel it is write protected
> > > (if any),  and how the kernel should handle a write to such a module
> > > ?
> > Suggest: set the NSATTR of namespace to 1 when identify namespace.
> > > As computer manufacturers, we had a request from some customers to
> > > have the NVMe module fully write protected (fpr safety). So we asked
> > > our NVMe manufacturer partner to add thiss feature to their NVMe.
> > > But the problem is that if a write is done to this module while it
> > > is write protected, the kernel treats it as "critical medium error"
> > > (giving something like this in the dmesg : blk_update_request:
> > > critical medium error, dev nvme0n1, sector 977537456 op 0x1:(WRITE)
> > > flags 0x800 phys_seg
> > >   2 prio class 0).
> > > OK, no write should be attempted if the write protection is enabled,
> > > but this critical medium error is maybe too much because the disk is
> > > actually not damaged and read is still possible.
> > > For SATA devices I see that we have a message like that in dmesg :
> > > "sd 6:0:0:0: [sdb] Write Protect is off", but nothing like this for
> > > NVMe. So maybe the write protection is not supported/expected for
> > > NVMe devices ?
> > > Thanks
> > > .
> > > 
> > .
> 
> 


  reply	other threads:[~2022-08-01 16:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01  8:36 NVMe write protection support Gilles Buloz
2022-08-01 10:01 ` Chao Leng
2022-08-01 12:41   ` Gilles BULOZ
2022-08-01 16:39     ` Keith Busch [this message]
2022-08-01 18:34 ` Christoph Hellwig
2022-08-02  9:20   ` Gilles Buloz
2022-08-06  8:35     ` Christoph Hellwig
2022-08-25  8:26       ` Gilles Buloz
2022-08-26 19:39         ` Jonathan Derrick
2022-08-26 19:40           ` Jonathan Derrick
2022-09-13 17:17             ` Gilles BULOZ
2022-09-19 14:59               ` Christoph Hellwig
2022-09-30 17:49                 ` Gilles BULOZ
2022-10-03  6:24                   ` Christoph Hellwig
2022-10-20 17:31                     ` Gilles BULOZ

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=YugBv1bYQMj4A9+m@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=gilles.buloz@kontron.com \
    --cc=lengchao@huawei.com \
    --cc=linux-nvme@lists.infradead.org \
    /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