Skip to content

Commit 898f6e7

Browse files
committed
feat: minimal chunk size
Set the minimal chunk size to 512MB. By default, XFS requires 300MB. Additional logic will be needed if we plan to use smaller chunk sizes. Signed-off-by: Serge Logvinov <[email protected]>
1 parent d3b2b84 commit 898f6e7

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# syntax = docker/dockerfile:1.10
1+
# syntax = docker/dockerfile:1.12
22
########################################
33

44
FROM golang:1.23-bookworm AS develop

pkg/csi/controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,9 @@ func (d *ControllerService) CreateVolume(_ context.Context, request *csi.CreateV
120120
}
121121
}
122122

123-
// Volume Size - Default is 10 GiB
124-
volSizeBytes := DefaultVolumeSize * GiB
123+
volSizeBytes := DefaultVolumeSizeBytes
125124
if request.GetCapacityRange() != nil {
126-
volSizeBytes = RoundUpSizeBytes(request.GetCapacityRange().GetRequiredBytes(), GiB)
125+
volSizeBytes = RoundUpSizeBytes(request.GetCapacityRange().GetRequiredBytes(), MinChunkSizeBytes)
127126
}
128127

129128
accessibleTopology := request.GetAccessibilityRequirements()
@@ -601,7 +600,7 @@ func (d *ControllerService) ControllerExpandVolume(_ context.Context, request *c
601600
return nil, status.Error(codes.InvalidArgument, "CapacityRange must be provided")
602601
}
603602

604-
volSizeBytes := RoundUpSizeBytes(capacityRange.GetRequiredBytes(), GiB)
603+
volSizeBytes := RoundUpSizeBytes(capacityRange.GetRequiredBytes(), MinChunkSizeBytes)
605604
maxVolSize := capacityRange.GetLimitBytes()
606605

607606
if maxVolSize > 0 && maxVolSize < volSizeBytes {

pkg/csi/controller_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ clusters:
242242
"data": []interface{}{
243243
map[string]interface{}{
244244
"format": "raw",
245-
"size": 1024 * 1024 * 1024,
245+
"size": csi.MinChunkSizeBytes,
246246
"volid": "local-lvm:vm-9999-pvc-123",
247247
},
248248
map[string]interface{}{
@@ -252,7 +252,7 @@ clusters:
252252
},
253253
map[string]interface{}{
254254
"format": "raw",
255-
"size": csi.MinVolumeSize * 1024 * 1024 * 1024,
255+
"size": csi.MinChunkSizeBytes,
256256
"volid": "local-lvm:vm-9999-pvc-exist-same-size",
257257
},
258258
map[string]interface{}{
@@ -579,7 +579,7 @@ func (ts *csiTestSuite) TestCreateVolume() {
579579
Parameters: volParam,
580580
VolumeCapabilities: []*proto.VolumeCapability{volcap},
581581
CapacityRange: &proto.CapacityRange{
582-
RequiredBytes: 100,
582+
RequiredBytes: 1 * csi.GiB,
583583
},
584584
AccessibilityRequirements: &proto.TopologyRequirement{
585585
Preferred: []*proto.Topology{
@@ -616,7 +616,7 @@ func (ts *csiTestSuite) TestCreateVolume() {
616616
Volume: &proto.Volume{
617617
VolumeId: "cluster-1/pve-1/local-lvm/vm-9999-pvc-exist-same-size",
618618
VolumeContext: volParam,
619-
CapacityBytes: int64(1024 * 1024 * 1024),
619+
CapacityBytes: csi.MinChunkSizeBytes,
620620
AccessibleTopology: []*proto.Topology{
621621
{
622622
Segments: map[string]string{
@@ -650,7 +650,7 @@ func (ts *csiTestSuite) TestCreateVolume() {
650650
Volume: &proto.Volume{
651651
VolumeId: "cluster-1/pve-1/local-lvm/vm-9999-pvc-123",
652652
VolumeContext: volParam,
653-
CapacityBytes: int64(1024 * 1024 * 1024),
653+
CapacityBytes: csi.MinChunkSizeBytes,
654654
AccessibleTopology: []*proto.Topology{
655655
{
656656
Segments: map[string]string{

pkg/csi/driver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ const (
4545

4646
// MaxVolumesPerNode is the maximum number of volumes that can be attached to a node
4747
MaxVolumesPerNode = 24
48-
// MinVolumeSize is the minimum size of a volume
49-
MinVolumeSize = 1 // GB
50-
// DefaultVolumeSize is the default size of a volume
51-
DefaultVolumeSize = 10 // GB
48+
// DefaultVolumeSizeBytes is the default size of a volume
49+
DefaultVolumeSizeBytes = 10 * GiB
50+
// MinChunkSizeBytes is the minimum size of a volume chunk
51+
MinChunkSizeBytes = 512 * MiB
5252

5353
// EncryptionPassphraseKey is the encryption passphrase secret key
5454
EncryptionPassphraseKey = "encryption-passphrase"

0 commit comments

Comments
 (0)