]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_objectstore: add very_large_write test 28967/head
authorSage Weil <sage@redhat.com>
Tue, 16 Apr 2019 13:53:56 +0000 (08:53 -0500)
committerSage Weil <sage@redhat.com>
Wed, 10 Jul 2019 15:42:37 +0000 (10:42 -0500)
Write 2GB to verify the blockdevice aio splitting.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 1974f011137976edf277833d68bdcc4ff22779b0)

- fixed set_val/get_val usage

src/test/objectstore/test_bluefs.cc

index bef64f6d34f5edb6c574e363fab1f4b72134053c..ff62230f13f2b06883c4ed80f6a5359857bb3448 100644 (file)
@@ -135,6 +135,58 @@ TEST(BlueFS, small_appends) {
   rm_temp_bdev(fn);
 }
 
+TEST(BlueFS, very_large_write) {
+  // we'll write a ~3G file, so allocate more than that for the whole fs
+  uint64_t size = 1048576 * 1024 * 8ull;
+  string fn = get_temp_bdev(size);
+  BlueFS fs(g_ceph_context);
+
+  bool old = g_ceph_context->_conf->get_val<bool>("bluefs_buffered_io");
+  g_ceph_context->_conf->set_val("bluefs_buffered_io", "false");
+
+  ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, fn, false));
+  fs.add_block_extent(BlueFS::BDEV_DB, 1048576, size - 1048576);
+  uuid_d fsid;
+  ASSERT_EQ(0, fs.mkfs(fsid));
+  ASSERT_EQ(0, fs.mount());
+  char buf[1048571]; // this is biggish, but intentionally not evenly aligned
+  for (unsigned i = 0; i < sizeof(buf); ++i) {
+    buf[i] = i;
+  }
+  {
+    BlueFS::FileWriter *h;
+    ASSERT_EQ(0, fs.mkdir("dir"));
+    ASSERT_EQ(0, fs.open_for_write("dir", "bigfile", &h, false));
+    for (unsigned i = 0; i < 3*1024*1048576ull / sizeof(buf); ++i) {
+      h->append(buf, sizeof(buf));
+    }
+    fs.fsync(h);
+    fs.close_writer(h);
+  }
+  {
+    BlueFS::FileReader *h;
+    ASSERT_EQ(0, fs.open_for_read("dir", "bigfile", &h));
+    bufferlist bl;
+    BlueFS::FileReaderBuffer readbuf(10485760);
+    for (unsigned i = 0; i < 3*1024*1048576ull / sizeof(buf); ++i) {
+      bl.clear();
+      fs.read(h, &readbuf, i * sizeof(buf), sizeof(buf), &bl, NULL);
+      int r = memcmp(buf, bl.c_str(), sizeof(buf));
+      if (r) {
+       cerr << "read got mismatch at offset " << i*sizeof(buf) << " r " << r
+            << std::endl;
+      }
+      ASSERT_EQ(0, r);
+    }
+    delete h;
+  }
+  fs.umount();
+
+  g_ceph_context->_conf->set_val("bluefs_buffered_io", stringify((int)old));
+
+  rm_temp_bdev(fn);
+}
+
 #define ALLOC_SIZE 4096
 
 void write_data(BlueFS &fs, uint64_t rationed_bytes)