femu/zns: key write caches by the request's zone - #195
Open
wnsah814 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The ZNS write cache is looked up with the global
active_zonevariable, which the NVMe I/O path overwrites on every write and the FTL thread reads asynchronously. Under concurrent writers a request can be matched with a cache bound to a different zone: its LPNs are appended there and later flushed into that zone's block, corrupting the modeled placement, the per-plane statistics, and reset invalidation (zns_invalidate_zone_cachematches bysblk, so pre-reset writes can survive a reset). The cache struct already carries a per-cachesblkbinding, so the lookup key was clearly meant to be the request's own zone.This patch derives the zone from
req->slbaand uses it for both lookup and binding, and initializessblktoINVALID_SBLKinstead of0..num_wc-1(which falsely claimed zones 0..2 at boot).Measured on current master with
FEMU_DEBUG_ZFTLenabled,multipoller_enabled=1, and 3 fio writers on 3 zones (3 zones / 3 caches, so no eviction can occur): 99 of 6,144 writes (1.6%) were appended to a cache bound to a different zone, e.g.After the patch the key is derived from the request itself, so the mis-association is impossible by construction.
Type of Change
Testing
Repro used for before/after verification (guest):
Before: 1.6% cross-zone cache appends (debug trace). After: none. Write throughput at 1/2/4/8 jobs is unchanged within noise.
FEMU Modes Tested
Platform Testing
Checklist
Related Issues
N/A
Additional Notes
active_zoneimmediately before enqueue and the FTL thread keeps up, so the mis-association is latent there (the same workload showed 0 occurrences); withmultipoller_enabled=1, or whenever FTL dequeue lags submission, it is routine. The unsynchronized cross-thread access exists in both configurations.