All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Anton Altaparmakov <aia21@cam.ac.uk>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Bug introduced in 3b93f911d5
Date: Fri, 8 Aug 2014 16:54:07 +0100	[thread overview]
Message-ID: <20140808155407.GT18016@ZenIV.linux.org.uk> (raw)
In-Reply-To: <435E586E-2045-4070-8FA7-8DF468280E3C@cam.ac.uk>

On Fri, Aug 08, 2014 at 12:11:39AM +0100, Anton Altaparmakov wrote:
> Hi Al,
> 
> Was just looking at __generic_file_write_iter() and found a bug in the code that you added in 3b93f911d5.
> 
> Consider the case where generic_file_direct_write() returns a partial write, i.e. written > 0 && written < count.
> 
> Also consider that the following generic_perform_write() fails with an error, i.e. status < 0.

*nod*

What we ought to do, AFAICS, is this:

diff --git a/mm/filemap.c b/mm/filemap.c
index 900edfa..8163e04 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2584,7 +2584,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 		 * that this differs from normal direct-io semantics, which
 		 * will return -EFOO even if some bytes were written.
 		 */
-		if (unlikely(status < 0) && !written) {
+		if (unlikely(status < 0)) {
 			err = status;
 			goto out;
 		}

Note that we return written ? written : err, so assignment to err will be
the right thing both when status < 0 && written == 0 and when status < 0 &&
written > 0.  In the latter case err will be simply ignored.

Objections?

  reply	other threads:[~2014-08-08 15:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-07 23:11 Bug introduced in 3b93f911d5 Anton Altaparmakov
2014-08-08 15:54 ` Al Viro [this message]
2014-08-08 21:38   ` Anton Altaparmakov

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=20140808155407.GT18016@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=aia21@cam.ac.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.