aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index d9f5336552d7..ad7242043bdb 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1695,8 +1695,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
1695 loff_t *ppos = &iocb->ki_pos; 1695 loff_t *ppos = &iocb->ki_pos;
1696 loff_t pos = *ppos; 1696 loff_t pos = *ppos;
1697 1697
1698 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ 1698 if (io_is_direct(file)) {
1699 if (file->f_flags & O_DIRECT) {
1700 struct address_space *mapping = file->f_mapping; 1699 struct address_space *mapping = file->f_mapping;
1701 struct inode *inode = mapping->host; 1700 struct inode *inode = mapping->host;
1702 size_t count = iov_iter_count(iter); 1701 size_t count = iov_iter_count(iter);
@@ -1723,9 +1722,11 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
1723 * we've already read everything we wanted to, or if 1722 * we've already read everything we wanted to, or if
1724 * there was a short read because we hit EOF, go ahead 1723 * there was a short read because we hit EOF, go ahead
1725 * and return. Otherwise fallthrough to buffered io for 1724 * and return. Otherwise fallthrough to buffered io for
1726 * the rest of the read. 1725 * the rest of the read. Buffered reads will not work for
1726 * DAX files, so don't bother trying.
1727 */ 1727 */
1728 if (retval < 0 || !iov_iter_count(iter) || *ppos >= size) { 1728 if (retval < 0 || !iov_iter_count(iter) || *ppos >= size ||
1729 IS_DAX(inode)) {
1729 file_accessed(file); 1730 file_accessed(file);
1730 goto out; 1731 goto out;
1731 } 1732 }
@@ -2582,18 +2583,20 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
2582 if (err) 2583 if (err)
2583 goto out; 2584 goto out;
2584 2585
2585 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ 2586 if (io_is_direct(file)) {
2586 if (unlikely(file->f_flags & O_DIRECT)) {
2587 loff_t endbyte; 2587 loff_t endbyte;
2588 2588
2589 written = generic_file_direct_write(iocb, from, pos); 2589 written = generic_file_direct_write(iocb, from, pos);
2590 if (written < 0 || written == count)
2591 goto out;
2592
2593 /* 2590 /*
2594 * direct-io write to a hole: fall through to buffered I/O 2591 * If the write stopped short of completing, fall back to
2595 * for completing the rest of the request. 2592 * buffered writes. Some filesystems do this for writes to
2593 * holes, for example. For DAX files, a buffered write will
2594 * not succeed (even if it did, DAX does not handle dirty
2595 * page-cache pages correctly).
2596 */ 2596 */
2597 if (written < 0 || written == count || IS_DAX(inode))
2598 goto out;
2599
2597 pos += written; 2600 pos += written;
2598 count -= written; 2601 count -= written;
2599 2602