Merge tag 'xfs-4.13-merge-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[muen/linux.git] / fs / iomap.c
index 432eed8f091f171d479c4c7174269c4a62d61e6b..173222863aca914f7992572d90723c173b6fbf93 100644 (file)
@@ -766,8 +766,8 @@ static void iomap_dio_bio_end_io(struct bio *bio)
        struct iomap_dio *dio = bio->bi_private;
        bool should_dirty = (dio->flags & IOMAP_DIO_DIRTY);
 
-       if (bio->bi_error)
-               iomap_dio_set_error(dio, bio->bi_error);
+       if (bio->bi_status)
+               iomap_dio_set_error(dio, blk_status_to_errno(bio->bi_status));
 
        if (atomic_dec_and_test(&dio->ref)) {
                if (is_sync_kiocb(dio->iocb)) {
@@ -887,6 +887,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
                bio->bi_bdev = iomap->bdev;
                bio->bi_iter.bi_sector =
                        iomap->blkno + ((pos - iomap->offset) >> 9);
+               bio->bi_write_hint = dio->iocb->ki_hint;
                bio->bi_private = dio;
                bio->bi_end_io = iomap_dio_bio_end_io;
 
@@ -975,6 +976,14 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
                flags |= IOMAP_WRITE;
        }
 
+       if (iocb->ki_flags & IOCB_NOWAIT) {
+               if (filemap_range_has_page(mapping, start, end)) {
+                       ret = -EAGAIN;
+                       goto out_free_dio;
+               }
+               flags |= IOMAP_NOWAIT;
+       }
+
        ret = filemap_write_and_wait_range(mapping, start, end);
        if (ret)
                goto out_free_dio;