aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-03-12 20:12:45 -0400
committerChris Mason <chris.mason@oracle.com>2009-03-24 16:14:26 -0400
commitb7ec40d7845bffca8bb3af2ea3f192d6257bbe21 (patch)
tree65b833b979417d36f0fd26d647573de1df0646b9 /fs/btrfs/inode.c
parentc3e69d58e86c3917ae4e9e31b4acf490a7cafe60 (diff)
Btrfs: reduce stalls during transaction commit
To avoid deadlocks and reduce latencies during some critical operations, some transaction writers are allowed to jump into the running transaction and make it run a little longer, while others sit around and wait for the commit to finish. This is a bit unfair, especially when the callers that jump in do a bunch of IO that makes all the others procs on the box wait. This commit reduces the stalls this produces by pre-reading file extent pointers during btrfs_finish_ordered_io before the transaction is joined. It also tunes the drop_snapshot code to politely wait for transactions that have started writing out their delayed refs to finish. This avoids new delayed refs being flooded into the queue while we're trying to close off the transaction. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 7d4f948bc22a..13a17477c4f4 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1502,6 +1502,7 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end)
1502 struct btrfs_trans_handle *trans; 1502 struct btrfs_trans_handle *trans;
1503 struct btrfs_ordered_extent *ordered_extent; 1503 struct btrfs_ordered_extent *ordered_extent;
1504 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; 1504 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
1505 struct btrfs_path *path;
1505 int compressed = 0; 1506 int compressed = 0;
1506 int ret; 1507 int ret;
1507 1508
@@ -1509,6 +1510,23 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end)
1509 if (!ret) 1510 if (!ret)
1510 return 0; 1511 return 0;
1511 1512
1513 /*
1514 * before we join the transaction, try to do some of our IO.
1515 * This will limit the amount of IO that we have to do with
1516 * the transaction running. We're unlikely to need to do any
1517 * IO if the file extents are new, the disk_i_size checks
1518 * covers the most common case.
1519 */
1520 if (start < BTRFS_I(inode)->disk_i_size) {
1521 path = btrfs_alloc_path();
1522 if (path) {
1523 ret = btrfs_lookup_file_extent(NULL, root, path,
1524 inode->i_ino,
1525 start, 0);
1526 btrfs_free_path(path);
1527 }
1528 }
1529
1512 trans = btrfs_join_transaction(root, 1); 1530 trans = btrfs_join_transaction(root, 1);
1513 1531
1514 ordered_extent = btrfs_lookup_ordered_extent(inode, start); 1532 ordered_extent = btrfs_lookup_ordered_extent(inode, start);