Repository navigation
DDT: Add locking for table ZAP destruction - #18115
Merged
Merged
Conversation
behlendorf
reviewed
Jan 8, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Signed-off-by: Alexander Motin
amotin
force-pushed
the
ddt_objects_lock
branch
from
January 9, 2026 16:41
3dac966 to
d95bb87
Compare
behlendorf
approved these changes
Jan 9, 2026
alek-p
added a commit
to alek-p/openzfs
that referenced
this pull request
Jan 12, 2026
Root Cause: The DDT ZAP object can be destroyed by the sync context (ddt_sync_update_stats) when a DDT class becomes empty. However, other threads might be accessing this ZAP object concurrently (e.g. via ddt_object_lookup or zpool status -D) without holding a lock that prevents the object's destruction. This leads to a use-after-free and kernel panic. Fix: Introduce a Read-Write lock (ddt_op_lock) in the ddt_t structure. - Writers (create/destroy) hold the lock exclusively. - Readers (lookup/update/count/etc) hold it shared. - This ensures the ZAP object remains valid while being accessed. Closes: #20 Relates-to: openzfs#18115 Relates-to: openzfs#18062 Relates-to: openzfs#18052 Relates-to: openzfs#18008
amotin
added a commit
to amotin/zfs
that referenced
this pull request
Jan 29, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes openzfs#18115
mcmilk
pushed a commit
to mcmilk/zfs
that referenced
this pull request
Jan 31, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes openzfs#18115
amotin
added a commit
to amotin/zfs
that referenced
this pull request
Feb 3, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes openzfs#18115
amotin
added a commit
to amotin/zfs
that referenced
this pull request
Feb 3, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes openzfs#18115
lundman
pushed a commit
to openzfsonosx/openzfs-fork
that referenced
this pull request
Feb 5, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes openzfs#18115
tonyhutter
pushed a commit
that referenced
this pull request
Feb 5, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes #18115
lundman
pushed a commit
to openzfsonwindows/openzfs
that referenced
this pull request
Feb 23, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes openzfs#18115
lundman
pushed a commit
to openzfsonwindows/openzfs
that referenced
this pull request
Feb 23, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes openzfs#18115
snajpa
pushed a commit
to vpsfreecz/zfs
that referenced
this pull request
Aug 5, 2026
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction. Reviewed-by: Brian BehlendorfSigned-off-by: Alexander Motin Closes openzfs#18115 Upstream: 765929c Ported-by: Pavel Snajdr Porting-notes: - Adapted table open and destroy paths to the object-ID-based DDT operation signatures used by 2.3.x. Patch development history: - v1: Upstream added a per-table read/write lock protecting DDT ZAP open contexts from concurrent destruction. - v2: Adapted the locking change to the objset/object-based 2.3.x DDT operation signatures, which do not use the newer dnode-based interface. Validation: The final corrected OpenZFS tree passed git diff --check, cstyle on changed C files, ksh syntax for the focused UID/GID-map ZTS, and a configured userland libzfs/zfs build. This message-only rewrite changes no source.
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.
Similar to BRT, DDT ZAP can be destroyed by sync context when it becomes empty. Respectively similar to BRT introduce RW-lock to protect open context methods from the destruction.
How Has This Been Tested?
Without this patch I've seen one kernel panic in CI, probably triggered by #18047. Hope this to fix it.
Types of changes
Checklist:
Signed-off-by.