diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 0b9bb0bba8e984..baae7c5ab2b601 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -2507,6 +2507,9 @@ void BlueFS::_rewrite_log_and_layout_sync_LNF_LD(bool allocate_with_fallback, } #endif _flush_bdev(); + ++log.seq_live; + dirty.seq_live = log.seq_live; + log.t.seq = log.seq_live; super.memorized_layout = layout; super.log_fnode = log_file->fnode; diff --git a/src/test/objectstore/test_bluefs.cc b/src/test/objectstore/test_bluefs.cc index c68337222981eb..2a84b27c9992e2 100644 --- a/src/test/objectstore/test_bluefs.cc +++ b/src/test/objectstore/test_bluefs.cc @@ -618,6 +618,9 @@ TEST(BlueFS, test_compaction_sync) { g_ceph_context->_conf.set_val( "bluefs_compact_log_sync", "true"); + const char* canary_dir = "dir.after_compact_test"; + const char* canary_file = "file.after_compact_test"; + const char* canary_data = "some random data"; BlueFS fs(g_ceph_context); ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev.path, false, 1048576)); @@ -644,14 +647,12 @@ TEST(BlueFS, test_compaction_sync) { fs.compact_log(); { - string dir = "dir.after_compact_test"; - ASSERT_EQ(0, fs.mkdir(dir)); - string file = "file.after_compact_test"; + ASSERT_EQ(0, fs.mkdir(canary_dir)); BlueFS::FileWriter *h; - ASSERT_EQ(0, fs.open_for_write(dir, file, &h, false)); + ASSERT_EQ(0, fs.open_for_write(canary_dir, canary_file, &h, false)); ASSERT_NE(nullptr, h); auto sg = make_scope_guard([&fs, h] { fs.close_writer(h); }); - h->append("some data", 9); + h->append(canary_data, strlen(canary_data)); int r = fs.fsync(h); ASSERT_EQ(r, 0); } @@ -661,12 +662,12 @@ TEST(BlueFS, test_compaction_sync) { fs.mount(); { BlueFS::FileReader *h; - ASSERT_EQ(0, fs.open_for_read("dir.after_compact_test", "file.after_compact_test", &h)); + ASSERT_EQ(0, fs.open_for_read(canary_dir, canary_file, &h)); ASSERT_NE(nullptr, h); bufferlist bl; - ASSERT_EQ(9, fs.read(h, 0, 1024, &bl, NULL)); + ASSERT_EQ(strlen(canary_data), fs.read(h, 0, 1024, &bl, NULL)); std::cout << bl.c_str() << std::endl; - ASSERT_EQ(0, strncmp("some data", bl.c_str(), 9)); + ASSERT_EQ(0, strncmp(canary_data, bl.c_str(), strlen(canary_data))); delete h; } fs.umount(); @@ -681,6 +682,9 @@ TEST(BlueFS, test_compaction_async) { g_ceph_context->_conf.set_val( "bluefs_compact_log_sync", "false"); + const char* canary_dir = "dir.after_compact_test"; + const char* canary_file = "file.after_compact_test"; + const char* canary_data = "some random data"; BlueFS fs(g_ceph_context); ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev.path, false, 1048576)); @@ -707,14 +711,12 @@ TEST(BlueFS, test_compaction_async) { fs.compact_log(); { - string dir = "dir.after_compact_test"; - ASSERT_EQ(0, fs.mkdir(dir)); - string file = "file.after_compact_test"; + ASSERT_EQ(0, fs.mkdir(canary_dir)); BlueFS::FileWriter *h; - ASSERT_EQ(0, fs.open_for_write(dir, file, &h, false)); + ASSERT_EQ(0, fs.open_for_write(canary_dir, canary_file, &h, false)); ASSERT_NE(nullptr, h); auto sg = make_scope_guard([&fs, h] { fs.close_writer(h); }); - h->append("some data", 9); + h->append(canary_data, strlen(canary_data)); int r = fs.fsync(h); ASSERT_EQ(r, 0); } @@ -724,12 +726,12 @@ TEST(BlueFS, test_compaction_async) { fs.mount(); { BlueFS::FileReader *h; - ASSERT_EQ(0, fs.open_for_read("dir.after_compact_test", "file.after_compact_test", &h)); + ASSERT_EQ(0, fs.open_for_read(canary_dir, canary_file, &h)); ASSERT_NE(nullptr, h); bufferlist bl; - ASSERT_EQ(9, fs.read(h, 0, 1024, &bl, NULL)); + ASSERT_EQ(strlen(canary_data), fs.read(h, 0, 1024, &bl, NULL)); std::cout << bl.c_str() << std::endl; - ASSERT_EQ(0, strncmp("some data", bl.c_str(), 9)); + ASSERT_EQ(0, strncmp(canary_data, bl.c_str(), strlen(canary_data))); delete h; } fs.umount();