All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Andrew Morton <akpm@digeo.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] write errors [3/3] fs-writepage-truncate
Date: Thu, 29 May 2003 14:45:40 -0500	[thread overview]
Message-ID: <20030529194540.GA23715@waste.org> (raw)
In-Reply-To: <20030529194410.GZ23715@waste.org>

Get rid of newly exposed (and meaningless) 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);

-- 
Matt Mackall : http://www.selenic.com : of or relating to the moon

      reply	other threads:[~2003-05-29 19:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-14 10:27 2.6 must-fix list, v3 Andrew Morton
2003-05-14 10:27 ` Andrew Morton
2003-05-14 10:28 ` Jens Axboe
2003-05-14 16:41 ` Tom Rini
2003-05-14 16:57 ` Greg KH
2003-05-14 17:10 ` Matt Mackall
2003-05-14 17:44   ` Andrew Morton
2003-05-29 19:42     ` [PATCH] write errors [1/3] async-write-errors Matt Mackall
2003-05-29 19:44       ` [PATCH] write errors [2/3] flags Matt Mackall
2003-05-29 19:45         ` Matt Mackall [this message]

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=20030529194540.GA23715@waste.org \
    --to=mpm@selenic.com \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@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.