mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Renaud Barbier <Renaud.Barbier@ametek.com>,
	Barebox List <barebox@lists.infradead.org>
Subject: Re: nvme sanitize command
Date: Mon, 13 Jan 2025 12:18:18 +0100	[thread overview]
Message-ID: <28c492e7-028f-4247-be7f-3edf699578fa@pengutronix.de> (raw)
In-Reply-To: <DM5PR07MB3532BD01391995069161C80BEC1F2@DM5PR07MB3532.namprd07.prod.outlook.com>

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@pengutronix.de/

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 |



  reply	other threads:[~2025-01-13 11:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 10:57 Renaud Barbier
2025-01-13 11:18 ` Ahmad Fatoum [this message]
2025-01-13 14:03   ` Renaud Barbier
2025-01-13 14:36     ` Ahmad Fatoum
2025-01-13 15:04       ` Renaud Barbier
2025-01-13 15:36         ` Ahmad Fatoum

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=28c492e7-028f-4247-be7f-3edf699578fa@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=Renaud.Barbier@ametek.com \
    --cc=barebox@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