Skip to content

Commit 41c7e05

Browse files
committed
test/test_bluefs.cc: Fix valgrind reported memleaks
1. Moved BlueFS::FileWriter iovs cleanup from _drain_writer to destructor 2. Add missing umount()s, close_writer()s, delete writers Signed-off-by: Adam Kupczyk <[email protected]>
1 parent 12ffad5 commit 41c7e05

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/os/bluestore/BlueFS.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4695,7 +4695,6 @@ void BlueFS::_drain_writer(FileWriter *h)
46954695
if (bdev[i]) {
46964696
if (h->iocv[i]) {
46974697
h->iocv[i]->aio_wait();
4698-
delete h->iocv[i];
46994698
}
47004699
}
47014700
}

src/os/bluestore/BlueFS.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ class BlueFS {
434434
// NOTE: caller must call BlueFS::close_writer()
435435
~FileWriter() {
436436
--file->num_writers;
437+
for (unsigned i = 0; i < MAX_BDEV; ++i) {
438+
delete iocv[i];
439+
}
437440
}
438441

439442
// note: BlueRocksEnv uses this append exclusively, so it's safe

src/test/objectstore/test_bluefs.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ TEST(BlueFS, test_wal_migrate) {
11371137
gen_debugable(70000, bl1);
11381138
fs.append_try_flush(writer, bl1.c_str(), bl1.length());
11391139
fs.fsync(writer);
1140-
1140+
fs.close_writer(writer);
11411141
// WAL files don't update internal extents while writing to save memory, only on _replay
11421142
fs.umount();
11431143
fs.mount();
@@ -1435,6 +1435,7 @@ TEST(BlueFS, test_wal_read_after_rollback_to_v1) {
14351435
gen_debugable(70000, bl1);
14361436
fs.append_try_flush(writer, bl1.c_str(), bl1.length());
14371437
fs.fsync(writer);
1438+
fs.close_writer(writer);
14381439

14391440
g_ceph_context->_conf.set_val("bluefs_wal_envelope_mode", "false");
14401441
fs.umount();
@@ -1454,6 +1455,7 @@ TEST(BlueFS, test_wal_read_after_rollback_to_v1) {
14541455
ASSERT_EQ(0, fs.open_for_write(dir_db, wal_file, &writer, false));
14551456
ASSERT_NE(nullptr, writer);
14561457
ASSERT_EQ(writer->file->fnode.encoding, bluefs_node_encoding::PLAIN);
1458+
fs.close_writer(writer);
14571459
}
14581460
fs.umount();
14591461
}
@@ -1671,6 +1673,7 @@ TEST(BlueFS, truncate_fsync) {
16711673
fs.fsync(h);
16721674
fs.close_writer(h);
16731675
}
1676+
fs.umount();
16741677
}
16751678
{
16761679
//this was broken due to https://tracker.ceph.com/issues/55307
@@ -2125,6 +2128,7 @@ TEST(BlueFS, test_log_runway) {
21252128
utime_t mtime;
21262129
fs.stat("dir", "file", &file_size, &mtime);
21272130
ASSERT_EQ(file_size, 9);
2131+
fs.umount();
21282132
}
21292133

21302134
TEST(BlueFS, test_log_runway_2) {
@@ -2182,6 +2186,7 @@ TEST(BlueFS, test_log_runway_2) {
21822186
std::vector<std::string> ls_longdir;
21832187
fs.readdir(longdir, &ls_longdir);
21842188
ASSERT_EQ(ls_longdir.front(), longfile);
2189+
fs.umount();
21852190
}
21862191

21872192
TEST(BlueFS, test_log_runway_3) {
@@ -2242,6 +2247,7 @@ TEST(BlueFS, test_log_runway_3) {
22422247
fs.stat(longdir, longfile, &file_size, &mtime);
22432248
ASSERT_EQ(file_size, 6);
22442249
}
2250+
fs.umount();
22452251
}
22462252

22472253
TEST(BlueFS, test_log_runway_advance_seq) {
@@ -2266,6 +2272,7 @@ TEST(BlueFS, test_log_runway_advance_seq) {
22662272
std::string longdir(max_log_runway*2, 'A');
22672273
ASSERT_EQ(fs.mkdir(longdir), 0);
22682274
fs.compact_log();
2275+
fs.umount();
22692276
}
22702277

22712278
TEST(BlueFS, test_69481_truncate_corrupts_log) {

0 commit comments

Comments
 (0)