diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2025-08-06 10:09:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-06 10:09:26 -0700 |
| commit | 4af182f88001033440f5d397f26b1c6f5e7635e1 (patch) | |
| tree | 65e0de8aa22c2daa273fb514e772edeae0d7141e /weed/filer/filechunk_section.go | |
| parent | e446234e9c2512b01040fffcefc429a8d974808e (diff) | |
| download | seaweedfs-4af182f88001033440f5d397f26b1c6f5e7635e1.tar.xz seaweedfs-4af182f88001033440f5d397f26b1c6f5e7635e1.zip | |
Context cancellation during reading range reading large files (#7093)
* context cancellation during reading range reading large files
* address comments
* cancellation for fuse read
* fix cancellation
* pass in context for each function to avoid racing condition
* Update reader_at_test.go
* remove dead code
* Update weed/filer/reader_at.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update weed/filer/filechunk_group.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update weed/filer/filechunk_group.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* address comments
* Update weed/mount/weedfs_file_read.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update weed/mount/weedfs_file_lseek.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update weed/mount/weedfs_file_read.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update weed/filer/reader_at.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update weed/mount/weedfs_file_lseek.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* test cancellation
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Diffstat (limited to 'weed/filer/filechunk_section.go')
| -rw-r--r-- | weed/filer/filechunk_section.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/weed/filer/filechunk_section.go b/weed/filer/filechunk_section.go index 75273a1ca..76eb84c23 100644 --- a/weed/filer/filechunk_section.go +++ b/weed/filer/filechunk_section.go @@ -1,6 +1,7 @@ package filer import ( + "context" "sync" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" @@ -62,7 +63,7 @@ func removeGarbageChunks(section *FileChunkSection, garbageFileIds map[string]st } } -func (section *FileChunkSection) setupForRead(group *ChunkGroup, fileSize int64) { +func (section *FileChunkSection) setupForRead(ctx context.Context, group *ChunkGroup, fileSize int64) { section.lock.Lock() defer section.lock.Unlock() @@ -84,25 +85,25 @@ func (section *FileChunkSection) setupForRead(group *ChunkGroup, fileSize int64) } if section.reader == nil { - section.reader = NewChunkReaderAtFromClient(group.readerCache, section.chunkViews, min(int64(section.sectionIndex+1)*SectionSize, fileSize)) + section.reader = NewChunkReaderAtFromClient(ctx, group.readerCache, section.chunkViews, min(int64(section.sectionIndex+1)*SectionSize, fileSize)) } section.isPrepared = true section.reader.fileSize = fileSize } -func (section *FileChunkSection) readDataAt(group *ChunkGroup, fileSize int64, buff []byte, offset int64) (n int, tsNs int64, err error) { +func (section *FileChunkSection) readDataAt(ctx context.Context, group *ChunkGroup, fileSize int64, buff []byte, offset int64) (n int, tsNs int64, err error) { - section.setupForRead(group, fileSize) + section.setupForRead(ctx, group, fileSize) section.lock.RLock() defer section.lock.RUnlock() - return section.reader.ReadAtWithTime(buff, offset) + return section.reader.ReadAtWithTime(ctx, buff, offset) } -func (section *FileChunkSection) DataStartOffset(group *ChunkGroup, offset int64, fileSize int64) int64 { +func (section *FileChunkSection) DataStartOffset(ctx context.Context, group *ChunkGroup, offset int64, fileSize int64) int64 { - section.setupForRead(group, fileSize) + section.setupForRead(ctx, group, fileSize) section.lock.RLock() defer section.lock.RUnlock() @@ -119,9 +120,9 @@ func (section *FileChunkSection) DataStartOffset(group *ChunkGroup, offset int64 return -1 } -func (section *FileChunkSection) NextStopOffset(group *ChunkGroup, offset int64, fileSize int64) int64 { +func (section *FileChunkSection) NextStopOffset(ctx context.Context, group *ChunkGroup, offset int64, fileSize int64) int64 { - section.setupForRead(group, fileSize) + section.setupForRead(ctx, group, fileSize) section.lock.RLock() defer section.lock.RUnlock() |
