]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/io: only track initial diff extents if no diffs exists
authorJason Dillaman <dillaman@redhat.com>
Wed, 3 Feb 2021 15:13:28 +0000 (10:13 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 4 Feb 2021 16:33:30 +0000 (11:33 -0500)
The purpose of the initial diff extents ({0, 0}) was to help track
whether or not objects exists for read-from-parent / whiteout
tracking. Once we have at least one set of diffs on the object, we
actually have enough information to know about the object state.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/io/ObjectRequest.cc
src/librbd/io/ObjectRequest.h

index 866e3c4ddafa97b1a6ec2d70f08a72083fa12129..b6287287326cc4c8166254b8b3d8d16edb133c7e 100644 (file)
@@ -786,7 +786,7 @@ void ObjectListSnapsRequest<I>::handle_list_snaps(int r) {
 
   if (r == -ENOENT) {
     // the object does not exist -- mark the missing extents
-    zero_initial_extent({}, true);
+    zero_initial_extent(true);
     list_from_parent();
     return;
   } else if (r < 0) {
@@ -805,6 +805,8 @@ void ObjectListSnapsRequest<I>::handle_list_snaps(int r) {
   librados::snap_t first_snap_id = *m_snap_ids.begin();
   librados::snap_t last_snap_id = *m_snap_ids.rbegin();
 
+  bool initial_extents_written = false;
+
   // loop through all expected snapshots and build interval sets for
   // data and zeroed ranges for each snapshot
   bool prev_exists = false;
@@ -895,8 +897,7 @@ void ObjectListSnapsRequest<I>::handle_list_snaps(int r) {
               interval.first, interval.second,
               SparseExtent(SPARSE_EXTENT_STATE_DATA, interval.second));
             if (maybe_whiteout_detected) {
-              initial_written_extents.union_insert(interval.first,
-                                                   interval.second);
+              initial_extents_written = true;
             }
           }
         } else {
@@ -915,8 +916,7 @@ void ObjectListSnapsRequest<I>::handle_list_snaps(int r) {
               interval.first, interval.second,
               SparseExtent(SPARSE_EXTENT_STATE_ZEROED, interval.second));
             if (maybe_whiteout_detected) {
-              initial_written_extents.union_insert(interval.first,
-                                                   interval.second);
+              initial_extents_written = true;
             }
           }
         }
@@ -929,7 +929,9 @@ void ObjectListSnapsRequest<I>::handle_list_snaps(int r) {
   }
 
   bool snapshot_delta_empty = snapshot_delta.empty();
-  zero_initial_extent(initial_written_extents, false);
+  if (!initial_extents_written) {
+    zero_initial_extent(false);
+  }
   ldout(cct, 20) << "snapshot_delta=" << snapshot_delta << dendl;
 
   if (snapshot_delta_empty) {
@@ -1040,8 +1042,7 @@ void ObjectListSnapsRequest<I>::handle_list_from_parent(int r) {
 }
 
 template <typename I>
-void ObjectListSnapsRequest<I>::zero_initial_extent(
-    const interval_set<uint64_t>& written_extents, bool dne) {
+void ObjectListSnapsRequest<I>::zero_initial_extent(bool dne) {
   I *image_ctx = this->m_ictx;
   auto cct = image_ctx->cct;
 
@@ -1058,10 +1059,6 @@ void ObjectListSnapsRequest<I>::zero_initial_extent(
       interval.insert(object_offset, object_length);
     }
 
-    interval_set<uint64_t> intersection;
-    intersection.intersection_of(interval, written_extents);
-
-    interval.subtract(intersection);
     for (auto [offset, length] : interval) {
       ldout(cct, 20) << "zeroing initial extent " << offset << "~" << length
                      << dendl;
index b3223304207e294d126a2a7c3bd017d4b20cf53f..8ba244b3d4676dd52c30cc3a4dddb1041a7911a8 100644 (file)
@@ -484,8 +484,7 @@ private:
   void list_from_parent();
   void handle_list_from_parent(int r);
 
-  void zero_initial_extent(const interval_set<uint64_t>& written_extents,
-                           bool dne);
+  void zero_initial_extent(bool dne);
 };
 
 } // namespace io