linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: clear uptodate flags of pages in sys_array eb
@ 2016-06-04  0:41 Liu Bo
  2016-06-04  0:58 ` Josef Bacik
  2016-06-04  1:16 ` Liu Bo
  0 siblings, 2 replies; 4+ messages in thread
From: Liu Bo @ 2016-06-04  0:41 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

We set uptodate flag to pages in the temporary sys_array eb,
but do not clear the flag after free eb.  As the special
btree inode may still hold a reference on those pages, the
uptodate flag can remain alive in them.

If btrfs_super_chunk_root has been intentionally changed to the
offset of this sys_array eb, reading chunk_root will read content
of sys_array and it will pass our beautiful checks in
btree_readpage_end_io_hook() because of
"pages of eb are uptodate => eb is uptodate"

This adds the 'clear uptodate' part to force it to read from disk.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/volumes.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 7a169de..d2ca03b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6681,12 +6681,14 @@ int btrfs_read_sys_array(struct btrfs_root *root)
 		sb_array_offset += len;
 		cur_offset += len;
 	}
+	clear_extent_buffer_uptodate(sb);
 	free_extent_buffer_stale(sb);
 	return ret;
 
 out_short_read:
 	printk(KERN_ERR "BTRFS: sys_array too short to read %u bytes at offset %u\n",
 			len, cur_offset);
+	clear_extent_buffer_uptodate(sb);
 	free_extent_buffer_stale(sb);
 	return -EIO;
 }
-- 
2.5.5


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

* Re: [PATCH] Btrfs: clear uptodate flags of pages in sys_array eb
  2016-06-04  0:41 [PATCH] Btrfs: clear uptodate flags of pages in sys_array eb Liu Bo
@ 2016-06-04  0:58 ` Josef Bacik
  2016-06-04  1:16 ` Liu Bo
  1 sibling, 0 replies; 4+ messages in thread
From: Josef Bacik @ 2016-06-04  0:58 UTC (permalink / raw)
  To: Liu Bo, linux-btrfs; +Cc: David Sterba

On 06/03/2016 08:41 PM, Liu Bo wrote:
> We set uptodate flag to pages in the temporary sys_array eb,
> but do not clear the flag after free eb.  As the special
> btree inode may still hold a reference on those pages, the
> uptodate flag can remain alive in them.
>
> If btrfs_super_chunk_root has been intentionally changed to the
> offset of this sys_array eb, reading chunk_root will read content
> of sys_array and it will pass our beautiful checks in
> btree_readpage_end_io_hook() because of
> "pages of eb are uptodate => eb is uptodate"
>
> This adds the 'clear uptodate' part to force it to read from disk.
>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>

Reviewed-by: Josef Bacik <jbacik@fb.com>

Thanks,

Josef

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

* Re: [PATCH] Btrfs: clear uptodate flags of pages in sys_array eb
  2016-06-04  0:41 [PATCH] Btrfs: clear uptodate flags of pages in sys_array eb Liu Bo
  2016-06-04  0:58 ` Josef Bacik
@ 2016-06-04  1:16 ` Liu Bo
  2016-06-06  8:15   ` David Sterba
  1 sibling, 1 reply; 4+ messages in thread
From: Liu Bo @ 2016-06-04  1:16 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

On Fri, Jun 03, 2016 at 05:41:42PM -0700, Liu Bo wrote:
> We set uptodate flag to pages in the temporary sys_array eb,
> but do not clear the flag after free eb.  As the special
> btree inode may still hold a reference on those pages, the
> uptodate flag can remain alive in them.
> 
> If btrfs_super_chunk_root has been intentionally changed to the
> offset of this sys_array eb, reading chunk_root will read content
> of sys_array and it will pass our beautiful checks in

s/pass/skip/

My mistake, sorry.

Thanks,

-liubo

> btree_readpage_end_io_hook() because of
> "pages of eb are uptodate => eb is uptodate"
> 
> This adds the 'clear uptodate' part to force it to read from disk.
> 
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> ---
>  fs/btrfs/volumes.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 7a169de..d2ca03b 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -6681,12 +6681,14 @@ int btrfs_read_sys_array(struct btrfs_root *root)
>  		sb_array_offset += len;
>  		cur_offset += len;
>  	}
> +	clear_extent_buffer_uptodate(sb);
>  	free_extent_buffer_stale(sb);
>  	return ret;
>  
>  out_short_read:
>  	printk(KERN_ERR "BTRFS: sys_array too short to read %u bytes at offset %u\n",
>  			len, cur_offset);
> +	clear_extent_buffer_uptodate(sb);
>  	free_extent_buffer_stale(sb);
>  	return -EIO;
>  }
> -- 
> 2.5.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] Btrfs: clear uptodate flags of pages in sys_array eb
  2016-06-04  1:16 ` Liu Bo
@ 2016-06-06  8:15   ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2016-06-06  8:15 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs, David Sterba

On Fri, Jun 03, 2016 at 06:16:18PM -0700, Liu Bo wrote:
> On Fri, Jun 03, 2016 at 05:41:42PM -0700, Liu Bo wrote:
> > We set uptodate flag to pages in the temporary sys_array eb,
> > but do not clear the flag after free eb.  As the special
> > btree inode may still hold a reference on those pages, the
> > uptodate flag can remain alive in them.
> > 
> > If btrfs_super_chunk_root has been intentionally changed to the
> > offset of this sys_array eb, reading chunk_root will read content
> > of sys_array and it will pass our beautiful checks in
> 
> s/pass/skip/
> 
> My mistake, sorry.

Updated in the patch.

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

end of thread, other threads:[~2016-06-06  8:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-04  0:41 [PATCH] Btrfs: clear uptodate flags of pages in sys_array eb Liu Bo
2016-06-04  0:58 ` Josef Bacik
2016-06-04  1:16 ` Liu Bo
2016-06-06  8:15   ` David Sterba

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).