aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-07-21 10:29:44 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:05 -0400
commit4a09675279674041862d2210635b0cc1f60be28e (patch)
tree19e4736c062f87729dcdc1bd57f4919b3227ec32 /fs/btrfs/inode.c
parente5a2217ef6ff088d08a27208929a6f9c635d672c (diff)
Btrfs: Data ordered fixes
* In btrfs_delete_inode, wait for ordered extents after calling truncate_inode_pages. This is much faster, and more correct * Properly clear our the PageChecked bit everywhere we redirty the page. * Change the writepage fixup handler to lock the page range and check to see if an ordered extent had been inserted since the improperly dirtied page was discovered * Wait for ordered extents outside the transaction. This isn't required for locking rules but does improve transaction latencies * Reduce contention on the alloc_mutex by dropping it while incrementing refs on a node/leaf and while dropping refs on a leaf. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 50ee4befac8e..8fb6dc25e7a5 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -418,7 +418,7 @@ void btrfs_writepage_fixup_worker(struct btrfs_work *work)
418 418
419 fixup = container_of(work, struct btrfs_writepage_fixup, work); 419 fixup = container_of(work, struct btrfs_writepage_fixup, work);
420 page = fixup->page; 420 page = fixup->page;
421 421again:
422 lock_page(page); 422 lock_page(page);
423 if (!page->mapping || !PageDirty(page) || !PageChecked(page)) { 423 if (!page->mapping || !PageDirty(page) || !PageChecked(page)) {
424 ClearPageChecked(page); 424 ClearPageChecked(page);
@@ -430,9 +430,21 @@ void btrfs_writepage_fixup_worker(struct btrfs_work *work)
430 page_end = page_offset(page) + PAGE_CACHE_SIZE - 1; 430 page_end = page_offset(page) + PAGE_CACHE_SIZE - 1;
431 431
432 lock_extent(&BTRFS_I(inode)->io_tree, page_start, page_end, GFP_NOFS); 432 lock_extent(&BTRFS_I(inode)->io_tree, page_start, page_end, GFP_NOFS);
433 ordered = btrfs_lookup_ordered_extent(inode, page_start); 433
434 if (ordered) 434 /* already ordered? We're done */
435 if (test_range_bit(&BTRFS_I(inode)->io_tree, page_start, page_end,
436 EXTENT_ORDERED, 0)) {
435 goto out; 437 goto out;
438 }
439
440 ordered = btrfs_lookup_ordered_extent(inode, page_start);
441 if (ordered) {
442 unlock_extent(&BTRFS_I(inode)->io_tree, page_start,
443 page_end, GFP_NOFS);
444 unlock_page(page);
445 btrfs_start_ordered_extent(inode, ordered, 1);
446 goto again;
447 }
436 448
437 set_extent_delalloc(&BTRFS_I(inode)->io_tree, page_start, page_end, 449 set_extent_delalloc(&BTRFS_I(inode)->io_tree, page_start, page_end,
438 GFP_NOFS); 450 GFP_NOFS);
@@ -1465,11 +1477,11 @@ void btrfs_delete_inode(struct inode *inode)
1465 unsigned long nr; 1477 unsigned long nr;
1466 int ret; 1478 int ret;
1467 1479
1468 btrfs_wait_ordered_range(inode, 0, (u64)-1);
1469 truncate_inode_pages(&inode->i_data, 0); 1480 truncate_inode_pages(&inode->i_data, 0);
1470 if (is_bad_inode(inode)) { 1481 if (is_bad_inode(inode)) {
1471 goto no_delete; 1482 goto no_delete;
1472 } 1483 }
1484 btrfs_wait_ordered_range(inode, 0, (u64)-1);
1473 1485
1474 btrfs_i_size_write(inode, 0); 1486 btrfs_i_size_write(inode, 0);
1475 trans = btrfs_start_transaction(root, 1); 1487 trans = btrfs_start_transaction(root, 1);
@@ -2707,6 +2719,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset)
2707 1, 1, GFP_NOFS); 2719 1, 1, GFP_NOFS);
2708 __btrfs_releasepage(page, GFP_NOFS); 2720 __btrfs_releasepage(page, GFP_NOFS);
2709 2721
2722 ClearPageChecked(page);
2710 if (PagePrivate(page)) { 2723 if (PagePrivate(page)) {
2711 invalidate_extent_lru(tree, page_offset(page), 2724 invalidate_extent_lru(tree, page_offset(page),
2712 PAGE_CACHE_SIZE); 2725 PAGE_CACHE_SIZE);
@@ -2818,10 +2831,10 @@ static void btrfs_truncate(struct inode *inode)
2818 return; 2831 return;
2819 2832
2820 btrfs_truncate_page(inode->i_mapping, inode->i_size); 2833 btrfs_truncate_page(inode->i_mapping, inode->i_size);
2834 btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1);
2821 2835
2822 trans = btrfs_start_transaction(root, 1); 2836 trans = btrfs_start_transaction(root, 1);
2823 btrfs_set_trans_block_group(trans, inode); 2837 btrfs_set_trans_block_group(trans, inode);
2824 btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1);
2825 btrfs_i_size_write(inode, inode->i_size); 2838 btrfs_i_size_write(inode, inode->i_size);
2826 2839
2827 /* FIXME, add redo link to tree so we don't leak on crash */ 2840 /* FIXME, add redo link to tree so we don't leak on crash */