-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -905,9 +905,6 @@ func (parent *Inode) Create( | |
|
||
fs := parent.fs | ||
|
||
parent.mu.Lock() | ||
defer parent.mu.Unlock() | ||
|
||
now := time.Now() | ||
inode = NewInode(fs, parent, &name) | ||
inode.Attributes = InodeAttributes{ | ||
|
@@ -948,9 +945,6 @@ func (parent *Inode) MkDir( | |
return | ||
} | ||
|
||
parent.mu.Lock() | ||
defer parent.mu.Unlock() | ||
|
||
Comment on lines
-951
to
-953
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need lock here as well, since caller already has a lock. |
||
inode = NewInode(fs, parent, &name) | ||
inode.ToDir() | ||
inode.touch() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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. |
||
inode, fh := parent.Create(op.Name, op.Metadata) | ||
|
||
fs.mu.Lock() | ||
defer fs.mu.Unlock() | ||
fs.insertInode(parent, inode) | ||
|
@@ -1049,14 +1049,14 @@ func (fs *Goofys) MkDir( | |
parent := fs.getInodeOrDie(op.Parent) | ||
fs.mu.RUnlock() | ||
|
||
parent.mu.Lock() | ||
|
||
// ignore op.Mode for now | ||
inode, err := parent.MkDir(op.Name) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
parent.mu.Lock() | ||
|
||
Comment on lines
-1058
to
-1059
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
fs.mu.Lock() | ||
defer fs.mu.Unlock() | ||
fs.insertInode(parent, inode) | ||
|
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.