Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128836
b: refs/heads/master
c: a61e6f2
h: refs/heads/master
v: v3
  • Loading branch information
Chris Mason committed Sep 25, 2008
1 parent 06e2c03 commit 96239d4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6af118ce51b52ceda357c671550c79628b9c4a65
refs/heads/master: a61e6f29dc7c9d56a776a518eed92bbc61848263
7 changes: 1 addition & 6 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ static int pin_down_bytes(struct btrfs_root *root, u64 bytenr, u32 num_bytes,
struct extent_buffer *buf;
buf = btrfs_find_tree_block(root, bytenr, num_bytes);
if (buf) {
if (!btrfs_try_tree_lock(buf) &&
if (btrfs_try_tree_lock(buf) &&
btrfs_buffer_uptodate(buf, 0)) {
u64 transid =
root->fs_info->running_transaction->transid;
Expand Down Expand Up @@ -3345,11 +3345,6 @@ int btrfs_read_block_groups(struct btrfs_root *root)
set_state_private(block_group_cache, found_key.objectid,
(unsigned long)cache);

/* hack for now */
if (cache->flags & BTRFS_BLOCK_GROUP_METADATA) {
cache_block_group(root->fs_info->extent_root,
cache);
}
if (key.objectid >=
btrfs_super_total_bytes(&info->super_copy))
break;
Expand Down
9 changes: 9 additions & 0 deletions trunk/fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2690,6 +2690,7 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
eb = kmem_cache_zalloc(extent_buffer_cache, mask);
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);
Expand Down Expand Up @@ -2837,6 +2838,7 @@ int clear_extent_buffer_dirty(struct extent_io_tree *tree,

for (i = 0; i < num_pages; i++) {
page = extent_buffer_page(eb, i);
lock_page(page);
if (i == 0)
set_page_extent_head(page, eb->len);
else
Expand All @@ -2854,6 +2856,7 @@ int clear_extent_buffer_dirty(struct extent_io_tree *tree,
end = start + PAGE_CACHE_SIZE - 1;
if (test_range_bit(tree, start, end,
EXTENT_DIRTY, 0)) {
unlock_page(page);
continue;
}
}
Expand All @@ -2865,6 +2868,7 @@ int clear_extent_buffer_dirty(struct extent_io_tree *tree,
PAGECACHE_TAG_DIRTY);
}
read_unlock_irq(&page->mapping->tree_lock);
unlock_page(page);
}
return 0;
}
Expand Down Expand Up @@ -2893,12 +2897,17 @@ int set_extent_buffer_dirty(struct extent_io_tree *tree,
* on us if the page isn't already dirty.
*/
if (i == 0) {
lock_page(page);
set_page_extent_head(page, eb->len);
} else if (PagePrivate(page) &&
page->private != EXTENT_PAGE_PRIVATE) {
lock_page(page);
set_page_extent_mapped(page);
unlock_page(page);
}
__set_page_dirty_nobuffers(extent_buffer_page(eb, i));
if (i == 0)
unlock_page(page);
}
return set_extent_dirty(tree, eb->start,
eb->start + eb->len - 1, GFP_NOFS);
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/btrfs/extent_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct extent_buffer {
int flags;
struct list_head leak_list;
struct rb_node rb_node;
struct mutex mutex;
};

struct extent_map_tree;
Expand Down
13 changes: 6 additions & 7 deletions trunk/fs/btrfs/locking.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,31 @@ int btrfs_tree_lock(struct extent_buffer *eb)
{
int i;

if (!TestSetPageLocked(eb->first_page))
if (mutex_trylock(&eb->mutex))
return 0;
for (i = 0; i < 512; i++) {
cpu_relax();
if (!TestSetPageLocked(eb->first_page))
if (mutex_trylock(&eb->mutex))
return 0;
}
cpu_relax();
lock_page(eb->first_page);
mutex_lock(&eb->mutex);
return 0;
}

int btrfs_try_tree_lock(struct extent_buffer *eb)
{
return TestSetPageLocked(eb->first_page);
return mutex_trylock(&eb->mutex);
}

int btrfs_tree_unlock(struct extent_buffer *eb)
{
WARN_ON(!PageLocked(eb->first_page));
unlock_page(eb->first_page);
mutex_unlock(&eb->mutex);
return 0;
}

int btrfs_tree_locked(struct extent_buffer *eb)
{
return PageLocked(eb->first_page);
return mutex_is_locked(&eb->mutex);
}

0 comments on commit 96239d4

Please sign in to comment.