From 471a5a93bb074cdd3dfb8a2c5d5be754d55c6f00 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 16 Jan 2018 15:50:08 -0500 Subject: [PATCH] rbd: dump op features in image info Signed-off-by: Jason Dillaman --- .../cli-integration/rbd/formatted-output.t | 24 +++++++++++++++++++ src/tools/rbd/action/Info.cc | 16 +++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/test/cli-integration/rbd/formatted-output.t b/src/test/cli-integration/rbd/formatted-output.t index 4c2faf934a1ec..eae9d4ea01fb8 100644 --- a/src/test/cli-integration/rbd/formatted-output.t +++ b/src/test/cli-integration/rbd/formatted-output.t @@ -118,6 +118,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 2 (esc) \tfeatures: layering, exclusive-lock, object-map, fast-diff, deep-flatten (esc) + \top_features: (esc) \tflags: (esc) \tcreate_timestamp:* (glob) $ rbd info bar --format json | python -mjson.tool | sed 's/,$/, /' @@ -136,6 +137,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "name": "bar", "object_size": 4194304, "objects": 256, + "op_features": [], "order": 22, "size": 1073741824 } @@ -155,6 +157,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten + * (glob) @@ -165,6 +168,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 2 (esc) \tfeatures: layering, exclusive-lock, object-map, fast-diff, deep-flatten (esc) + \top_features: (esc) \tflags: (esc) \tcreate_timestamp:* (glob) \tprotected: True (esc) @@ -184,6 +188,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "name": "bar", "object_size": 4194304, "objects": 128, + "op_features": [], "order": 22, "protected": "true", "size": 536870912 @@ -204,6 +209,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten + * (glob) true @@ -215,6 +221,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 2 (esc) \tfeatures: layering, exclusive-lock, object-map, fast-diff, deep-flatten (esc) + \top_features: (esc) \tflags: (esc) \tcreate_timestamp:* (glob) \tprotected: False (esc) @@ -234,6 +241,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "name": "bar", "object_size": 4194304, "objects": 256, + "op_features": [], "order": 22, "protected": "false", "size": 1073741824 @@ -254,6 +262,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten + * (glob) false @@ -265,6 +274,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 2 (esc) \tfeatures: layering (esc) + \top_features: (esc) \tflags: (esc) \tcreate_timestamp:* (glob) $ rbd info baz --format json | python -mjson.tool | sed 's/,$/, /' @@ -279,6 +289,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "name": "baz", "object_size": 4194304, "objects": 512, + "op_features": [], "order": 22, "size": 2147483648 } @@ -294,6 +305,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. layering + * (glob) @@ -330,6 +342,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 2 (esc) \tfeatures: layering, exclusive-lock, object-map, fast-diff (esc) + \top_features: (esc) \tflags: (esc) \tcreate_timestamp:* (glob) $ rbd info rbd_other/child --format json | python -mjson.tool | sed 's/,$/, /' @@ -347,6 +360,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "name": "child", "object_size": 4194304, "objects": 128, + "op_features": [], "order": 22, "size": 536870912 } @@ -365,6 +379,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. object-map fast-diff + * (glob) @@ -375,6 +390,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 2 (esc) \tfeatures: layering, exclusive-lock, object-map, fast-diff (esc) + \top_features: (esc) \tflags: (esc) \tcreate_timestamp:* (glob) \tprotected: False (esc) @@ -395,6 +411,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "name": "child", "object_size": 4194304, "objects": 128, + "op_features": [], "order": 22, "parent": { "image": "bar", @@ -420,6 +437,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. object-map fast-diff + * (glob) false @@ -437,6 +455,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 2 (esc) \tfeatures: layering, exclusive-lock, object-map, fast-diff, deep-flatten (esc) + \top_features: (esc) \tflags: (esc) \tcreate_timestamp:* (glob) $ rbd info rbd_other/deep-flatten-child --format json | python -mjson.tool | sed 's/,$/, /' @@ -455,6 +474,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "name": "deep-flatten-child", "object_size": 4194304, "objects": 128, + "op_features": [], "order": 22, "size": 536870912 } @@ -474,6 +494,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten + * (glob) @@ -484,6 +505,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. [^^]+ (re) \tformat: 2 (esc) \tfeatures: layering, exclusive-lock, object-map, fast-diff, deep-flatten (esc) + \top_features: (esc) \tflags: (esc) \tcreate_timestamp:* (glob) \tprotected: False (esc) @@ -503,6 +525,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. "name": "deep-flatten-child", "object_size": 4194304, "objects": 128, + "op_features": [], "order": 22, "protected": "false", "size": 536870912 @@ -523,6 +546,7 @@ whenever it is run. grep -v to ignore it, but still work on other distros. fast-diff deep-flatten + * (glob) false diff --git a/src/tools/rbd/action/Info.cc b/src/tools/rbd/action/Info.cc index 5ed9c70eab224..8f462ba1fadcf 100644 --- a/src/tools/rbd/action/Info.cc +++ b/src/tools/rbd/action/Info.cc @@ -56,6 +56,15 @@ static void format_features(Formatter *f, uint64_t features) format_bitmask(f, "feature", at::ImageFeatures::FEATURE_MAPPING, features); } +static void format_op_features(Formatter *f, uint64_t op_features) +{ + static std::map mapping = { + {RBD_OPERATION_FEATURE_CLONE_V2, RBD_OPERATION_FEATURE_NAME_CLONE_V2}, + {RBD_OPERATION_FEATURE_GROUP, RBD_OPERATION_FEATURE_NAME_GROUP}, + {RBD_OPERATION_FEATURE_SNAP_TRASH, RBD_OPERATION_FEATURE_NAME_SNAP_TRASH}}; + format_bitmask(f, "op_feature", mapping, op_features); +} + static void format_flags(Formatter *f, uint64_t flags) { std::map mapping = { @@ -106,6 +115,12 @@ static int do_show_info(librados::IoCtx &io_ctx, librbd::Image& image, if (r < 0) return r; + uint64_t op_features; + r = image.get_op_features(&op_features); + if (r < 0) { + return r; + } + r = image.get_flags(&flags); if (r < 0) { return r; @@ -197,6 +212,7 @@ static int do_show_info(librados::IoCtx &io_ctx, librbd::Image& image, if (!old_format) { format_features(f, features); + format_op_features(f, op_features); format_flags(f, flags); } -- 2.39.5