aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorJosef Bacik <jwhiter@redhat.com>2007-08-10 16:22:09 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-10 16:22:09 -0400
commit15ee9bc7ed171248d1405df5854da5fa91bfdc39 (patch)
tree5f29f51e1c14a6b35b2019a2ada5bb80fb97e2bd /fs/btrfs/file.c
parentf2183bde1a918d338337955c8e8ba29bd8f5e7b1 (diff)
Btrfs: delay commits during fsync to allow more writers
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 00b118a2db69..6933ab11a5cd 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -694,22 +694,36 @@ static int btrfs_sync_file(struct file *file,
694{ 694{
695 struct inode *inode = dentry->d_inode; 695 struct inode *inode = dentry->d_inode;
696 struct btrfs_root *root = BTRFS_I(inode)->root; 696 struct btrfs_root *root = BTRFS_I(inode)->root;
697 int ret; 697 int ret = 0;
698 struct btrfs_trans_handle *trans; 698 struct btrfs_trans_handle *trans;
699 699
700 /* 700 /*
701 * FIXME, use inode generation number to check if we can skip the 701 * check the transaction that last modified this inode
702 * commit 702 * and see if its already been committed
703 */ 703 */
704 mutex_lock(&root->fs_info->fs_mutex); 704 mutex_lock(&root->fs_info->fs_mutex);
705 if (!BTRFS_I(inode)->last_trans)
706 goto out;
707 mutex_lock(&root->fs_info->trans_mutex);
708 if (BTRFS_I(inode)->last_trans <=
709 root->fs_info->last_trans_committed) {
710 BTRFS_I(inode)->last_trans = 0;
711 mutex_unlock(&root->fs_info->trans_mutex);
712 goto out;
713 }
714 mutex_unlock(&root->fs_info->trans_mutex);
715
716 /*
717 * ok we haven't committed the transaction yet, lets do a commit
718 */
705 trans = btrfs_start_transaction(root, 1); 719 trans = btrfs_start_transaction(root, 1);
706 if (!trans) { 720 if (!trans) {
707 ret = -ENOMEM; 721 ret = -ENOMEM;
708 goto out; 722 goto out;
709 } 723 }
710 ret = btrfs_commit_transaction(trans, root); 724 ret = btrfs_commit_transaction(trans, root);
711 mutex_unlock(&root->fs_info->fs_mutex);
712out: 725out:
726 mutex_unlock(&root->fs_info->fs_mutex);
713 return ret > 0 ? EIO : ret; 727 return ret > 0 ? EIO : ret;
714} 728}
715 729