diff mbox series

[RFC,05/11] iov_iter: Use IOMAP_WRITE rather than iterator direction

Message ID 20230630152524.661208-6-dhowells@redhat.com (mailing list archive)
State New, archived
Headers show
Series iov_iter: Use I/O direction from kiocb, iomap & request rather than iov_iter | expand

Commit Message

David Howells June 30, 2023, 3:25 p.m. UTC
If an iomap_iter is available, use the IOMAP_WRITE flag instead of the
iterator direction.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Jens Axboe <axboe@kernel.dk>
cc: Christian Brauner <christian@brauner.io>
cc: Alexander Viro <viro@zeniv.linux.org.uk>
cc: linux-block@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
 fs/dax.c             | 4 ++--
 fs/iomap/direct-io.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig July 6, 2023, 3:30 p.m. UTC | #1
On Fri, Jun 30, 2023 at 04:25:18PM +0100, David Howells wrote:
> If an iomap_iter is available, use the IOMAP_WRITE flag instead of the
> iterator direction.

This is really two patches, one for dax and one for iomap, and not one
for the iov_iter code.
diff mbox series

Patch

diff --git a/fs/dax.c b/fs/dax.c
index 5c6ebe64a3fd..d49480675fc0 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1438,7 +1438,7 @@  static loff_t dax_iomap_iter(const struct iomap_iter *iomi,
 	loff_t pos = iomi->pos;
 	struct dax_device *dax_dev = iomap->dax_dev;
 	loff_t end = pos + length, done = 0;
-	bool write = iov_iter_rw(iter) == WRITE;
+	bool write = iomi->flags & IOMAP_WRITE;
 	bool cow = write && iomap->flags & IOMAP_F_SHARED;
 	ssize_t ret = 0;
 	size_t xfer;
@@ -1498,7 +1498,7 @@  static loff_t dax_iomap_iter(const struct iomap_iter *iomi,
 
 		map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size),
 				DAX_ACCESS, &kaddr, NULL);
-		if (map_len == -EIO && iov_iter_rw(iter) == WRITE) {
+		if (map_len == -EIO && write) {
 			map_len = dax_direct_access(dax_dev, pgoff,
 					PHYS_PFN(size), DAX_RECOVERY_WRITE,
 					&kaddr, NULL);
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index a56099470185..3095091af680 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -587,7 +587,7 @@  __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	 * Revert iter to a state corresponding to that as some callers (such
 	 * as the splice code) rely on it.
 	 */
-	if (iov_iter_rw(iter) == READ && iomi.pos >= dio->i_size)
+	if (!(iomi.flags & IOMAP_WRITE) && iomi.pos >= dio->i_size)
 		iov_iter_revert(iter, iomi.pos - dio->i_size);
 
 	if (ret == -EFAULT && dio->size && (dio_flags & IOMAP_DIO_PARTIAL)) {