linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix regression in lock_delalloc_pages
@ 2017-03-07  2:20 Liu Bo
  2017-03-07  5:54 ` Qu Wenruo
  0 siblings, 1 reply; 3+ messages in thread
From: Liu Bo @ 2017-03-07  2:20 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The bug is a regression after commit
(da2c7009f6ca "btrfs: teach __process_pages_contig about PAGE_LOCK operation")
and commit
(76c0021db8fd "Btrfs: use helper to simplify lock/unlock pages").

So if the dirty pages which are under writeback got truncated partially
before we lock the dirty pages, we couldn't find all pages mapping to the
delalloc range, and the bug didn't return an error so it kept going on and
found that the delalloc range got truncated and got to unlock the dirty
pages, and then the ASSERT could caught the error, and showed

-----------------------------------------------------------------------------
assertion failed: page_ops & PAGE_LOCK, file: fs/btrfs/extent_io.c, line: 1716
-----------------------------------------------------------------------------

This fixes the bug by returning the proper -EAGAIN.

Cc: David Sterba <dsterba@suse.com>
Reported-by: Dave Jones <davej@codemonkey.org.uk>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/extent_io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 28e8192..8df7974 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1714,7 +1714,8 @@ static int __process_pages_contig(struct address_space *mapping,
 			 * can we find nothing at @index.
 			 */
 			ASSERT(page_ops & PAGE_LOCK);
-			return ret;
+			err = -EAGAIN;
+			goto out;
 		}
 
 		for (i = 0; i < ret; i++) {
-- 
2.5.5


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

* Re: [PATCH] Btrfs: fix regression in lock_delalloc_pages
  2017-03-07  2:20 [PATCH] Btrfs: fix regression in lock_delalloc_pages Liu Bo
@ 2017-03-07  5:54 ` Qu Wenruo
  2017-03-07 19:55   ` Liu Bo
  0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2017-03-07  5:54 UTC (permalink / raw)
  To: Liu Bo, linux-btrfs; +Cc: David Sterba



At 03/07/2017 10:20 AM, Liu Bo wrote:
> The bug is a regression after commit
> (da2c7009f6ca "btrfs: teach __process_pages_contig about PAGE_LOCK operation")
> and commit
> (76c0021db8fd "Btrfs: use helper to simplify lock/unlock pages").
>
> So if the dirty pages which are under writeback got truncated partially
> before we lock the dirty pages, we couldn't find all pages mapping to the
> delalloc range, and the bug didn't return an error so it kept going on and
> found that the delalloc range got truncated and got to unlock the dirty
> pages, and then the ASSERT could caught the error, and showed
>
> -----------------------------------------------------------------------------
> assertion failed: page_ops & PAGE_LOCK, file: fs/btrfs/extent_io.c, line: 1716
> -----------------------------------------------------------------------------

We also triggered such bug when running xfstests btrfs/070, although 
possibility is somewhat low.

However since it's more about possibility, any fsstress may trigger it 
though.

Thanks,
Qu

>
> This fixes the bug by returning the proper -EAGAIN.
>
> Cc: David Sterba <dsterba@suse.com>
> Reported-by: Dave Jones <davej@codemonkey.org.uk>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> ---
>  fs/btrfs/extent_io.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index 28e8192..8df7974 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -1714,7 +1714,8 @@ static int __process_pages_contig(struct address_space *mapping,
>  			 * can we find nothing at @index.
>  			 */
>  			ASSERT(page_ops & PAGE_LOCK);
> -			return ret;
> +			err = -EAGAIN;
> +			goto out;
>  		}
>
>  		for (i = 0; i < ret; i++) {
>



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

* Re: [PATCH] Btrfs: fix regression in lock_delalloc_pages
  2017-03-07  5:54 ` Qu Wenruo
@ 2017-03-07 19:55   ` Liu Bo
  0 siblings, 0 replies; 3+ messages in thread
From: Liu Bo @ 2017-03-07 19:55 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs, David Sterba

On Tue, Mar 07, 2017 at 01:54:31PM +0800, Qu Wenruo wrote:
> 
> 
> At 03/07/2017 10:20 AM, Liu Bo wrote:
> > The bug is a regression after commit
> > (da2c7009f6ca "btrfs: teach __process_pages_contig about PAGE_LOCK operation")
> > and commit
> > (76c0021db8fd "Btrfs: use helper to simplify lock/unlock pages").
> > 
> > So if the dirty pages which are under writeback got truncated partially
> > before we lock the dirty pages, we couldn't find all pages mapping to the
> > delalloc range, and the bug didn't return an error so it kept going on and
> > found that the delalloc range got truncated and got to unlock the dirty
> > pages, and then the ASSERT could caught the error, and showed
> > 
> > -----------------------------------------------------------------------------
> > assertion failed: page_ops & PAGE_LOCK, file: fs/btrfs/extent_io.c, line: 1716
> > -----------------------------------------------------------------------------
> 
> We also triggered such bug when running xfstests btrfs/070, although
> possibility is somewhat low.
> 
> However since it's more about possibility, any fsstress may trigger it
> though.
>

Yes, I think buffer writes with O_SYNC and some concurrent truncate
could get us to ASSERT.

Thanks,

-liubo

> Thanks,
> Qu
> 
> > 
> > This fixes the bug by returning the proper -EAGAIN.
> > 
> > Cc: David Sterba <dsterba@suse.com>
> > Reported-by: Dave Jones <davej@codemonkey.org.uk>
> > Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> > ---
> >  fs/btrfs/extent_io.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> > index 28e8192..8df7974 100644
> > --- a/fs/btrfs/extent_io.c
> > +++ b/fs/btrfs/extent_io.c
> > @@ -1714,7 +1714,8 @@ static int __process_pages_contig(struct address_space *mapping,
> >  			 * can we find nothing at @index.
> >  			 */
> >  			ASSERT(page_ops & PAGE_LOCK);
> > -			return ret;
> > +			err = -EAGAIN;
> > +			goto out;
> >  		}
> > 
> >  		for (i = 0; i < ret; i++) {
> > 
> 
> 

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

end of thread, other threads:[~2017-03-07 19:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-07  2:20 [PATCH] Btrfs: fix regression in lock_delalloc_pages Liu Bo
2017-03-07  5:54 ` Qu Wenruo
2017-03-07 19:55   ` Liu Bo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).