Skip to content

Commit ef30b1d

Browse files
committed
test/objectstore/unittest_bluefs: Add test for envelope more recovery
The test intends to prove that recovery breaks when reading random data. The problem is that "length" read is random. When "length" is larger than 2^63 the read request is passed to Block Device, where it fail is_valid_io() test. Signed-off-by: Adam Kupczyk <[email protected]>
1 parent 56d7e88 commit ef30b1d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/test/objectstore/test_bluefs.cc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,49 @@ TEST_F(BlueFS_wal, wal_v2_simulate_crash)
12751275
fs.umount();
12761276
}
12771277

1278+
TEST_F(BlueFS_wal, wal_v2_recovery_from_dirty_allocated)
1279+
{
1280+
ConfSaver conf(g_ceph_context->_conf);
1281+
conf.SetVal("bluefs_alloc_size", "4096");
1282+
conf.SetVal("bluefs_shared_alloc_size", "4096");
1283+
conf.SetVal("bluefs_min_flush_size", "65536");
1284+
conf.SetVal("bluefs_wal_envelope_mode", "true");
1285+
conf.ApplyChanges();
1286+
1287+
Create(1048576 * 256, 1048576 * 128, 1048576 * 64);
1288+
ASSERT_EQ(0, fs.mount());
1289+
std::string dir = "dir";
1290+
std::string file = "wal.log";
1291+
int r = fs.mkdir(dir);
1292+
ASSERT_TRUE(r == 0 || r == -EEXIST);
1293+
BlueFS::FileWriter *writer;
1294+
ASSERT_EQ(0, fs.open_for_write(dir, file, &writer, false));
1295+
ASSERT_NE(nullptr, writer);
1296+
bufferlist content;
1297+
1298+
//preallocate and write "0xae" so ENVELOPE_MODE recovery will see length=0xaeaeaeaeaeaeaeae
1299+
fs.preallocate(writer->file, 0, 4096 * 2);
1300+
bluefs_extent_t ext = writer->file->fnode.extents[0];
1301+
BlockDevice* x = fs.get_block_device(ext.bdev);
1302+
ASSERT_EQ(ext.length, 4096 * 2);
1303+
bufferlist filler;
1304+
filler.append(string(4096 * 2, 0xae));
1305+
x->write(ext.offset, filler, false);
1306+
x->flush();
1307+
1308+
many_small_writes(writer, content, 4096 / (48 + 8 + 8) * 48, 48, 48, 0);
1309+
delete writer; //close without orderly shutdown, simulate failure
1310+
fs.umount();
1311+
fs.mount();
1312+
bufferlist read_content;
1313+
BlueFS::FileReader *h;
1314+
ASSERT_EQ(0, fs.open_for_read(dir, file, &h));
1315+
bufferlist bl;
1316+
ASSERT_EQ(0, fs.read(h, 0xea01020304050607, 1, &bl, NULL)); // no read but no failure
1317+
delete h;
1318+
fs.umount();
1319+
}
1320+
12781321
TEST_F(BlueFS_wal, support_wal_v2_and_v1)
12791322
{
12801323
ConfSaver conf(g_ceph_context->_conf);

0 commit comments

Comments
 (0)