From 340e124452d1cdf0084f13e21d2d79d054eb0dce Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Fri, 14 Sep 2018 16:38:01 +0200 Subject: [PATCH 1/3] Convert RBD feature flags to constants with iota --- rbd/rbd.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/rbd/rbd.go b/rbd/rbd.go index d4f839a..7319384 100644 --- a/rbd/rbd.go +++ b/rbd/rbd.go @@ -16,15 +16,27 @@ import ( "unsafe" ) +const ( + // RBD features + RbdFeatureLayering uint64 = 1 << iota + RbdFeatureStripingV2 + RbdFeatureExclusiveLock + RbdFeatureObjectMap + RbdFeatureFastDiff + RbdFeatureDeepFlatten + RbdFeatureJournaling + RbdFeatureDataPool + RbdFeatureOperations + RbdFeatureMigrating +) + // type RBDError int -var RbdErrorImageNotOpen = errors.New("RBD image not open") -var RbdErrorNotFound = errors.New("RBD image not found") - -//Rdb feature -var RbdFeatureLayering = uint64(1 << 0) -var RbdFeatureStripingV2 = uint64(1 << 1) +var ( + RbdErrorImageNotOpen = errors.New("RBD image not open") + RbdErrorNotFound = errors.New("RBD image not found") +) // type ImageInfo struct { From 3a8c38ca4114586978a2ff91e9db0e353ac05672 Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Fri, 14 Sep 2018 16:59:08 +0200 Subject: [PATCH 2/3] Add RBD feature flag sets as per Python rbd module --- rbd/rbd.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/rbd/rbd.go b/rbd/rbd.go index 7319384..38bf050 100644 --- a/rbd/rbd.go +++ b/rbd/rbd.go @@ -17,7 +17,7 @@ import ( ) const ( - // RBD features + // RBD features. RbdFeatureLayering uint64 = 1 << iota RbdFeatureStripingV2 RbdFeatureExclusiveLock @@ -28,6 +28,34 @@ const ( RbdFeatureDataPool RbdFeatureOperations RbdFeatureMigrating + + // Features that make an image inaccessible for read or write by clients that don't understand + // them. + RbdFeaturesIncompatible = RbdFeatureLayering | + RbdFeatureStripingV2 | + RbdFeatureDataPool + + // Features that make an image unwritable by clients that don't understand them. + RbdFeaturesRwIncompatible = RbdFeaturesIncompatible | + RbdFeatureExclusiveLock | + RbdFeatureObjectMap | + RbdFeatureFastDiff | + RbdFeatureDeepFlatten | + RbdFeatureJournaling | + RbdFeatureOperations | + RbdFeatureMigrating + + // Features that may be dynamically enabled or disabled. + RbdFeaturesMutable = RbdFeatureExclusiveLock | + RbdFeatureObjectMap | + RbdFeatureFastDiff | + RbdFeatureJournaling + + // Features that only work when used with a single client using the image for writes. + RbdFeaturesSingleClient = RbdFeatureExclusiveLock | + RbdFeatureObjectMap | + RbdFeatureFastDiff | + RbdFeatureJournaling ) // From 1623e77d20a2eb603c18c83575bf49894128e349 Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Fri, 14 Sep 2018 23:52:24 +0200 Subject: [PATCH 3/3] Wrap feature macros from rbd/features.h --- rbd/rbd.go | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/rbd/rbd.go b/rbd/rbd.go index 38bf050..e18567e 100644 --- a/rbd/rbd.go +++ b/rbd/rbd.go @@ -5,6 +5,7 @@ package rbd // #include // #include // #include +// #include import "C" import ( @@ -18,44 +19,29 @@ import ( const ( // RBD features. - RbdFeatureLayering uint64 = 1 << iota - RbdFeatureStripingV2 - RbdFeatureExclusiveLock - RbdFeatureObjectMap - RbdFeatureFastDiff - RbdFeatureDeepFlatten - RbdFeatureJournaling - RbdFeatureDataPool - RbdFeatureOperations - RbdFeatureMigrating + RbdFeatureLayering = C.RBD_FEATURE_LAYERING + RbdFeatureStripingV2 = C.RBD_FEATURE_STRIPINGV2 + RbdFeatureExclusiveLock = C.RBD_FEATURE_EXCLUSIVE_LOCK + RbdFeatureObjectMap = C.RBD_FEATURE_OBJECT_MAP + RbdFeatureFastDiff = C.RBD_FEATURE_FAST_DIFF + RbdFeatureDeepFlatten = C.RBD_FEATURE_DEEP_FLATTEN + RbdFeatureJournaling = C.RBD_FEATURE_JOURNALING + RbdFeatureDataPool = C.RBD_FEATURE_DATA_POOL + + RbdFeaturesDefault = C.RBD_FEATURES_DEFAULT // Features that make an image inaccessible for read or write by clients that don't understand // them. - RbdFeaturesIncompatible = RbdFeatureLayering | - RbdFeatureStripingV2 | - RbdFeatureDataPool + RbdFeaturesIncompatible = C.RBD_FEATURES_INCOMPATIBLE // Features that make an image unwritable by clients that don't understand them. - RbdFeaturesRwIncompatible = RbdFeaturesIncompatible | - RbdFeatureExclusiveLock | - RbdFeatureObjectMap | - RbdFeatureFastDiff | - RbdFeatureDeepFlatten | - RbdFeatureJournaling | - RbdFeatureOperations | - RbdFeatureMigrating + RbdFeaturesRwIncompatible = C.RBD_FEATURES_RW_INCOMPATIBLE // Features that may be dynamically enabled or disabled. - RbdFeaturesMutable = RbdFeatureExclusiveLock | - RbdFeatureObjectMap | - RbdFeatureFastDiff | - RbdFeatureJournaling + RbdFeaturesMutable = C.RBD_FEATURES_MUTABLE // Features that only work when used with a single client using the image for writes. - RbdFeaturesSingleClient = RbdFeatureExclusiveLock | - RbdFeatureObjectMap | - RbdFeatureFastDiff | - RbdFeatureJournaling + RbdFeaturesSingleClient = C.RBD_FEATURES_SINGLE_CLIENT ) //