From ee2b2dc73957d53eac2e1d5c37e044945db876f8 Mon Sep 17 00:00:00 2001 From: marko <> Date: Mon, 16 Mar 2009 09:43:34 +0000 Subject: [PATCH] branches/zip: UT_LIST_VALIDATE(): Add the parameter ASSERTION and adjust all callers. --- buf/buf0buddy.c | 12 ++++++++--- buf/buf0buf.c | 3 ++- buf/buf0flu.c | 6 ++++-- buf/buf0lru.c | 10 ++++++--- fil/fil0fil.c | 6 ++++-- include/ut0lst.h | 56 +++++++++++++++++++++++++----------------------- mem/mem0pool.c | 3 ++- 7 files changed, 57 insertions(+), 39 deletions(-) diff --git a/buf/buf0buddy.c b/buf/buf0buddy.c index 93692416475..151e6615c83 100644 --- a/buf/buf0buddy.c +++ b/buf/buf0buddy.c @@ -136,7 +136,9 @@ buf_buddy_alloc_zip( #if defined UNIV_DEBUG && !defined UNIV_DEBUG_VALGRIND /* Valgrind would complain about accessing free memory. */ - UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i]); + UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i], + ut_a(buf_page_get_state(ut_list_node_313) + == BUF_BLOCK_ZIP_FREE)); #endif /* UNIV_DEBUG && !UNIV_DEBUG_VALGRIND */ bpage = UT_LIST_GET_FIRST(buf_pool->zip_free[i]); @@ -264,7 +266,9 @@ buf_buddy_alloc_from( bpage->state = BUF_BLOCK_ZIP_FREE; #if defined UNIV_DEBUG && !defined UNIV_DEBUG_VALGRIND /* Valgrind would complain about accessing free memory. */ - UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[j]); + UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[j], + ut_a(buf_page_get_state(ut_list_node_313) + == BUF_BLOCK_ZIP_FREE)); #endif /* UNIV_DEBUG && !UNIV_DEBUG_VALGRIND */ buf_buddy_add_to_free(bpage, j); } @@ -573,7 +577,9 @@ buddy_free2: #ifndef UNIV_DEBUG_VALGRIND buddy_nonfree: /* Valgrind would complain about accessing free memory. */ - ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i])); + ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->zip_free[i], + ut_a(buf_page_get_state(ut_list_node_313) + == BUF_BLOCK_ZIP_FREE))); #endif /* UNIV_DEBUG_VALGRIND */ /* The buddy is not free. Is there a free block of this size? */ diff --git a/buf/buf0buf.c b/buf/buf0buf.c index 3c19a3d4a23..cf575c19b4e 100644 --- a/buf/buf0buf.c +++ b/buf/buf0buf.c @@ -1155,7 +1155,8 @@ buf_relocate( #endif /* UNIV_LRU_DEBUG */ } - ut_d(UT_LIST_VALIDATE(LRU, buf_page_t, buf_pool->LRU)); + ut_d(UT_LIST_VALIDATE(LRU, buf_page_t, buf_pool->LRU, + ut_ad(ut_list_node_313->in_LRU_list))); /* relocate buf_pool->page_hash */ fold = buf_page_address_fold(bpage->space, bpage->offset); diff --git a/buf/buf0flu.c b/buf/buf0flu.c index a3d9d0ab26b..6d45daaad26 100644 --- a/buf/buf0flu.c +++ b/buf/buf0flu.c @@ -227,7 +227,8 @@ buf_flush_remove( bpage->oldest_modification = 0; - ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->flush_list)); + ut_d(UT_LIST_VALIDATE(list, buf_page_t, buf_pool->flush_list, + ut_ad(ut_list_node_313->in_flush_list))); } /************************************************************************ @@ -1206,7 +1207,8 @@ buf_flush_validate_low(void) { buf_page_t* bpage; - UT_LIST_VALIDATE(list, buf_page_t, buf_pool->flush_list); + UT_LIST_VALIDATE(list, buf_page_t, buf_pool->flush_list, + ut_ad(ut_list_node_313->in_flush_list)); bpage = UT_LIST_GET_FIRST(buf_pool->flush_list); diff --git a/buf/buf0lru.c b/buf/buf0lru.c index 409e58dc4af..d0571ca3e68 100644 --- a/buf/buf0lru.c +++ b/buf/buf0lru.c @@ -1908,7 +1908,8 @@ buf_LRU_validate(void) ut_a(old_len <= new_len + BUF_LRU_OLD_TOLERANCE); } - UT_LIST_VALIDATE(LRU, buf_page_t, buf_pool->LRU); + UT_LIST_VALIDATE(LRU, buf_page_t, buf_pool->LRU, + ut_ad(ut_list_node_313->in_LRU_list)); bpage = UT_LIST_GET_FIRST(buf_pool->LRU); @@ -1956,7 +1957,8 @@ buf_LRU_validate(void) ut_a(buf_pool->LRU_old_len == old_len); } - UT_LIST_VALIDATE(list, buf_page_t, buf_pool->free); + UT_LIST_VALIDATE(list, buf_page_t, buf_pool->free, + ut_ad(ut_list_node_313->in_free_list)); for (bpage = UT_LIST_GET_FIRST(buf_pool->free); bpage != NULL; @@ -1965,7 +1967,9 @@ buf_LRU_validate(void) ut_a(buf_page_get_state(bpage) == BUF_BLOCK_NOT_USED); } - UT_LIST_VALIDATE(unzip_LRU, buf_block_t, buf_pool->unzip_LRU); + UT_LIST_VALIDATE(unzip_LRU, buf_block_t, buf_pool->unzip_LRU, + ut_ad(ut_list_node_313->in_unzip_LRU_list + && ut_list_node_313->page.in_LRU_list)); for (block = UT_LIST_GET_FIRST(buf_pool->unzip_LRU); block; diff --git a/fil/fil0fil.c b/fil/fil0fil.c index 4d778cf8a93..5f713335740 100644 --- a/fil/fil0fil.c +++ b/fil/fil0fil.c @@ -4693,7 +4693,9 @@ fil_validate(void) space = HASH_GET_FIRST(system->spaces, i); while (space != NULL) { - UT_LIST_VALIDATE(chain, fil_node_t, space->chain); + UT_LIST_VALIDATE(chain, fil_node_t, space->chain, + ut_a(ut_list_node_313->open + || !ut_list_node_313->n_pending)); fil_node = UT_LIST_GET_FIRST(space->chain); @@ -4713,7 +4715,7 @@ fil_validate(void) ut_a(system->n_open == n_open); - UT_LIST_VALIDATE(LRU, fil_node_t, system->LRU); + UT_LIST_VALIDATE(LRU, fil_node_t, system->LRU, (void) 0); fil_node = UT_LIST_GET_FIRST(system->LRU); diff --git a/include/ut0lst.h b/include/ut0lst.h index 46ee23a2538..75f9aaee463 100644 --- a/include/ut0lst.h +++ b/include/ut0lst.h @@ -210,34 +210,36 @@ if the list is empty. BASE is the base node (not a pointer to it). */ /************************************************************************ Checks the consistency of a two-way list. NAME is the name of the list, -TYPE is the node type, and BASE is the base node (not a pointer to it). */ - -#define UT_LIST_VALIDATE(NAME, TYPE, BASE)\ -{\ - ulint ut_list_i_313;\ - TYPE * ut_list_node_313;\ -\ - ut_list_node_313 = (BASE).start;\ -\ - for (ut_list_i_313 = 0; ut_list_i_313 < (BASE).count;\ - ut_list_i_313++) {\ - ut_a(ut_list_node_313);\ - ut_list_node_313 = (ut_list_node_313->NAME).next;\ - }\ -\ - ut_a(ut_list_node_313 == NULL);\ -\ - ut_list_node_313 = (BASE).end;\ -\ - for (ut_list_i_313 = 0; ut_list_i_313 < (BASE).count;\ - ut_list_i_313++) {\ - ut_a(ut_list_node_313);\ - ut_list_node_313 = (ut_list_node_313->NAME).prev;\ - }\ -\ - ut_a(ut_list_node_313 == NULL);\ -}\ +TYPE is the node type, BASE is the base node (not a pointer to it), +and ASSERTION is a condition on ut_list_node_313. */ +#define UT_LIST_VALIDATE(NAME, TYPE, BASE, ASSERTION) \ +do { \ + ulint ut_list_i_313; \ + TYPE * ut_list_node_313; \ + \ + ut_list_node_313 = (BASE).start; \ + \ + for (ut_list_i_313 = 0; ut_list_i_313 < (BASE).count; \ + ut_list_i_313++) { \ + ut_a(ut_list_node_313); \ + ASSERTION; \ + ut_list_node_313 = (ut_list_node_313->NAME).next; \ + } \ + \ + ut_a(ut_list_node_313 == NULL); \ + \ + ut_list_node_313 = (BASE).end; \ + \ + for (ut_list_i_313 = 0; ut_list_i_313 < (BASE).count; \ + ut_list_i_313++) { \ + ut_a(ut_list_node_313); \ + ASSERTION; \ + ut_list_node_313 = (ut_list_node_313->NAME).prev; \ + } \ + \ + ut_a(ut_list_node_313 == NULL); \ +} while (0) #endif diff --git a/mem/mem0pool.c b/mem/mem0pool.c index 34de6b2a706..8ff87e9da64 100644 --- a/mem/mem0pool.c +++ b/mem/mem0pool.c @@ -624,7 +624,8 @@ mem_pool_validate( for (i = 0; i < 64; i++) { - UT_LIST_VALIDATE(free_list, mem_area_t, pool->free_list[i]); + UT_LIST_VALIDATE(free_list, mem_area_t, pool->free_list[i], + (void) 0); area = UT_LIST_GET_FIRST(pool->free_list[i]);