vfs: fix data race discovered by the race detector

This fixes a place where we read from item.o without the item.mu held.
This commit is contained in:
Nick Craig-Wood 2021-02-17 20:25:38 +00:00
parent 25d5ed763c
commit 687a3b1832
1 changed files with 2 additions and 1 deletions

View File

@ -605,8 +605,9 @@ func (item *Item) _store(ctx context.Context, storeFn StoreFn) (err error) {
fs.Debugf(item.name, "vfs cache: writeback object to VFS layer")
// Write the object back to the VFS layer as last
// thing we do with mutex unlocked
o := item.o
item.mu.Unlock()
storeFn(item.o)
storeFn(o)
item.mu.Lock()
}
return nil