fs: Introduce IOMAP_NOWAIT
authorGoldwyn Rodrigues <rgoldwyn@suse.com>
Tue, 20 Jun 2017 12:05:45 +0000 (07:05 -0500)
committerJens Axboe <axboe@kernel.dk>
Tue, 20 Jun 2017 13:12:03 +0000 (07:12 -0600)
IOCB_NOWAIT translates to IOMAP_NOWAIT for iomaps.
This is used by XFS in the XFS patch.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/iomap.c
include/linux/iomap.h

index 18f2f2b8ba2c8802585e651131cfebb8375efc89..c71a64b97fbac32bf187e374a2e5754e2f6a013a 100644 (file)
@@ -881,6 +881,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;
index f753e788da3109cc85cd07ac44b2f7e47fcde9b6..69f4e9470084b7e98288deb0bc45cae59bd8477f 100644 (file)
@@ -52,6 +52,7 @@ struct iomap {
 #define IOMAP_REPORT           (1 << 2) /* report extent status, e.g. FIEMAP */
 #define IOMAP_FAULT            (1 << 3) /* mapping for page fault */
 #define IOMAP_DIRECT           (1 << 4) /* direct I/O */
+#define IOMAP_NOWAIT           (1 << 5) /* Don't wait for writeback */
 
 struct iomap_ops {
        /*