]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: speed up librbd::copy based on objectmap 18967/head
authorSong Shun <song.shun3@zte.com.cn>
Wed, 15 Nov 2017 06:17:03 +0000 (14:17 +0800)
committerSong Shun <song.shun3@zte.com.cn>
Wed, 22 Nov 2017 04:40:33 +0000 (12:40 +0800)
  speed up librbd::copy based on objectmap

Signed-off-by: Song Shun <song.shun3@zte.com.cn>
src/librbd/internal.cc

index f583d9632a84a1c013351c2175a0826c8cbbf606..c1872295c68b9bb66865bf01e945d1851f1587ab 100644 (file)
@@ -1940,10 +1940,30 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2)
     uint64_t period = src->get_stripe_period();
     unsigned fadvise_flags = LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL |
                             LIBRADOS_OP_FLAG_FADVISE_NOCACHE;
+    uint64_t object_id = 0;
     for (uint64_t offset = 0; offset < src_size; offset += period) {
       if (throttle.pending_error()) {
         return throttle.wait_for_ret();
       }
+      
+      {
+        RWLock::RLocker snap_locker(src->snap_lock);
+        if (src->object_map != nullptr) {
+          bool skip = true;
+          // each period is related to src->stripe_count objects, check them all
+          for (uint64_t i=0; i < src->stripe_count; i++) {
+            if (object_id < src->object_map->size() &&
+                src->object_map->object_may_exist(object_id)) {
+              skip = false;
+            }
+            ++object_id;
+          }
+
+          if (skip) continue;
+        } else {
+          object_id += src->stripe_count;
+        }
+      }      
 
       uint64_t len = min(period, src_size - offset);
       bufferlist *bl = new bufferlist();