extent_io.c has debugging code to report and free leaked extent_state
and extent_buffer objects at rmmod time. This helps track down
leaks and it saves you from rebooting just to properly remove the
kmem_cache object.
But, the code runs under a fairly expensive spinlock and the checks to
see if it is currently enabled are not entirely consistent. Some use
#ifdef and some #if.
This changes everything to #if and disables the leak checking.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
static LIST_HEAD(states);
#define LEAK_DEBUG 0
static LIST_HEAD(states);
#define LEAK_DEBUG 0
static DEFINE_SPINLOCK(leak_lock);
#endif
static DEFINE_SPINLOCK(leak_lock);
#endif
static struct extent_state *alloc_extent_state(gfp_t mask)
{
struct extent_state *state;
static struct extent_state *alloc_extent_state(gfp_t mask)
{
struct extent_state *state;
unsigned long flags;
#endif
unsigned long flags;
#endif
state->state = 0;
state->private = 0;
state->tree = NULL;
state->state = 0;
state->private = 0;
state->tree = NULL;
spin_lock_irqsave(&leak_lock, flags);
list_add(&state->leak_list, &states);
spin_unlock_irqrestore(&leak_lock, flags);
spin_lock_irqsave(&leak_lock, flags);
list_add(&state->leak_list, &states);
spin_unlock_irqrestore(&leak_lock, flags);
if (!state)
return;
if (atomic_dec_and_test(&state->refs)) {
if (!state)
return;
if (atomic_dec_and_test(&state->refs)) {
unsigned long flags;
#endif
WARN_ON(state->tree);
unsigned long flags;
#endif
WARN_ON(state->tree);
spin_lock_irqsave(&leak_lock, flags);
list_del(&state->leak_list);
spin_unlock_irqrestore(&leak_lock, flags);
spin_lock_irqsave(&leak_lock, flags);
list_del(&state->leak_list);
spin_unlock_irqrestore(&leak_lock, flags);
gfp_t mask)
{
struct extent_buffer *eb = NULL;
gfp_t mask)
{
struct extent_buffer *eb = NULL;
unsigned long flags;
#endif
unsigned long flags;
#endif
eb->start = start;
eb->len = len;
mutex_init(&eb->mutex);
eb->start = start;
eb->len = len;
mutex_init(&eb->mutex);
spin_lock_irqsave(&leak_lock, flags);
list_add(&eb->leak_list, &buffers);
spin_unlock_irqrestore(&leak_lock, flags);
spin_lock_irqsave(&leak_lock, flags);
list_add(&eb->leak_list, &buffers);
spin_unlock_irqrestore(&leak_lock, flags);
static void __free_extent_buffer(struct extent_buffer *eb)
{
static void __free_extent_buffer(struct extent_buffer *eb)
{
unsigned long flags;
spin_lock_irqsave(&leak_lock, flags);
list_del(&eb->leak_list);
unsigned long flags;
spin_lock_irqsave(&leak_lock, flags);
list_del(&eb->leak_list);