/******************************************************************** Creates the memory copies for the rollback segments and initializes the rseg list and array in trx_sys at a database startup. */ static void trx_rseg_create_instance( /*=====================*/ trx_sysf_t* sys_header, /*!< in: trx system header */ mtr_t* mtr) /*!< in: mtr */ { ulint i; for (i = 0; i < TRX_SYS_N_RSEGS; i++) { ulint page_no; page_no = trx_sysf_rseg_get_page_no(sys_header, i, mtr); if (page_no == FIL_NULL) { trx_sys_set_nth_rseg(trx_sys, i, NULL); } else { ulint space; ulint zip_size; trx_rseg_t* rseg = NULL; ut_a(!trx_rseg_get_on_id(i)); space = trx_sysf_rseg_get_space(sys_header, i, mtr); zip_size = space ? fil_space_get_zip_size(space) : 0; rseg = trx_rseg_mem_create( i, space, zip_size, page_no, mtr); ut_a(rseg->id == i); } } }
void trx_rseg_list_and_array_init( /*=========================*/ trx_sysf_t* sys_header, /* in: trx system header */ mtr_t* mtr) /* in: mtr */ { ulint i; ulint page_no; ulint space; UT_LIST_INIT(trx_sys->rseg_list); trx_sys->rseg_history_len = 0; for (i = 0; i < TRX_SYS_N_RSEGS; i++) { page_no = trx_sysf_rseg_get_page_no(sys_header, i, mtr); if (page_no == FIL_NULL) { trx_sys_set_nth_rseg(trx_sys, i, NULL); } else { space = trx_sysf_rseg_get_space(sys_header, i, mtr); trx_rseg_mem_create(i, space, page_no, mtr); } } }
trx_rseg_t* trx_rseg_create( /*============*/ /* out: the created segment object, NULL if fail */ ulint space, /* in: space id */ ulint max_size, /* in: max size in pages */ ulint* id, /* out: rseg id */ mtr_t* mtr) /* in: mtr */ { ulint page_no; trx_rseg_t* rseg; mtr_x_lock(fil_space_get_latch(space), mtr); mutex_enter(&kernel_mutex); page_no = trx_rseg_header_create(space, max_size, id, mtr); if (page_no == FIL_NULL) { mutex_exit(&kernel_mutex); return(NULL); } rseg = trx_rseg_mem_create(*id, space, page_no, mtr); mutex_exit(&kernel_mutex); return(rseg); }
/****************************************************************//** Creates a new rollback segment to the database. @return the created segment object, NULL if fail */ UNIV_INTERN trx_rseg_t* trx_rseg_create( /*============*/ ulint space, /*!< in: space id */ ulint max_size, /*!< in: max size in pages */ ulint* id, /*!< out: rseg id */ mtr_t* mtr) /*!< in: mtr */ { ulint flags; ulint zip_size; ulint page_no; trx_rseg_t* rseg; mtr_x_lock(fil_space_get_latch(space, &flags), mtr); zip_size = dict_table_flags_to_zip_size(flags); mutex_enter(&kernel_mutex); page_no = trx_rseg_header_create(space, zip_size, max_size, id, mtr); if (page_no == FIL_NULL) { mutex_exit(&kernel_mutex); return(NULL); } rseg = trx_rseg_mem_create(*id, space, zip_size, page_no, mtr); mutex_exit(&kernel_mutex); return(rseg); }
/********************************************************************* Creates a rollback segment. @return pointer to new rollback segment if create successful */ UNIV_INTERN trx_rseg_t* trx_rseg_create(void) /*=================*/ { mtr_t mtr; ulint slot_no; trx_rseg_t* rseg = NULL; mtr_start(&mtr); /* To obey the latching order, acquire the file space x-latch before the kernel mutex. */ mtr_x_lock(fil_space_get_latch(TRX_SYS_SPACE, NULL), &mtr); mutex_enter(&kernel_mutex); slot_no = trx_sysf_rseg_find_free(&mtr); if (slot_no != ULINT_UNDEFINED) { ulint space; ulint page_no; ulint zip_size; trx_sysf_t* sys_header; page_no = trx_rseg_header_create( TRX_SYS_SPACE, 0, ULINT_MAX, slot_no, &mtr); ut_a(page_no != FIL_NULL); ut_ad(!trx_rseg_get_on_id(slot_no)); sys_header = trx_sysf_get(&mtr); space = trx_sysf_rseg_get_space(sys_header, slot_no, &mtr); zip_size = space ? fil_space_get_zip_size(space) : 0; rseg = trx_rseg_mem_create( slot_no, space, zip_size, page_no, &mtr); } mutex_exit(&kernel_mutex); mtr_commit(&mtr); return(rseg); }