diff --git a/internal/lvmd/lvservice.go b/internal/lvmd/lvservice.go index cad569825..a7c0eb1d4 100644 --- a/internal/lvmd/lvservice.go +++ b/internal/lvmd/lvservice.go @@ -242,6 +242,18 @@ func (s *lvService) CreateLVSnapshot(ctx context.Context, req *proto.CreateLVSna return nil, status.Errorf(codes.OutOfRange, "requested size %v is smaller than source logical volume: %v", desiredSize, sizeOnCreation) } + pool, err := vg.FindPool(ctx, dc.ThinPoolConfig.Name) + if err != nil { + logger.Error(err, "failed to get thinpool") + return nil, status.Error(codes.Internal, err.Error()) + } + tpu, err := pool.Free(ctx) + free := calcThinPoolFreeBytes(dc.ThinPoolConfig.OverprovisionRatio, tpu.SizeBytes, tpu.VirtualBytes) + if free < desiredSize { + logger.Error(err, "not enough space left on VG", "free", free, "desiredSize", desiredSize) + return nil, status.Errorf(codes.ResourceExhausted, "no enough space left on VG: free=%d, desiredSize=%d", free, desiredSize) + } + logger.Info( "lvservice req", "sizeOnCreation", sizeOnCreation,