Fix refresh_gen reading wrong lock for mode - #326
Open
aversecat wants to merge 1 commit into
Open
Conversation
This function determines if the local inode is cached under a different mode in the client local state. On receiving an updated mode it should therefore inspect it's own lock mode and not the mode passed by the server, which can have a different view after recovery. This was caught twice in CI by `BUG_ON(atomic64_read(&si->last_refreshed) > refresh_gen) in scoutfs_inode_refresh` in scoutfs_inode_refresh() during the lock-recover-invalidate test - our most flakey CI test by a mile. Pulling the core revealed the lock was mode=WRITE but refresh_gen=0 with invalidate_pending=1, which means it should have had refresh_gen assigned on the null to write transition. This happens because it's only assigned if the server-supplied lock changes, because it doesn't look at the client's view of the state: `!can_read(nl->old_mode) && can_read(nl->new_mode)` Exactly the thing that can go wrong after a server fence/recovery, as exposed by this CI test. Signed-off-by: Auke Kok <auke.kok@versity.com>
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.
This function determines if the local inode is cached under a different mode in the client local state. On receiving an updated mode it should therefore inspect it's own lock mode and not the mode passed by the server, which can have a different view after recovery.
This was caught twice in CI by
BUG_ON(atomic64_read(&si->last_refreshed) > refresh_gen) in scoutfs_inode_refreshin scoutfs_inode_refresh() during the lock-recover-invalidate test - our most flakey CI test by a mile.Pulling the core revealed the lock was mode=WRITE but refresh_gen=0 with invalidate_pending=1, which means it should have had refresh_gen assigned on the null to write transition. This happens because it's only assigned if the server-supplied lock changes, because it doesn't look at the client's view of the state:
!can_read(nl->old_mode) && can_read(nl->new_mode)Exactly the thing that can go wrong after a server fence/recovery, as exposed by this CI test.