All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Mason <mason@suse.com>
To: linux-fsdevel@vger.kernel.org, akpm@osdl.org
Subject: [PATCH] O_SYNC error handling fix
Date: Sun, 15 Jan 2006 19:43:50 -0500	[thread overview]
Message-ID: <200601151943.51771.mason@suse.com> (raw)


If we hit errors during generic_osync_inode(), generic_file_buffered_write 
will still return written ? written : status;  This patch ensures the -EIO 
gets back up to userland at all times.

diff -r 7e48cbfbccad mm/filemap.c
--- a/mm/filemap.c	Sat Jan 14 01:12:21 2006 +0800
+++ b/mm/filemap.c	Fri Jan 13 13:48:02 2006 -0500
@@ -2026,7 +2026,6 @@ generic_file_buffered_write(struct kiocb
 		balance_dirty_pages_ratelimited(mapping);
 		cond_resched();
 	} while (count);
-	*ppos = pos;
 
 	if (cached_page)
 		page_cache_release(cached_page);
@@ -2047,10 +2046,24 @@ generic_file_buffered_write(struct kiocb
 	 * to buffered writes (block instantiation inside i_size).  So we sync
 	 * the file data here, to try to honour O_DIRECT expectations.
 	 */
-	if (unlikely(file->f_flags & O_DIRECT) && written)
+	if (unlikely(file->f_flags & O_DIRECT) && status >= 0 && written)
 		status = filemap_write_and_wait(mapping);
 
 	pagevec_lru_add(&lru_pvec);
+
+	/*
+	 * We must let know userspace if something hasn't been written
+	 * correctly. If we got an I/O error it means we got an hardware
+	 * failure, anything can be happening to the on-disk data,
+	 * letting know userspace that a bit of data might have been
+	 * written correctly on disk is a very low priority, compared
+	 * to letting know userspace that some data has _not_ been
+	 * written at all.
+	 */
+	if (unlikely(status == -EIO))
+		return status;
+	*ppos = pos;
+
 	return written ? written : status;
 }
 EXPORT_SYMBOL(generic_file_buffered_write);



             reply	other threads:[~2006-01-16  0:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-16  0:43 Chris Mason [this message]
2006-01-16  7:58 ` [PATCH] O_SYNC error handling fix Andrew Morton
2006-01-16 14:26   ` Chris Mason
2006-01-16 20:11     ` Andrew Morton

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=200601151943.51771.mason@suse.com \
    --to=mason@suse.com \
    --cc=akpm@osdl.org \
    --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 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.