]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: use a bit to track if we're in the radix tree
authorJosef Bacik <jbacik@fb.com>
Fri, 13 Dec 2013 15:41:51 +0000 (10:41 -0500)
committerChris Mason <clm@fb.com>
Tue, 28 Jan 2014 21:19:54 +0000 (13:19 -0800)
For creating a dummy in-memory btree I need to be able to use the radix tree to
keep track of the buffers like normal extent buffers.  With dummy buffers we
skip the radix tree step, and we still want to do that for the tree mod log
dummy buffers but for my test buffers we need to be able to remove them from the
radix tree like normal.  This will give me a way to do that.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h

index 1d8244d39b66dddd37df240f386ee3d4d9629251..92a3ad4656a657dc76cf9a4a45a76e84cada3682 100644 (file)
@@ -4617,6 +4617,7 @@ again:
        }
        /* add one reference for the tree */
        check_buffer_tree_ref(eb);
+       set_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags);
 
        /*
         * there is a race where release page may have
@@ -4660,9 +4661,7 @@ static int release_extent_buffer(struct extent_buffer *eb)
 {
        WARN_ON(atomic_read(&eb->refs) == 0);
        if (atomic_dec_and_test(&eb->refs)) {
-               if (test_bit(EXTENT_BUFFER_DUMMY, &eb->bflags)) {
-                       spin_unlock(&eb->refs_lock);
-               } else {
+               if (test_and_clear_bit(EXTENT_BUFFER_IN_TREE, &eb->bflags)) {
                        struct extent_io_tree *tree = eb->tree;
 
                        spin_unlock(&eb->refs_lock);
@@ -4671,6 +4670,8 @@ static int release_extent_buffer(struct extent_buffer *eb)
                        radix_tree_delete(&tree->buffer,
                                          eb->start >> PAGE_CACHE_SHIFT);
                        spin_unlock(&tree->buffer_lock);
+               } else {
+                       spin_unlock(&eb->refs_lock);
                }
 
                /* Should be safe to release our pages at this point */
index 19620c58f096ef2dd8f0a5810ff632c575e0f5ee..92e4347315e6389cd9454d03a8a9d1c1bb1d3772 100644 (file)
@@ -43,6 +43,7 @@
 #define EXTENT_BUFFER_WRITEBACK 7
 #define EXTENT_BUFFER_IOERR 8
 #define EXTENT_BUFFER_DUMMY 9
+#define EXTENT_BUFFER_IN_TREE 10
 
 /* these are flags for extent_clear_unlock_delalloc */
 #define PAGE_UNLOCK            (1 << 0)