Browse Source
fix: BatchIO review fixes — linked SQE, ring overflow, resource leak, sync parity
fix: BatchIO review fixes — linked SQE, ring overflow, resource leak, sync parity
1. HIGH: LinkedWriteFsync now uses SubmitLinkRequests (IOSQE_IO_LINK) instead of SubmitRequests, ensuring write+fdatasync execute as a linked chain in the kernel. Falls back to sequential on error. 2. HIGH: PreadBatch/PwriteBatch chunk ops by ring capacity to prevent "too many requests" rejection when dirty map exceeds ring size (256). 3. MED: CloseBatchIO() added to Flusher, called in BlockVol.Close() after final flush to release io_uring ring / kernel resources. 4. MED: Sync parity — both standard and io_uring paths now use fdatasync (via platform-specific fdatasync_linux.go / fdatasync_other.go). Standard path previously used fsync; now matches io_uring semantics. On non-Linux, fdatasync falls back to fsync (only option available). 10 batchio tests, all blockvol tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>feature/sw-block
7 changed files with 104 additions and 32 deletions
-
11weed/storage/blockvol/batchio/batchio.go
-
14weed/storage/blockvol/batchio/fdatasync_linux.go
-
11weed/storage/blockvol/batchio/fdatasync_other.go
-
79weed/storage/blockvol/batchio/iouring_linux.go
-
9weed/storage/blockvol/batchio/standard.go
-
3weed/storage/blockvol/blockvol.go
-
9weed/storage/blockvol/flusher.go
@ -0,0 +1,14 @@ |
|||||
|
//go:build linux
|
||||
|
|
||||
|
package batchio |
||||
|
|
||||
|
import ( |
||||
|
"os" |
||||
|
"syscall" |
||||
|
) |
||||
|
|
||||
|
// fdatasync flushes file data to disk without updating metadata (mtime, size).
|
||||
|
// On Linux, this uses the fdatasync(2) syscall directly.
|
||||
|
func fdatasync(fd *os.File) error { |
||||
|
return syscall.Fdatasync(int(fd.Fd())) |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
//go:build !linux
|
||||
|
|
||||
|
package batchio |
||||
|
|
||||
|
import "os" |
||||
|
|
||||
|
// fdatasync flushes file data to disk. On non-Linux platforms, fdatasync is
|
||||
|
// not available, so this falls back to fsync via os.File.Sync().
|
||||
|
func fdatasync(fd *os.File) error { |
||||
|
return fd.Sync() |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue