]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: add test for fiemap xfs issue when #extents > 1364 11554/head
authorNing Yao <yaoning@unitedstack.com>
Thu, 13 Oct 2016 09:25:36 +0000 (17:25 +0800)
committeryaoning <yaoning@unitedstack.com>
Thu, 3 Nov 2016 18:16:06 +0000 (02:16 +0800)
Signed-off-by: Ning Yao <yaoning@unitedstack.com>
src/test/objectstore/store_test.cc

index 6372742f3c2c69656159c789198ce4a97c1e7568..9451e554f3cd68748f7c3296237df758239b0b48 100644 (file)
@@ -264,6 +264,8 @@ TEST_P(StoreTest, FiemapEmpty) {
 
 TEST_P(StoreTest, FiemapHoles) {
   ObjectStore::Sequencer osr("test");
+  const uint64_t MAX_EXTENTS = 4000;
+  const uint64_t SKIP_STEP = 65536;
   coll_t cid;
   int r = 0;
   ghobject_t oid(hobject_t(sobject_t("fiemap_object", CEPH_NOSNAP)));
@@ -273,27 +275,28 @@ TEST_P(StoreTest, FiemapHoles) {
     ObjectStore::Transaction t;
     t.create_collection(cid, 0);
     t.touch(cid, oid);
-    t.write(cid, oid, 0, 3, bl);
-    t.write(cid, oid, 1048576, 3, bl);
-    t.write(cid, oid, 4194304, 3, bl);
+    for (uint64_t i = 0; i < MAX_EXTENTS; i++)
+      t.write(cid, oid, SKIP_STEP * i, 3, bl);
     r = apply_transaction(store, &osr, std::move(t));
     ASSERT_EQ(r, 0);
   }
   {
     bufferlist bl;
-    store->fiemap(cid, oid, 0, 4194307, bl);
+    store->fiemap(cid, oid, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3, bl);
     map<uint64_t,uint64_t> m, e;
     bufferlist::iterator p = bl.begin();
     ::decode(m, p);
     cout << " got " << m << std::endl;
     ASSERT_TRUE(!m.empty());
     ASSERT_GE(m[0], 3u);
+    bool extents_exist = true;
+    if (m.size() == MAX_EXTENTS) {
+      for (uint64_t i = 0; i < MAX_EXTENTS; i++)
+        extents_exist = extents_exist && m.count(SKIP_STEP*i);
+    }
     ASSERT_TRUE((m.size() == 1 &&
-                m[0] > 4194304u) ||
-               (m.size() == 3 &&
-                m.count(0) &&
-                m.count(1048576) &&
-                m.count(4194304)));
+                m[0] > SKIP_STEP * (MAX_EXTENTS - 1)) ||
+                (m.size() == MAX_EXTENTS && extents_exist));
   }
   {
     ObjectStore::Transaction t;