Re: nvme sanitize command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Renaud,

On 13.01.25 11:57, Renaud Barbier wrote:
> I would like to add a nvme sanitize command to the barebox. Something like "nvme sanitize" where at first the only option is block erase.

That would indeed be useful to have.

> I have a level of understanding on how admin commands are passed to the device through the /drivers/nvme/host/[core.c|pci.c.]
> Looking at the parted command, I am not sure how it goes from the command call to the partition layer support (EFI or DOS) to the driver.
> 
> I see that Linux make use of an ioctl to trigger the sanitize command. 

We do have ioctls on cdev in barebox, but we also have an actual erase
operation, so I prefer we use that instead.

> How would you approach the introduction of this new command?
> Any help is appreciated.

I did something similar recently with SD/MMC[1], which also have special commands for
erase.

In short, I would suggest you extend nvme_block_device_ops in drivers/nvme/host/core.c
with a new .erase operation and use that instead of creating a new ioctl.

Erasure is then possible manually via the erase command.

As second step, we can then discuss if we should call it automatically before
partition table write.

Note that the erasure types supported by barebox are currently:

  ERASE_TO_WRITE: Mainly applicable to raw flash
  ERASE_TO_CLEAR: Reading will return a fixed pattern and not any stale data

You may want to add a third option:

  ERASE_TO_DISCARD: A hint to the storage medium that we don't care for the data
                    in the erased region and reads from that region are allowed to
                    return arbitrary values until written again.
                    Useful for wear leveling.

I suspect that last erase type is what you are interested in (perhaps with a better
name?)

[1]: https://lore.barebox.org/barebox/20240731080510.364706-1-a.fatoum@xxxxxxxxxxxxxx/

Cheers,
Ahmad

> 
> Renaud
> 
> 
> 
> 
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux