]> git.baikalelectronics.ru Git - kernel.git/commit
NFS: Fix a potential file corruption issue when writing
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 7 Feb 2008 22:24:07 +0000 (17:24 -0500)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 8 Feb 2008 00:20:20 +0000 (19:20 -0500)
commitf5b8a6e4b0a0aea40b80fdd0751b48302bbc228e
tree63b6ac010939b45ce53e65dedae68f1296bd98e7
parent9c55c7eb914df5b2334ce9adea9265ab568d1413
NFS: Fix a potential file corruption issue when writing

If the inode is flagged as having an invalid mapping, then we can't rely on
the PageUptodate() flag. Ensure that we don't use the "anti-fragmentation"
write optimisation in nfs_updatepage(), since that will cause NFS to write
out areas of the page that are no longer guaranteed to be up to date.

A potential corruption could occur in the following scenario:

client 1 client 2
=============== ===============
fd=open("f",O_CREAT|O_WRONLY,0644);
write(fd,"fubar\n",6); // cache last page
close(fd);
fd=open("f",O_WRONLY|O_APPEND);
write(fd,"foo\n",4);
close(fd);

fd=open("f",O_WRONLY|O_APPEND);
write(fd,"bar\n",4);
close(fd);
-----
The bug may lead to the file "f" reading 'fubar\n\0\0\0\nbar\n' because
client 2 does not update the cached page after re-opening the file for
write. Instead it keeps it marked as PageUptodate() until someone calls
invaldate_inode_pages2() (typically by calling read()).

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/write.c