]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Fix invalid compression statfs caused by clone op 11351/head
authorIgor Fedotov <ifedotov@mirantis.com>
Thu, 6 Oct 2016 16:29:47 +0000 (16:29 +0000)
committerIgor Fedotov <ifedotov@mirantis.com>
Thu, 6 Oct 2016 16:35:00 +0000 (16:35 +0000)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/BlueStore.cc
src/test/objectstore/store_test.cc

index 9ace1f8700ac53ad8189e1045c6912ece641b0cb..97bcf6f01de69362843ab70ed65c82ec9a234864 100644 (file)
@@ -8462,9 +8462,11 @@ int BlueStore::_do_clone_range(
     }
     dout(20) << __func__ << "  src " << e << dendl;
     BlobRef cb;
+    bool blob_duped = true;
     if (e.blob->last_encoded_id >= 0) {
       // blob is already duped
       cb = id_to_blob[e.blob->last_encoded_id];
+      blob_duped = false;
     } else {
       // dup the blob
       const bluestore_blob_t& blob = e.blob->get_blob();
@@ -8513,7 +8515,10 @@ int BlueStore::_do_clone_range(
     // be freed (relative to the shared_blob).
     txc->statfs_delta.stored() += ne->length;
     if (e.blob->get_blob().is_compressed()) {
-      txc->statfs_delta.compressed_original() -= ne->length;
+      txc->statfs_delta.compressed_original() += ne->length;
+      if (blob_duped){
+        txc->statfs_delta.compressed() += cb->get_blob().get_compressed_payload_length();;
+      }
     }
     dout(20) << __func__ << "  dst " << *ne << dendl;
     ++n;
index 3441d8b79f506da45d2e07b7110ea6e6ac77877d..c00cff73bddd3cbc7eb3c94928299cdd9f54d519 100644 (file)
@@ -1363,6 +1363,8 @@ TEST_P(StoreTest, BluestoreStatFSTest) {
   ObjectStore::Sequencer osr("test");
   coll_t cid;
   ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+  ghobject_t hoid2 = hoid;
+  hoid2.hobj.snap = 1;
   {
     bufferlist in;
     r = store->read(cid, hoid, 0, 5, in);
@@ -1552,10 +1554,30 @@ TEST_P(StoreTest, BluestoreStatFSTest) {
     EXPECT_EQ(store->umount(), 0);
     EXPECT_EQ(store->mount(), 0);
   }
+  {
+    struct store_statfs_t statfs;
+    r = store->statfs(&statfs);
+    ASSERT_EQ(r, 0);
+
+    ObjectStore::Transaction t;
+    t.clone(cid, hoid, hoid2);
+    cerr << "Clone compressed objecte" << std::endl;
+    r = apply_transaction(store, &osr, std::move(t));
+    ASSERT_EQ(r, 0);
+    struct store_statfs_t statfs2;
+    r = store->statfs(&statfs2);
+    ASSERT_EQ(r, 0);
+    ASSERT_GT(statfs2.stored, statfs.stored);
+    ASSERT_EQ(statfs2.allocated, statfs.allocated);
+    ASSERT_GT(statfs2.compressed, statfs.compressed);
+    ASSERT_GT(statfs2.compressed_original, statfs.compressed_original);
+    ASSERT_EQ(statfs2.compressed_allocated, statfs.compressed_allocated);
+  }
 
   {
     ObjectStore::Transaction t;
     t.remove(cid, hoid);
+    t.remove(cid, hoid2);
     t.remove_collection(cid);
     cerr << "Cleaning" << std::endl;
     r = apply_transaction(store, &osr, std::move(t));