aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
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