Btrfs: Change find_extent_buffer to use TestSetPageLocked
authorChris Mason <chris.mason@oracle.com>
Wed, 25 Jun 2008 20:01:31 +0000 (16:01 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:04:03 +0000 (11:04 -0400)
This makes it possible for callers to check for extent_buffers in cache
without deadlocking against any btree locks held.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c

index a9b3a25a45b79a216ec3fb854ccd119bcdd2c21b..dc3c03c6612db57af9e694f82831c43a0f407dc2 100644 (file)
@@ -1438,7 +1438,6 @@ static int pin_down_bytes(struct btrfs_root *root, u64 bytenr, u32 num_bytes,
        int err = 0;
 
        if (!pending) {
-#if 0
                struct extent_buffer *buf;
                buf = btrfs_find_tree_block(root, bytenr, num_bytes);
                if (buf) {
@@ -1460,7 +1459,6 @@ static int pin_down_bytes(struct btrfs_root *root, u64 bytenr, u32 num_bytes,
                        }
                        free_extent_buffer(buf);
                }
-#endif
                update_pinned_extents(root, bytenr, num_bytes, 1);
        } else {
                set_extent_bits(&root->fs_info->pending_del,
index bd15cdcaba952ac0bd83021c4596723a6dca33aa..40a5f53cb040eca7c7bb723f835a25c4f99729d3 100644 (file)
@@ -2808,10 +2808,15 @@ struct extent_buffer *find_extent_buffer(struct extent_io_tree *tree,
                goto lru_add;
 
        for (i = 0; i < num_pages; i++, index++) {
-               p = find_lock_page(mapping, index);
+               p = find_get_page(mapping, index);
                if (!p) {
                        goto fail;
                }
+               if (TestSetPageLocked(p)) {
+                       page_cache_release(p);
+                       goto fail;
+               }
+
                set_page_extent_mapped(p);
                mark_page_accessed(p);