dm bufio: store stacktrace in buffers to help find buffer leaks
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 24 Nov 2015 00:20:06 +0000 (19:20 -0500)
committerMike Snitzer <snitzer@redhat.com>
Thu, 10 Dec 2015 15:38:58 +0000 (10:38 -0500)
commit86bad0c7071c24efee0a395d8b622764bdd24320
tree49fa95844e79ed05c16735dfa31cb6953683836d
parentf98c8f797021e78ba27143ecd39c51995c47aa8b
dm bufio: store stacktrace in buffers to help find buffer leaks

The option DM_DEBUG_BLOCK_STACK_TRACING is moved from persistent-data
directory to device mapper directory because it will now be used by
persistent-data and bufio.  When the option is enabled, each bufio buffer
stores the stacktrace of the last dm_bufio_get(), dm_bufio_read() or
dm_bufio_new() call that increased the hold count to 1.  The buffer's
stacktrace is printed if the buffer was not released before the bufio
client is destroyed.

When DM_DEBUG_BLOCK_STACK_TRACING is enabled, any bufio buffer leaks are
considered warnings - i.e. the kernel continues afterwards.  If not
enabled, buffer leaks are considered BUGs and the kernel with crash.
Reasoning on this disposition is: if we only ever warned on buffer leaks
users would generally ignore them and the problematic code would never
get fixed.

Successfully used to find source of bufio leaks fixed with commit
fce079f63c3 ("dm btree: fix bufio buffer leaks in dm_btree_del() error
path").

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/Kconfig
drivers/md/dm-bufio.c
drivers/md/persistent-data/Kconfig