linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: akpm@linux-foundation.org, npiggin@suse.de,
	Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH] direct_io: Allow partial writes
Date: Tue,  6 Apr 2010 18:47:23 +0400	[thread overview]
Message-ID: <1270565243-29698-1-git-send-email-dmonakhov@openvz.org> (raw)

Current direct io allocation behavior is inconvenient. Partial writes
are not supported. If we try to issue 10Mb chunk, but only 5Mb is
available then we will allocate thees 5Mb until ENOSPC, and then
drop such space and return ENOSPC.
Partial success was rejected because it wasn't obvious how to
distinguish non fatal errors (ENOSPC,EDQUOT,ENOMEM, etc) from fatal
ones (EIO,EFAULT, and so on).
But in fact there are only two sources of fatal error:
1) from bi_end_io and result in EIO and saved to dio->io_error
2) from get_user_pages_fast and saved to dio->page_errors

In case of partial write it is safe to ignore error code because in
case of fatal error it will be restored and returned to caller from
dio_complete().

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/direct-io.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index e82adc2..1298dc3 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -230,7 +230,13 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret)
 
 	if (dio->result) {
 		transferred = dio->result;
-
+		/*
+		 * Ignore non fatal error if some data was written.
+		 * Fatal error was saved in dio structure and will be
+		 * restored later at the bottom of the function.
+		 */
+		if (dio->rw & WRITE)
+			ret = 0;
 		/* Check for short read case */
 		if ((dio->rw == READ) && ((offset + transferred) > dio->i_size))
 			transferred = dio->i_size - offset;
-- 
1.6.6.1


                 reply	other threads:[~2010-04-06 14:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1270565243-29698-1-git-send-email-dmonakhov@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=npiggin@suse.de \
    /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).