diff --git a/Documentation/CRDs/specification.md b/Documentation/CRDs/specification.md
index 06754acbb..1715f8fe7 100644
--- a/Documentation/CRDs/specification.md
+++ b/Documentation/CRDs/specification.md
@@ -7169,6 +7169,19 @@ string
If absent, defaults to the plugin specified in osd_pool_default_erasure_code_profile.
+
+
+stripeUnit
+
+k8s.io/apimachinery/pkg/api/resource.Quantity
+
+ |
+
+(Optional)
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+Value must be a multiple of 4096 (4Ki).
+ |
+
ExternalSpec
diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml
index 2bdf52b20..bfb459d67 100644
--- a/deploy/charts/rook-ceph/templates/resources.yaml
+++ b/deploy/charts/rook-ceph/templates/resources.yaml
@@ -475,6 +475,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -7762,6 +7777,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -7957,6 +7987,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -12886,6 +12931,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -14528,6 +14588,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -15597,6 +15672,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -15787,6 +15877,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml
index dd845277a..355f7790c 100644
--- a/deploy/examples/crds.yaml
+++ b/deploy/examples/crds.yaml
@@ -477,6 +477,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -7757,6 +7772,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -7952,6 +7982,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -12875,6 +12920,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -14517,6 +14577,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -15583,6 +15658,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
@@ -15773,6 +15863,21 @@ spec:
as dataChunks so be aware that the larger the number of data chunks, the higher the cost of recovery.
minimum: 0
type: integer
+ stripeUnit:
+ anyOf:
+ - type: integer
+ - type: string
+ description: |-
+ Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ Value must be a multiple of 4096 (4Ki).
+ enum:
+ - 4Ki
+ - 16Ki
+ - 64Ki
+ - 256Ki
+ - 1Mi
+ pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
+ x-kubernetes-int-or-string: true
required:
- codingChunks
- dataChunks
diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go
index b1f07401d..f3ec2994e 100755
--- a/pkg/apis/ceph.rook.io/v1/types.go
+++ b/pkg/apis/ceph.rook.io/v1/types.go
@@ -1429,6 +1429,12 @@ type ErasureCodedSpec struct {
// +kubebuilder:validation:Enum=isa;jerasure
// +optional
Algorithm string `json:"algorithm,omitempty"`
+
+ // Erasure code stripe size in bytes. Ceph default is 4096 bytes (4 KiB).
+ // Value must be a multiple of 4096 (4Ki).
+ // +kubebuilder:validation:Enum={"4Ki","16Ki","64Ki","256Ki","1Mi"}
+ // +optional
+ StripeUnit *resource.Quantity `json:"stripeUnit,omitempty"`
}
// +genclient
diff --git a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go
index 0cba6d6ad..3ccfcfb33 100644
--- a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go
@@ -2690,6 +2690,11 @@ func (in *EndpointAddress) DeepCopy() *EndpointAddress {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ErasureCodedSpec) DeepCopyInto(out *ErasureCodedSpec) {
*out = *in
+ if in.StripeUnit != nil {
+ in, out := &in.StripeUnit, &out.StripeUnit
+ x := (*in).DeepCopy()
+ *out = &x
+ }
return
}
@@ -4922,7 +4927,7 @@ func (in *PoolSpec) DeepCopyInto(out *PoolSpec) {
**out = **in
}
in.Replicated.DeepCopyInto(&out.Replicated)
- out.ErasureCoded = in.ErasureCoded
+ in.ErasureCoded.DeepCopyInto(&out.ErasureCoded)
if in.Parameters != nil {
in, out := &in.Parameters, &out.Parameters
*out = make(map[string]string, len(*in))
diff --git a/pkg/daemon/ceph/client/erasure-code-profile.go b/pkg/daemon/ceph/client/erasure-code-profile.go
index 115e65c22..b6f2cb130 100644
--- a/pkg/daemon/ceph/client/erasure-code-profile.go
+++ b/pkg/daemon/ceph/client/erasure-code-profile.go
@@ -92,6 +92,13 @@ func CreateErasureCodeProfile(context *clusterd.Context, clusterInfo *ClusterInf
if pool.DeviceClass != "" {
profilePairs = append(profilePairs, fmt.Sprintf("crush-device-class=%s", pool.DeviceClass))
}
+ if pool.ErasureCoded.StripeUnit != nil && !pool.ErasureCoded.StripeUnit.IsZero() {
+ stripeBytes, ok := pool.ErasureCoded.StripeUnit.AsInt64()
+ if !ok {
+ return errors.Errorf("erasure-coded stripeUnit %q cannot be represented as a byte stripe for Ceph", pool.ErasureCoded.StripeUnit.String())
+ }
+ profilePairs = append(profilePairs, fmt.Sprintf("stripe_unit=%d", stripeBytes))
+ }
args := []string{"osd", "erasure-code-profile", "set", profileName, "--force"}
args = append(args, profilePairs...)
diff --git a/pkg/daemon/ceph/client/erasure-code-profile_test.go b/pkg/daemon/ceph/client/erasure-code-profile_test.go
index 26603113b..4b50a64c4 100644
--- a/pkg/daemon/ceph/client/erasure-code-profile_test.go
+++ b/pkg/daemon/ceph/client/erasure-code-profile_test.go
@@ -23,6 +23,7 @@ import (
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
exectest "github.com/rook/rook/pkg/util/exec/test"
"github.com/stretchr/testify/assert"
+ "k8s.io/apimachinery/pkg/api/resource"
"github.com/rook/rook/pkg/clusterd"
)
@@ -40,6 +41,7 @@ func TestCreateProfileWithDeviceClass(t *testing.T) {
}
func testCreateProfile(t *testing.T, failureDomain, crushRoot, deviceClass string) {
+ stripeUnit := resource.MustParse("4Ki")
spec := cephv1.PoolSpec{
FailureDomain: failureDomain,
CrushRoot: crushRoot,
@@ -47,6 +49,7 @@ func testCreateProfile(t *testing.T, failureDomain, crushRoot, deviceClass strin
ErasureCoded: cephv1.ErasureCodedSpec{
DataChunks: 2,
CodingChunks: 3,
+ StripeUnit: &stripeUnit,
},
}
@@ -77,6 +80,13 @@ func testCreateProfile(t *testing.T, failureDomain, crushRoot, deviceClass strin
}
if deviceClass != "" {
assert.Equal(t, fmt.Sprintf("crush-device-class=%s", deviceClass), args[nextArg])
+ nextArg++
+ }
+ if spec.ErasureCoded.StripeUnit != nil && !spec.ErasureCoded.StripeUnit.IsZero() {
+ stripeBytes, ok := spec.ErasureCoded.StripeUnit.AsInt64()
+ assert.True(t, ok)
+ assert.Equal(t, fmt.Sprintf("stripe_unit=%d", stripeBytes), args[nextArg])
+ assert.Equal(t, stripeBytes, int64(4096), "Validate the resource conversion to bytes")
}
return "", nil
}