Skip to content

Commit

Permalink
Btrfs: disable leak debugging checks in extent_io.c
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
chrismason-xx committed Feb 4, 2009
1 parent b7a9f29 commit 3935127
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static LIST_HEAD(buffers);
static LIST_HEAD(states);

#define LEAK_DEBUG 0
#ifdef LEAK_DEBUG
#if LEAK_DEBUG
static DEFINE_SPINLOCK(leak_lock);
#endif

Expand Down Expand Up @@ -119,7 +119,7 @@ void extent_io_tree_init(struct extent_io_tree *tree,
static struct extent_state *alloc_extent_state(gfp_t mask)
{
struct extent_state *state;
#ifdef LEAK_DEBUG
#if LEAK_DEBUG
unsigned long flags;
#endif

Expand All @@ -129,7 +129,7 @@ static struct extent_state *alloc_extent_state(gfp_t mask)
state->state = 0;
state->private = 0;
state->tree = NULL;
#ifdef LEAK_DEBUG
#if LEAK_DEBUG
spin_lock_irqsave(&leak_lock, flags);
list_add(&state->leak_list, &states);
spin_unlock_irqrestore(&leak_lock, flags);
Expand All @@ -144,11 +144,11 @@ static void free_extent_state(struct extent_state *state)
if (!state)
return;
if (atomic_dec_and_test(&state->refs)) {
#ifdef LEAK_DEBUG
#if LEAK_DEBUG
unsigned long flags;
#endif
WARN_ON(state->tree);
#ifdef LEAK_DEBUG
#if LEAK_DEBUG
spin_lock_irqsave(&leak_lock, flags);
list_del(&state->leak_list);
spin_unlock_irqrestore(&leak_lock, flags);
Expand Down Expand Up @@ -2983,15 +2983,15 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
gfp_t mask)
{
struct extent_buffer *eb = NULL;
#ifdef LEAK_DEBUG
#if LEAK_DEBUG
unsigned long flags;
#endif

eb = kmem_cache_zalloc(extent_buffer_cache, mask);
eb->start = start;
eb->len = len;
mutex_init(&eb->mutex);
#ifdef LEAK_DEBUG
#if LEAK_DEBUG
spin_lock_irqsave(&leak_lock, flags);
list_add(&eb->leak_list, &buffers);
spin_unlock_irqrestore(&leak_lock, flags);
Expand All @@ -3003,7 +3003,7 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,

static void __free_extent_buffer(struct extent_buffer *eb)
{
#ifdef LEAK_DEBUG
#if LEAK_DEBUG
unsigned long flags;
spin_lock_irqsave(&leak_lock, flags);
list_del(&eb->leak_list);
Expand Down

0 comments on commit 3935127

Please sign in to comment.