Commit Graph

21 Commits

Author SHA1 Message Date
Lei Xue
76ab15b0df feat: add S3-compatible object storage backend
Add a new backend store that enables iSCSI targets backed by
S3-compatible object storage (AWS S3, MinIO, Ceph RGW, etc.).

The implementation uses a chunked storage strategy where the virtual
block device is divided into fixed-size chunks (default 4 MiB), each
stored as an independent S3 object. This enables efficient random
read/write access on top of object storage.

Key features:
- Chunked storage with configurable chunk size
- Sparse device support (unwritten chunks treated as zeros)
- Concurrent multi-chunk I/O via errgroup
- Per-chunk locking for safe read-modify-write
- AWS SDK v2 with default credential chain
- In-process gofakes3 test server (no Docker needed)
- 12 unit tests + 2 integration tests

Also updates CI workflow to run S3 backend tests and updates
README with S3 backend documentation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 16:22:57 +08:00
Lei Xue
a5628f4ec0 add end-to-end IO benchmarks and fix pprof-identified hotspots
Add comprehensive benchmark suite (io_bench_test.go):
- BenchmarkEndToEndRead/Write: full SCSI stack (512B to 256KB)
- BenchmarkEndToEndReadParallel/WriteParallel: concurrent IO
- BenchmarkFileBackingStoreRead/Write: isolated backing store

pprof-guided optimizations:
- Guard hot-path log.Debugf with log.GetLevel() check in scsi.go,
  sbc.go, backingstore.go — eliminates 22% CPU overhead from logrus
  Entry allocation even when debug logging is disabled
- Add FileBackingStore.ReadAt for zero-copy reads directly into
  caller's buffer, bypassing Read()'s per-call make([]byte, tl)
- Use ReadAt via interface assertion in bsPerformCommand to read
  directly into InSDBBuffer, eliminating allocation + copy

Results (256KB reads): +42% throughput, allocs reduced from 10 to 5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 19:41:48 +08:00
Lei Xue
16108ced95 optimize performance: reduce allocations, buffered I/O, and zero-copy reads
- Read path: eliminate redundant allocation in bsPerformCommand - remove
  the pre-allocation before bs.Read() and the append loop for zero-fill,
  use direct copy and in-place zero-fill instead
- parseHeader: use command pool (getCommand) instead of direct allocation,
  reducing GC pressure on the hot path
- Unmap: use a shared 1MB zero buffer instead of allocating per-descriptor,
  dramatically reducing allocations for large unmap operations
- Network I/O: add 256KB bufio.Writer to iSCSI connections, batching
  small PDU writes into fewer syscalls. Flush after txHandler completes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 19:03:30 +08:00
Lei Xue
00d0c3a306 fix UNMAP data corruption by implementing block zeroing
The UNMAP command was a no-op in all backing stores, causing unmapped
blocks to retain stale data instead of returning zeros per SCSI spec.

- Implement Unmap in FileBackingStore to zero out unmapped blocks
- Implement Unmap in IOUringBackingStore to zero out unmapped blocks
- Enable Unmap in RemBackingStore (was commented out)
- Change UnmapBlockDescriptor.TL from uint32 to uint64 to prevent
  integer overflow when converting block count to byte length with
  large block shifts

Fixes #119

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 12:29:12 +08:00
Lei Xue
00cfac3d24 optimize the perf and support more features 2026-03-14 11:45:35 +08:00
Lei Xue
8a3e19f0c9 fix daemon 's host flag 2022-12-10 22:05:19 +08:00
Jeremy Gill
a8468ecec8 Resolve travis-ci / gofmt issue with common.go 2020-12-15 11:26:26 -05:00
Jeremy Gill
228e53351d Add support for block device storage endpoints. 2020-09-04 13:28:51 -04:00
chessman
0b1ffd5704 provide offset and tl to DataSync 2019-06-27 19:54:16 +03:00
chessman
8d17243b3a update dependencies 2019-06-12 19:10:59 +03:00
chessman
12b06c21ef UNMAP: propagate request to backing store 2019-05-29 16:14:31 +03:00
chessman
22d47a9212 enable UNMAP when LUN is thin provisioned
- support Block Limits VPD page (0xB0)
 - add UNMAP to REPORT SUPPORTED OPERATION CODES
 - READ CAPACITY(16): set LBPME when Thin provisioning is enabled
 - move Thinprovisioning and BlockShift to config
 - add Unmap to BackingStore
2019-05-28 13:53:06 +03:00
Lei Xue
a523a583dc fix some issues for SCSI command 2017-06-24 12:09:05 +08:00
Lei Xue
d3c3a96920 delete cit to use new gotgt as main cmd, use logrus instead of glog 2016-11-29 11:21:40 +08:00
Lei Xue
05b6f88de4 restruct the backend storage command submit 2016-11-28 11:11:24 +08:00
Lei Xue
bd7193880e basic change for godoc 2016-11-27 13:31:43 +08:00
Lei Xue
f4197d0024 add more comments 2016-11-24 21:02:17 +08:00
Le Zhang
c9b93c7527 mapping lun and fix portal management 2016-10-04 13:39:55 +08:00
Lei Xue
ca14aab4c2 date: 2016-08-30/17:00 2016-08-30 17:04:11 +08:00
Lei Xue
aedc09021f fix bugs and make it run basically 2016-08-27 20:07:51 +08:00
Lei Xue
a9a7d63c20 init commit 2015-12-14 10:23:35 +08:00