Research notes / Block semantics
Discard is not zeroing: what TRIM, UNMAP and fstrim actually promise
Published 11 October 2026 · Updated 9 November 2026 · Source review and offline fixtures, not a device benchmark
Discard says that logical ranges are no longer needed. It does not, by itself, establish zero-filled reads, recovered physical capacity or sanitization. Each of those claims needs different evidence.
On this page16 sections
Related operations, different contracts
For a practical introduction and an evidence checklist, start with the TRIM technology card.
Do not treat protocol names as aliases. The sg3_utils manual identifies UNMAP as a SCSI logical-block-provisioning command and relates it to ATA DATA SET MANAGEMENT with Trim. SCSI WRITE SAME can also request unmapping. The shared purpose does not make the command encodings or capabilities interchangeable. [1]
| Operation | What it addresses | What not to infer |
|---|---|---|
| ATA TRIM / SCSI UNMAP | Protocol-specific block deallocation | Interchangeable commands or a physical erase certificate |
| Filesystem fstrim | Unused filesystem ranges eligible for discard | Newly recovered physical bytes |
| Ordinary blkdiscard | Selected device ranges, potentially the entire device | A safe probe or a zero-fill request |
| blkdiscard zeroout | Zero-filling instead of ordinary discard | Removal of every hidden old copy |
The last two rows are deliberately separate: util-linux documents zeroout and secure discard as distinct options. Secure discard requires device support and covers garbage-collection copies. Direct block discard can destroy live data; filesystem-aware selection and direct device access are not interchangeable workflows. No destructive command is needed to understand these distinctions. [6]
NVMe: request acceptance is not the read contract
In NVMe 1.4a, Dataset Management is advisory: ranges may remain allocated. For actually deallocated blocks, DLFEAT identifies read values; supported and enabled DULBE can instead require a deallocated/unwritten-block error. With that error disabled, section 6.7.1.1 specifies zeros, FFh bytes, or either pattern according to DLFEAT. A deterministic value is not necessarily zero. These rules apply to that cited revision and state, not every successful discard request. [2, sections 6.7 and 6.7.1.1; Figure 247]
Diagnostic consequence: record the command, advertised namespace capability and active error policy together. A single returned buffer leaves too much context missing to establish which contract was exercised.
Write Zeroes: a logical result, not a physical recipe
NVMe Write Zeroes is distinct from Dataset Management. For range operation with NSZ=0, NVM Command Set 1.3 requires zero-valued subsequent successful reads after successful completion, until another write to that LBA range. DULBE can still make reads fail after deallocation. DEAC=0 permits deallocation when zero-read behavior supports it; DEAC=1 requests it. Neither setting proves physical overwriting. [13, section 3.3.8]
Namespace scope needs the completion result: with NSZ=1, success alone does not establish whole-namespace zeroing. NVM Command Set 1.3 distinguishes LBACZ=1 (the entire namespace) from LBACZ=0 (the command's NLB range). The host must check the completion field. A failed command also does not prove that no clearing occurred. [13, section 3.3.8.1 and Figure 88]
There is a second distinction between the operating-system request and the wire command. Linux v6.16 normally sets DEAC only when REQ_NOUNMAP is absent and its namespace DEAC feature (NVME_NS_DEAC) is set. A separate controller-quirk branch routes the request through Dataset Management instead. This is source-level behavior, not a trace from a tested drive. [14, nvme_setup_write_zeroes]
Diagnostic consequence: retain the actual command and flags alongside read status, not just the returned bytes or a high-level zeroing label. A zero buffer alone cannot establish whether the controller wrote media or changed a mapping. Disposal assurance still needs the separate sanitization evidence, including the hidden-copy limitation discussed below.
When a read error was requested
NVMe Write Uncorrectable deliberately invalidates a logical-block range. Subsequent reads report Unrecovered Read Error; a later write clears the invalid state. Clearing that state does not recover the previous contents. The API contract describes logical invalidation, not a procedure for physically damaging flash. [15]
Range decoding matters: the 16-bit NLB field is zero-based, so NLB=0 selects one block, not an empty operation. Namespace bounds and command limits still apply. NVM Command Set 1.3 interprets the encoded WUSL size with NVMWUSV to distinguish a hard limit from a recommendation. With NVMWUSV=1, WUSL=0 means no recommended maximum is reported; with NVMWUSV=0, WUSL=0 means the command is unsupported. Do not carry older support checks into a different revision without review. [13, sections 3.3.7 and 4.1.5.4]
The Media and Data Integrity Errors counter may include or exclude errors introduced by this command. An unchanged counter therefore does not establish that the range remained readable, and an increase alone does not identify spontaneous media damage. Preserve command history, target LBAs and completion status alongside health logs. [16]
Operational boundary: this is a state-changing command, not a read-only health probe. Read failure is also not a physical-erasure certificate; the hidden-copy evidence addresses a different layer. No device command was executed for this source review.
Decode the byte before inferring the behavior
DLFEAT is a packed field, not a yes/no zero-read flag. Its low three bits describe read values; bit 3 advertises Write Zeroes deallocation support, and bit 4 describes the protection-information Guard. The libnvme definitions separate these masks. [11]
Generated field examples, not device captures. Guard applies when protection information is present. These declarations alone do not predict a command result.
| DLFEAT byte | Read-value field | Write Zeroes DEAC support | Guard field | Decoder warning |
|---|---|---|---|---|
00h | Not reported | No | FFFFh | None |
01h | All 00h | No | FFFFh | None |
02h | All FFh | No | FFFFh | None |
08h | Not reported | Yes | FFFFh | None |
09h | All 00h | Yes | FFFFh | None |
12h | All FFh | No | CRC | None |
03h | Reserved | No | FFFFh | Reserved encoding |
20h | Not reported | No | FFFFh | Reserved encoding |
DULBE is separate: the Error Recovery feature enables the namespace's deallocated/unwritten-block error. Identify Namespace reports support, not the current setting. With support and enablement established, Read, Verify and Compare that include such blocks fail under the cited 1.4a rule. [2, section 5.21.1.5 and Figure 282]
Hesela ingestion rule: retain missing settings as unknown, preserve reserved encodings and record the namespace and observation time. Our offline helper checks all 256 byte values; it does not issue commands or infer allocation, sanitization or hardware compliance. The eight displayed rows are examples, not a drive sample.
Inspect the method, decoder, executable tests, generated examples and source manifest.
WRITE SAME: repeated data is not automatically zeros
SCSI WRITE SAME normally sends one logical block for repetition across a contiguous range. A tool's default zero buffer is not the command family's only payload. The 10-, 16- and 32-byte variants have different fields and capability requirements. [21]
| Observation | Interpretation boundary |
|---|---|
| UNMAP=1, ANCHOR=0 | Table 252 permits a write fallback; reclamation is not established. [22] |
| NDOB=1 in WRITE SAME(16) | No data-out transfer; LBPRZ=010b selects the provisioning initialization pattern. [22, section 3.78] |
| Zero block count | May cover the remaining device; WSNZ can prohibit it. Never assume an empty operation. [21] |
A source-example trap: the pinned manual places an NDOB example under whole-device zeroing but omits the block count. In the same revision, DEF_WS_NUMBLOCKS is 1; the NDOB option changes only its flag, and the command encoder uses the unchanged count. That example therefore selects one logical block, not the whole device. NDOB changes data transfer, not range selection. This is a source-level finding, not a device test or an instruction to run the example. [21, Examples] [23, main and do_write_same]
Evidence to retain: the command variant, range, payload or NDOB, provisioning capabilities and completion status. Check logical readback and backend allocation separately. Neither alone establishes that inaccessible or remapped physical copies have been sanitized. This extension is source review; no device command was run.
SCSI: a status report is not a readback guarantee
SCSI GET LBA STATUS returns information about extents of logical blocks. The requested starting address, response-size limit and report type matter: returned descriptors do not automatically cover the whole device. The sg3_utils manual documents both 16-byte and 32-byte command variants. These are reporting commands, not alternative spellings of UNMAP. [8]
| Code | Decoded state | Interpretation boundary |
|---|---|---|
| 0 | Mapped or unknown | Not proof of mapping |
| 1 | Deallocated | Not a physical-erasure result |
| 2 | Anchored | A distinct state; not code 1 |
| 3 | Mapped | Not a filesystem used-space count |
| 4 | Unknown | Missing state knowledge, not evidence of deallocation |
Do not assume a consistent snapshot: concurrent operations can change the reported state. Check the report-type-processed (RTP) bit before trusting filtering. Seagate's reference also permits a requested mapped LBA to remain mapped after UNMAP. [10, sections 3.4 and 3.58]
LBPRZ addresses readback instead. The same reference distinguishes the READ CAPACITY(16) bit from the wider Logical Block Provisioning VPD field. In that field, 010b selects an initialization pattern, whereas xx1b specifies zeros; testing merely for a nonzero field is wrong. [10, section 3.25.2 and Table 544]
Investigation record: preserve raw responses, command variant, requested and returned ranges, report type, RTP, LBPRZ representation, tool revision and concurrent activity. This is Hesela's diagnostic synthesis. Treat omitted coverage and unknown state as unresolved. Compare physical allocation using the relevant backend's own counters, and keep sanitization assurance separate.
The reviewed sg3_utils source and manual disagree on the default response-buffer size. For reproducible collection, record an explicit size rather than assuming a default. No hardware command was run for this source review. [8] [9]
Offline capture: success can outlive the missing bytes
Hesela fixture result: two tested builds of sg_get_lba_status accepted an eight-byte, header-only file and printed two descriptor rows that were absent from the capture. Both returned exit code zero. A successful decode is therefore not a completeness check.
We constructed a 40-byte response with two 16-byte descriptors, then supplied every prefix from zero to 40 bytes using --inhex, --maxlen=256 and --verbose. The retained header still advertised 40 bytes. No device argument was supplied. The builds were Ubuntu package 1.46-3ubuntu4.1 (utility version 1.21 20190913) and author commit 1929463554c5 (utility version 1.46 20260613). Package and utility versions are different identifiers.
| Captured bytes | Complete descriptors in file | Printed descriptor rows | Exit code |
|---|---|---|---|
| 8 | 0 | 2 | 0 |
| 24 | 1 | 2 | 0 |
| 40 | 2 | 2 | 0 |
The absent rows had zero block counts. Each build returned success for 36 of the 40 shortened prefixes. Eight additional fixtures varied status, completion or RTP, giving 49 cases per build. These deliberately selected inputs are not a sample of drive failures. The preserved completion field in a shortened file is also not fresh evidence that a medium was fully scanned.
The pinned source reads the input length but bounds this decode path by the advertised length and allocation buffer. That explains why checking the byte count separately matters. This is an offline-path observation, not a claim about live SCSI transfers or every software release. [9]
Ingestion correction: our strict framing guard rejects all 40 shortened prefixes before accepting a complete capture. It checks the advertised length, actual byte count and whole-descriptor boundary. Keep partial captures explicitly partial. Even a complete frame can stop at an allocation or scan limit; it does not establish full-device coverage, consistent state, valid field semantics or sanitization.
Reproduce and inspect: method and build provenance, runner and framing guard, tests, packaged-build observations and pinned-build observations. No hardware behavior or erasure outcome was measured.
Why the fstrim number is not a reclamation meter
The util-linux manual describes verbose output as bytes submitted for potential discard. Repeating a run can report the same ranges again. Adjustments deeper in the block stack need not be reflected in that number. Adding successive reports therefore does not measure unique physical space returned to an SSD or storage pool. [3, verbose option]
For the file-to-pool boundary, see sparse files, preallocation and thin-pool capacity.
For capacity planning, compare allocation counters at the layer whose capacity you manage and record the observation times. A filesystem's free-space total and a backend's allocated-space total answer different questions. This is an operational inference, not a claim that we measured a particular array.
FITRIM: preserve the request as well as the result
FITRIM is the Linux filesystem ioctl used by fstrim, not the ATA command. Its fstrim_range has three unsigned 64-bit fields. Input start is a filesystem-relative byte offset, len is the requested search length in bytes and minlen is the requested minimum free-extent length in bytes. These are not offsets into the file used to select the filesystem. [17] [3]
In util-linux 2.41.2, the utility copies the requested structure before invoking FITRIM and, on successful completion with --verbose, prints the returned len. Preserve both values: a request length and a reported discard amount are different observations. The dry-run branch returns before the ioctl, so its zero-byte output does not measure available discard space. [18]
The manual describes upward minimum rounding and reporting an adjusted minimum, but that is not a universal implementation rule. Linux v6.12 ext4 shifts the requested minimum into allocation units and applies device granularity to a local variable when the requested minimum is smaller. It changes range.len while leaving range.minlen unchanged; the ioctl then copies the structure back. Returned minlen therefore does not reveal the effective threshold on that path. [3] [19] [20]
Reporting consequence: retain the filesystem and kernel versions, invocation options, requested fields, returned fields and outcome separately. Treat an unobserved effective threshold as unknown. This is source review, not a device experiment; none of these fields certifies physical erasure.
Two easily misread Linux details
discard_zeroes_data is not a live zero-read capability test. Linux 6.12's stable ABI documentation says it always reports zero and should not be relied upon. The separate maximum-discard attributes describe request limits, not sanitization or readback guarantees. The software maximum can be reduced to limit individual requests on devices with long discard latency; that is a tuning option, not evidence that a particular workload will improve. [4]
Device-mapper thin provisioning adds another boundary. no_discard_passdown removes the thin mapping without forwarding discard to the underlying data device. ignore_discard disables discard support instead. Removing a mapping at one layer therefore does not prove that NAND below it received an erase operation. Record which layer accepted the request and which layer's allocation you inspected. [5, optional feature arguments]
FlashVM: when avoiding a discard saved work
Saxena and Swift's USENIX ATC 2010 paper measured discard latency on an OCZ-Vertex SSD and reported a 55 ms fixed cost in its cost model. Their proposed merged discard batches free ranges; dummy discard skips an explicit discard when a block is likely to be overwritten soon. Dummy discard does not itself create a new reserve of clean blocks. [12, section 4.3]
The evaluation boundary matters: section 5.3.3 collected paging traces, transformed their discard requests and replayed them on an aged, trim-capable OCZ-Vertex. This was not a fleet study or a modern NVMe latency measurement. The suggested internal cause of the fixed cost was speculation, not direct observation of flash operations. [12]
Practical question, not a tuning prescription: how long will a freed range remain unused, and what work does the discard add to competing I/O? Measure those on the relevant stack before choosing a policy. Hesela did not reproduce this experiment, and its timing is not a present-day default.
Why logical readback cannot inspect hidden copies
Wei, Grupp, Spada and Swanson's FAST 2011 study used recognizable data patterns and raw flash extraction after erasure procedures. Its method crossed the translation-layer boundary instead of trusting only host-visible reads. Out-of-place writes and garbage collection can leave physical copies outside the currently mapped logical address. [7, sections 2.2 and 3]
Their fingerprint recorded generation, logical address and overwrite iteration, with a checksum and group identifier. Raw-chip extraction could therefore distinguish old copies from the current host-visible data. For the encrypted drive, the authors could not verify key deletion: unreadable data alone did not establish that the key had gone. [7, Figure 3 and section 3.2.1]
That historical laboratory evidence supports a distinction between logical visibility and physical remnants. It does not give a failure rate for today's NVMe drives or prove that every current implementation behaves identically. For disposal assurance, use the separate sanitization evidence review; this article concerns routine deallocation semantics.
A compact investigation record
Hesela's synthesis is to separate four observations before declaring success:
- Selection: which filesystem or caller declared the ranges unused?
- Propagation: which storage layers accepted, translated or stopped the request?
- Read semantics: what capability and error policy apply at the interface being read?
- Allocation: which backend counter changed, over what interval and with what concurrent activity?
Sanitization is a separate assurance question. Do not relabel this record as an erasure certificate. Avoid experiments against a live device; even a command intended to inspect behavior may be destructive if it issues discard.
Method and limits
We reviewed the named specification sections, upstream documentation and the FAST paper's mechanisms and experimental method. No drive was discarded, zeroed or tested; there are no new throughput, capacity or erasure measurements here. The separate offline fixture experiment exercises captured response decoding, not storage commands. Linux 6.12, util-linux 2.41.2 and NVMe 1.4a are explicit reference versions, not claims about the newest releases. The SCSI extension uses Seagate reference revision M (June 2022) and sg3_utils commit 1929463554c5dc749c5a89bcefb2c88a08d45575. The Write Zeroes range and namespace-completion explanations use NVM Command Set 1.3 and Linux v6.16; they do not update the earlier decoder's 1.4a scope. Verify the deployed implementation before applying any operational conclusion.
The corpus now distinguishes discard, ATA TRIM, SCSI UNMAP, thin provisioning and deallocated read behavior. The legacy UNMAP identifier remains available for existing consumers.
Primary sources
- sg3_utils: sg_unmap manual, description
- NVM Express 1.4a: sections 6.7, 6.7.1.1 and Figure 247
- util-linux 2.41.2: fstrim manual, verbose output
- Linux 6.12: stable sysfs block ABI, discard attributes
- Linux 6.12: device-mapper thin provisioning, optional feature arguments
- util-linux 2.41.2: blkdiscard manual
- Wei, Grupp, Spada and Swanson: Reliably Erasing Data From Flash-Based Solid State Drives, FAST 2011, sections 2-3
- sg3_utils: GET LBA STATUS manual (commit 1929463554c5)
- sg3_utils: provisioning-status decoder (commit 1929463554c5)
- Seagate SCSI Commands Reference, Rev. M: sections 3.4, 3.25.2, 3.58 and 5.4.13
- libnvme v1.13: namespace feature and DLFEAT field definitions
- Saxena and Swift: FlashVM, USENIX ATC 2010, sections 4.3 and 5.3.3
- NVM Command Set 1.3, sections 3.3.7, 3.3.8 and 4.1.5.4. Copyright 2008-2026 NVM Express, Inc. All rights reserved.
- Linux v6.16: nvme_setup_write_zeroes and namespace DEAC selection
- libnvme v1.15: nvme_write_uncorrectable API contract
- libnvme v1.15: nvme_smart_log.media_errors
- Linux v6.12: fstrim_range and FITRIM UAPI
- util-linux v2.41.2: fstrim invocation and returned-length output
- Linux v6.12: ext4_trim_fs minimum conversion and returned length
- Linux v6.12: ext4 FITRIM ioctl input and output copy
- sg3_utils sg_write_same manual, pinned author commit 1929463554c5: description, NDOB, NUM and UNMAP
- Seagate SCSI Commands Reference Rev. M (June 2022), sections 3.77-3.79 and Table 252
- sg3_utils pinned source: DEF_WS_NUMBLOCKS, main option parsing and do_write_same encoding
Original sources accessed 11 October 2026; SCSI and NVMe extensions and FlashVM sources accessed 21 October 2026, Europe/Warsaw. Write Zeroes sources accessed 23 October 2026; Write Uncorrectable sources accessed 6 November 2026; FITRIM source review 8 November 2026. This is a source-linked engineering explanation, not a reproduction of the FAST experiment.