NVMe write protection support
Keith Busch
kbusch at kernel.org
Mon Aug 1 09:39:28 PDT 2022
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
> > > .
> > >
> > .
>
>
More information about the Linux-nvme
mailing list