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>
This commit is contained in:
@@ -628,8 +628,14 @@ func (bs *IOUringBackingStore) DataAdvise(offset, length int64, advise uint32) e
|
||||
return nil
|
||||
}
|
||||
|
||||
// Unmap is a no-op for file-based storage
|
||||
func (bs *IOUringBackingStore) Unmap([]api.UnmapBlockDescriptor) error {
|
||||
// Unmap zeros out the specified blocks
|
||||
func (bs *IOUringBackingStore) Unmap(descriptors []api.UnmapBlockDescriptor) error {
|
||||
for _, desc := range descriptors {
|
||||
zeros := make([]byte, desc.TL)
|
||||
if _, err := bs.file.WriteAt(zeros, int64(desc.Offset)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user