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.
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
Fix parallel mount race #8878
Fix parallel mount race #8878
Changes from all commits
152fb96
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Can you expand on this comment and explain what you mean? How can an unmount failure be caused by a race condition in
zfs mount -a
?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.
????
That's what's been discussed since the original issue reported in #8833.
When threads are under race condition, mount order is undefined.
When a thread for a mountpoint deeper in directory tree wins (which is a bug), that's not what
zfs unmount -a
expects, hence unmount fails.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.
@kusumi Please be patient with me. I'm asking clarifying questions in good faith. I legitimately did not understand how a race condition in the mount code could cause unmount to fail, even after having read the issue. Furthermore, people reading this code in the future won't know to go look at that issue. Comments should be self-contained and self-explanatory.
This comment is evidently trying to explain why
canmount
has to be set tooff
on$TESTPOOL2
, which has amountpoint
of$MNTPT
. This has to be done because you can't mount two filesystems on the same mountpoint. In the test,$TESTPOOL1/$TESTFS1
has the same mountpoint. Both cannot be mounted; hence, one of them has to havecanmount
set tooff
.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.
The unmount assumes mount order was in correct order, so if a mount point deeper in the directory tree is shadowed by another one due to undefined mount order caused by the race among pthreads, then unmount will fail, because unmount can't see a mount that is supposed to exist.
(See my fist comment and example I pasted in #8833, as well as my first comment in this thread. Also see #8450 which is likely the same problem.)
I did add a bit more description (basically my previous comment to your question) in my previous push, but apparently I won't/can't explain all the details of implementation I explained in this thread as well as the commit message (plus this test file already does have lots of comments with ascii-art). That's why it has had a reference to GitHub url.
Right, that's why it has
turn it off for convenience of mount layout used in this test case
, but whether that property is set or not, the race itself in initial thread dispatching does happen. See #8450, it's not usingcanmount
.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.
Can you also add a test that does the exact same thing, except sets
canmount=off
onTESTPOOL1
instead, just in case the code is accidentally dependent on the ordering of the filesystems passed in?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 don't get what "accidentally" is supposed to mean, but the entire point of this race fix on initial thread dispatching isn't anything to do with
canmount
property. Ifcanmount=off
on a different top level dir is causing difference or a problem, that's another issue.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.
@kusumi From my understanding, the
canmount
property has to be set tooff
on the filesystems with duplicate mount points in order to hit this bug. Can you show me a case where this bug gets hit andcanmount
isn't set tooff
on any of the filesystems?Essentially, this has to do with two or more filesystems having the same mountpoint, all but one of which does not get mounted (
canmount=off
). If a thread handling the mounting of a filesystem whosecanmount
property is set tooff
spawns child filesystem mounts before others, then those child mounts will fail because their parent filesystems will not have been mounted. This updated fix addresses this issue because the threads with duplicate mountpoints will no longer be spawned in parallel, and the one legitimate filesystem (the one that will be mounted) will be guaranteed to be mounted before the threads that mount its child filesystems get spawned.I'm not trying to criticize your code or tests here, I'm providing you with feedback so that we can solidify the code. This is supposed to be constructive.
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.
This example does fail to unmount without
canmount=off
. In this test or an example in #8833,canmount=off
is set to TESTPOOL2 or p2, so while it does fail to mount TESTPOOL2 or p2 onset mountpoint=/...
withoutset canmount=off
, the race condition in other two mounts (which are to be mounted by different threads without this fix, but run in a single thread with this fix) exist.Also #8450 isn't using canmount property as well.