Add better valgrind support for journal write buffers.

This commit is contained in:
Justin Husted 2019-10-04 16:25:50 -07:00 committed by Kent Overstreet
parent ff4d082246
commit bf7574260c
2 changed files with 5 additions and 0 deletions

View 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 */

View 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);