-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Synchronize the update of feature refcount #17632
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
base: master
Are you sure you want to change the base?
Conversation
@@ -432,7 +433,20 @@ feature_do_action(spa_t *spa, spa_feature_t fid, feature_action_t action, | |||
break; | |||
} | |||
|
|||
feature_sync(spa, feature, refcount, tx); |
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.
why the code duplication? wouldn't it be better to ensure feature_sync
is OK to be called with spa_feat_stats_lock
held and then enforce the lock being held in all instances feature_sync
is called? (via an ASSERT)
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.
@snajpa - I thought about it and didn't like the code duplication too. A new version is force pushed, please take a look. Thanks.
Signed-off-by: Youzhong Yang <[email protected]>
b03e91d
to
5c46263
Compare
Signed-off-by: Youzhong Yang <[email protected]>
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.
I'm a little concerned with how much is now being done in feature_sync()
under this mutex. But after reading through it I don't see anything clearly problematic, so I'm good with this straight forward fix to close the race.
Motivation and Context
As reported and analyzed in #17184, the concurrent execution of feature_sync() can lead to panic due to unprotected update of the feature refcount.
Description
Use spa->spa_feat_stats_lock to synchronize the update of the refcount.
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.