Skip to content

Commit

Permalink
xfs: do not discard page cache data on EAGAIN
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
  • Loading branch information
Christoph Hellwig authored and Dave Chinner committed Aug 24, 2010
1 parent 3b93c7a commit b5420f2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fs/xfs/linux-2.6/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -1245,12 +1245,15 @@ xfs_vm_writepage(
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;
Expand Down

0 comments on commit b5420f2

Please sign in to comment.