> Hi Renaud, > > On 13.01.25 15:03, Renaud Barbier wrote: > >> We do have ioctls on cdev in barebox, but we also have an actual > >> erase operation, so I prefer we use that instead. > > > > Below the option for sanitize command: > > # nvme sanitize --help > > Usage: nvme sanitize <device> [OPTIONS] > > > > Send a sanitize command. > > > > Options: > > [ --no-dealloc, -d ] --- No deallocate after sanitize. > > [ --oipbp, -i ] --- Overwrite invert pattern between > > passes. > > [ --owpass=<NUM>, -n <NUM> ] --- Overwrite pass count. > > [ --ause, -u ] --- Allow unrestricted sanitize exit. > > [ --sanact=<NUM>, -a <NUM> ] --- Sanitize action. > > [ --ovrpat=<NUM>, -p <NUM> ] --- Overwrite pattern. > > Thanks, I had looked in nvme(1), but I should have looked in nvme-sanitize(1) > instead. > > > Note I am talking about sanitize operation that is the whole device being > erased i.e there is no start and end block to be specified. > > So this is a single command that erases the whole device, but doesn't take > block offsets/length as arguments? Do you know what value the erased data > can have afterwards? Indeed. No block offset/length as far as I can see from libnvme and nvme-cli Linux commands I have added the erase entry point and ran the sanitize block erase command. This wiped out the whole device barebox@LS1046A RDB Board:/ md -s /dev/nvme0n1 00000000: 00000000 00000000 00000000 00000000 ................ 00000010: 00000000 00000000 00000000 00000000 ................ 00000020: 00000000 00000000 00000000 00000000 ................ 00000030: 00000000 00000000 00000000 00000000 ................ 00000040: 00000000 00000000 00000000 00000000 ................ 00000050: 00000000 00000000 00000000 00000000 ................ ... Whatever the offset I give, I get 0. > > > Using erase would limit sanitisation to erasing the whole media > > Isn't this what you want? Erase the whole device at once? Yes. My number one goal is reached. There maybe a requirement for pattern writing with several passes later. > Anyway, the erase command can be extended as needed to take offset/length > or to change erasure type. > > Currently erasing only part of the device is possible by adding calling erase on a > partition (perhaps allocated via addpart). > > > and no possibility to use the other options such as overwrite where a pattern > and a number of pass is specified. > > Generally, I prefer not to copy the Linux style of device-specific ioctl codes > unless necessary. > > For such very specific use cases, ioctl makes sense, yes. > > cdev already supports ioctl, but block device doesn't, so the natural step > would be to add struct block_device_ops::ioctl, which is called from struct > block_device::cdev::ioctl. > > I think we don't need that yet though, see below. > > > Unless a way can be added to set features for sanitize. > > At present, erase is all I need so I will add the erase entry point with the > sanitisation action being NVME_SANITIZE_SANACT_START_BLOCK_ERASE as > default. > > How about you implement erase in nvme, but check that size arguments > indeed describe the whole device: If it does, you do your sanitize operation > and if it doesn't, return -ENOSYS. > > Would that work for you? Perfect. Thanks. > > Cheers, > Ahmad > > > > > > > > > -- > Pengutronix e.K. | | > Steuerwalder Str. 21 | > https://urldefense.com/v3/__http://www.pengutronix.de/__;!!HKOSU0g!AUi > 6RmEZIZYR- > U1OlElGWJEdi0g1ZCeRGBk5zYyXFu6ifUk_2PdDAdTfmpe_cMMuA4dN5J9hJ3 > bQtQzKggqYiqQvkqc$ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |