]> git.hungrycats.org Git - linux/commitdiff
zygo: apply experimental patch from https://friendpaste.com/3relYTEwZZX44kxwOlrcQn... zygo-4.1-rc3-zb64
authorZygo Blaxell <zblaxell@thirteen.furryterror.org>
Fri, 15 May 2015 15:46:43 +0000 (11:46 -0400)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Fri, 15 May 2015 15:46:43 +0000 (11:46 -0400)
fs/btrfs/extent_io.c
fs/btrfs/inode.c

index 43af5a61ad25b4dbb3f4c0f2cb89160c120d1ac7..fe50c98b00a028e986d2ceab8b53c2098bd89c8e 100644 (file)
@@ -227,6 +227,7 @@ void free_extent_state(struct extent_state *state)
        if (!state)
                return;
        if (atomic_dec_and_test(&state->refs)) {
+               ASSERT(!waitqueue_active(&state->wq));
                WARN_ON(extent_state_in_tree(state));
                btrfs_leak_debug_del(&state->leak_list);
                trace_free_extent_state(state, _RET_IP_);
@@ -378,6 +379,7 @@ static void merge_state(struct extent_io_tree *tree,
                        state->start = other->start;
                        rb_erase(&other->rb_node, &tree->state);
                        RB_CLEAR_NODE(&other->rb_node);
+                       ASSERT(!waitqueue_active(&other->wq));
                        free_extent_state(other);
                }
        }
@@ -390,6 +392,7 @@ static void merge_state(struct extent_io_tree *tree,
                        state->end = other->end;
                        rb_erase(&other->rb_node, &tree->state);
                        RB_CLEAR_NODE(&other->rb_node);
+                       ASSERT(!waitqueue_active(&other->wq));
                        free_extent_state(other);
                }
        }
@@ -523,6 +526,8 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
        }
        clear_state_cb(tree, state, bits);
        state->state &= ~bits_to_clear;
+       smp_mb();
+       BUG_ON((bits_to_clear & EXTENT_LOCKED) && !wake && waitqueue_active(&state->wq));
        if (wake)
                wake_up(&state->wq);
        if (state->state == 0) {
@@ -530,6 +535,7 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
                if (extent_state_in_tree(state)) {
                        rb_erase(&state->rb_node, &tree->state);
                        RB_CLEAR_NODE(&state->rb_node);
+                       ASSERT(!waitqueue_active(&state->wq));
                        free_extent_state(state);
                } else {
                        WARN_ON(1);
index 8bb013672aee061e81eb03fcba6d51db9cd169af..1abc931c84d50a764938db80776d02cffd1fe3e6 100644 (file)
@@ -4990,14 +4990,24 @@ static void evict_inode_truncate_pages(struct inode *inode)
        while (!RB_EMPTY_ROOT(&io_tree->state)) {
                struct extent_state *state;
                struct extent_state *cached_state = NULL;
+               int locked;
 
                node = rb_first(&io_tree->state);
                state = rb_entry(node, struct extent_state, rb_node);
                atomic_inc(&state->refs);
                spin_unlock(&io_tree->lock);
 
+               locked = state->state & EXTENT_LOCKED;
+               if (locked)
+                       printk(KERN_ERR "AQUI3 evict inode %llu root %llu range [%llu %llu], state %u, refs %d, before lock, in tree %d\n",
+                              btrfs_ino(inode), BTRFS_I(inode)->root->root_key.objectid, state->start, state->end, state->state,
+                              atomic_read(&state->refs), !RB_EMPTY_NODE(&state->rb_node));
                lock_extent_bits(io_tree, state->start, state->end,
                                 0, &cached_state);
+               if (locked)
+                       printk(KERN_ERR "AQUI3 evict inode %llu root %llu range [%llu %llu], state %u, refs %d, after lock, in tree %d\n",
+                              btrfs_ino(inode), BTRFS_I(inode)->root->root_key.objectid, state->start, state->end, state->state,
+                              atomic_read(&state->refs), !RB_EMPTY_NODE(&state->rb_node));
                clear_extent_bit(io_tree, state->start, state->end,
                                 EXTENT_LOCKED | EXTENT_DIRTY |
                                 EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING |