|
@ -239,9 +239,17 @@ func (dir *Dir) ReadDirAll(ctx context.Context) (ret []fuse.Dirent, err error) { |
|
|
|
|
|
|
|
|
err = dir.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error { |
|
|
err = dir.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error { |
|
|
|
|
|
|
|
|
|
|
|
paginationLimit := 1024 |
|
|
|
|
|
remaining := dir.wfs.option.DirListingLimit |
|
|
|
|
|
|
|
|
|
|
|
lastEntryName := "" |
|
|
|
|
|
|
|
|
|
|
|
for remaining >= 0 { |
|
|
|
|
|
|
|
|
request := &filer_pb.ListEntriesRequest{ |
|
|
request := &filer_pb.ListEntriesRequest{ |
|
|
Directory: dir.Path, |
|
|
Directory: dir.Path, |
|
|
Limit: uint32(dir.wfs.option.DirListingLimit), |
|
|
|
|
|
|
|
|
StartFromFileName: lastEntryName, |
|
|
|
|
|
Limit: uint32(paginationLimit), |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
glog.V(4).Infof("read directory: %v", request) |
|
|
glog.V(4).Infof("read directory: %v", request) |
|
@ -262,6 +270,15 @@ func (dir *Dir) ReadDirAll(ctx context.Context) (ret []fuse.Dirent, err error) { |
|
|
ret = append(ret, dirent) |
|
|
ret = append(ret, dirent) |
|
|
} |
|
|
} |
|
|
dir.wfs.listDirectoryEntriesCache.Set(path.Join(dir.Path, entry.Name), entry, cacheTtl) |
|
|
dir.wfs.listDirectoryEntriesCache.Set(path.Join(dir.Path, entry.Name), entry, cacheTtl) |
|
|
|
|
|
lastEntryName = entry.Name |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
remaining -= len(resp.Entries) |
|
|
|
|
|
|
|
|
|
|
|
if len(resp.Entries) < paginationLimit { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return nil |
|
|
return nil |
|
@ -351,10 +368,7 @@ func estimatedCacheTtl(numEntries int) time.Duration { |
|
|
// 10 ms per entry
|
|
|
// 10 ms per entry
|
|
|
return 100 * time.Second |
|
|
return 100 * time.Second |
|
|
} |
|
|
} |
|
|
if numEntries < 100000 { |
|
|
|
|
|
// 10 ms per entry
|
|
|
|
|
|
return 1000 * time.Second |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2 ms per entry
|
|
|
// 2 ms per entry
|
|
|
return time.Duration(numEntries*2) * time.Millisecond |
|
|
return time.Duration(numEntries*2) * time.Millisecond |
|
|
} |
|
|
} |