From: kevin.lewis Date: March 23 2011 1:46pm Subject: bzr commit into mysql-trunk-innodb branch (kevin.lewis:3550) List-Archive: http://lists.mysql.com/commits/133645 Message-Id: <20110323134645.3A2C9D6D8B5@kevin-lewis-macbook.local> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///Users/kevinlewis/Work/Mysql/WL5628/Part2/mysql-trunk-innodb/ based on revid:kevin.lewis@stripped 3550 kevin.lewis@stripped 2011-03-23 [merge] merge modified: storage/innobase/include/btr0pcur.h storage/innobase/include/btr0pcur.ic storage/innobase/include/page0page.h storage/innobase/include/rem0rec.h storage/innobase/include/rem0rec.ic storage/innobase/include/srv0srv.h storage/innobase/include/thr0loc.h storage/innobase/page/page0page.c storage/innobase/srv/srv0srv.c storage/innobase/thr/thr0loc.c === modified file 'storage/innobase/include/btr0pcur.h' --- a/storage/innobase/include/btr0pcur.h revid:kevin.lewis@stripped +++ b/storage/innobase/include/btr0pcur.h revid:kevin.lewis@stripped @@ -151,7 +151,7 @@ UNIV_INLINE ulint btr_pcur_get_up_match( /*==================*/ - btr_pcur_t* cursor); /*!< in: memory buffer for persistent cursor */ + const btr_pcur_t* cursor); /*!< in: persistent cursor */ /**************************************************************//** Gets the low_match value for a pcur after a search. @return number of matched fields at the cursor or to the right if @@ -160,7 +160,7 @@ UNIV_INLINE ulint btr_pcur_get_low_match( /*===================*/ - btr_pcur_t* cursor); /*!< in: memory buffer for persistent cursor */ + const btr_pcur_t* cursor); /*!< in: persistent cursor */ /**************************************************************//** If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first user record satisfying the search condition, in the case PAGE_CUR_L or @@ -265,22 +265,6 @@ ulint btr_pcur_get_rel_pos( /*=================*/ const btr_pcur_t* cursor);/*!< in: persistent cursor */ -/*********************************************************//** -Sets the mtr field for a pcur. */ -UNIV_INLINE -void -btr_pcur_set_mtr( -/*=============*/ - btr_pcur_t* cursor, /*!< in: persistent cursor */ - mtr_t* mtr); /*!< in, own: mtr */ -/*********************************************************//** -Gets the mtr field for a pcur. -@return mtr */ -UNIV_INLINE -mtr_t* -btr_pcur_get_mtr( -/*=============*/ - btr_pcur_t* cursor); /*!< in: persistent cursor */ /**************************************************************//** Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, that is, the cursor becomes detached. If there have been modifications @@ -388,10 +372,6 @@ page_cur_t* btr_pcur_get_page_cur( /*==================*/ const btr_pcur_t* cursor); /*!< in: persistent cursor */ -#else /* UNIV_DEBUG */ -# define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur) -# define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur) -#endif /* UNIV_DEBUG */ /*********************************************************//** Returns the page of a persistent cursor. @return pointer to the page */ @@ -399,7 +379,7 @@ UNIV_INLINE page_t* btr_pcur_get_page( /*==============*/ - btr_pcur_t* cursor);/*!< in: persistent cursor */ + const btr_pcur_t* cursor);/*!< in: persistent cursor */ /*********************************************************//** Returns the buffer block of a persistent cursor. @return pointer to the block */ @@ -407,7 +387,7 @@ UNIV_INLINE buf_block_t* btr_pcur_get_block( /*===============*/ - btr_pcur_t* cursor);/*!< in: persistent cursor */ + const btr_pcur_t* cursor);/*!< in: persistent cursor */ /*********************************************************//** Returns the record of a persistent cursor. @return pointer to the record */ @@ -415,7 +395,14 @@ UNIV_INLINE rec_t* btr_pcur_get_rec( /*=============*/ - btr_pcur_t* cursor);/*!< in: persistent cursor */ + const btr_pcur_t* cursor);/*!< in: persistent cursor */ +#else /* UNIV_DEBUG */ +# define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur) +# define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur) +# define btr_pcur_get_page(cursor) ((cursor)->btr_cur.page_cur.block->frame) +# define btr_pcur_get_block(cursor) ((cursor)->btr_cur.page_cur.block) +# define btr_pcur_get_rec(cursor) ((cursor)->btr_cur.page_cur.rec) +#endif /* UNIV_DEBUG */ /*********************************************************//** Checks if the persistent cursor is on a user record. */ UNIV_INLINE @@ -518,9 +505,6 @@ struct btr_pcur_struct{ /* NOTE that the following fields may possess dynamically allocated memory which should be freed if not needed anymore! */ - mtr_t* mtr; /*!< NULL, or this field may contain - a mini-transaction which holds the - latch on the cursor page */ byte* old_rec_buf; /*!< NULL, or a dynamically allocated buffer for old_rec */ ulint buf_size; /*!< old_rec_buf size if old_rec_buf === modified file 'storage/innobase/include/btr0pcur.ic' --- a/storage/innobase/include/btr0pcur.ic revid:kevin.lewis@stripped +++ b/storage/innobase/include/btr0pcur.ic revid:kevin.lewis@stripped @@ -42,34 +42,6 @@ btr_pcur_get_rel_pos( return(cursor->rel_pos); } -/*********************************************************//** -Sets the mtr field for a pcur. */ -UNIV_INLINE -void -btr_pcur_set_mtr( -/*=============*/ - btr_pcur_t* cursor, /*!< in: persistent cursor */ - mtr_t* mtr) /*!< in, own: mtr */ -{ - ut_ad(cursor); - - cursor->mtr = mtr; -} - -/*********************************************************//** -Gets the mtr field for a pcur. -@return mtr */ -UNIV_INLINE -mtr_t* -btr_pcur_get_mtr( -/*=============*/ - btr_pcur_t* cursor) /*!< in: persistent cursor */ -{ - ut_ad(cursor); - - return(cursor->mtr); -} - #ifdef UNIV_DEBUG /*********************************************************//** Returns the btr cursor component of a persistent cursor. @@ -95,7 +67,7 @@ btr_pcur_get_page_cur( { return(btr_cur_get_page_cur(btr_pcur_get_btr_cur(cursor))); } -#endif /* UNIV_DEBUG */ + /*********************************************************//** Returns the page of a persistent cursor. @return pointer to the page */ @@ -103,7 +75,7 @@ UNIV_INLINE page_t* btr_pcur_get_page( /*==============*/ - btr_pcur_t* cursor) /*!< in: persistent cursor */ + const btr_pcur_t* cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -117,7 +89,7 @@ UNIV_INLINE buf_block_t* btr_pcur_get_block( /*===============*/ - btr_pcur_t* cursor) /*!< in: persistent cursor */ + const btr_pcur_t* cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); @@ -131,13 +103,14 @@ UNIV_INLINE rec_t* btr_pcur_get_rec( /*=============*/ - btr_pcur_t* cursor) /*!< in: persistent cursor */ + const btr_pcur_t* cursor) /*!< in: persistent cursor */ { ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->latch_mode != BTR_NO_LATCHES); return(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor))); } +#endif /* UNIV_DEBUG */ /**************************************************************//** Gets the up_match value for a pcur after a search. @@ -147,9 +120,9 @@ UNIV_INLINE ulint btr_pcur_get_up_match( /*==================*/ - btr_pcur_t* cursor) /*!< in: memory buffer for persistent cursor */ + const btr_pcur_t* cursor) /*!< in: persistent cursor */ { - btr_cur_t* btr_cursor; + const btr_cur_t* btr_cursor; ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED) || (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); @@ -169,9 +142,9 @@ UNIV_INLINE ulint btr_pcur_get_low_match( /*===================*/ - btr_pcur_t* cursor) /*!< in: memory buffer for persistent cursor */ + const btr_pcur_t* cursor) /*!< in: persistent cursor */ { - btr_cur_t* btr_cursor; + const btr_cur_t* btr_cursor; ut_ad((cursor->pos_state == BTR_PCUR_WAS_POSITIONED) || (cursor->pos_state == BTR_PCUR_IS_POSITIONED)); === modified file 'storage/innobase/include/page0page.h' --- a/storage/innobase/include/page0page.h revid:kevin.lewis@stripped +++ b/storage/innobase/include/page0page.h revid:kevin.lewis@stripped @@ -952,7 +952,7 @@ UNIV_INTERN ibool page_rec_validate( /*==============*/ - rec_t* rec, /*!< in: physical record */ + const rec_t* rec, /*!< in: physical record */ const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ /***************************************************************//** Checks that the first directory slot points to the infimum record and @@ -972,7 +972,7 @@ UNIV_INTERN ibool page_simple_validate_old( /*=====================*/ - page_t* page); /*!< in: old-style index page */ + const page_t* page); /*!< in: index page in ROW_FORMAT=REDUNDANT */ /***************************************************************//** This function checks the consistency of an index page when we do not know the index. This is also resilient so that this should never crash @@ -982,7 +982,7 @@ UNIV_INTERN ibool page_simple_validate_new( /*=====================*/ - page_t* block); /*!< in: new-style index page */ + const page_t* page); /*!< in: index page in ROW_FORMAT!=REDUNDANT */ /***************************************************************//** This function checks the consistency of an index page. @return TRUE if ok */ @@ -990,7 +990,7 @@ UNIV_INTERN ibool page_validate( /*==========*/ - page_t* page, /*!< in: index page */ + const page_t* page, /*!< in: index page */ dict_index_t* index); /*!< in: data dictionary index containing the page record type definition */ /***************************************************************//** === modified file 'storage/innobase/include/rem0rec.h' --- a/storage/innobase/include/rem0rec.h revid:kevin.lewis@stripped +++ b/storage/innobase/include/rem0rec.h revid:kevin.lewis@stripped @@ -600,6 +600,7 @@ ulint rec_offs_size( /*==========*/ const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ +#ifdef UNIV_DEBUG /**********************************************************//** Returns a pointer to the start of the record. @return pointer to start */ @@ -607,7 +608,7 @@ UNIV_INLINE byte* rec_get_start( /*==========*/ - rec_t* rec, /*!< in: pointer to record */ + const rec_t* rec, /*!< in: pointer to record */ const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ /**********************************************************//** Returns a pointer to the end of the record. @@ -616,8 +617,12 @@ UNIV_INLINE byte* rec_get_end( /*========*/ - rec_t* rec, /*!< in: pointer to record */ + const rec_t* rec, /*!< in: pointer to record */ const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ +#else /* UNIV_DEBUG */ +# define rec_get_start(rec, offsets) ((rec) - rec_offs_extra_size(offsets)) +# define rec_get_end(rec, offsets) ((rec) + rec_offs_data_size(offsets)) +#endif /* UNIV_DEBUG */ /***************************************************************//** Copies a physical record to a buffer. @return pointer to the origin of the copy */ === modified file 'storage/innobase/include/rem0rec.ic' --- a/storage/innobase/include/rem0rec.ic revid:kevin.lewis@stripped +++ b/storage/innobase/include/rem0rec.ic revid:kevin.lewis@stripped @@ -1462,6 +1462,7 @@ rec_offs_size( return(rec_offs_data_size(offsets) + rec_offs_extra_size(offsets)); } +#ifdef UNIV_DEBUG /**********************************************************//** Returns a pointer to the end of the record. @return pointer to end */ @@ -1469,11 +1470,11 @@ UNIV_INLINE byte* rec_get_end( /*========*/ - rec_t* rec, /*!< in: pointer to record */ + const rec_t* rec, /*!< in: pointer to record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ { ut_ad(rec_offs_validate(rec, NULL, offsets)); - return(rec + rec_offs_data_size(offsets)); + return((rec_t*) rec + rec_offs_data_size(offsets)); } /**********************************************************//** @@ -1483,12 +1484,13 @@ UNIV_INLINE byte* rec_get_start( /*==========*/ - rec_t* rec, /*!< in: pointer to record */ + const rec_t* rec, /*!< in: pointer to record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ { ut_ad(rec_offs_validate(rec, NULL, offsets)); - return(rec - rec_offs_extra_size(offsets)); + return((rec_t*) rec - rec_offs_extra_size(offsets)); } +#endif /* UNIV_DEBUG */ /***************************************************************//** Copies a physical record to a buffer. === modified file 'storage/innobase/include/srv0srv.h' --- a/storage/innobase/include/srv0srv.h revid:kevin.lewis@stripped +++ b/storage/innobase/include/srv0srv.h revid:kevin.lewis@stripped @@ -575,27 +575,6 @@ srv_conc_exit_innodb( /*=================*/ trx_t* trx); /*!< in: transaction object associated with the thread */ -/***************************************************************//** -Puts a MySQL OS thread to wait for a lock to be released. If an error -occurs during the wait trx->error_state associated with thr is -!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK -are possible errors. DB_DEADLOCK is returned if selective deadlock -resolution chose this transaction as a victim. */ -UNIV_INTERN -void -srv_suspend_mysql_thread( -/*=====================*/ - que_thr_t* thr); /*!< in: query thread associated with the MySQL - OS thread */ -/********************************************************************//** -Releases a MySQL OS thread waiting for a lock to be released, if the -thread is already suspended. */ -UNIV_INTERN -void -srv_release_mysql_thread_if_suspended( -/*==================================*/ - que_thr_t* thr); /*!< in: query thread associated with the - MySQL OS thread */ /*********************************************************************//** A thread which prints the info output by various InnoDB monitors. @return a dummy parameter */ === modified file 'storage/innobase/include/thr0loc.h' --- a/storage/innobase/include/thr0loc.h revid:kevin.lewis@stripped +++ b/storage/innobase/include/thr0loc.h revid:kevin.lewis@stripped @@ -59,22 +59,6 @@ thr_local_free( /*===========*/ os_thread_id_t id); /*!< in: thread id */ /*******************************************************************//** -Gets the slot number in the thread table of a thread. -@return slot number */ -UNIV_INTERN -ulint -thr_local_get_slot_no( -/*==================*/ - os_thread_id_t id); /*!< in: thread id of the thread */ -/*******************************************************************//** -Sets in the local storage the slot number in the thread table of a thread. */ -UNIV_INTERN -void -thr_local_set_slot_no( -/*==================*/ - os_thread_id_t id, /*!< in: thread id of the thread */ - ulint slot_no);/*!< in: slot number */ -/*******************************************************************//** Returns pointer to the 'in_ibuf' field within the current thread local storage. @return pointer to the in_ibuf field */ === modified file 'storage/innobase/page/page0page.c' --- a/storage/innobase/page/page0page.c revid:kevin.lewis@stripped +++ b/storage/innobase/page/page0page.c revid:kevin.lewis@stripped @@ -166,11 +166,11 @@ static ibool page_dir_slot_check( /*================*/ - page_dir_slot_t* slot) /*!< in: slot */ + const page_dir_slot_t* slot) /*!< in: slot */ { - page_t* page; - ulint n_slots; - ulint n_owned; + const page_t* page; + ulint n_slots; + ulint n_owned; ut_a(slot); @@ -1803,12 +1803,12 @@ UNIV_INTERN ibool page_rec_validate( /*==============*/ - rec_t* rec, /*!< in: physical record */ + const rec_t* rec, /*!< in: physical record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ { - ulint n_owned; - ulint heap_no; - page_t* page; + ulint n_owned; + ulint heap_no; + const page_t* page; page = page_align(rec); ut_a(!page_is_comp(page) == !rec_offs_comp(offsets)); @@ -1889,16 +1889,16 @@ UNIV_INTERN ibool page_simple_validate_old( /*=====================*/ - page_t* page) /*!< in: old-style index page */ + const page_t* page) /*!< in: index page in ROW_FORMAT=REDUNDANT */ { - page_dir_slot_t* slot; - ulint slot_no; - ulint n_slots; - rec_t* rec; - byte* rec_heap_top; - ulint count; - ulint own_count; - ibool ret = FALSE; + const page_dir_slot_t* slot; + ulint slot_no; + ulint n_slots; + const rec_t* rec; + const byte* rec_heap_top; + ulint count; + ulint own_count; + ibool ret = FALSE; ut_a(!page_is_comp(page)); @@ -2011,7 +2011,7 @@ page_simple_validate_old( goto func_exit; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); own_count++; } @@ -2072,7 +2072,7 @@ page_simple_validate_old( goto func_exit; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); } if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) { @@ -2099,16 +2099,16 @@ UNIV_INTERN ibool page_simple_validate_new( /*=====================*/ - page_t* page) /*!< in: new-style index page */ + const page_t* page) /*!< in: index page in ROW_FORMAT!=REDUNDANT */ { - page_dir_slot_t* slot; - ulint slot_no; - ulint n_slots; - rec_t* rec; - byte* rec_heap_top; - ulint count; - ulint own_count; - ibool ret = FALSE; + const page_dir_slot_t* slot; + ulint slot_no; + ulint n_slots; + const rec_t* rec; + const byte* rec_heap_top; + ulint count; + ulint own_count; + ibool ret = FALSE; ut_a(page_is_comp(page)); @@ -2221,7 +2221,7 @@ page_simple_validate_new( goto func_exit; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); own_count++; } @@ -2283,7 +2283,7 @@ page_simple_validate_new( goto func_exit; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); } if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) { @@ -2308,26 +2308,26 @@ UNIV_INTERN ibool page_validate( /*==========*/ - page_t* page, /*!< in: index page */ + const page_t* page, /*!< in: index page */ dict_index_t* index) /*!< in: data dictionary index containing the page record type definition */ { - page_dir_slot_t*slot; - mem_heap_t* heap; - byte* buf; - ulint count; - ulint own_count; - ulint rec_own_count; - ulint slot_no; - ulint data_size; - rec_t* rec; - rec_t* old_rec = NULL; - ulint offs; - ulint n_slots; - ibool ret = FALSE; - ulint i; - ulint* offsets = NULL; - ulint* old_offsets = NULL; + const page_dir_slot_t* slot; + mem_heap_t* heap; + byte* buf; + ulint count; + ulint own_count; + ulint rec_own_count; + ulint slot_no; + ulint data_size; + const rec_t* rec; + const rec_t* old_rec = NULL; + ulint offs; + ulint n_slots; + ibool ret = FALSE; + ulint i; + ulint* offsets = NULL; + ulint* old_offsets = NULL; if (UNIV_UNLIKELY((ibool) !!page_is_comp(page) != dict_table_is_comp(index->table))) { @@ -2482,7 +2482,7 @@ page_validate( count++; own_count++; old_rec = rec; - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); /* set old_offsets to offsets; recycle offsets */ { @@ -2556,7 +2556,7 @@ n_owned_zero: buf[offs + i] = 1; } - rec = page_rec_get_next(rec); + rec = page_rec_get_next_const(rec); } if (UNIV_UNLIKELY(page_dir_get_n_heap(page) != count + 1)) { === modified file 'storage/innobase/srv/srv0srv.c' --- a/storage/innobase/srv/srv0srv.c revid:kevin.lewis@stripped +++ b/storage/innobase/srv/srv0srv.c revid:kevin.lewis@stripped @@ -693,6 +693,7 @@ srv_table_get_nth_slot( /*===================*/ ulint index) /*!< in: index of the slot */ { + ut_ad(srv_sys_mutex_own()); ut_a(index < OS_THREAD_MAX_N); return(srv_sys->sys_threads + index); @@ -721,28 +722,61 @@ srv_get_n_threads(void) return(n_threads); } +#ifdef UNIV_DEBUG /*********************************************************************//** -Reserves a slot in the thread table for the current thread. Also creates the -thread local storage struct for the current thread. NOTE! The server mutex -has to be reserved by the caller! -@return reserved slot index */ +Validates the type of a thread table slot. +@return TRUE if ok */ static -ulint +ibool +srv_thread_type_validate( +/*=====================*/ + enum srv_thread_type type) /*!< in: thread type */ +{ + switch (type) { + case SRV_NONE: + break; + case SRV_WORKER: + case SRV_PURGE: + case SRV_MASTER: + return(TRUE); + } + ut_error; + return(FALSE); +} +#endif /* UNIV_DEBUG */ + +/*********************************************************************//** +Gets the type of a thread table slot. +@return thread type */ +static +enum srv_thread_type +srv_slot_get_type( +/*==============*/ + const srv_slot_t* slot) /*!< in: thread slot */ +{ + enum srv_thread_type type = (enum srv_thread_type) slot->type; + ut_ad(srv_thread_type_validate(type)); + return(type); +} + +/*********************************************************************//** +Reserves a slot in the thread table for the current thread. +NOTE! The server mutex has to be reserved by the caller! +@return reserved slot */ +static +srv_slot_t* srv_table_reserve_slot( /*===================*/ enum srv_thread_type type) /*!< in: type of the thread */ { - ulint i; srv_slot_t* slot; ut_ad(srv_sys_mutex_own()); - ut_a(type > 0); - ut_a(type <= SRV_MASTER); + ut_ad(srv_thread_type_validate(type)); if (type != SRV_MASTER) { - - i = 1; + ulint i = 1; /* Find an empty slot. */ for (slot = srv_table_get_nth_slot(i); @@ -753,60 +787,45 @@ srv_table_reserve_slot( } } else { - ut_a(type != SRV_NONE); - i = 0; slot = srv_table_get_nth_slot(0); } - ut_a(slot->in_use == FALSE); - slot->in_use = TRUE; slot->suspended = FALSE; slot->type = type; + ut_ad(srv_slot_get_type(slot) == type); slot->id = os_thread_get_curr_id(); slot->handle = os_thread_get_curr(); - thr_local_create(); - - thr_local_set_slot_no(os_thread_get_curr_id(), i); - - return(i); + return(slot); } /*********************************************************************//** -Suspends the calling thread to wait for the event in its thread slot. -@return event for the calling thread to wait */ +Suspends the calling thread to wait for the event in its thread slot. */ static -os_event_t -srv_suspend_thread(void) -/*====================*/ +void +srv_suspend_thread( +/*===============*/ + srv_slot_t* slot) /*!< in/out: thread slot */ { - srv_slot_t* slot; - os_event_t event; - ulint slot_no; enum srv_thread_type type; srv_sys_mutex_enter(); - - slot_no = thr_local_get_slot_no(os_thread_get_curr_id()); + ut_ad(slot->in_use); + ut_ad(!slot->suspended); + ut_ad(slot->id == os_thread_get_curr_id()); if (srv_print_thread_releases) { fprintf(stderr, "Suspending thread %lu to slot %lu\n", - (ulong) os_thread_get_curr_id(), (ulong) slot_no); + (ulong) os_thread_get_curr_id(), + (ulong) (slot - srv_sys->sys_threads)); } - slot = srv_table_get_nth_slot(slot_no); - - type = slot->type; - - ut_ad(type >= SRV_WORKER); - ut_ad(type <= SRV_MASTER); - - /* The master thread always uses slot number 0. */ - ut_a(type != SRV_MASTER || slot_no == 0); + type = srv_slot_get_type(slot); - event = slot->event; + /* The master thread always uses the first slot. */ + ut_a(type != SRV_MASTER || slot == srv_sys->sys_threads); slot->suspended = TRUE; @@ -814,11 +833,9 @@ srv_suspend_thread(void) srv_sys->n_threads_active[type]--; - os_event_reset(event); + os_event_reset(slot->event); srv_sys_mutex_exit(); - - return(event); } /*********************************************************************//** @@ -836,8 +853,7 @@ srv_release_threads( ulint i; ulint count = 0; - ut_ad(type >= SRV_WORKER); - ut_ad(type <= SRV_MASTER); + ut_ad(srv_thread_type_validate(type)); ut_ad(n > 0); srv_sys_mutex_enter(); @@ -847,7 +863,8 @@ srv_release_threads( slot = srv_table_get_nth_slot(i); - if (slot->in_use && slot->type == type && slot->suspended) { + if (slot->in_use && slot->suspended + && srv_slot_get_type(slot) == type) { slot->suspended = FALSE; @@ -894,6 +911,7 @@ srv_thread_has_reserved_slot( ulint i; ulint slot_no = ULINT_UNDEFINED; + ut_ad(srv_thread_type_validate(type)); srv_sys_mutex_enter(); for (i = 0; i < OS_THREAD_MAX_N; i++) { @@ -901,7 +919,7 @@ srv_thread_has_reserved_slot( slot = srv_table_get_nth_slot(i); - if (slot->in_use && slot->type == type) { + if (slot->in_use && srv_slot_get_type(slot) == type) { slot_no = i; break; } @@ -943,7 +961,7 @@ srv_init(void) for (i = 0; i < OS_THREAD_MAX_N; i++) { srv_slot_t* slot; - slot = srv_table_get_nth_slot(i); + slot = srv_sys->sys_threads + i; slot->event = os_event_create(NULL); @@ -2032,7 +2050,7 @@ srv_active_wake_master_thread(void) /* Only if the master thread has been started. */ if (slot->in_use) { - ut_a(slot->type == SRV_MASTER); + ut_a(srv_slot_get_type(slot) == SRV_MASTER); if (slot->suspended) { @@ -2552,9 +2570,8 @@ srv_master_thread( /*!< in: a dummy parameter required by os_thread_create */ { - ulint slot; + srv_slot_t* slot; ulint old_activity_count = srv_get_activity_count(); - os_event_t event; ib_time_t last_print_time; #ifdef UNIV_DEBUG_THREAD_CREATION @@ -2572,7 +2589,7 @@ srv_master_thread( srv_sys_mutex_enter(); slot = srv_table_reserve_slot(SRV_MASTER); - ut_a(slot == 0); + ut_a(slot == srv_sys->sys_threads); srv_sys->n_threads_active[SRV_MASTER]++; @@ -2607,7 +2624,7 @@ loop: suspend_thread: srv_main_thread_op_info = "suspending"; - event = srv_suspend_thread(); + srv_suspend_thread(slot); /* DO NOT CHANGE THIS STRING. innobase_start_or_create_for_mysql() waits for database activity to die down when converting < 4.1.x @@ -2615,7 +2632,7 @@ suspend_thread: manual also mentions this string in several places. */ srv_main_thread_op_info = "waiting for server activity"; - os_event_wait(event); + os_event_wait(slot->event); if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { /* This is only extra safety, the thread should exit @@ -2626,8 +2643,6 @@ suspend_thread: } goto loop; - - OS_THREAD_DUMMY_RETURN; /* Not reached, avoid compiler warning */ } /*********************************************************************//** @@ -2681,7 +2696,6 @@ srv_worker_thread( required by os_thread_create */ { srv_slot_t* slot; - ulint slot_no = ULINT_UNDEFINED; #ifdef UNIV_DEBUG_THREAD_CREATION fprintf(stderr, "Worker thread starts, id %lu\n", @@ -2690,7 +2704,7 @@ srv_worker_thread( srv_sys_mutex_enter(); - slot_no = srv_table_reserve_slot(SRV_WORKER); + slot = srv_table_reserve_slot(SRV_WORKER); ++srv_sys->n_threads_active[SRV_WORKER]; @@ -2701,11 +2715,9 @@ srv_worker_thread( while (srv_shutdown_state == SRV_SHUTDOWN_NONE && !srv_fast_shutdown) { - os_event_t event; - - event = srv_suspend_thread(); + srv_suspend_thread(slot); - os_event_wait(event); + os_event_wait(slot->event); srv_task_execute(); @@ -2715,15 +2727,12 @@ srv_worker_thread( srv_wake_purge_thread_if_not_active(); } - srv_suspend_thread(); - - /* Free the thread local memory. */ - thr_local_free(os_thread_get_curr_id()); + srv_suspend_thread(slot); srv_sys_mutex_enter(); /* Free the slot for reuse. */ - slot = srv_table_get_nth_slot(slot_no); + ut_ad(slot->in_use); slot->in_use = FALSE; srv_sys_mutex_exit(); @@ -2751,7 +2760,6 @@ srv_purge_coordinator_thread( required by os_thread_create */ { srv_slot_t* slot; - ulint slot_no = ULINT_UNDEFINED; ut_a(srv_n_purge_threads >= 1); @@ -2769,7 +2777,7 @@ srv_purge_coordinator_thread( srv_sys_mutex_enter(); - slot_no = srv_table_reserve_slot(SRV_PURGE); + slot = srv_table_reserve_slot(SRV_PURGE); ++srv_sys->n_threads_active[SRV_PURGE]; @@ -2900,19 +2908,16 @@ srv_purge_coordinator_thread( } /* Decrement the active count. */ - srv_suspend_thread(); + srv_suspend_thread(slot); srv_sys_mutex_enter(); /* Free the slot for reuse. */ - slot = srv_table_get_nth_slot(slot_no); + ut_ad(slot->in_use); slot->in_use = FALSE; srv_sys_mutex_exit(); - /* Free the thread local memory. */ - thr_local_free(os_thread_get_curr_id()); - #ifdef UNIV_DEBUG_THREAD_CREATION fprintf(stderr, "Purge coordinator exiting, id %lu\n", os_thread_pf(os_thread_get_curr_id())); === modified file 'storage/innobase/thr/thr0loc.c' --- a/storage/innobase/thr/thr0loc.c revid:kevin.lewis@stripped +++ b/storage/innobase/thr/thr0loc.c revid:kevin.lewis@stripped @@ -65,8 +65,6 @@ for the field. */ struct thr_local_struct{ os_thread_id_t id; /*!< id of the thread which owns this struct */ os_thread_t handle; /*!< operating system handle to the thread */ - ulint slot_no;/*!< the index of the slot in the thread table - for this thread */ ibool in_ibuf;/*!< TRUE if the thread is doing an ibuf operation */ hash_node_t hash; /*!< hash chain node */ @@ -87,8 +85,6 @@ thr_local_validate( const thr_local_t* local) /*!< in: data to validate */ { ut_ad(local->magic_n == THR_LOCAL_MAGIC_N); - ut_ad(local->slot_no == ULINT_UNDEFINED - || local->slot_no < OS_THREAD_MAX_N); ut_ad(local->in_ibuf == FALSE || local->in_ibuf == TRUE); return(TRUE); } @@ -132,49 +128,6 @@ try_again: } /*******************************************************************//** -Gets the slot number in the thread table of a thread. -@return slot number */ -UNIV_INTERN -ulint -thr_local_get_slot_no( -/*==================*/ - os_thread_id_t id) /*!< in: thread id of the thread */ -{ - ulint slot_no; - thr_local_t* local; - - mutex_enter(&thr_local_mutex); - - local = thr_local_get(id); - - slot_no = local->slot_no; - - mutex_exit(&thr_local_mutex); - - return(slot_no); -} - -/*******************************************************************//** -Sets the slot number in the thread table of a thread. */ -UNIV_INTERN -void -thr_local_set_slot_no( -/*==================*/ - os_thread_id_t id, /*!< in: thread id of the thread */ - ulint slot_no)/*!< in: slot number */ -{ - thr_local_t* local; - - mutex_enter(&thr_local_mutex); - - local = thr_local_get(id); - - local->slot_no = slot_no; - - mutex_exit(&thr_local_mutex); -} - -/*******************************************************************//** Returns pointer to the 'in_ibuf' field within the current thread local storage. @return pointer to the in_ibuf field */ @@ -212,7 +165,6 @@ thr_local_create(void) local->id = os_thread_get_curr_id(); local->handle = os_thread_get_curr(); local->magic_n = THR_LOCAL_MAGIC_N; - local->slot_no = ULINT_UNDEFINED; local->in_ibuf = FALSE; mutex_enter(&thr_local_mutex); No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).