summaryrefslogtreecommitdiff
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorJosef Bacik <jwhiter@redhat.com>2007-08-10 20:22:09 (GMT)
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-10 20:22:09 (GMT)
commit15ee9bc7ed171248d1405df5854da5fa91bfdc39 (patch)
tree5f29f51e1c14a6b35b2019a2ada5bb80fb97e2bd /fs/btrfs/file.c
parentf2183bde1a918d338337955c8e8ba29bd8f5e7b1 (diff)
downloadlinux-fsl-qoriq-15ee9bc7ed171248d1405df5854da5fa91bfdc39.tar.xz
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 00b118a..6933ab1 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -694,22 +694,36 @@ static int btrfs_sync_file(struct file *file,
{
struct inode *inode = dentry->d_inode;
struct btrfs_root *root = BTRFS_I(inode)->root;
- int ret;
+ int ret = 0;
struct btrfs_trans_handle *trans;
/*
- * FIXME, use inode generation number to check if we can skip the
- * commit
+ * check the transaction that last modified this inode
+ * and see if its already been committed
*/
mutex_lock(&root->fs_info->fs_mutex);
+ if (!BTRFS_I(inode)->last_trans)
+ goto out;
+ mutex_lock(&root->fs_info->trans_mutex);
+ if (BTRFS_I(inode)->last_trans <=
+ root->fs_info->last_trans_committed) {
+ BTRFS_I(inode)->last_trans = 0;
+ mutex_unlock(&root->fs_info->trans_mutex);
+ goto out;
+ }
+ mutex_unlock(&root->fs_info->trans_mutex);
+
+ /*
+ * ok we haven't committed the transaction yet, lets do a commit
+ */
trans = btrfs_start_transaction(root, 1);
if (!trans) {
ret = -ENOMEM;
goto out;
}
ret = btrfs_commit_transaction(trans, root);
- mutex_unlock(&root->fs_info->fs_mutex);
out:
+ mutex_unlock(&root->fs_info->fs_mutex);
return ret > 0 ? EIO : ret;
}