]> 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>
Thu, 5 Jun 2025 19:31:56 +0000 (19:31 +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>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h
src/test/objectstore/test_bluefs.cc

index a8f961074a50784f02405cc7a3857d02cc049db6..fe1dccca01fe74a7cdf74158bc9f2479f0b4460b 100644 (file)
@@ -4695,7 +4695,6 @@ void BlueFS::_drain_writer(FileWriter *h)
     if (bdev[i]) {
       if (h->iocv[i]) {
        h->iocv[i]->aio_wait();
-       delete h->iocv[i];
       }
     }
   }
index a7e12e02e737a4c486b37c7675522378f30640b7..dfa0d1a1b09237a85c0eb860ebf48ffc5669240f 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 19328629558d08aea940a76264737ec25654455b..3abca215e7fb791adf17559af79058baad6d5504 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();
@@ -1435,6 +1435,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();
@@ -1454,6 +1455,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();
 }
@@ -1671,6 +1673,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
@@ -2125,6 +2128,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) {
@@ -2182,6 +2186,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) {
@@ -2242,6 +2247,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) {
@@ -2266,6 +2272,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) {