From 687a3b1832ab1c8e0c36c7f9e99fd23d45b60e32 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 17 Feb 2021 20:25:38 +0000 Subject: [PATCH] vfs: fix data race discovered by the race detector This fixes a place where we read from item.o without the item.mu held. --- vfs/vfscache/item.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go index baecaa8f3..8fffb2bc5 100644 --- a/vfs/vfscache/item.go +++ b/vfs/vfscache/item.go @@ -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