]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/operation/SnapshotUnprotectRequest.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / librbd / operation / SnapshotUnprotectRequest.cc
index 369d8e283a140e58bf372385a35a818013853a8c..4a58dbc0bbacbd15eec3809ab82c28d1c4c8c21d 100644 (file)
@@ -56,7 +56,7 @@ template <typename I>
 class C_ScanPoolChildren : public C_AsyncObjectThrottle<I> {
 public:
   C_ScanPoolChildren(AsyncObjectThrottle<I> &throttle, I *image_ctx,
-                     const ParentSpec &pspec, const Pools &pools,
+                     const cls::rbd::ParentImageSpec &pspec, const Pools &pools,
                      size_t pool_idx)
     : C_AsyncObjectThrottle<I>(throttle, *image_ctx), m_pspec(pspec),
       m_pool(pools[pool_idx]) {
@@ -64,7 +64,7 @@ public:
 
   int send() override {
     I &image_ctx = this->m_image_ctx;
-    assert(image_ctx.owner_lock.is_locked());
+    ceph_assert(image_ctx.owner_lock.is_locked());
 
     CephContext *cct = image_ctx.cct;
     ldout(cct, 10) << this << " scanning pool '" << m_pool.second << "'"
@@ -87,14 +87,11 @@ public:
       return 1;
     }
 
-    r = rados.ioctx_create2(m_pool.first, m_pool_ioctx);
+    r = util::create_ioctx(image_ctx.md_ctx, "child image", m_pool.first, {},
+                           &m_pool_ioctx);
     if (r == -ENOENT) {
-      ldout(cct, 1) << "pool '" << m_pool.second << "' no longer exists"
-                    << dendl;
       return 1;
     } else if (r < 0) {
-      lderr(cct) << "can't create ioctx for pool '" << m_pool.second
-                 << "'" << dendl;
       return r;
     }
 
@@ -105,7 +102,7 @@ public:
       util::create_rados_callback(this);
     r = m_pool_ioctx.aio_operate(RBD_CHILDREN, rados_completion, &op,
                                  &m_children_bl);
-    assert(r == 0);
+    ceph_assert(r == 0);
     rados_completion->release();
     return 0;
   }
@@ -116,7 +113,7 @@ protected:
     CephContext *cct = image_ctx.cct;
 
     if (r == 0) {
-      bufferlist::iterator it = m_children_bl.begin();
+      auto it = m_children_bl.cbegin();
       r= cls_client::get_children_finish(&it, &m_children);
     }
 
@@ -139,7 +136,7 @@ protected:
   }
 
 private:
-  ParentSpec m_pspec;
+  cls::rbd::ParentImageSpec m_pspec;
   Pool m_pool;
 
   IoCtx m_pool_ioctx;
@@ -155,7 +152,8 @@ SnapshotUnprotectRequest<I>::SnapshotUnprotectRequest(I &image_ctx,
                                                       const cls::rbd::SnapshotNamespace &snap_namespace,
                                                      const std::string &snap_name)
   : Request<I>(image_ctx, on_finish), m_snap_namespace(snap_namespace),
-    m_snap_name(snap_name), m_ret_val(0), m_snap_id(CEPH_NOSNAP) {
+    m_snap_name(snap_name), m_state(STATE_UNPROTECT_SNAP_START),
+    m_ret_val(0), m_snap_id(CEPH_NOSNAP) {
 }
 
 template <typename I>
@@ -198,7 +196,7 @@ bool SnapshotUnprotectRequest<I>::should_complete(int r) {
     finished = true;
     break;
   default:
-    assert(false);
+    ceph_abort();
     break;
   }
   return finished;
@@ -224,13 +222,11 @@ bool SnapshotUnprotectRequest<I>::should_complete_error() {
 template <typename I>
 void SnapshotUnprotectRequest<I>::send_unprotect_snap_start() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  ceph_assert(image_ctx.owner_lock.is_locked());
 
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
 
-  m_state = STATE_UNPROTECT_SNAP_START;
-
   int r = verify_and_send_unprotect_snap_start();
   if (r < 0) {
     this->async_complete(r);
@@ -241,7 +237,7 @@ void SnapshotUnprotectRequest<I>::send_unprotect_snap_start() {
 template <typename I>
 void SnapshotUnprotectRequest<I>::send_scan_pool_children() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  ceph_assert(image_ctx.owner_lock.is_locked());
 
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
@@ -256,7 +252,9 @@ void SnapshotUnprotectRequest<I>::send_scan_pool_children() {
   std::list<Pool> pool_list;
   rados.pool_list2(pool_list);
 
-  ParentSpec pspec(image_ctx.md_ctx.get_id(), image_ctx.id, m_snap_id);
+  cls::rbd::ParentImageSpec pspec(image_ctx.md_ctx.get_id(),
+                                  image_ctx.md_ctx.get_namespace(),
+                                  image_ctx.id, m_snap_id);
   Pools pools(pool_list.begin(), pool_list.end());
 
   Context *ctx = this->create_callback_context();
@@ -265,13 +263,14 @@ void SnapshotUnprotectRequest<I>::send_scan_pool_children() {
       boost::lambda::_1, &image_ctx, pspec, pools, boost::lambda::_2));
   AsyncObjectThrottle<I> *throttle = new AsyncObjectThrottle<I>(
     nullptr, image_ctx, context_factory, ctx, NULL, 0, pools.size());
-  throttle->start_ops(image_ctx.concurrent_management_ops);
+  throttle->start_ops(
+    image_ctx.config.template get_val<uint64_t>("rbd_concurrent_management_ops"));
 }
 
 template <typename I>
 void SnapshotUnprotectRequest<I>::send_unprotect_snap_finish() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  ceph_assert(image_ctx.owner_lock.is_locked());
 
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
@@ -284,14 +283,14 @@ void SnapshotUnprotectRequest<I>::send_unprotect_snap_finish() {
 
   librados::AioCompletion *comp = this->create_callback_completion();
   int r = image_ctx.md_ctx.aio_operate(image_ctx.header_oid, comp, &op);
-  assert(r == 0);
+  ceph_assert(r == 0);
   comp->release();
 }
 
 template <typename I>
 void SnapshotUnprotectRequest<I>::send_unprotect_snap_rollback() {
   I &image_ctx = this->m_image_ctx;
-  assert(image_ctx.owner_lock.is_locked());
+  ceph_assert(image_ctx.owner_lock.is_locked());
 
   CephContext *cct = image_ctx.cct;
   ldout(cct, 5) << this << " " << __func__ << dendl;
@@ -304,7 +303,7 @@ void SnapshotUnprotectRequest<I>::send_unprotect_snap_rollback() {
 
   librados::AioCompletion *comp = this->create_callback_completion();
   int r = image_ctx.md_ctx.aio_operate(image_ctx.header_oid, comp, &op);
-  assert(r == 0);
+  ceph_assert(r == 0);
   comp->release();
 }
 
@@ -342,7 +341,7 @@ int SnapshotUnprotectRequest<I>::verify_and_send_unprotect_snap_start() {
 
   librados::AioCompletion *comp = this->create_callback_completion();
   r = image_ctx.md_ctx.aio_operate(image_ctx.header_oid, comp, &op);
-  assert(r == 0);
+  ceph_assert(r == 0);
   comp->release();
 
   // TODO legacy code threw a notification post UNPROTECTING update -- required?