fusefrontend: use DirIVCache in OpenDir()
Previously, OpenDir() did not use the cache at all, missing an opportunity to speed up repeated directory reads.
This commit is contained in:
parent
7da0e97c8b
commit
276567eb13
|
@ -260,18 +260,24 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
|
||||||
// Get DirIV (stays nil if PlaintextNames is used)
|
// Get DirIV (stays nil if PlaintextNames is used)
|
||||||
var cachedIV []byte
|
var cachedIV []byte
|
||||||
if !fs.args.PlaintextNames {
|
if !fs.args.PlaintextNames {
|
||||||
// Read the DirIV once and use it for all later name decryptions
|
cachedIV, _ = fs.nameTransform.DirIVCache.Lookup(dirName)
|
||||||
cachedIV, err = nametransform.ReadDirIV(cDirAbsPath)
|
if cachedIV == nil {
|
||||||
if err != nil {
|
// Read the DirIV from disk and store it in the cache
|
||||||
// This can happen during normal operation when the directory has
|
fs.dirIVLock.RLock()
|
||||||
// been deleted concurrently. But it can also mean that the
|
cachedIV, err = nametransform.ReadDirIV(cDirAbsPath)
|
||||||
// gocryptfs.diriv is missing due to an error, so log the event
|
if err != nil {
|
||||||
// at "info" level.
|
fs.dirIVLock.RUnlock()
|
||||||
tlog.Info.Printf("OpenDir: %v", err)
|
// This can happen during normal operation when the directory has
|
||||||
return nil, fuse.ToStatus(err)
|
// been deleted concurrently. But it can also mean that the
|
||||||
|
// gocryptfs.diriv is missing due to an error, so log the event
|
||||||
|
// at "info" level.
|
||||||
|
tlog.Info.Printf("OpenDir: %v", err)
|
||||||
|
return nil, fuse.ToStatus(err)
|
||||||
|
}
|
||||||
|
fs.nameTransform.DirIVCache.Store(dirName, cachedIV, cDirName)
|
||||||
|
fs.dirIVLock.RUnlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrypted directory entries
|
// Decrypted directory entries
|
||||||
var plain []fuse.DirEntry
|
var plain []fuse.DirEntry
|
||||||
var errorCount int
|
var errorCount int
|
||||||
|
|
Loading…
Reference in New Issue