diff options
| author | chrislu <chris.lu@gmail.com> | 2023-01-06 01:03:29 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2023-01-06 01:03:29 -0800 |
| commit | 296fdc296c8bd672d86c9aef19e9f568dab1b8a0 (patch) | |
| tree | 259a6be7e3c958cbe057a14c4e0226a11ccfd452 /weed/filer/filechunk_section.go | |
| parent | 49b84d5866db9da6fb99526a1f2230b8071e6ef6 (diff) | |
| download | seaweedfs-296fdc296c8bd672d86c9aef19e9f568dab1b8a0.tar.xz seaweedfs-296fdc296c8bd672d86c9aef19e9f568dab1b8a0.zip | |
mount: faster add chunks
Diffstat (limited to 'weed/filer/filechunk_section.go')
| -rw-r--r-- | weed/filer/filechunk_section.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/weed/filer/filechunk_section.go b/weed/filer/filechunk_section.go index 60c919569..5804c7160 100644 --- a/weed/filer/filechunk_section.go +++ b/weed/filer/filechunk_section.go @@ -32,10 +32,17 @@ func (section *FileChunkSection) addChunk(chunk *filer_pb.FileChunk) error { if section.visibleIntervals != nil { MergeIntoVisibles(section.visibleIntervals, start, stop, chunk) - } - - if section.visibleIntervals != nil { - section.chunks, _ = SeparateGarbageChunks(section.visibleIntervals, section.chunks) + garbageFileIds := FindGarbageChunks(section.visibleIntervals, start, stop) + for _, garbageFileId := range garbageFileIds { + length := len(section.chunks) + for i, t := range section.chunks { + if t.FileId == garbageFileId { + section.chunks[i] = section.chunks[length-1] + section.chunks = section.chunks[:length-1] + break + } + } + } } if section.chunkViews != nil { |
