preallocate disk space during compaction also, add cleanup for failed compaction

This commit is contained in:
Chris Lu
2017-08-29 23:59:53 -07:00
parent f7c22f0159
commit 58344980e4
10 changed files with 92 additions and 17 deletions

View File

@@ -22,13 +22,13 @@ func (s *Store) CheckCompactVolume(volumeIdString string, garbageThresholdString
}
return fmt.Errorf("volume id %d is not found during check compact", vid), false
}
func (s *Store) CompactVolume(volumeIdString string) error {
func (s *Store) CompactVolume(volumeIdString string, preallocate int64) error {
vid, err := NewVolumeId(volumeIdString)
if err != nil {
return fmt.Errorf("Volume Id %s is not a valid unsigned integer", volumeIdString)
}
if v := s.findVolume(vid); v != nil {
return v.Compact()
return v.Compact(preallocate)
}
return fmt.Errorf("volume id %d is not found during compact", vid)
}
@@ -42,3 +42,13 @@ func (s *Store) CommitCompactVolume(volumeIdString string) error {
}
return fmt.Errorf("volume id %d is not found during commit compact", vid)
}
func (s *Store) CommitCleanupVolume(volumeIdString string) error {
vid, err := NewVolumeId(volumeIdString)
if err != nil {
return fmt.Errorf("Volume Id %s is not a valid unsigned integer", volumeIdString)
}
if v := s.findVolume(vid); v != nil {
return v.cleanupCompact()
}
return fmt.Errorf("volume id %d is not found during cleaning up", vid)
}