aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-10-13 13:21:08 -0400
committerChris Mason <chris.mason@oracle.com>2009-10-13 13:35:12 -0400
commit257c62e1bce03e5b9f3f069fd52ad73a56de71fd (patch)
treead047fe5796156aa88e3f3600111bf2b8d12759f /fs/btrfs/inode.c
parent4722607db6a78bd7748c51fa4c8d7371da797254 (diff)
Btrfs: avoid tree log commit when there are no changes
rpm has a habit of running fdatasync when the file hasn't changed. We already detect if a file hasn't been changed in the current transaction but it might have been sent to the tree-log in this transaction and not changed since the last call to fsync. In this case, we want to avoid a tree log sync, which includes a number of synchronous writes and barriers. This commit extends the existing tracking of the last transaction to change a file to also track the last sub-transaction. The end result is that rpm -ivh and -Uvh are roughly twice as fast, and on par with ext3. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ef399a7794f..5b9567caba0 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3480,6 +3480,7 @@ static noinline void init_btrfs_i(struct inode *inode)
3480 bi->generation = 0; 3480 bi->generation = 0;
3481 bi->sequence = 0; 3481 bi->sequence = 0;
3482 bi->last_trans = 0; 3482 bi->last_trans = 0;
3483 bi->last_sub_trans = 0;
3483 bi->logged_trans = 0; 3484 bi->logged_trans = 0;
3484 bi->delalloc_bytes = 0; 3485 bi->delalloc_bytes = 0;
3485 bi->reserved_bytes = 0; 3486 bi->reserved_bytes = 0;
@@ -4980,7 +4981,9 @@ again:
4980 set_page_dirty(page); 4981 set_page_dirty(page);
4981 SetPageUptodate(page); 4982 SetPageUptodate(page);
4982 4983
4983 BTRFS_I(inode)->last_trans = root->fs_info->generation + 1; 4984 BTRFS_I(inode)->last_trans = root->fs_info->generation;
4985 BTRFS_I(inode)->last_sub_trans = BTRFS_I(inode)->root->log_transid;
4986
4984 unlock_extent(io_tree, page_start, page_end, GFP_NOFS); 4987 unlock_extent(io_tree, page_start, page_end, GFP_NOFS);
4985 4988
4986out_unlock: 4989out_unlock:
@@ -5100,6 +5103,7 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
5100 if (!ei) 5103 if (!ei)
5101 return NULL; 5104 return NULL;
5102 ei->last_trans = 0; 5105 ei->last_trans = 0;
5106 ei->last_sub_trans = 0;
5103 ei->logged_trans = 0; 5107 ei->logged_trans = 0;
5104 ei->outstanding_extents = 0; 5108 ei->outstanding_extents = 0;
5105 ei->reserved_extents = 0; 5109 ei->reserved_extents = 0;