From 7411773f7367f4ef05f9012f71361bfcd6cf6a70 Mon Sep 17 00:00:00 2001 From: Konstantin Shalygin Date: Thu, 16 Sep 2021 13:38:04 +0300 Subject: [PATCH] rbd: added RBD features support for krbd Added support for `object-map, fast-diff` Signed-off-by: Konstantin Shalygin --- charts/ceph-csi-rbd/values.yaml | 9 +++++---- docs/deploy-rbd.md | 2 +- examples/rbd/storageclass.yaml | 9 +++++---- internal/rbd/rbd_util.go | 10 +++++++++- internal/rbd/rbd_util_test.go | 32 ++++++++++++++++++++++++++++---- 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/charts/ceph-csi-rbd/values.yaml b/charts/ceph-csi-rbd/values.yaml index 740ff12db..e37e17de2 100644 --- a/charts/ceph-csi-rbd/values.yaml +++ b/charts/ceph-csi-rbd/values.yaml @@ -284,10 +284,11 @@ storageClass: thickProvision: false # (required) RBD image features, CSI creates image with image-format 2 - # CSI RBD currently supports `layering`, `journaling`, `exclusive-lock` - # features. If `journaling` is enabled, must enable `exclusive-lock` too. - # imageFeatures: layering,journaling,exclusive-lock - imageFeatures: layering + # CSI RBD currently supports `layering`, `journaling`, `exclusive-lock`, + # `object-map`, `fast-diff` features. If `journaling` is enabled, must + # enable `exclusive-lock` too. + # imageFeatures: layering,journaling,exclusive-lock,object-map,fast-diff + imageFeatures: "layering" # (optional) Specifies whether to try other mounters in case if the current # mounter fails to mount the rbd image for any reason. True means fallback diff --git a/docs/deploy-rbd.md b/docs/deploy-rbd.md index 2dd798c1e..6e20b5f98 100644 --- a/docs/deploy-rbd.md +++ b/docs/deploy-rbd.md @@ -55,7 +55,7 @@ make image-cephcsi | `dataPool` | no | Ceph pool used for the data of the RBD images. | | `volumeNamePrefix` | no | Prefix to use for naming RBD images (defaults to `csi-vol-`). | | `snapshotNamePrefix` | no | Prefix to use for naming RBD snapshot images (defaults to `csi-snap-`). | -| `imageFeatures` | yes | RBD image features. CSI RBD currently supports `layering`, `journaling`, `exclusive-lock` features. If `journaling` is enabled, must enable `exclusive-lock` too. See [man pages](http://docs.ceph.com/docs/master/man/8/rbd/#cmdoption-rbd-image-feature) Note that the required support for [object-map and fast-diff were added in 5.3 and journaling does not have KRBD support yet](https://docs.ceph.com/en/latest/rbd/rbd-config-ref/#image-features). deep-flatten is added for cloned images. | +| `imageFeatures` | yes | RBD image features. CSI RBD currently supports `layering`, `journaling`, `exclusive-lock`, `object-map`, `fast-diff` features. If `journaling` is enabled, must enable `exclusive-lock` too. See [man pages](http://docs.ceph.com/docs/master/man/8/rbd/#cmdoption-rbd-image-feature) Note that the required support for [object-map and fast-diff were added in 5.3 and journaling does not have KRBD support yet](https://docs.ceph.com/en/latest/rbd/rbd-config-ref/#image-features). deep-flatten is added for cloned images. | | `tryOtherMounters` | no | Specifies whether to try other mounters in case if the current mounter fails to mount the rbd image for any reason | | `mapOptions` | no | Map options to use when mapping rbd image. See [krbd](https://docs.ceph.com/docs/master/man/8/rbd/#kernel-rbd-krbd-options) and [nbd](https://docs.ceph.com/docs/master/man/8/rbd-nbd/#options) options. | | `unmapOptions` | no | Unmap options to use when unmapping rbd image. See [krbd](https://docs.ceph.com/docs/master/man/8/rbd/#kernel-rbd-krbd-options) and [nbd](https://docs.ceph.com/docs/master/man/8/rbd-nbd/#options) options. | diff --git a/examples/rbd/storageclass.yaml b/examples/rbd/storageclass.yaml index 65ce181ab..3df8552b3 100644 --- a/examples/rbd/storageclass.yaml +++ b/examples/rbd/storageclass.yaml @@ -34,10 +34,11 @@ parameters: # thickProvision: "false" # (required) RBD image features, CSI creates image with image-format 2 - # CSI RBD currently supports `layering`, `journaling`, `exclusive-lock` - # features. If `journaling` is enabled, must enable `exclusive-lock` too. - # imageFeatures: layering,journaling,exclusive-lock - imageFeatures: layering + # CSI RBD currently supports `layering`, `journaling`, `exclusive-lock`, + # `object-map`, `fast-diff` features. If `journaling` is enabled, must + # enable `exclusive-lock` too. + # imageFeatures: layering,journaling,exclusive-lock,object-map,fast-diff + imageFeatures: "layering" # (optional) Specifies whether to try other mounters in case if the current # mounter fails to mount the rbd image for any reason. True means fallback diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 1ac823be9..550ece80c 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -206,7 +206,15 @@ var ( needRbdNbd: false, }, librbd.FeatureNameExclusiveLock: { - needRbdNbd: true, + needRbdNbd: false, + }, + librbd.FeatureNameObjectMap: { + needRbdNbd: false, + dependsOn: []string{librbd.FeatureNameExclusiveLock}, + }, + librbd.FeatureNameFastDiff: { + needRbdNbd: false, + dependsOn: []string{librbd.FeatureNameObjectMap}, }, librbd.FeatureNameJournaling: { needRbdNbd: true, diff --git a/internal/rbd/rbd_util_test.go b/internal/rbd/rbd_util_test.go index f00bc038c..331eb693d 100644 --- a/internal/rbd/rbd_util_test.go +++ b/internal/rbd/rbd_util_test.go @@ -88,21 +88,37 @@ func TestValidateImageFeatures(t *testing.T) { false, "", }, + { + "layering,exclusive-lock,object-map,fast-diff", + &rbdVolume{ + Mounter: rbdDefaultMounter, + }, + false, + "", + }, { "layering,journaling", &rbdVolume{ - Mounter: rbdNbdMounter, + Mounter: rbdDefaultMounter, }, true, "feature journaling requires exclusive-lock to be set", }, { - "layering,exclusive-lock,journaling", + "object-map,fast-diff", &rbdVolume{ Mounter: rbdDefaultMounter, }, true, - "feature exclusive-lock requires rbd-nbd for mounter", + "feature object-map requires exclusive-lock to be set", + }, + { + "fast-diff", + &rbdVolume{ + Mounter: rbdDefaultMounter, + }, + true, + "feature fast-diff requires object-map to be set", }, { "layering,exclusive-lock,journaling", @@ -110,7 +126,15 @@ func TestValidateImageFeatures(t *testing.T) { Mounter: rbdDefaultMounter, }, true, - "feature exclusive-lock requires rbd-nbd for mounter", + "feature journaling requires rbd-nbd for mounter", + }, + { + "layering,exclusive-lock,journaling", + &rbdVolume{ + Mounter: rbdDefaultMounter, + }, + true, + "feature journaling requires rbd-nbd for mounter", }, { "layering,exclusive-loc,journaling",