-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ddt prune: Add SCL_ZIO deadlock workaround #17793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The context is:
What could be the best fit in this context? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the minimal targeted fix. We'll definitely want to revisit this and replace it with something cleaner, but I agree at least for now we can make this small change to resolve the deadlock.
Originally this was created for MMP, but now new cases are emerging where the same mechanism is required. Hence the name's generalization. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Igor Ostapenko <[email protected]>
Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Igor Ostapenko <[email protected]>
54073e4
to
ccdbf1c
Compare
FYI: I've split it onto two commits:
It feels such way it must be easier to get back to this in the future. |
Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Igor Kozhukhov <[email protected]> Signed-off-by: Igor Ostapenko <[email protected]> Closes #17793
I wonder why |
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Motivation and Context
The situation seems to be mirror related only and it happens if one logic path takes
SCL_ZIO
reader lock, then another one landsscl_write_wanted
by waiting forSCL_ZIO
writer lock, and the first one asks forSCL_ZIO
reader lock again.Currently, pruning code path has only two entry points:
zpool prune
CLI andztest_ddt_prune()
test. Both of them callddt_prune_unique_entries()
, which begins and ends the pruning process by switching thespa->spa_active_ddt_prune
bool flag.The following is the actual example of the case happened with ztest. The paragraph number depicts the sequence of events.
1
ztest_ddt_prune()
test running in a separate ztest thread enqueuesdsl_sync_task(prune_candidates_sync)
, and keeps waiting for a txg_sync_thread to get it done.2 The
txg_sync_thread()
runsdsl_pool_sync()
which invokesprune_candidates_sync
sync task. Theprune_candidates_sync()
takesSCL_ZIO
reader lock before the actual work.3 Another thread asks and waits for
SCL_ZIO
writer lock viaspa_vdev_state_enter()
, in this case it wasztest_scrub
. The lock getsscl_write_wanted++
.4 The
txg_sync_thread()
continues runningprune_candidates_sync()
, eventually it hitszio_vdev_io_start()
which decides to takeSCL_ZIO
reader lock. And havingscl_write_wanted > 0
it is not going to happen, as theztest_scrub
thread actually waits for the pruning process to finish and freeSCL_ZIO
reader lock.Description
The
mmp_flag
ofspa_config_enter_impl()
is used to ignore pending write locks. And the condition for this isspa->spa_spa_active_ddt_prune
flag.As long as such change makes
spa_config_enter_mmp()
function have general application it is proposed to rename it tospa_config_enter_priority()
.How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.