linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Christoph Hellwig <hch@lst.de>,
	"Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: [PATCH RFC] iomap: only return IO error if no data has been transferred
Date: Tue, 17 Nov 2020 15:17:18 -0700	[thread overview]
Message-ID: <2a56ae95-b64e-f20f-8875-62a2f2e8e00f@kernel.dk> (raw)

If we've successfully transferred some data in __iomap_dio_rw(),
don't mark an error for a latter segment in the dio.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

---

Debugging an issue with io_uring, which uses IOCB_NOWAIT for the
IO. If we do parts of an IO, then once that completes, we still
return -EAGAIN if we ran into a problem later on. That seems wrong,
normal convention would be to return the short IO instead. For the
-EAGAIN case, io_uring will retry later parts without IOCB_NOWAIT
and complete it successfully.

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 933f234d5bec..1aa462bf9266 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -538,7 +538,11 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	} while ((count = iov_iter_count(iter)) > 0);
 	blk_finish_plug(&plug);
 
-	if (ret < 0)
+	/*
+	 * Only flag an error if we're still at the start of the operation.
+	 * If we've already done some IO, return a short result instead.
+	 */
+	if (ret < 0 && iocb->ki_pos == pos)
 		iomap_dio_set_error(dio, ret);
 
 	/*

-- 
Jens Axboe


             reply	other threads:[~2020-11-17 22:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 22:17 Jens Axboe [this message]
2020-11-18  7:09 ` [PATCH RFC] iomap: only return IO error if no data has been transferred Christoph Hellwig
2020-11-18  7:19 ` Dave Chinner
2020-11-18  7:55   ` Dave Chinner
2020-11-18 15:26   ` Jens Axboe
2020-11-18 20:37     ` Dave Chinner
2020-11-18 21:00       ` Jens Axboe
2020-11-18 21:15         ` Dave Chinner
2020-11-18 21:19           ` Jens Axboe
2020-11-18 21:33             ` Dave Chinner
2020-11-18 21:36               ` Jens Axboe
2020-11-18 21:48                 ` Dave Chinner
2020-11-18 21:55                   ` Jens Axboe
2020-11-18 22:21                     ` Dave Chinner
2020-11-26 14:00 ` [iomap] b258228a4e: Assertion_failed kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a56ae95-b64e-f20f-8875-62a2f2e8e00f@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).