[PATCH] Oversight in generic_file_aio_write_nolock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
 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;
 	}

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux