From 9782ddcbc08eb30f3120b78e6ac6f960474933fd Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Thu, 30 Aug 2018 08:31:10 -0400 Subject: [PATCH] librbd: require nautilus or later OSDs before permitting namespaces Signed-off-by: Jason Dillaman --- src/librbd/api/Namespace.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/librbd/api/Namespace.cc b/src/librbd/api/Namespace.cc index f73ae845486c2..37d8181aec1ce 100644 --- a/src/librbd/api/Namespace.cc +++ b/src/librbd/api/Namespace.cc @@ -23,11 +23,27 @@ int Namespace::create(librados::IoCtx& io_ctx, const std::string& name) return -EINVAL; } + librados::Rados rados(io_ctx); + int8_t require_osd_release; + int r = rados.get_min_compatible_osd(&require_osd_release); + if (r < 0) { + lderr(cct) << "failed to retrieve min OSD release: " << cpp_strerror(r) + << dendl; + return r; + } + + if (require_osd_release < CEPH_RELEASE_NAUTILUS) { + ldout(cct, 1) << "namespace support requires nautilus or later OSD" + << dendl; + return -ENOSYS; + } + + librados::IoCtx default_ns_ctx; default_ns_ctx.dup(io_ctx); default_ns_ctx.set_namespace(""); - int r = cls_client::namespace_add(&default_ns_ctx, name); + r = cls_client::namespace_add(&default_ns_ctx, name); if (r < 0) { lderr(cct) << "failed to add namespace: " << cpp_strerror(r) << dendl; return r; -- 2.39.5