public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Re-dirty pages on I/O error
@ 2008-09-11  8:37 Lachlan McIlroy
  2008-09-11 10:33 ` Christoph Hellwig
  2008-09-13  4:19 ` Dave Chinner
  0 siblings, 2 replies; 14+ messages in thread
From: Lachlan McIlroy @ 2008-09-11  8:37 UTC (permalink / raw)
  To: xfs-dev, xfs-oss

If we get an error in xfs_page_state_convert() - and it's not EAGAIN - then
we throw away the dirty page without converting the delayed allocation.  This
leaves delayed allocations that can never be removed and confuses code that
expects a flush of the file to clear them.  We need to re-dirty the page on
error so we can try again later or report that the flush failed.

--- a/fs/xfs/linux-2.6/xfs_aops.c	2008-09-11 16:32:11.000000000 +1000
+++ b/fs/xfs/linux-2.6/xfs_aops.c	2008-09-11 15:44:09.000000000 +1000
@@ -1147,16 +1147,6 @@ error:
 	if (iohead)
 		xfs_cancel_ioend(iohead);
 
-	/*
-	 * If it's delalloc and we have nowhere to put it,
-	 * throw it away, unless the lower layers told
-	 * us to try again.
-	 */
-	if (err != -EAGAIN) {
-		if (!unmapped)
-			block_invalidatepage(page, 0);
-		ClearPageUptodate(page);
-	}
 	return err;
 }
 
@@ -1216,8 +1206,11 @@ xfs_vm_writepage(
 	 * then mark the page dirty again and leave the page
 	 * as is.
 	 */
-	if (current_test_flags(PF_FSTRANS) && need_trans)
-		goto out_fail;
+	if (current_test_flags(PF_FSTRANS) && need_trans) {
+		redirty_page_for_writepage(wbc, page);
+		unlock_page(page);
+		return -EAGAIN;
+	}
 
 	/*
 	 * Delay hooking up buffer heads until we have
@@ -1231,20 +1224,14 @@ xfs_vm_writepage(
 	 * to real space and flush out to disk.
 	 */
 	error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
-	if (error == -EAGAIN)
-		goto out_fail;
-	if (unlikely(error < 0))
-		goto out_unlock;
 
-	return 0;
+	if (error < 0) {
+		redirty_page_for_writepage(wbc, page);
+		unlock_page(page);
+		return error;
+	}
 
-out_fail:
-	redirty_page_for_writepage(wbc, page);
-	unlock_page(page);
 	return 0;
-out_unlock:
-	unlock_page(page);
-	return error;
 }
 
 STATIC int

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH] Re-dirty pages on I/O error
@ 2009-02-10  1:48 Lachlan McIlroy
  2009-02-10 10:01 ` Dave Chinner
  0 siblings, 1 reply; 14+ messages in thread
From: Lachlan McIlroy @ 2009-02-10  1:48 UTC (permalink / raw)
  To: xfs-oss

[This patch seems to have slipped through the proverbial crack.]

If we get an error in xfs_page_state_convert() - and it's not EAGAIN - then
we throw away the dirty page without converting the delayed allocation.  This
leaves delayed allocations that can never be removed and confuses code that
expects a flush of the file to clear them.  We need to re-dirty the page on
error so we can try again later or report that the flush failed.


Index: xfs-fixes/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- xfs-fixes.orig/fs/xfs/linux-2.6/xfs_aops.c
+++ xfs-fixes/fs/xfs/linux-2.6/xfs_aops.c
@@ -1185,16 +1185,6 @@ error:
  	if (iohead)
  		xfs_cancel_ioend(iohead);

-	/*
-	 * If it's delalloc and we have nowhere to put it,
-	 * throw it away, unless the lower layers told
-	 * us to try again.
-	 */
-	if (err != -EAGAIN) {
-		if (!unmapped)
-			block_invalidatepage(page, 0);
-		ClearPageUptodate(page);
-	}
  	return err;
  }

@@ -1223,7 +1213,7 @@ xfs_vm_writepage(
  	struct page		*page,
  	struct writeback_control *wbc)
  {
-	int			error;
+	int			error = 0;
  	int			need_trans;
  	int			delalloc, unmapped, unwritten;
  	struct inode		*inode = page->mapping->host;
@@ -1269,19 +1259,16 @@ xfs_vm_writepage(
  	 * to real space and flush out to disk.
  	 */
  	error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
-	if (error == -EAGAIN)
-		goto out_fail;
  	if (unlikely(error < 0))
-		goto out_unlock;
+		goto out_fail;

  	return 0;

  out_fail:
  	redirty_page_for_writepage(wbc, page);
  	unlock_page(page);
-	return 0;
-out_unlock:
-	unlock_page(page);
+	if (error == -EAGAIN)
+		error = 0;
  	return error;
  }

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-02-15 20:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-11  8:37 [PATCH] Re-dirty pages on I/O error Lachlan McIlroy
2008-09-11 10:33 ` Christoph Hellwig
2008-09-11 21:21   ` Eric Sandeen
2008-09-12  6:44     ` Lachlan McIlroy
2008-09-12 13:17       ` Eric Sandeen
2008-09-12  6:04   ` Lachlan McIlroy
2008-09-13  4:19 ` Dave Chinner
2008-09-15  3:22   ` Lachlan McIlroy
2008-09-16  4:01     ` Dave Chinner
2008-09-16  6:30       ` Lachlan McIlroy
  -- strict thread matches above, loose matches on Subject: below --
2009-02-10  1:48 Lachlan McIlroy
2009-02-10 10:01 ` Dave Chinner
2009-02-10 23:33   ` Lachlan McIlroy
2009-02-15 20:05   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox