Skip to content

Commit

Permalink
Revert "Btrfs: do not do filemap_write_and_wait_range in fsync"
Browse files Browse the repository at this point in the history
This reverts commit 0885ef5

After applying the above patch, the performance slowed down because the dirty
page flush can only be done by one task, so revert it.

The following is the test result of sysbench:
	Before		After
	24MB/s		39MB/s

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
  • Loading branch information
Miao Xie authored and Chris Mason committed Oct 1, 2012
1 parent 698d008 commit 90abccf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,12 +1544,20 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)

trace_btrfs_sync_file(file, datasync);

/*
* We write the dirty pages in the range and wait until they complete
* out of the ->i_mutex. If so, we can flush the dirty pages by
* multi-task, and make the performance up.
*/
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (ret)
return ret;

mutex_lock(&inode->i_mutex);

/*
* we wait first, since the writeback may change the inode, also wait
* ordered range does a filemape_write_and_wait_range which is why we
* don't do it above like other file systems.
* We flush the dirty pages again to avoid some dirty pages in the
* range being left.
*/
atomic_inc(&root->log_batch);
btrfs_wait_ordered_range(inode, start, end);
Expand Down

0 comments on commit 90abccf

Please sign in to comment.