Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5420f23 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner
Browse files

xfs: do not discard page cache data on EAGAIN



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: default avatarChristoph Hellwig <hch@lst.de>
Reported-by: default avatarMike Gao <ygao.linux@gmail.com>
Tested-by: default avatarMike Gao <ygao.linux@gmail.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
parent 3b93c7aa
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -1068,7 +1068,7 @@ xfs_vm_writepage(
	 * by themselves.
	 * by themselves.
	 */
	 */
	if ((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == PF_MEMALLOC)
	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
	 * 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);
	xfs_count_page_state(page, &delalloc, &unwritten);
	if ((current->flags & PF_FSTRANS) && (delalloc || unwritten))
	if ((current->flags & PF_FSTRANS) && (delalloc || unwritten))
		goto out_fail;
		goto redirty;


	/* Is this page beyond the end of the file? */
	/* Is this page beyond the end of the file? */
	offset = i_size_read(inode);
	offset = i_size_read(inode);
@@ -1245,12 +1245,15 @@ xfs_vm_writepage(
	if (iohead)
	if (iohead)
		xfs_cancel_ioend(iohead);
		xfs_cancel_ioend(iohead);


	if (err == -EAGAIN)
		goto redirty;

	xfs_aops_discard_page(page);
	xfs_aops_discard_page(page);
	ClearPageUptodate(page);
	ClearPageUptodate(page);
	unlock_page(page);
	unlock_page(page);
	return err;
	return err;


out_fail:
redirty:
	redirty_page_for_writepage(wbc, page);
	redirty_page_for_writepage(wbc, page);
	unlock_page(page);
	unlock_page(page);
	return 0;
	return 0;