mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
dc204dd137
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1d340b4] goroutine 130523 [running]: github.com/chrislusf/seaweedfs/weed/filer.FileSize(...) /code/seaweedfs/weed/filer/filechunks.go:26 github.com/chrislusf/seaweedfs/weed/mount.(*WFS).Lookup(0xc000866d80, 0x1, 0xc002897f40, {0xc004b00980, 0x39}, 0x1ec19e0) /code/seaweedfs/weed/mount/weedfs_dir_lookup.go:59 +0x654 github.com/hanwen/go-fuse/v2/fuse.doLookup(0xc00033c000, 0xc00033c000) /code/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.0/fuse/opcode.go:333 +0x6b github.com/hanwen/go-fuse/v2/fuse.(*Server).handleRequest(0xc000ab2420, 0xc00033c000) /code/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.0/fuse/server.go:483 +0x1f3 github.com/hanwen/go-fuse/v2/fuse.(*Server).loop(0xc000ab2420, 0x0) /code/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.0/fuse/server.go:456 +0x110 created by github.com/hanwen/go-fuse/v2/fuse.(*Server).readRequest /code/go/pkg/mod/github.com/hanwen/go-fuse/v2@v2.1.0/fuse/server.go:323 +0x534
68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
package mount
|
|
|
|
import (
|
|
"context"
|
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
|
"github.com/chrislusf/seaweedfs/weed/mount/meta_cache"
|
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
|
"github.com/hanwen/go-fuse/v2/fuse"
|
|
)
|
|
|
|
// Lookup is called by the kernel when the VFS wants to know
|
|
// about a file inside a directory. Many lookup calls can
|
|
// occur in parallel, but only one call happens for each (dir,
|
|
// name) pair.
|
|
|
|
func (wfs *WFS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name string, out *fuse.EntryOut) (code fuse.Status) {
|
|
|
|
if s := checkName(name); s != fuse.OK {
|
|
return s
|
|
}
|
|
|
|
dirPath, code := wfs.inodeToPath.GetPath(header.NodeId)
|
|
if code != fuse.OK {
|
|
return
|
|
}
|
|
|
|
fullFilePath := dirPath.Child(name)
|
|
|
|
visitErr := meta_cache.EnsureVisited(wfs.metaCache, wfs, dirPath, nil)
|
|
if visitErr != nil {
|
|
glog.Errorf("dir Lookup %s: %v", dirPath, visitErr)
|
|
return fuse.EIO
|
|
}
|
|
localEntry, cacheErr := wfs.metaCache.FindEntry(context.Background(), fullFilePath)
|
|
if cacheErr == filer_pb.ErrNotFound {
|
|
return fuse.ENOENT
|
|
}
|
|
|
|
if localEntry == nil {
|
|
// glog.V(3).Infof("dir Lookup cache miss %s", fullFilePath)
|
|
entry, err := filer_pb.GetEntry(wfs, fullFilePath)
|
|
if err != nil {
|
|
glog.V(1).Infof("dir GetEntry %s: %v", fullFilePath, err)
|
|
return fuse.ENOENT
|
|
}
|
|
localEntry = filer.FromPbEntry(string(dirPath), entry)
|
|
} else {
|
|
glog.V(4).Infof("dir Lookup cache hit %s", fullFilePath)
|
|
}
|
|
|
|
if localEntry == nil {
|
|
return fuse.ENOENT
|
|
}
|
|
|
|
inode := wfs.inodeToPath.Lookup(fullFilePath, localEntry.Mode, len(localEntry.HardLinkId) > 0, localEntry.Inode, true)
|
|
|
|
if fh, found := wfs.fhmap.FindFileHandle(inode); found && fh.entry != nil {
|
|
glog.V(4).Infof("lookup opened file %s size %d", dirPath.Child(localEntry.Name()), filer.FileSize(fh.entry))
|
|
localEntry = filer.FromPbEntry(string(dirPath), fh.entry)
|
|
}
|
|
|
|
wfs.outputFilerEntry(out, inode, localEntry)
|
|
|
|
return fuse.OK
|
|
|
|
}
|