public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: do not discard page cache data on EAGAIN
@ 2010-08-23  9:10 Christoph Hellwig
  2010-08-23 12:11 ` Dave Chinner
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2010-08-23  9:10 UTC (permalink / raw)
  To: xfs

If xfs_map_blocks returns EAGAIN because of lock contention we must redirty
the page and not disard the pagecache content and return an error from
writepage.  We used to do this correctly, but the logic got lost during
the recent reshuffle of the writepage code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Mike Gao <ygao.linux@gmail.com> 
Tested-by: Mike Gao <ygao.linux@gmail.com> 

Index: xfs/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
--- xfs.orig/fs/xfs/linux-2.6/xfs_aops.c	2010-08-18 18:10:48.140261091 +0200
+++ xfs/fs/xfs/linux-2.6/xfs_aops.c	2010-08-18 18:12:41.167005888 +0200
@@ -1068,7 +1068,7 @@ xfs_vm_writepage(
 	 * by themselves.
 	 */
 	if ((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == PF_MEMALLOC)
-		goto out_fail;
+		goto redirty;
 
 	/*
 	 * We need a transaction if there are delalloc or unwritten buffers
@@ -1080,7 +1080,7 @@ xfs_vm_writepage(
 	 */
 	xfs_count_page_state(page, &delalloc, &unwritten);
 	if ((current->flags & PF_FSTRANS) && (delalloc || unwritten))
-		goto out_fail;
+		goto redirty;
 
 	/* Is this page beyond the end of the file? */
 	offset = i_size_read(inode);
@@ -1245,12 +1245,15 @@ error:
 	if (iohead)
 		xfs_cancel_ioend(iohead);
 
+	if (err == -EAGAIN)
+		goto redirty;
+
 	xfs_aops_discard_page(page);
 	ClearPageUptodate(page);
 	unlock_page(page);
 	return err;
 
-out_fail:
+redirty:
 	redirty_page_for_writepage(wbc, page);
 	unlock_page(page);
 	return 0;

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

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

* Re: [PATCH] xfs: do not discard page cache data on EAGAIN
  2010-08-23  9:10 [PATCH] xfs: do not discard page cache data on EAGAIN Christoph Hellwig
@ 2010-08-23 12:11 ` Dave Chinner
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2010-08-23 12:11 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Mon, Aug 23, 2010 at 05:10:15AM -0400, Christoph Hellwig wrote:
> If xfs_map_blocks returns EAGAIN because of lock contention we must redirty
> the page and not disard the pagecache content and return an error from
> writepage.  We used to do this correctly, but the logic got lost during
> the recent reshuffle of the writepage code.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reported-by: Mike Gao <ygao.linux@gmail.com> 
> Tested-by: Mike Gao <ygao.linux@gmail.com> 

Looks good.

Reviewed-by: Dave Chinner <dchinner@redhat.com>

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

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

end of thread, other threads:[~2010-08-23 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-23  9:10 [PATCH] xfs: do not discard page cache data on EAGAIN Christoph Hellwig
2010-08-23 12:11 ` Dave Chinner

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