-
Notifications
You must be signed in to change notification settings - Fork 525
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
Fixing the creation of multiple inode creation for the same name when… #572
base: master
Are you sure you want to change the base?
Fixing the creation of multiple inode creation for the same name when… #572
Conversation
… MkDir or CreateFile executed simultaneously. Get parent lock before creating inode from `Goofys.MkDir` or `Goofys.CreateFile` to avoid creating a duplicate inode. Remove get lock from `Inode.Create` and `Inode.MkDir` since it lock already acquired by the caller.
d714e44
to
1ff2c07
Compare
parent.mu.Lock() | ||
defer parent.mu.Unlock() | ||
|
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.
We don't need to parent lock since it is already locked from caller.
parent.mu.Lock() | ||
defer parent.mu.Unlock() | ||
|
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.
We need lock here as well, since caller already has a lock.
@@ -1013,10 +1013,10 @@ func (fs *Goofys) CreateFile( | |||
parent := fs.getInodeOrDie(op.Parent) | |||
fs.mu.RUnlock() | |||
|
|||
inode, fh := parent.Create(op.Name, op.Metadata) | |||
|
|||
parent.mu.Lock() | |||
|
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 folder creation is moved after acquiring the parent lock. This lock needs to be atomic between creating inode and inserting into map of inodes.
parent.mu.Lock() | ||
|
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 folder creation is moved after acquiring the parent lock. This lock needs to be atomic between creating inode and inserting into map of inodes.
@kahing could you review this PR and give us your expert advice. |
@kahing could you review this PR? |
This PR seems to fix multiple issues but we need a rebase to make it work with current code base. I'm not sure you're still tracking it but we probably want to try to get this PR merged as part of the next release. |
Fixing the creation of multiple inode creation for the same name when MkDir executed simultaneously.