Browse Source

MountEcShards/UnmountEcShards updated for generation support

add-ec-vacuum
chrislu 4 months ago
parent
commit
99f132729c
  1. 2
      weed/server/volume_grpc_erasure_coding.go
  2. 6
      weed/shell/command_ec_common.go
  3. 4
      weed/storage/store_ec.go

2
weed/server/volume_grpc_erasure_coding.go

@ -324,7 +324,7 @@ func (vs *VolumeServer) VolumeEcShardsUnmount(ctx context.Context, req *volume_s
glog.V(0).Infof("VolumeEcShardsUnmount: %v", req)
for _, shardId := range req.ShardIds {
err := vs.store.UnmountEcShards(needle.VolumeId(req.VolumeId), erasure_coding.ShardId(shardId))
err := vs.store.UnmountEcShards(needle.VolumeId(req.VolumeId), erasure_coding.ShardId(shardId), req.Generation)
if err != nil {
glog.Errorf("ec shard unmount %v: %v", req, err)

6
weed/shell/command_ec_common.go

@ -441,8 +441,9 @@ func unmountEcShards(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, s
return operation.WithVolumeServerClient(false, sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
_, deleteErr := volumeServerClient.VolumeEcShardsUnmount(context.Background(), &volume_server_pb.VolumeEcShardsUnmountRequest{
VolumeId: uint32(volumeId),
ShardIds: toBeUnmountedhardIds,
VolumeId: uint32(volumeId),
ShardIds: toBeUnmountedhardIds,
Generation: 0, // shell commands operate on existing (generation 0) volumes
})
return deleteErr
})
@ -457,6 +458,7 @@ func mountEcShards(grpcDialOption grpc.DialOption, collection string, volumeId n
VolumeId: uint32(volumeId),
Collection: collection,
ShardIds: toBeMountedhardIds,
Generation: 0, // shell commands operate on existing (generation 0) volumes
})
return mountErr
})

4
weed/storage/store_ec.go

@ -62,6 +62,7 @@ func (s *Store) MountEcShards(collection string, vid needle.VolumeId, shardId er
DiskType: string(location.DiskType),
ExpireAtSec: ecVolume.ExpireAtSec,
DiskId: uint32(diskId),
Generation: generation, // include generation in mount message
}
return nil
} else if err == os.ErrNotExist {
@ -74,7 +75,7 @@ func (s *Store) MountEcShards(collection string, vid needle.VolumeId, shardId er
return fmt.Errorf("MountEcShards %d.%d not found on disk", vid, shardId)
}
func (s *Store) UnmountEcShards(vid needle.VolumeId, shardId erasure_coding.ShardId) error {
func (s *Store) UnmountEcShards(vid needle.VolumeId, shardId erasure_coding.ShardId, generation uint32) error {
diskId, ecShard, found := s.findEcShard(vid, shardId)
if !found {
@ -88,6 +89,7 @@ func (s *Store) UnmountEcShards(vid needle.VolumeId, shardId erasure_coding.Shar
EcIndexBits: uint32(shardBits.AddShardId(shardId)),
DiskType: string(ecShard.DiskType),
DiskId: diskId,
Generation: generation, // include generation in unmount message
}
location := s.Locations[diskId]

Loading…
Cancel
Save