linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Ritesh Harjani <riteshh@linux.ibm.com>,
	linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	darrick.wong@oracle.com
Subject: Re: [PATCH v2] iomap: return partial I/O count on error in iomap_dio_bio_actor
Date: Fri, 28 Feb 2020 13:44:01 -0600	[thread overview]
Message-ID: <20200228194401.o736qvvr4zpklyiz@fiona> (raw)
In-Reply-To: <20200225205342.GA12066@infradead.org>

[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]

On 12:53 25/02, Christoph Hellwig wrote:
> On Fri, Feb 21, 2020 at 10:21:04AM +0530, Ritesh Harjani wrote:
> > >   		if (dio->error) {
> > >   			iov_iter_revert(dio->submit.iter, copied);
> > > -			copied = ret = 0;
> > > +			ret = 0;
> > >   			goto out;
> > >   		}
> > 
> > But if I am seeing this correctly, even after there was a dio->error
> > if you return copied > 0, then the loop in iomap_dio_rw will continue
> > for next iteration as well. Until the second time it won't copy
> > anything since dio->error is set and from there I guess it may return
> > 0 which will break the loop.
> 


Reading the code again, there are a few clarifications.

If iomap_end() handles (written < length) as an error, iomap_apply()
will return an error immediately. It will not execute the 
loop a second time.

On the other hand, if there is no ->iomap_end() defined by the
filesystem such as in the case of XFS, we will need to check for
dio->error in the do {} while loop of iomap_dio_rw().

> In addition to that copied is also iov_iter_reexpand call.  We don't
> really need the re-expand in case of errors, and in fact we also
> have the iov_iter_revert call before jumping out, so this will
> need a little bit more of an audit and properly documented in the
> commit log.

We are still handling this as an error, so why are we concerned about
expanding? There is no success/written returned in iomap_dio_rw() call
in case of an error.

Attached is an updated patch.


-- 
Goldwyn

[-- Attachment #2: 0004-iomap-return-partial-I-O-count-on-error-in-iomap_dio.patch --]
[-- Type: text/x-patch, Size: 2132 bytes --]

From af694f4fc662daf5c62a78391ced5f8e2d4beed2 Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Date: Thu, 13 Feb 2020 13:28:55 -0600
Subject: [PATCH] iomap: return partial I/O count on error in
 iomap_dio_bio_actor

Currently, I/Os that complete with an error indicate this by passing
written == 0 to the iomap_end function.  However, btrfs needs to know how
many bytes were written for its own accounting.  Change the convention
to pass the number of bytes which were actually written, and change the
only user (ext4) to check for a short write instead of a zero length write.

In case a filesystem does not define an ->iomap_end(), check for
dio->error after the iomap_apply() call to diagnose the error.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/ext4/inode.c      | 2 +-
 fs/iomap/direct-io.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index fa0ff78dc033..d52c70f851e6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3475,7 +3475,7 @@ static int ext4_iomap_end(struct inode *inode, loff_t offset, loff_t length,
 	 * the I/O. Any blocks that may have been allocated in preparation for
 	 * the direct I/O will be reused during buffered I/O.
 	 */
-	if (flags & (IOMAP_WRITE | IOMAP_DIRECT) && written == 0)
+	if (flags & (IOMAP_WRITE | IOMAP_DIRECT) && written < length)
 		return -ENOTBLK;
 
 	return 0;
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 41c1e7c20a1f..a0002311cc20 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -264,7 +264,7 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
 		size_t n;
 		if (dio->error) {
 			iov_iter_revert(dio->submit.iter, copied);
-			copied = ret = 0;
+			ret = 0;
 			goto out;
 		}
 
@@ -499,6 +499,10 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	do {
 		ret = iomap_apply(inode, pos, count, flags, ops, dio,
 				iomap_dio_actor);
+
+		if (ret >= 0 && dio->error)
+			ret = dio->error;
+
 		if (ret <= 0) {
 			/* magic error code to fall back to buffered I/O */
 			if (ret == -ENOTBLK) {
-- 
2.25.0


  parent reply	other threads:[~2020-02-28 19:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 15:23 [PATCH v2] iomap: return partial I/O count on error in iomap_dio_bio_actor Goldwyn Rodrigues
2020-02-20 17:42 ` Matthew Wilcox
2020-02-21  2:06   ` Goldwyn Rodrigues
2020-02-21  4:51 ` Ritesh Harjani
2020-02-21 12:48   ` Goldwyn Rodrigues
2020-02-25 20:53   ` Christoph Hellwig
2020-02-26  2:12     ` Damien Le Moal
2020-02-26  2:55     ` Goldwyn Rodrigues
2020-02-28 19:44     ` Goldwyn Rodrigues [this message]
2020-02-28 19:59       ` Matthew Wilcox
2020-02-28 20:35         ` Goldwyn Rodrigues
2020-03-02 13:31           ` Christoph Hellwig
2020-02-21 13:14 ` David Sterba
2020-02-20 15:24 Goldwyn Rodrigues
2020-03-19 15:08 Goldwyn Rodrigues
2020-03-20 14:05 ` Christoph Hellwig
2020-03-20 14:23   ` Josef Bacik
2020-03-20 14:35     ` Christoph Hellwig
2020-03-20 15:35       ` Goldwyn Rodrigues

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=20200228194401.o736qvvr4zpklyiz@fiona \
    --to=rgoldwyn@suse.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=riteshh@linux.ibm.com \
    /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).