mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-12-17 17:51:20 +08:00
destroy ec volume if it is empty
This commit is contained in:
@@ -142,7 +142,7 @@ func (vs *VolumeServer) doDeleteMountedShards(ctx context.Context, req *volume_s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(ecv.Shards) == 0 {
|
if len(ecv.Shards) == 0 {
|
||||||
ecv.Destroy()
|
vs.store.DestroyEcVolume(needle.VolumeId(req.VolumeId))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -27,6 +27,17 @@ func (l *DiskLocation) FindEcVolume(vid needle.VolumeId) (*erasure_coding.EcVolu
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *DiskLocation) DestroyEcVolume(vid needle.VolumeId) {
|
||||||
|
l.ecVolumesLock.Lock()
|
||||||
|
defer l.ecVolumesLock.Unlock()
|
||||||
|
|
||||||
|
ecVolume, found := l.ecVolumes[vid]
|
||||||
|
if found {
|
||||||
|
ecVolume.Destroy()
|
||||||
|
delete(l.ecVolumes,vid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (l *DiskLocation) FindEcShard(vid needle.VolumeId, shardId erasure_coding.ShardId) (*erasure_coding.EcVolumeShard, bool) {
|
func (l *DiskLocation) FindEcShard(vid needle.VolumeId, shardId erasure_coding.ShardId) (*erasure_coding.EcVolumeShard, bool) {
|
||||||
l.ecVolumesLock.RLock()
|
l.ecVolumesLock.RLock()
|
||||||
defer l.ecVolumesLock.RUnlock()
|
defer l.ecVolumesLock.RUnlock()
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ func (s *Store) FindEcVolume(vid needle.VolumeId) (*erasure_coding.EcVolume, boo
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Store) DestroyEcVolume(vid needle.VolumeId) {
|
||||||
|
for _, location := range s.Locations {
|
||||||
|
location.DestroyEcVolume(vid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Store) ReadEcShardNeedle(ctx context.Context, vid needle.VolumeId, n *needle.Needle) (int, error) {
|
func (s *Store) ReadEcShardNeedle(ctx context.Context, vid needle.VolumeId, n *needle.Needle) (int, error) {
|
||||||
for _, location := range s.Locations {
|
for _, location := range s.Locations {
|
||||||
if localEcVolume, found := location.FindEcVolume(vid); found {
|
if localEcVolume, found := location.FindEcVolume(vid); found {
|
||||||
|
|||||||
Reference in New Issue
Block a user