linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: linux-fsdevel@vger.kernel.org
Subject: [PATCH] Oversight in generic_file_aio_write_nolock
Date: Tue, 7 Apr 2009 20:16:08 +0400	[thread overview]
Message-ID: <20090407161608.GA1514155@fiona.linuxhacker.ru> (raw)

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

Hello!

   There seems to be an oversight in generic_file_aio_write_nolock where
   when we open inode with O_SYNC and O_APPEND, then after we are done the
   writing, we flush wrong byterange from the file, from original offset for
   number of bytes written, instead from the actual oppended offset.
   This can lead to an unexpected data loss should the crash happen soon after
   such a write was performed.

   Here is a simple fix, though perhaps we can just throw away the pos argument
   from the ->aio_write prototype eventually.

Bye,
    Oleg

[-- Attachment #2: osync_oappend_bug.diff --]
[-- Type: text/plain, Size: 465 bytes --]

 filemap.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
--- mm/filemap.c.orig	2009-04-07 12:06:30.000000000 -0400
+++ mm/filemap.c	2009-04-07 12:06:49.000000000 -0400
@@ -2420,7 +2420,8 @@
 	if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
 		ssize_t err;
 
-		err = sync_page_range_nolock(inode, mapping, pos, ret);
+		err = sync_page_range_nolock(inode, mapping, iocb->ki_pos - ret,
+					     ret);
 		if (err < 0)
 			ret = err;
 	}

             reply	other threads:[~2009-04-07 16:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-07 16:16 Oleg Drokin [this message]
2009-04-07 17:35 ` [PATCH] Oversight in generic_file_aio_write_nolock Jeff Garzik

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=20090407161608.GA1514155@fiona.linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --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).