]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/test_bluefs: reproduce a weird file unlink+fsync scenario.
authorIgor Fedotov <igor.fedotov@croit.io>
Tue, 12 Jul 2022 17:13:30 +0000 (20:13 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Fri, 4 Aug 2023 15:57:57 +0000 (18:57 +0300)
This triggers misordered op_update record in bluefs log which follows
op_unlink one.

Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
(cherry picked from commit 4240a315d663e2c68d796884c30be171dc73c397)

src/test/objectstore/test_bluefs.cc

index 3c6ec2dbb4419e725baf5a820ac613bb25e8512c..5698651f4edf49f39939320af091cd3052d4564a 100644 (file)
@@ -1302,6 +1302,44 @@ TEST(BlueFS, test_concurrent_dir_link_and_compact_log_56210) {
     }
   }
 }
+TEST(BlueFS, broken_unlink_fsync_seq) {
+  uint64_t size = 1048576 * 128;
+  TempBdev bdev{size};
+  BlueFS fs(g_ceph_context);
+  ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev.path, false, 1048576));
+  uuid_d fsid;
+  ASSERT_EQ(0, fs.mkfs(fsid, { BlueFS::BDEV_DB, false, false }));
+  ASSERT_EQ(0, fs.mount());
+  ASSERT_EQ(0, fs.maybe_verify_layout({ BlueFS::BDEV_DB, false, false }));
+  {
+    /*
+    * This reproduces a weird file op sequence (unlink+fsync) that Octopus
+    * RocksDB might issue to BlueFS when recycle_log_file_num setting is 0
+    * See https://tracker.ceph.com/issues/55636 for more details
+    *
+    */
+    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", "file", &h, false));
+
+    h->append(buf, sizeof(buf));
+    fs.flush(h);
+    h->append(buf, sizeof(buf));
+    fs.unlink("dir", "file");
+    fs.fsync(h);
+    fs.close_writer(h);
+  }
+  fs.umount();
+
+  // remount and check log can replay safe?
+  ASSERT_EQ(0, fs.mount());
+  ASSERT_EQ(0, fs.maybe_verify_layout({ BlueFS::BDEV_DB, false, false }));
+  fs.umount();
+}
 
 int main(int argc, char **argv) {
   auto args = argv_to_vec(argc, argv);