From: Jason Dillaman Date: Tue, 3 Feb 2015 04:37:35 +0000 (-0500) Subject: rbd: add image flags to 'rbd info' X-Git-Tag: v0.93~102^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d00891f9a2bc041963cc1f60d0b4a2ea30133b75;p=ceph.git rbd: add image flags to 'rbd info' The 'rbd info' CLI tool now includes the image's flags. Signed-off-by: Jason Dillaman --- diff --git a/src/rbd.cc b/src/rbd.cc index dee1367c420a..806b73928777 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -208,6 +209,39 @@ static void format_features(Formatter *f, uint64_t features) f->close_section(); } +static void format_flags(Formatter *f, uint64_t flags) +{ + int count = 0; + std::map flag_mapping = boost::assign::map_list_of( + RBD_FLAG_OBJECT_MAP_INVALID, "object map invalid"); + + if (f == NULL) { + cout << "\tflags: "; + } else { + f->open_array_section("flags"); + } + for (std::map::iterator it = flag_mapping.begin(); + it != flag_mapping.end(); ++it) { + if ((it->first & flags) == 0) { + continue; + } + + if (f == NULL) { + if (count++ > 0) { + cout << ", "; + } + cout << it->second; + } else { + f->dump_string("flag", it->second); + } + } + if (f == NULL) { + cout << std::endl; + } else { + f->close_section(); + } +} + struct MyProgressContext : public librbd::ProgressContext { const char *operation; int last_pc; @@ -504,7 +538,7 @@ static int do_show_info(const char *imgname, librbd::Image& image, librbd::image_info_t info; string parent_pool, parent_name, parent_snapname; uint8_t old_format; - uint64_t overlap, features; + uint64_t overlap, features, flags; bool snap_protected = false; int r; @@ -524,6 +558,11 @@ static int do_show_info(const char *imgname, librbd::Image& image, if (r < 0) return r; + r = image.get_flags(&flags); + if (r < 0) { + return r; + } + if (snapname) { r = image.snap_is_protected(snapname, &snap_protected); if (r < 0) @@ -562,6 +601,7 @@ static int do_show_info(const char *imgname, librbd::Image& image, format_features(f, features); else cout << "\tfeatures: " << features_str(features) << std::endl; + format_flags(f, flags); } // snapshot info, if present