Skip to contentSkip to conversation

xfs: Fix WARN_ON(delalloc) in xfs_vm_releasepage()

PATCH Applied Jan Kara 4 participants 10 messages Mar 14, 2013 – Mar 22, 2013 XFS filesystem

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 xfs: Fix WARN_ON(delalloc) in xfs_vm_releasepage()

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

---
 fs/xfs/xfs_aops.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
fs/xfs/xfs_aops.c +6 -6
index 5f707e5..3244c98 100644
@@ -953,13 +953,13 @@ xfs_vm_writepage(
 		unsigned offset_into_page = offset & (PAGE_CACHE_SIZE - 1);
 
 		/*
-		 * Just skip the page if it is fully outside i_size, e.g. due
-		 * to a truncate operation that is in progress.
+		 * Skip the page if it is fully outside i_size, e.g. due to a
+		 * truncate operation that is in progress. We must redirty the
+		 * page so that reclaim stops reclaiming it. Otherwise
+		 * xfs_vm_releasepage() is called on it and gets confused.
 		 */
-		if (page->index >= end_index + 1 || offset_into_page == 0) {
-			unlock_page(page);
-			return 0;
-		}
+		if (page->index >= end_index + 1 || offset_into_page == 0)
+			goto redirty;
 
 		/*
 		 * The page straddles i_size.  It must be zeroed out on each
Signature · 6 lines
1.7.1

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/1
#1 lore raw
Quoted 47 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

---
 fs/xfs/xfs_aops.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
fs/xfs/xfs_aops.c +6 -6
index 5f707e5..3244c98 100644
@@ -953,13 +953,13 @@ xfs_vm_writepage(
 		unsigned offset_into_page = offset & (PAGE_CACHE_SIZE - 1);
 
 		/*
-		 * Just skip the page if it is fully outside i_size, e.g. due
-		 * to a truncate operation that is in progress.
+		 * Skip the page if it is fully outside i_size, e.g. due to a
+		 * truncate operation that is in progress. We must redirty the
+		 * page so that reclaim stops reclaiming it. Otherwise
+		 * xfs_vm_releasepage() is called on it and gets confused.
 		 */
-		if (page->index >= end_index + 1 || offset_into_page == 0) {
-			unlock_page(page);
-			return 0;
-		}
+		if (page->index >= end_index + 1 || offset_into_page == 0)
+			goto redirty;
 
 		/*
 		 * The page straddles i_size.  It must be zeroed out on each
Signature · 6 lines
1.7.1

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Looks Good,

Signature · 6 lines
Carlos

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
In reply to Jan Kara

Hi Jan,

Quoted 10 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

Was there an easy way to reproduce this? I'm testing and reviewing this now and it might help.

Thanks much,
Ben

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

author
#3 lore raw
Quoted 10 lines · Ben Myers

Hi Jan,

Quoted 7 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Quoted 6 lines
Quoted 3 lines

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

Was there an easy way to reproduce this? I'm testing and reviewing this now and it might help.

I used scripts/run-bash-shared-mapping.sh from the attached tarball - it
fires up several processes beating a file with mmap accesses while truncating the file and memory stressing the machine. I presume fsx with some memhog could trigger the issue as well.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
Quoted 15 lines · Jan Kara
Quoted 14 lines · Ben Myers

Hi Jan,

Quoted 10 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

Quoted 6 lines
Quoted 2 lines

Was there an easy way to reproduce this? I'm testing and reviewing this now and it might help.

I used scripts/run-bash-shared-mapping.sh from the attached tarball - it
fires up several processes beating a file with mmap accesses while truncating the file and memory stressing the machine. I presume fsx with some memhog could trigger the issue as well.

I have seen fsx trip this occasionally. The problem is that it was never reliable because of the fact that other memory pressure had to be generated at the same time....

Is the above script something you could turn into an xfstest (I haven't looked at the script yet)?

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#5 lore raw
Quoted 23 lines · Dave Chinner
Quoted 15 lines · Jan Kara
Quoted 14 lines · Ben Myers

Hi Jan,

Quoted 10 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

Quoted 6 lines
Quoted 2 lines

Was there an easy way to reproduce this? I'm testing and reviewing this now and it might help.

I used scripts/run-bash-shared-mapping.sh from the attached tarball - it
fires up several processes beating a file with mmap accesses while truncating the file and memory stressing the machine. I presume fsx with some memhog could trigger the issue as well.

Quoted 6 lines

I have seen fsx trip this occasionally. The problem is that it was never reliable because of the fact that other memory pressure had to be generated at the same time....

Is the above script something you could turn into an xfstest (I haven't looked at the script yet)?

Yes, that should be doable. I'll try combining fsx and usemem whether
that will be enough to trigger the race.

Honza

Signature · 7 lines
Jan Kara <[email protected]>
SUSE Labs, CR

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#6 lore raw
In reply to Ben Myers
Quoted 10 lines · Ben Myers

Hi Jan,

Quoted 7 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Quoted 6 lines
Quoted 3 lines

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

Was there an easy way to reproduce this? I'm testing and reviewing this now and it might help.

This patch has been confirmed to fix the report generated by the DB workload I mentioned in another part of the thread. Hence I think it should be good to go.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#7 lore raw
Quoted 15 lines · Dave Chinner
Quoted 14 lines · Ben Myers

Hi Jan,

Quoted 10 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

Quoted 6 lines
Quoted 2 lines

Was there an easy way to reproduce this? I'm testing and reviewing this now and it might help.

This patch has been confirmed to fix the report generated by the DB workload I mentioned in another part of the thread. Hence I think it should be good to go.

Agreed, Thanks.

-Ben

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#8 lore raw
In reply to Jan Kara
Quoted 7 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Quoted 5 lines

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

Definitely look s like a problem taht needs fixing, and it seems to me to be the correct fix.

I got a bug report recently about this warning being triggered, but the total report was the warning and a workload description of "XFS produced a warning at some point during a 28 hour long DB benchmark." Not particularly helpful, but this looks like a potential cause. Thanks!

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Applied
#9 lore raw
In reply to Jan Kara
Quoted 7 lines · Jan Kara

When a dirty page is truncated from a file but reclaim gets to it before truncate_inode_pages(), we hit WARN_ON(delalloc) in xfs_vm_releasepage(). This is because reclaim tries to write the page, xfs_vm_writepage() just bails out (leaving page clean) and thus reclaim thinks it can continue and calls xfs_vm_releasepage() on page with dirty buffers.

Quoted 5 lines

Fix the issue by redirtying the page in xfs_vm_writepage(). This makes reclaim stop reclaiming the page and also logically it keeps page in a more consistent state where page with dirty buffers has PageDirty set.

Applied.

Regards,
Ben

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs