Fixed CreateFile concurrency issues in memfs.
commit
b82157437e
|
@ -23,6 +23,7 @@ import (
|
|||
const (
|
||||
// Errors corresponding to kernel error numbers. These may be treated
|
||||
// specially by fuseops.Op.Respond methods.
|
||||
EEXIST = bazilfuse.EEXIST
|
||||
EINVAL = bazilfuse.Errno(syscall.EINVAL)
|
||||
EIO = bazilfuse.EIO
|
||||
ENOENT = bazilfuse.ENOENT
|
||||
|
|
|
@ -341,6 +341,14 @@ func (fs *memFS) CreateFile(
|
|||
parent := fs.getInodeForModifyingOrDie(op.Parent)
|
||||
defer parent.mu.Unlock()
|
||||
|
||||
// Ensure that the name doesn't alread exist, so we don't wind up with a
|
||||
// duplicate.
|
||||
_, exists := parent.LookUpChild(op.Name)
|
||||
if exists {
|
||||
err = fuse.EEXIST
|
||||
return
|
||||
}
|
||||
|
||||
// Set up attributes from the child, using the credentials of the calling
|
||||
// process as owner (matching inode_init_owner, cf. http://goo.gl/5qavg8).
|
||||
now := fs.clock.Now()
|
||||
|
|
|
@ -1251,3 +1251,15 @@ func (t *MemFSTest) DeleteSymlink() {
|
|||
AssertEq(nil, err)
|
||||
ExpectThat(entries, ElementsAre())
|
||||
}
|
||||
|
||||
func (t *MemFSTest) CreateInParallel_NoTruncate() {
|
||||
runCreateInParallelTest_NoTruncate(t.Ctx, t.Dir)
|
||||
}
|
||||
|
||||
func (t *MemFSTest) CreateInParallel_Truncate() {
|
||||
runCreateInParallelTest_Truncate(t.Ctx, t.Dir)
|
||||
}
|
||||
|
||||
func (t *MemFSTest) CreateInParallel_Exclusive() {
|
||||
runCreateInParallelTest_Exclusive(t.Ctx, t.Dir)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue