On 10/10/23 16:15, Hannes Reinecke wrote: > On 10/10/23 08:48, Damien Le Moal wrote: >> On 10/9/23 15:15, Hannes Reinecke wrote: >>> On 10/9/23 02:56, charlesfdotz@xxxxxxxxxxxx wrote: >>>> Hello, >>>> >>>> I would like to request a new device manager layer be added that accepts >>>> trim requests for sectors and instead writes zeros to those sectors. >>>> >>>> This would be useful to deal with SMR (shingled magnetic recording) drives >>>> that do not support trim. Currently after an SMR drive has had enough data >>>> written to it the performance drops dramatically because the disk must >>>> shuffle around data as if it were full and without trim support there is no >>>> way to inform the disk which sectors are no longer used. Currently there's >>>> no way to "fix" or reset this without doing an ATA secure erase despite >>>> many of these disk being sold without informing customers that they were >>>> SMR drives (western digital was sued for selling SMR drives as NAS >>>> drives). >>>> >>> Gosh, no, please don't. SMR drives have a write pointer, and if the zone >>> needs to be reset you just reset the write pointer. Writing zeroes will >>> result in the opposite; the zone continues to be full, and no writes can >>> happen there. >> >> Yes. And zone reset *is* a trim also since after a zone reset, the sectors in >> the zone cannot be read. >> > On the same vein: why didn't we hook up 'wp reset' to trim/unmap? > The code says: > > if (sd_is_zoned(sdkp)) { > sd_config_discard(sdkp, SD_LBP_DISABLE); > return count; > } > > I distinctly remember to enable discards via 'wp reset' in the > original code; what happened to it? Hmmm... I do not recall exactly. I think it was all about being clear and to not overload trim/discard, or scsi unmap, which at the time was not the prettiest thing in scsi code (it got better though). But I do prefer having zone reset separate from trim/discard, to be clear about the fact that things are zone aligned. From the code perspective, there are only few places were overloading trim with zone reset would simplify a little the code. F2fs is probably the main one that comes to mind, but simplification would be minor. So not worth the confusion I think. > > Cheers, > > Hannes -- Damien Le Moal Western Digital Research