mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 13:30:46 +02:00
Adds sync.RWMutex (ioMu) to BlockVol enforcing mutual exclusion between normal I/O and destructive state operations. Shared (RLock): WriteLBA, ReadLBA, Trim, SyncCache, replica applyEntry, rebuild applyRebuildEntry — concurrent I/O safe. Exclusive (Lock): RestoreSnapshot, ImportSnapshot, Expand, PrepareExpand, CommitExpand, CancelExpand — drains all in-flight I/O before modifying extent/WAL/dirtyMap. Scope rule: RLock covers local data-structure mutation only. Replication shipping is asynchronous and outside the lock, so exclusive holders block only behind local I/O, not network stalls. Lock ordering: ioMu > snapMu > assignMu > mu. Closes the critical ER item: restore/import vs concurrent WriteLBA silent data corruption gap. 3 new tests: concurrent writes allowed, real restore-vs-write contention with data integrity check, close coordination. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>