]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/test_bluefs.cc: Fix valgrind reported memleaks
authorAdam Kupczyk <akupczyk@ibm.com>
Thu, 5 Jun 2025 19:31:56 +0000 (19:31 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Fri, 6 Jun 2025 08:02:07 +0000 (08:02 +0000)
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 <akupczyk@ibm.com>
(cherry picked from commit 41c7e05be4eeacaaea87cab4addef7535f6bbcb7)

src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h
src/test/objectstore/test_bluefs.cc

index 4972518d4b6d96e41548e9a562b8857100e89c7c..12a0d6725202d75a6bc8fd700f7183f3c6f61d76 100644 (file)
@@ -4693,7 +4693,6 @@ void BlueFS::_drain_writer(FileWriter *h)
     if (bdev[i]) {
       if (h->iocv[i]) {
        h->iocv[i]->aio_wait();
-       delete h->iocv[i];
       }
     }
   }
index 8011292ebdc823dd9881b85a45b9f6660fbe14d5..fd5af65f321bc8b2cd0da4f676a135e19a839336 100644 (file)
@@ -434,6 +434,9 @@ public:
     // NOTE: caller must call BlueFS::close_writer()
     ~FileWriter() {
       --file->num_writers;
+      for (unsigned i = 0; i < MAX_BDEV; ++i) {
+        delete iocv[i];
+      }
     }
 
     // note: BlueRocksEnv uses this append exclusively, so it's safe
index 2193157cc8a246fa3e44c47b06a0fe252b0aaf69..b588839997ed91acab63690111537e8fab3c5bae 100644 (file)
@@ -1137,7 +1137,7 @@ TEST(BlueFS, test_wal_migrate) {
   gen_debugable(70000, bl1);
   fs.append_try_flush(writer, bl1.c_str(), bl1.length());
   fs.fsync(writer);
-
+  fs.close_writer(writer);
   // WAL files don't update internal extents while writing to save memory, only on _replay
   fs.umount();
   fs.mount();
@@ -1392,6 +1392,7 @@ TEST(BlueFS, test_wal_read_after_rollback_to_v1) {
   gen_debugable(70000, bl1);
   fs.append_try_flush(writer, bl1.c_str(), bl1.length());
   fs.fsync(writer);
+  fs.close_writer(writer);
 
   g_ceph_context->_conf.set_val("bluefs_wal_envelope_mode", "false");
   fs.umount();
@@ -1411,6 +1412,7 @@ TEST(BlueFS, test_wal_read_after_rollback_to_v1) {
     ASSERT_EQ(0, fs.open_for_write(dir_db, wal_file, &writer, false));
     ASSERT_NE(nullptr, writer);
     ASSERT_EQ(writer->file->fnode.encoding, bluefs_node_encoding::PLAIN);
+    fs.close_writer(writer);
   }
   fs.umount();
 }
@@ -1628,6 +1630,7 @@ TEST(BlueFS, truncate_fsync) {
         fs.fsync(h);
         fs.close_writer(h);
       }
+      fs.umount();
     }
     {
       //this was broken due to https://tracker.ceph.com/issues/55307
@@ -2082,6 +2085,7 @@ TEST(BlueFS, test_log_runway) {
   utime_t mtime;
   fs.stat("dir", "file", &file_size, &mtime);
   ASSERT_EQ(file_size, 9);
+  fs.umount();
 }
 
 TEST(BlueFS, test_log_runway_2) {
@@ -2139,6 +2143,7 @@ TEST(BlueFS, test_log_runway_2) {
   std::vector<std::string> ls_longdir;
   fs.readdir(longdir, &ls_longdir);
   ASSERT_EQ(ls_longdir.front(), longfile);
+  fs.umount();
 }
 
 TEST(BlueFS, test_log_runway_3) {
@@ -2199,6 +2204,7 @@ TEST(BlueFS, test_log_runway_3) {
     fs.stat(longdir, longfile, &file_size, &mtime);
     ASSERT_EQ(file_size, 6);
   }
+  fs.umount();
 }
 
 TEST(BlueFS, test_log_runway_advance_seq) {
@@ -2223,6 +2229,7 @@ TEST(BlueFS, test_log_runway_advance_seq) {
   std::string longdir(max_log_runway*2, 'A');
   ASSERT_EQ(fs.mkdir(longdir), 0);
   fs.compact_log();
+  fs.umount();
 }
 
 TEST(BlueFS, test_69481_truncate_corrupts_log) {