aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2012-11-16 13:56:32 -0500
committerChris Mason <chris.mason@fusionio.com>2012-12-16 20:46:22 -0500
commitb812ce28796f746f14ba6cc451250c422db447b2 (patch)
tree81f116613d7642b80a5a23668b7642d7931ad672 /fs/btrfs/file.c
parenta95249b392c3ab843d7b25ab6817ecc9ea0b82ee (diff)
Btrfs: inline csums if we're fsyncing
The tree logging stuff needs the csums to be on the ordered extents in order to log them properly, so mark that we're sync and inline the csum creation so we don't have to wait on the csumming to be done when logging extents that are still in flight. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 71c2dc1ea15a..7f4654a15207 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1472,6 +1472,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1472 ssize_t num_written = 0; 1472 ssize_t num_written = 0;
1473 ssize_t err = 0; 1473 ssize_t err = 0;
1474 size_t count, ocount; 1474 size_t count, ocount;
1475 bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host);
1475 1476
1476 sb_start_write(inode->i_sb); 1477 sb_start_write(inode->i_sb);
1477 1478
@@ -1529,6 +1530,9 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1529 } 1530 }
1530 } 1531 }
1531 1532
1533 if (sync)
1534 atomic_inc(&BTRFS_I(inode)->sync_writers);
1535
1532 if (unlikely(file->f_flags & O_DIRECT)) { 1536 if (unlikely(file->f_flags & O_DIRECT)) {
1533 num_written = __btrfs_direct_write(iocb, iov, nr_segs, 1537 num_written = __btrfs_direct_write(iocb, iov, nr_segs,
1534 pos, ppos, count, ocount); 1538 pos, ppos, count, ocount);
@@ -1563,6 +1567,8 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1563 num_written = err; 1567 num_written = err;
1564 } 1568 }
1565out: 1569out:
1570 if (sync)
1571 atomic_dec(&BTRFS_I(inode)->sync_writers);
1566 sb_end_write(inode->i_sb); 1572 sb_end_write(inode->i_sb);
1567 current->backing_dev_info = NULL; 1573 current->backing_dev_info = NULL;
1568 return num_written ? num_written : err; 1574 return num_written ? num_written : err;
@@ -1613,7 +1619,9 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
1613 * out of the ->i_mutex. If so, we can flush the dirty pages by 1619 * out of the ->i_mutex. If so, we can flush the dirty pages by
1614 * multi-task, and make the performance up. 1620 * multi-task, and make the performance up.
1615 */ 1621 */
1622 atomic_inc(&BTRFS_I(inode)->sync_writers);
1616 ret = filemap_write_and_wait_range(inode->i_mapping, start, end); 1623 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
1624 atomic_dec(&BTRFS_I(inode)->sync_writers);
1617 if (ret) 1625 if (ret)
1618 return ret; 1626 return ret;
1619 1627