[Ocfs2-tools-devel] [PATCH 2/2] Modify the check in io_cache_disconnect.

Joel Becker Joel.Becker at oracle.com
Fri Oct 19 13:38:29 PDT 2007


On Fri, Oct 19, 2007 at 02:57:50PM +0800, Tao Ma wrote:
> In the io_cache rb-tree, we may want to erase a cached block
> which is the root of the whole tree. In this scenario, the rb_parent
> will be NULL. So this io_cache will not be removed by the original
> io_cache_disconnect and lead to the "assert" problem when we try
> io_cache_insert by using the same icb.

	You've seen this happen in practice, I assume?  The root is
RB_ROOT, a special value.  It should not be one of the icbs.
ic->ic_lookup is RB_ROOT, not an icb.
	Looking at the code, it would seem that rb_parent should never
be NULL while the node is attached.  This is, of course, what I thought
when I checked for NULL, but I can't see different in the code.
	I could very well be wrong, however.  Can you send me info on
the test case with the problem?  Or if you see where it happens in
kernel-rbtree.c, can you describe it?
	Also, anyone else who is familiar with rbtree and knows I'm
wrong, please speak up! :-)
 
Joel

> Instead, the icb->icb_blkno will be checked when we want to remove
> the specified io_cache. The icb->icb_blkno is set to to UINT64_MAX
> when it is removed.
> 
> Signed-off-by: Tao Ma <tao.ma at oracle.com>
> ---
>  libocfs2/unix_io.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libocfs2/unix_io.c b/libocfs2/unix_io.c
> index 65f2791..8a21f17 100644
> --- a/libocfs2/unix_io.c
> +++ b/libocfs2/unix_io.c
> @@ -217,11 +217,12 @@ static void io_cache_disconnect(struct io_cache *ic,
>  {
>  	/*
>  	 * This icb should longer be looked up.
> -	 * If rb_parent is NULL, it's already disconnected.
> +	 * If icb->icb_blkno is UINT64_MAX, it's already disconnected.
>  	 */
> -	if (icb->icb_node.rb_parent) {
> +	if (icb->icb_blkno != UINT64_MAX) {
>  		rb_erase(&icb->icb_node, &ic->ic_lookup);
>  		memset(&icb->icb_node, 0, sizeof(struct rb_node));
> +		icb->icb_blkno = UINT64_MAX;
>  	}
>  }
>  
> -- 
> 1.5.3.2.g4f337
> 
> _______________________________________________
> Ocfs2-tools-devel mailing list
> Ocfs2-tools-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-tools-devel

-- 

"People with narrow minds usually have broad tongues."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list