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

Joel Becker Joel.Becker at oracle.com
Wed Oct 24 01:53:17 PDT 2007


On Wed, Oct 24, 2007 at 09:15:49AM +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.
> 
> 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 and we also initialize it to UINT64_MAX in
> io_init_cache.
> 
> Signed-off-by: Tao Ma <tao.ma at oracle.com>
Signed-off-by: Joel Becker <joel.becker at oracle.com>

> ---
>  libocfs2/unix_io.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libocfs2/unix_io.c b/libocfs2/unix_io.c
> index 65f2791..d453471 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;
>  	}
>  }
>  
> @@ -375,6 +376,7 @@ errcode_t io_init_cache(io_channel *channel, size_t nr_blocks)
>  	icb_list = ic->ic_metadata_buffer;
>  	dbuf = ic->ic_data_buffer;
>  	for (i = 0; i < nr_blocks; i++) {
> +		icb_list[i].icb_blkno = UINT64_MAX;
>  		icb_list[i].icb_buf = dbuf;
>  		dbuf += channel->io_blksize;
>  		list_add_tail(&icb_list[i].icb_list, &ic->ic_lru);
> -- 
> 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

-- 

"The only way to get rid of a temptation is to yield to it."
         - Oscar Wilde 

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