* [PATCH] [3/3] writes: fix spurious fs truncate errors
@ 2003-08-02 4:20 Oliver Xymoron
2003-08-02 10:50 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Xymoron @ 2003-08-02 4:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
Get rid of newly exposed EIO errors from truncate races in filesystems
diff -urN -x genksyms -x '*.ver' -x '.patch*' -x '*.orig' orig/fs/buffer.c patched/fs/buffer.c
--- orig/fs/buffer.c 2003-05-21 13:26:41.000000000 -0500
+++ patched/fs/buffer.c 2003-05-21 13:26:41.000000000 -0500
@@ -2625,7 +2625,7 @@
*/
block_invalidatepage(page, 0);
unlock_page(page);
- return -EIO;
+ return 0; /* don't care */
}
/*
diff -urN -x genksyms -x '*.ver' -x '.patch*' -x '*.orig' orig/fs/cifs/file.c patched/fs/cifs/file.c
--- orig/fs/cifs/file.c 2003-05-12 14:34:30.000000000 -0500
+++ patched/fs/cifs/file.c 2003-05-21 13:26:41.000000000 -0500
@@ -433,12 +433,18 @@
write_data = kmap(page);
write_data += from;
- if((to > PAGE_CACHE_SIZE) || (from > to) || (offset > mapping->host->i_size)) {
+ if((to > PAGE_CACHE_SIZE) || (from > to)) {
kunmap(page);
FreeXid(xid);
return -EIO;
}
+ /* racing with truncate? */
+ if(offset > mapping->host->i_size) {
+ FreeXid(xid);
+ return 0; /* don't care */
+ }
+
/* check to make sure that we are not extending the file */
if(mapping->host->i_size - offset < (loff_t)to)
to = (unsigned)(mapping->host->i_size - offset);
diff -urN -x genksyms -x '*.ver' -x '.patch*' -x '*.orig' orig/fs/nfs/write.c patched/fs/nfs/write.c
--- orig/fs/nfs/write.c 2003-05-21 12:54:32.000000000 -0500
+++ patched/fs/nfs/write.c 2003-05-21 13:30:39.000000000 -0500
@@ -241,7 +241,7 @@
offset = inode->i_size & (PAGE_CACHE_SIZE-1);
/* OK, are we completely out? */
- err = -EIO;
+ err = 0; /* potential race with truncate - ignore */
if (page->index >= end_index+1 || !offset)
goto out;
do_it:
diff -urN -x genksyms -x '*.ver' -x '.patch*' -x '*.orig' orig/fs/ntfs/aops.c patched/fs/ntfs/aops.c
--- orig/fs/ntfs/aops.c 2003-05-12 14:34:30.000000000 -0500
+++ patched/fs/ntfs/aops.c 2003-05-21 13:26:41.000000000 -0500
@@ -811,8 +811,8 @@
if (unlikely(page->index >= (vi->i_size + PAGE_CACHE_SIZE - 1) >>
PAGE_CACHE_SHIFT)) {
unlock_page(page);
- ntfs_debug("Write outside i_size. Returning i/o error.");
- return -EIO;
+ ntfs_debug("Write outside i_size - truncated?");
+ return 0;
}
ni = NTFS_I(vi);
diff -urN -x genksyms -x '*.ver' -x '.patch*' -x '*.orig' orig/fs/reiserfs/inode.c patched/fs/reiserfs/inode.c
--- orig/fs/reiserfs/inode.c 2003-05-21 12:54:32.000000000 -0500
+++ patched/fs/reiserfs/inode.c 2003-05-21 13:26:41.000000000 -0500
@@ -2048,8 +2048,8 @@
last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1) ;
/* no file contents in this page */
if (page->index >= end_index + 1 || !last_offset) {
- error = -EIO ;
- goto fail ;
+ error = 0 ;
+ goto done ;
}
kaddr = kmap_atomic(page, KM_USER0);
memset(kaddr + last_offset, 0, PAGE_CACHE_SIZE-last_offset) ;
diff -urN -x genksyms -x '*.ver' -x '.patch*' -x '*.orig' orig/fs/smbfs/file.c patched/fs/smbfs/file.c
--- orig/fs/smbfs/file.c 2003-04-19 21:50:45.000000000 -0500
+++ patched/fs/smbfs/file.c 2003-05-21 13:26:41.000000000 -0500
@@ -193,7 +193,7 @@
offset = inode->i_size & (PAGE_CACHE_SIZE-1);
/* OK, are we completely out? */
if (page->index >= end_index+1 || !offset)
- return -EIO;
+ return 0; /* truncated - don't care */
do_it:
page_cache_get(page);
err = smb_writepage_sync(inode, page, 0, offset);
--
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [3/3] writes: fix spurious fs truncate errors
2003-08-02 4:20 [PATCH] [3/3] writes: fix spurious fs truncate errors Oliver Xymoron
@ 2003-08-02 10:50 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2003-08-02 10:50 UTC (permalink / raw)
To: Oliver Xymoron; +Cc: linux-kernel
Oliver Xymoron <oxymoron@waste.org> wrote:
>
> Get rid of newly exposed EIO errors from truncate races in filesystems
>
One fix.
The reiserfs change looks OK from a breif scan, but I need to wake up a
resierfs developer to take a look at it.
- Missing kunmap in CIFS.
fs/cifs/file.c | 1 +
1 files changed, 1 insertion(+)
diff -puN fs/cifs/file.c~awe-fix-truncate-errors-fixes fs/cifs/file.c
--- 25/fs/cifs/file.c~awe-fix-truncate-errors-fixes 2003-08-02 03:28:02.000000000 -0700
+++ 25-akpm/fs/cifs/file.c 2003-08-02 03:28:02.000000000 -0700
@@ -456,6 +456,7 @@ cifs_partialpagewrite(struct page *page,
/* racing with truncate? */
if(offset > mapping->host->i_size) {
+ kunmap(page);
FreeXid(xid);
return 0; /* don't care */
}
_
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-02 10:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-02 4:20 [PATCH] [3/3] writes: fix spurious fs truncate errors Oliver Xymoron
2003-08-02 10:50 ` Andrew Morton
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).