DDT: Add locking for table ZAP destruction#18115
Merged
behlendorf merged 1 commit intoopenzfs:masterfrom Jan 13, 2026
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 <alexander.motin@TrueNAS.com>
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 Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> 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 Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> 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 Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> 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 Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> 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 Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> 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 Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> 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 Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> 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 Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> Closes openzfs#18115
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.