summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-28 09:29:35 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-28 09:29:35 -0400
commit7c4452b9a6ca7aabe37ea2e43d443110bdc08cd8 (patch)
tree6d3db5ec3a394dfcf143869796f1c59c4e86278f /fs/btrfs/transaction.c
parent06a2f9fa4c12a055cc396936408a78ae0acfb6b4 (diff)
Btrfs: smarter transaction writeback
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 8a2545f6a5b..f9b8864dcc4 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -45,6 +45,7 @@ static int join_transaction(struct btrfs_root *root)
cur_trans->use_count = 1;
cur_trans->commit_done = 0;
list_add_tail(&cur_trans->list, &root->fs_info->trans_list);
+ init_bit_radix(&cur_trans->dirty_pages);
}
cur_trans->num_writers++;
return 0;
@@ -106,8 +107,40 @@ int btrfs_end_transaction(struct btrfs_trans_handle *trans,
int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
- filemap_write_and_wait(root->fs_info->btree_inode->i_mapping);
- return 0;
+ unsigned long gang[16];
+ int ret;
+ int i;
+ int err;
+ int werr = 0;
+ struct page *page;
+ struct radix_tree_root *dirty_pages;
+ struct inode *btree_inode = root->fs_info->btree_inode;
+
+ if (!trans || !trans->transaction) {
+ return filemap_write_and_wait(btree_inode->i_mapping);
+ }
+ dirty_pages = &trans->transaction->dirty_pages;
+ while(1) {
+ ret = find_first_radix_bit(dirty_pages, gang, ARRAY_SIZE(gang));
+ if (!ret)
+ break;
+ for (i = 0; i < ret; i++) {
+ /* FIXME EIO */
+ clear_radix_bit(dirty_pages, gang[i]);
+ page = find_lock_page(btree_inode->i_mapping,
+ gang[i]);
+ if (!page)
+ continue;
+ err = write_one_page(page, 0);
+ if (err)
+ werr = err;
+ page_cache_release(page);
+ }
+ }
+ err = filemap_fdatawait(btree_inode->i_mapping);
+ if (err)
+ werr = err;
+ return werr;
}
int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,