]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Add better valgrind support for journal write buffers.
authorJustin Husted <sigstop@gmail.com>
Fri, 4 Oct 2019 23:25:50 +0000 (16:25 -0700)
committerKent Overstreet <kent.overstreet@gmail.com>
Mon, 4 Nov 2019 04:17:43 +0000 (23:17 -0500)
include/linux/bug.h
libbcachefs/journal_io.c

index a64a309c81a11f74f60ef2d57c9b83c751f5203c..eb53f39c15958c7fbdc94159417732d450814c7f 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <assert.h>
 #include <linux/compiler.h>
+#include <valgrind/memcheck.h>
 
 #define BUILD_BUG_ON_NOT_POWER_OF_2(n)                 \
        BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
@@ -52,4 +53,6 @@
        __ret_warn_on;                                                  \
 })
 
+#define DEBUG_MEMORY_FREED(p, len) VALGRIND_MAKE_MEM_UNDEFINED(p, len)
+
 #endif /* __TOOLS_LINUX_BUG_H */
index 387377dadab53c729b75b8df729c9ec5e53443fc..a6a4dda5eaa3a6606e1c01dd092704a1aad005c3 100644 (file)
@@ -934,6 +934,8 @@ out:
        /* also must come before signalling write completion: */
        closure_debug_destroy(cl);
 
+       DEBUG_MEMORY_FREED(w->data, w->buf_size);
+
        BUG_ON(!j->reservations.prev_buf_unwritten);
        atomic64_sub(((union journal_res_state) { .prev_buf_unwritten = 1 }).v,
                     &j->reservations.counter);