diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2017-11-16 02:10:28 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-01-22 18:08:13 +0300 |
commit | 343e4fc1c60971b0734de26dbbd475d433950982 (patch) | |
tree | b900c92ed8a718f05f81779132754a0609ebce55 | |
parent | 0fb08bccbce2c1900d18f7ecc01ff8b8f677ce3e (diff) | |
download | linux-343e4fc1c60971b0734de26dbbd475d433950982.tar.xz |
Btrfs: set plug for fsync
Setting plug can merge adjacent IOs before dispatching IOs to the disk
driver.
Without plug, it'd not be a problem for single disk usecases, but for
multiple disks using raid profile, a large IO can be split to several
IOs of stripe length, and plug can be helpful to bring them together
for each disk so that we can save several disk access.
Moreover, fsync issues synchronous writes, so plug can really take
effect.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/file.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index b85b6d7d0ccd..1096398e1351 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2019,10 +2019,19 @@ int btrfs_release_file(struct inode *inode, struct file *filp) static int start_ordered_ops(struct inode *inode, loff_t start, loff_t end) { int ret; + struct blk_plug plug; + /* + * This is only called in fsync, which would do synchronous writes, so + * a plug can merge adjacent IOs as much as possible. Esp. in case of + * multiple disks using raid profile, a large IO can be split to + * several segments of stripe length (currently 64K). + */ + blk_start_plug(&plug); atomic_inc(&BTRFS_I(inode)->sync_writers); ret = btrfs_fdatawrite_range(inode, start, end); atomic_dec(&BTRFS_I(inode)->sync_writers); + blk_finish_plug(&plug); return ret; } |