]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: tweaks to support testing of trim state machine
authorJason Dillaman <dillaman@redhat.com>
Fri, 13 Oct 2017 19:49:00 +0000 (15:49 -0400)
committerJason Dillaman <dillaman@redhat.com>
Sun, 15 Oct 2017 13:13:07 +0000 (09:13 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/io/ObjectRequest.cc
src/librbd/io/ObjectRequest.h
src/librbd/operation/TrimRequest.cc
src/librbd/operation/TrimRequest.h

index 0b2415cf42e8a2f443e9d1f3e42d1bbaaf7c3feb..d6a3905deabafb24a2c1ed6c70cd33c3eb780d23 100644 (file)
@@ -53,6 +53,16 @@ ObjectRequest<I>::create_truncate(I *ictx, const std::string &oid,
                                    object_off, snapc, parent_trace, completion);
 }
 
+template <typename I>
+ObjectRequest<I>*
+ObjectRequest<I>::create_trim(I *ictx, const std::string &oid,
+                              uint64_t object_no, const ::SnapContext &snapc,
+                              bool post_object_map_update,
+                              Context *completion) {
+  return new ObjectTrimRequest(util::get_image_ctx(ictx), oid, object_no,
+                               snapc, post_object_map_update, completion);
+}
+
 template <typename I>
 ObjectRequest<I>*
 ObjectRequest<I>::create_write(I *ictx, const std::string &oid,
index b683dbf12c56d33b331ac7382f038e226a763e31..9b6b5a9bc6d6ac89f56c7317c14e806c547ce20d 100644 (file)
@@ -58,6 +58,11 @@ public:
                                         const ::SnapContext &snapc,
                                        const ZTracer::Trace &parent_trace,
                                         Context *completion);
+  static ObjectRequest* create_trim(ImageCtxT *ictx, const std::string &oid,
+                                    uint64_t object_no,
+                                    const ::SnapContext &snapc,
+                                    bool post_object_map_update,
+                                    Context *completion);
   static ObjectRequest* create_write(ImageCtxT *ictx, const std::string &oid,
                                      uint64_t object_no,
                                      uint64_t object_off,
index a7e370b2fd1e67ec369c72fe99ac214c3670ff43..00d3423cb28f191e847457b148224771e73e1129 100644 (file)
@@ -45,8 +45,8 @@ public:
     string oid = image_ctx.get_object_name(m_object_no);
     ldout(image_ctx.cct, 10) << "removing (with copyup) " << oid << dendl;
 
-    auto req = new io::ObjectTrimRequest(&image_ctx, oid, m_object_no,
-                                         m_snapc, false, this);
+    auto req = io::ObjectRequest<I>::create_trim(&image_ctx, oid, m_object_no,
+                                                 m_snapc, false, this);
     req->send();
     return 0;
   }
@@ -58,7 +58,7 @@ private:
 template <typename I>
 class C_RemoveObject : public C_AsyncObjectThrottle<I> {
 public:
-  C_RemoveObject(AsyncObjectThrottle<I> &throttle, ImageCtx *image_ctx,
+  C_RemoveObject(AsyncObjectThrottle<I> &throttle, I *image_ctx,
                  uint64_t object_no)
     : C_AsyncObjectThrottle<I>(throttle, *image_ctx), m_object_no(object_no)
   {
@@ -281,7 +281,7 @@ void TrimRequest<I>::send_post_trim() {
   {
     RWLock::RLocker snap_locker(image_ctx.snap_lock);
     if (image_ctx.object_map != nullptr) {
-      ldout(image_ctx.cct, 5) << this << " send_post_copyup:"
+      ldout(image_ctx.cct, 5) << this << " send_post_trim:"
                               << " delete_start_min=" << m_delete_start_min
                               << " num_objects=" << m_num_objects << dendl;
       m_state = STATE_POST_TRIM;
@@ -338,13 +338,15 @@ void TrimRequest<I>::send_clean_boundary() {
     ldout(cct, 20) << " ex " << *p << dendl;
     Context *req_comp = new C_ContextCompletion(*completion);
 
-    io::ObjectRequest<> *req;
+    io::ObjectRequest<I> *req;
     if (p->offset == 0) {
-      req = new io::ObjectTrimRequest(&image_ctx, p->oid.name, p->objectno,
-                                      snapc, true, req_comp);
+      req = io::ObjectRequest<I>::create_trim(&image_ctx, p->oid.name,
+                                              p->objectno, snapc, true,
+                                              req_comp);
     } else {
-      req = new io::ObjectTruncateRequest(&image_ctx, p->oid.name, p->objectno,
-                                          p->offset, snapc, {}, req_comp);
+      req = io::ObjectRequest<I>::create_truncate(&image_ctx, p->oid.name,
+                                                  p->objectno, p->offset, snapc,
+                                                  {}, req_comp);
     }
     req->send();
   }
index 69fb5a97fd0d4d0b867ff24d3da0b07ba4e6f708..8526046c94b3e4d4a1ec431a384b2f825800aace 100644 (file)
@@ -24,6 +24,10 @@ public:
                            prog_ctx);
   }
 
+  TrimRequest(ImageCtxT &image_ctx, Context *on_finish,
+             uint64_t original_size, uint64_t new_size,
+             ProgressContext &prog_ctx);
+
   void send() override;
 
 protected:
@@ -86,10 +90,6 @@ private:
   uint64_t m_new_size;
   ProgressContext &m_prog_ctx;
 
-  TrimRequest(ImageCtxT &image_ctx, Context *on_finish,
-             uint64_t original_size, uint64_t new_size,
-             ProgressContext &prog_ctx);
-
   void send_pre_trim();
   void send_copyup_objects();
   void send_remove_objects();