mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 06:44:16 +01:00
4f1d044053
------------------------------------------------------------------------ r4152 | marko | 2009-02-10 12:52:27 +0200 (Tue, 10 Feb 2009) | 12 lines branches/zip: When innodb_use_sys_malloc is set, ignore innodb_additional_mem_pool_size, because nothing will be allocated from mem_comm_pool. mem_pool_create(): Remove the assertion about size. The function will work with any size. However, an assertion would fail in ut_malloc_low() when size==0. mem_init(): When srv_use_sys_malloc is set, pass size=1 to mem_pool_create(). mem0mem.c: Add #include "srv0srv.h" that is needed by mem0dbg.c. ------------------------------------------------------------------------ r4153 | vasil | 2009-02-10 22:58:17 +0200 (Tue, 10 Feb 2009) | 14 lines branches/zip: (followup to r4145) Non-functional change: Change the os_atomic_increment() and os_compare_and_swap() functions to macros to avoid artificial limitations on the types of those functions' arguments. As a consequence typecasts from the source code can be removed. Also remove Google's copyright from os0sync.ic because that file no longer contains code from Google. Approved by: Marko (rb://88), also ok from Inaam via IM ------------------------------------------------------------------------ r4163 | marko | 2009-02-12 00:14:19 +0200 (Thu, 12 Feb 2009) | 4 lines branches/zip: Make innodb_thread_concurrency=0 the default. The old default was 8. ------------------------------------------------------------------------ r4169 | calvin | 2009-02-12 10:37:10 +0200 (Thu, 12 Feb 2009) | 3 lines branches/zip: Adjust the result file of innodb_thread_concurrency_basic test. The default value of innodb_thread_concurrency is changed to 0 (from 8) via r4163. ------------------------------------------------------------------------ r4174 | vasil | 2009-02-12 17:38:27 +0200 (Thu, 12 Feb 2009) | 4 lines branches/zip: Fix pathname of the file to patch. ------------------------------------------------------------------------ r4176 | vasil | 2009-02-13 10:06:31 +0200 (Fri, 13 Feb 2009) | 7 lines branches/zip: Fix the failing mysql-test partition_innodb, which failed only if run after innodb_trx_weight (or other test that would leave LATEST DEADLOCK ERROR into the output of SHOW ENGINE INNODB STATUS). Find further explanation for the failure at the top of the added patch partition_innodb.diff. ------------------------------------------------------------------------ r4198 | vasil | 2009-02-17 09:06:07 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: Add the full text of the GPLv2 license into the root directory of the plugin. In previous releases this file was copied from an external source (https://svn.innodb.com/svn/plugin/trunk/support/COPYING) "manually" when creating the source and binary archives. It is less confusing to have this present in the root directory of the SVN branch. ------------------------------------------------------------------------ r4199 | vasil | 2009-02-17 09:11:58 +0200 (Tue, 17 Feb 2009) | 4 lines branches/zip: Add Google's license into COPYING.Google. ------------------------------------------------------------------------ r4200 | vasil | 2009-02-17 09:56:33 +0200 (Tue, 17 Feb 2009) | 11 lines branches/zip: To the files touched by the Google patch from c4144 (excluding include/os0sync.ic because later we removed Google code from that file): * Remove the Google license * Remove old Innobase copyright lines * Add a reference to the Google license and to the GPLv2 license at the top, as recommended by the lawyers at Oracle Legal. ------------------------------------------------------------------------ r4201 | vasil | 2009-02-17 10:12:02 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 1/28] ------------------------------------------------------------------------ r4202 | vasil | 2009-02-17 10:15:06 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 2/28] ------------------------------------------------------------------------ r4203 | vasil | 2009-02-17 10:25:45 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 3/28] ------------------------------------------------------------------------ r4204 | vasil | 2009-02-17 10:55:41 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 4/28] ------------------------------------------------------------------------ r4205 | vasil | 2009-02-17 10:59:22 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 5/28] ------------------------------------------------------------------------ r4206 | vasil | 2009-02-17 11:02:27 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 6/28] ------------------------------------------------------------------------ r4207 | vasil | 2009-02-17 11:04:28 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 7/28] ------------------------------------------------------------------------ r4208 | vasil | 2009-02-17 11:06:49 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 8/28] ------------------------------------------------------------------------ r4209 | vasil | 2009-02-17 11:10:18 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 9/28] ------------------------------------------------------------------------ r4210 | vasil | 2009-02-17 11:12:41 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 10/28] ------------------------------------------------------------------------ r4211 | vasil | 2009-02-17 11:14:40 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 11/28] ------------------------------------------------------------------------ r4212 | vasil | 2009-02-17 11:18:35 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 12/28] ------------------------------------------------------------------------ r4213 | vasil | 2009-02-17 11:24:40 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 13/28] ------------------------------------------------------------------------ r4214 | vasil | 2009-02-17 11:27:31 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 13/28] ------------------------------------------------------------------------ r4215 | vasil | 2009-02-17 11:29:55 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 15/28] ------------------------------------------------------------------------ r4216 | vasil | 2009-02-17 11:33:38 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 16/28] ------------------------------------------------------------------------ r4217 | vasil | 2009-02-17 11:36:44 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 17/28] ------------------------------------------------------------------------ r4218 | vasil | 2009-02-17 11:39:11 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 18/28] ------------------------------------------------------------------------ r4219 | vasil | 2009-02-17 11:41:24 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 19/28] ------------------------------------------------------------------------ r4220 | vasil | 2009-02-17 11:43:50 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 20/28] ------------------------------------------------------------------------ r4221 | vasil | 2009-02-17 11:46:52 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 21/28] ------------------------------------------------------------------------ r4222 | vasil | 2009-02-17 11:50:12 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 22/28] ------------------------------------------------------------------------ r4223 | vasil | 2009-02-17 11:53:58 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 23/28] ------------------------------------------------------------------------ r4224 | vasil | 2009-02-17 12:01:41 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 24/28] ------------------------------------------------------------------------ r4225 | vasil | 2009-02-17 12:05:45 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 25/28] ------------------------------------------------------------------------ r4226 | vasil | 2009-02-17 12:09:16 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 26/28] ------------------------------------------------------------------------ r4227 | vasil | 2009-02-17 12:12:56 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 27/28] ------------------------------------------------------------------------ r4228 | vasil | 2009-02-17 12:14:04 +0200 (Tue, 17 Feb 2009) | 8 lines branches/zip: * Remove old Innobase copyright lines from C source files * Add a reference to the GPLv2 license as recommended by the lawyers at Oracle Legal [Step 28/28] ------------------------------------------------------------------------ r4229 | vasil | 2009-02-17 12:30:55 +0200 (Tue, 17 Feb 2009) | 4 lines branches/zip: Add the copyright notice to the non C files. ------------------------------------------------------------------------ r4231 | marko | 2009-02-17 14:26:53 +0200 (Tue, 17 Feb 2009) | 12 lines Minor cleanup of the Google SMP patch. sync_array_object_signalled(): Add a (void) cast to eliminate a gcc warning about the return value of os_atomic_increment() being ignored. rw_lock_create_func(): Properly indent the preprocessor directives. rw_lock_x_lock_low(), rw_lock_x_lock_func_nowait(): Split lines correctly. rw_lock_set_writer_id_and_recursion_flag(): Silence a Valgrind warning. Do not mix statements and variable declarations. ------------------------------------------------------------------------ r4232 | marko | 2009-02-17 14:59:54 +0200 (Tue, 17 Feb 2009) | 3 lines branches/zip: When assigning lock->recursive = FALSE, also flag lock->writer_thread invalid, so that Valgrind will catch more errors. This is related to Issue #175. ------------------------------------------------------------------------ r4242 | marko | 2009-02-18 17:01:09 +0200 (Wed, 18 Feb 2009) | 2 lines branches/zip: UT_DBG_STOP: Use do{} while(0) to silence a g++-4.3.2 warning about a while(0); statement. This should fix (part of) Issue #176. ------------------------------------------------------------------------ r4243 | marko | 2009-02-18 17:04:03 +0200 (Wed, 18 Feb 2009) | 3 lines branches/zip: buf_buddy_get_slot(): Fix a gcc 4.3.2 warning about an empty body of a "for" statement. This fixes part of Issue #176. ------------------------------------------------------------------------ r4244 | marko | 2009-02-18 17:25:45 +0200 (Wed, 18 Feb 2009) | 11 lines branches/zip: Protect ut_total_allocated_memory with ut_list_mutex. Unprotected updates to ut_total_allocated_memory in os_mem_alloc_large() and os_mem_free_large(), called during fast index creation, may corrupt the variable and cause assertion failures. Also, add UNIV_MEM_ALLOC() and UNIV_MEM_FREE() instrumentation around os_mem_alloc_large() and os_mem_free_large(), so that Valgrind can detect more errors. rb://90 approved by Heikki Tuuri. This addresses Issue #177. ------------------------------------------------------------------------ r4248 | marko | 2009-02-19 11:52:39 +0200 (Thu, 19 Feb 2009) | 2 lines branches/zip: page_zip_set_size(): Fix a g++ 4.3.2 warning about an empty body in a "for" statement. This closes Issue #176. ------------------------------------------------------------------------ r4251 | inaam | 2009-02-19 15:46:27 +0200 (Thu, 19 Feb 2009) | 8 lines branches/zip: Issue #178 rb://91 Change plug.in to have same CXXFLAGS as CFLAGS. This is to ensure that both .c and .cc files get compiled with same flags. To fix the issue where UNIV_LINUX was defined only in .c files. Approved by: Marko ------------------------------------------------------------------------ r4258 | vasil | 2009-02-20 11:52:19 +0200 (Fri, 20 Feb 2009) | 7 lines branches/zip: Cleanup in ChangeLog: * Wrap lines at 78 characters * Changed files are listed alphabetically * White-space cleanup ------------------------------------------------------------------------ r4259 | vasil | 2009-02-20 11:59:42 +0200 (Fri, 20 Feb 2009) | 6 lines branches/zip: ChangeLog: Remove include/os0sync.ic from the entry about the google patch, this file was modified later to not include Google's code. ------------------------------------------------------------------------ r4262 | vasil | 2009-02-20 14:56:59 +0200 (Fri, 20 Feb 2009) | 373 lines branches/zip: Merge revisions 4035:4261 from branches/5.1: ------------------------------------------------------------------------ r4065 | sunny | 2009-01-29 16:01:36 +0200 (Thu, 29 Jan 2009) | 8 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: In the last round of AUTOINC cleanup we assumed that AUTOINC is only defined for integer columns. This caused an assertion failure when we checked for the maximum value of a column type. We now calculate the max value for floating-point autoinc columns too. Fix Bug#42400 - InnoDB autoinc code can't handle floating-point columns rb://84 and Mantis issue://162 ------------------------------------------------------------------------ r4111 | sunny | 2009-02-03 22:06:52 +0200 (Tue, 03 Feb 2009) | 2 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc branches/5.1: Add the ULL suffix otherwise there is an overflow. ------------------------------------------------------------------------ r4128 | vasil | 2009-02-08 21:36:45 +0200 (Sun, 08 Feb 2009) | 18 lines Changed paths: M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Merge a change from MySQL: ------------------------------------------------------------ revno: 2709.20.31 committer: Timothy Smith <timothy.smith@sun.com> branch nick: 51 timestamp: Fri 2008-12-19 01:28:51 +0100 message: Disable part of innodb-autoinc.test, because the MySQL server asserts when compiled --with-debug, due to bug 39828, "autoinc wraps around when offset and increment > 1". This change should be reverted when that bug is fixed (and a a few other minor changes to the test as described in comments). modified: mysql-test/r/innodb-autoinc.result mysql-test/t/innodb-autoinc.test ------------------------------------------------------------------------ r4129 | vasil | 2009-02-08 21:54:25 +0200 (Sun, 08 Feb 2009) | 310 lines Changed paths: M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Merge a change from MySQL: [looks like the changes to innodb-autoinc.test were made as part of the following huge merge, but we are merging only changes to that file] ------------------------------------------------------------ revno: 2546.47.1 committer: Luis Soares <luis.soares@sun.com> branch nick: 5.1-rpl timestamp: Fri 2009-01-23 13:22:05 +0100 message: merge: 5.1 -> 5.1-rpl conflicts: Text conflict in client/mysqltest.cc Text conflict in mysql-test/include/wait_until_connected_again.inc Text conflict in mysql-test/lib/mtr_report.pm Text conflict in mysql-test/mysql-test-run.pl Text conflict in mysql-test/r/events_bugs.result Text conflict in mysql-test/r/log_state.result Text conflict in mysql-test/r/myisam_data_pointer_size_func.result Text conflict in mysql-test/r/mysqlcheck.result Text conflict in mysql-test/r/query_cache.result Text conflict in mysql-test/r/status.result Text conflict in mysql-test/suite/binlog/r/binlog_index.result Text conflict in mysql-test/suite/binlog/r/binlog_innodb.result Text conflict in mysql-test/suite/rpl/r/rpl_packet.result Text conflict in mysql-test/suite/rpl/t/rpl_packet.test Text conflict in mysql-test/t/disabled.def Text conflict in mysql-test/t/events_bugs.test Text conflict in mysql-test/t/log_state.test Text conflict in mysql-test/t/myisam_data_pointer_size_func.test Text conflict in mysql-test/t/mysqlcheck.test Text conflict in mysql-test/t/query_cache.test Text conflict in mysql-test/t/rpl_init_slave_func.test Text conflict in mysql-test/t/status.test removed: mysql-test/suite/parts/r/partition_bit_ndb.result mysql-test/suite/parts/t/partition_bit_ndb.test mysql-test/suite/parts/t/partition_sessions.test mysql-test/suite/sys_vars/inc/tmp_table_size_basic.inc mysql-test/suite/sys_vars/r/tmp_table_size_basic_32.result mysql-test/suite/sys_vars/r/tmp_table_size_basic_64.result mysql-test/suite/sys_vars/t/tmp_table_size_basic_32.test mysql-test/suite/sys_vars/t/tmp_table_size_basic_64.test mysql-test/t/log_bin_trust_function_creators_func-master.opt mysql-test/t/rpl_init_slave_func-slave.opt added: mysql-test/include/check_events_off.inc mysql-test/include/cleanup_fake_relay_log.inc mysql-test/include/have_simple_parser.inc mysql-test/include/no_running_event_scheduler.inc mysql-test/include/no_running_events.inc mysql-test/include/running_event_scheduler.inc mysql-test/include/setup_fake_relay_log.inc mysql-test/include/wait_condition_sp.inc mysql-test/r/fulltext_plugin.result mysql-test/r/have_simple_parser.require mysql-test/r/innodb_bug38231.result mysql-test/r/innodb_bug39438.result mysql-test/r/innodb_mysql_rbk.result mysql-test/r/partition_innodb_semi_consistent.result mysql-test/r/query_cache_28249.result mysql-test/r/status2.result mysql-test/std_data/bug40482-bin.000001 mysql-test/suite/binlog/r/binlog_innodb_row.result mysql-test/suite/binlog/t/binlog_innodb_row.test mysql-test/suite/rpl/r/rpl_binlog_corruption.result mysql-test/suite/rpl/t/rpl_binlog_corruption-master.opt mysql-test/suite/rpl/t/rpl_binlog_corruption.test mysql-test/suite/sys_vars/r/tmp_table_size_basic.result mysql-test/suite/sys_vars/t/tmp_table_size_basic.test mysql-test/t/fulltext_plugin-master.opt mysql-test/t/fulltext_plugin.test mysql-test/t/innodb_bug38231.test mysql-test/t/innodb_bug39438-master.opt mysql-test/t/innodb_bug39438.test mysql-test/t/innodb_mysql_rbk-master.opt mysql-test/t/innodb_mysql_rbk.test mysql-test/t/partition_innodb_semi_consistent-master.opt mysql-test/t/partition_innodb_semi_consistent.test mysql-test/t/query_cache_28249.test mysql-test/t/status2.test renamed: mysql-test/suite/funcs_1/r/is_collation_character_set_applicability.result => mysql-test/suite/funcs_1/r/is_coll_char_set_appl.result mysql-test/suite/funcs_1/t/is_collation_character_set_applicability.test => mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test modified: .bzr-mysql/default.conf CMakeLists.txt client/mysql.cc client/mysql_upgrade.c client/mysqlcheck.c client/mysqltest.cc configure.in extra/resolve_stack_dump.c extra/yassl/include/openssl/ssl.h include/config-win.h include/m_ctype.h include/my_global.h mysql-test/extra/binlog_tests/database.test mysql-test/extra/rpl_tests/rpl_auto_increment.test mysql-test/include/commit.inc mysql-test/include/have_32bit.inc mysql-test/include/have_64bit.inc mysql-test/include/index_merge1.inc mysql-test/include/linux_sys_vars.inc mysql-test/include/windows_sys_vars.inc mysql-test/lib/mtr_report.pm mysql-test/mysql-test-run.pl mysql-test/r/alter_table.result mysql-test/r/commit_1innodb.result mysql-test/r/create.result mysql-test/r/csv.result mysql-test/r/ctype_ucs.result mysql-test/r/date_formats.result mysql-test/r/events_bugs.result mysql-test/r/events_scheduling.result mysql-test/r/fulltext.result mysql-test/r/func_if.result mysql-test/r/func_in.result mysql-test/r/func_str.result mysql-test/r/func_time.result mysql-test/r/grant.result mysql-test/r/index_merge_myisam.result mysql-test/r/information_schema.result mysql-test/r/innodb-autoinc.result mysql-test/r/innodb.result mysql-test/r/innodb_mysql.result mysql-test/r/log_bin_trust_function_creators_func.result mysql-test/r/log_state.result mysql-test/r/myisampack.result mysql-test/r/mysql.result mysql-test/r/mysqlcheck.result mysql-test/r/partition_datatype.result mysql-test/r/partition_mgm.result mysql-test/r/partition_pruning.result mysql-test/r/query_cache.result mysql-test/r/read_buffer_size_basic.result mysql-test/r/read_rnd_buffer_size_basic.result mysql-test/r/rpl_init_slave_func.result mysql-test/r/select.result mysql-test/r/status.result mysql-test/r/strict.result mysql-test/r/temp_table.result mysql-test/r/type_bit.result mysql-test/r/type_date.result mysql-test/r/type_float.result mysql-test/r/warnings_engine_disabled.result mysql-test/r/xml.result mysql-test/suite/binlog/r/binlog_database.result mysql-test/suite/binlog/r/binlog_index.result mysql-test/suite/binlog/r/binlog_innodb.result mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result mysql-test/suite/binlog/t/binlog_innodb.test mysql-test/suite/funcs_1/r/is_columns_is.result mysql-test/suite/funcs_1/r/is_engines.result mysql-test/suite/funcs_1/r/storedproc.result mysql-test/suite/funcs_1/storedproc/param_check.inc mysql-test/suite/funcs_2/t/disabled.def mysql-test/suite/ndb/t/disabled.def mysql-test/suite/parts/r/partition_bit_innodb.result mysql-test/suite/parts/r/partition_bit_myisam.result mysql-test/suite/parts/r/partition_special_innodb.result mysql-test/suite/parts/t/disabled.def mysql-test/suite/parts/t/partition_special_innodb.test mysql-test/suite/parts/t/partition_value_innodb.test mysql-test/suite/parts/t/partition_value_myisam.test mysql-test/suite/parts/t/partition_value_ndb.test mysql-test/suite/rpl/r/rpl_auto_increment.result mysql-test/suite/rpl/r/rpl_packet.result mysql-test/suite/rpl/r/rpl_row_create_table.result mysql-test/suite/rpl/r/rpl_slave_skip.result mysql-test/suite/rpl/r/rpl_trigger.result mysql-test/suite/rpl/t/disabled.def mysql-test/suite/rpl/t/rpl_packet.test mysql-test/suite/rpl/t/rpl_row_create_table.test mysql-test/suite/rpl/t/rpl_slave_skip.test mysql-test/suite/rpl/t/rpl_trigger.test mysql-test/suite/rpl_ndb/t/disabled.def mysql-test/suite/sys_vars/inc/key_buffer_size_basic.inc mysql-test/suite/sys_vars/inc/sort_buffer_size_basic.inc mysql-test/suite/sys_vars/r/key_buffer_size_basic_32.result mysql-test/suite/sys_vars/r/key_buffer_size_basic_64.result mysql-test/suite/sys_vars/r/sort_buffer_size_basic_32.result mysql-test/suite/sys_vars/r/sort_buffer_size_basic_64.result mysql-test/t/alter_table.test mysql-test/t/create.test mysql-test/t/csv.test mysql-test/t/ctype_ucs.test mysql-test/t/date_formats.test mysql-test/t/disabled.def mysql-test/t/events_bugs.test mysql-test/t/events_scheduling.test mysql-test/t/fulltext.test mysql-test/t/func_if.test mysql-test/t/func_in.test mysql-test/t/func_str.test mysql-test/t/func_time.test mysql-test/t/grant.test mysql-test/t/information_schema.test mysql-test/t/innodb-autoinc.test mysql-test/t/innodb.test mysql-test/t/innodb_mysql.test mysql-test/t/log_bin_trust_function_creators_func.test mysql-test/t/log_state.test mysql-test/t/myisam_data_pointer_size_func.test mysql-test/t/myisampack.test mysql-test/t/mysql.test mysql-test/t/mysqlcheck.test mysql-test/t/partition_innodb_stmt.test mysql-test/t/partition_mgm.test mysql-test/t/partition_pruning.test mysql-test/t/query_cache.test mysql-test/t/rpl_init_slave_func.test mysql-test/t/select.test mysql-test/t/status.test mysql-test/t/strict.test mysql-test/t/temp_table.test mysql-test/t/type_bit.test mysql-test/t/type_date.test mysql-test/t/type_float.test mysql-test/t/warnings_engine_disabled.test mysql-test/t/xml.test mysys/my_getopt.c mysys/my_init.c scripts/mysql_install_db.sh sql-common/my_time.c sql/field.cc sql/field.h sql/filesort.cc sql/ha_partition.cc sql/ha_partition.h sql/item.cc sql/item_cmpfunc.cc sql/item_func.h sql/item_strfunc.cc sql/item_sum.cc sql/item_timefunc.cc sql/item_timefunc.h sql/log.cc sql/log.h sql/log_event.cc sql/log_event.h sql/mysql_priv.h sql/mysqld.cc sql/opt_range.cc sql/partition_info.cc sql/repl_failsafe.cc sql/rpl_constants.h sql/set_var.cc sql/slave.cc sql/spatial.h sql/sql_acl.cc sql/sql_base.cc sql/sql_binlog.cc sql/sql_class.h sql/sql_cursor.cc sql/sql_delete.cc sql/sql_lex.cc sql/sql_lex.h sql/sql_locale.cc sql/sql_parse.cc sql/sql_partition.cc sql/sql_plugin.cc sql/sql_plugin.h sql/sql_profile.cc sql/sql_repl.cc sql/sql_select.cc sql/sql_select.h sql/sql_show.cc sql/sql_table.cc sql/sql_trigger.cc sql/sql_trigger.h sql/table.cc sql/table.h sql/unireg.cc storage/csv/ha_tina.cc storage/federated/ha_federated.cc storage/heap/ha_heap.cc storage/innobase/Makefile.am storage/innobase/btr/btr0sea.c storage/innobase/buf/buf0lru.c storage/innobase/dict/dict0dict.c storage/innobase/dict/dict0mem.c storage/innobase/handler/ha_innodb.cc storage/innobase/handler/ha_innodb.h storage/innobase/include/btr0sea.h storage/innobase/include/dict0dict.h storage/innobase/include/dict0mem.h storage/innobase/include/ha_prototypes.h storage/innobase/include/lock0lock.h storage/innobase/include/row0mysql.h storage/innobase/include/sync0sync.ic storage/innobase/include/ut0ut.h storage/innobase/lock/lock0lock.c storage/innobase/os/os0file.c storage/innobase/plug.in storage/innobase/row/row0mysql.c storage/innobase/row/row0sel.c storage/innobase/srv/srv0srv.c storage/innobase/srv/srv0start.c storage/innobase/ut/ut0ut.c storage/myisam/ft_boolean_search.c strings/ctype.c strings/xml.c tests/mysql_client_test.c win/configure.js mysql-test/suite/funcs_1/t/is_coll_char_set_appl.test ------------------------------------------------------------------------ r4165 | calvin | 2009-02-12 01:34:27 +0200 (Thu, 12 Feb 2009) | 1 line Changed paths: M /branches/5.1/handler/ha_innodb.cc branches/5.1: minor non-functional changes. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r4263 | vasil | 2009-02-20 15:00:46 +0200 (Fri, 20 Feb 2009) | 4 lines branches/zip: Add a ChangeLog entry for a change in r4262. ------------------------------------------------------------------------ r4265 | marko | 2009-02-20 22:31:03 +0200 (Fri, 20 Feb 2009) | 5 lines branches/zip: Make innodb_use_sys_malloc=ON the default. Replace srv_use_sys_malloc with UNIV_LIKELY(srv_use_sys_malloc) to improve branch prediction in the default case. Approved by Ken over the IM. ------------------------------------------------------------------------ r4266 | vasil | 2009-02-20 23:29:32 +0200 (Fri, 20 Feb 2009) | 7 lines branches/zip: Add a sentence at the top of COPYING.Google to clarify that this license does not apply to the whole InnoDB. Suggested by: Ken ------------------------------------------------------------------------ r4268 | marko | 2009-02-23 12:43:51 +0200 (Mon, 23 Feb 2009) | 9 lines branches/zip: Initialize ut_list_mutex at startup. Without this fix, ut_list_mutex would be used uninitialized when innodb_use_sys_malloc=1. This fix addresses Issue #181. ut_mem_block_list_init(): Rename to ut_mem_init() and make public. ut_malloc_low(), ut_free_all_mem(): Add ut_a(ut_mem_block_list_inited). mem_init(): Call ut_mem_init(). ------------------------------------------------------------------------ r4269 | marko | 2009-02-23 15:09:49 +0200 (Mon, 23 Feb 2009) | 7 lines branches/zip: When freeing an uncompressed BLOB page, tolerate garbage in FIL_PAGE_TYPE. (Bug #43043, Issue #182) btr_check_blob_fil_page_type(): New function. btr_free_externally_stored_field(), btr_copy_blob_prefix(): Call btr_check_blob_fil_page_type() to check FIL_PAGE_TYPE. ------------------------------------------------------------------------ r4272 | marko | 2009-02-23 23:10:18 +0200 (Mon, 23 Feb 2009) | 8 lines branches/zip: Adjust the fix of Issue #182 in r4269 per Inaam's suggestion. btr_check_blob_fil_page_type(): Replace the parameter const char* op with ibool read. Do not print anything about page type mismatch when reading a BLOB page in Antelope format. Print space id before page number. ------------------------------------------------------------------------ r4273 | marko | 2009-02-24 00:11:11 +0200 (Tue, 24 Feb 2009) | 1 line branches/zip: ut_mem_init(): Add the assertion !ut_mem_block_list_inited. ------------------------------------------------------------------------ r4274 | marko | 2009-02-24 00:14:38 +0200 (Tue, 24 Feb 2009) | 12 lines branches/zip: Fix bugs in the fix of Issue #181. Tested inside and outside Valgrind, with innodb_use_sys_malloc set to 0 and 1. mem_init(): Invoke ut_mem_init() before mem_pool_create(), because the latter one will invoke ut_malloc(). srv_general_init(): Do not initialize the memory subsystem (mem_init()). innobase_init(): Initialize the memory subsystem (mem_init()) before calling srv_parse_data_file_paths_and_sizes(), which needs ut_malloc(). Call ut_free_all_mem() in error handling to clean up after the mem_init(). ------------------------------------------------------------------------ r4280 | marko | 2009-02-24 15:14:59 +0200 (Tue, 24 Feb 2009) | 1 line branches/zip: Remove unused function os_mem_alloc_nocache(). ------------------------------------------------------------------------ r4281 | marko | 2009-02-24 16:02:48 +0200 (Tue, 24 Feb 2009) | 1 line branches/zip: Remove the unused function dict_index_get_type(). ------------------------------------------------------------------------ r4283 | marko | 2009-02-24 23:06:56 +0200 (Tue, 24 Feb 2009) | 1 line branches/zip: srv0start.c: Remove unnecessary #include "mem0pool.h". ------------------------------------------------------------------------ r4284 | marko | 2009-02-24 23:26:38 +0200 (Tue, 24 Feb 2009) | 1 line branches/zip: mem0mem.c: Remove unnecessary #include "mach0data.h". ------------------------------------------------------------------------ r4288 | vasil | 2009-02-25 10:48:07 +0200 (Wed, 25 Feb 2009) | 21 lines branches/zip: Merge revisions 4261:4287 from branches/5.1: ------------------------------------------------------------------------ r4287 | sunny | 2009-02-25 05:32:01 +0200 (Wed, 25 Feb 2009) | 10 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Fix Bug#42714 AUTO_INCREMENT errors in 5.1.31. There are two changes to the autoinc handling. 1. To fix the immediate problem from the bug report, we must ensure that the value written to the table is always less than the max value stored in dict_table_t. 2. The second related change is that according to MySQL documentation when the offset is greater than the increment, we should ignore the offset. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r4289 | vasil | 2009-02-25 10:53:51 +0200 (Wed, 25 Feb 2009) | 4 lines branches/zip: Add ChangeLog entry for the fix in r4288. ------------------------------------------------------------------------ r4290 | vasil | 2009-02-25 11:05:44 +0200 (Wed, 25 Feb 2009) | 11 lines branches/zip: Make ChangeLog entries for bugs in bugs.mysql.com in the form: Fix Bug#12345 bug title (for bugs after 1.0.2 was released and the ChangeLog published) There is no need to bloat the ChangeLog with information that is available via bugs.mysql.com. Discussed with: Marko ------------------------------------------------------------------------ r4291 | vasil | 2009-02-25 11:08:32 +0200 (Wed, 25 Feb 2009) | 4 lines branches/zip: Fix Bug synopsis and remove explanation ------------------------------------------------------------------------ r4292 | marko | 2009-02-25 12:09:15 +0200 (Wed, 25 Feb 2009) | 25 lines branches/zip: Correct the initialization of the memory subsystem once again, to finally put Issue #181 to rest. Revert some parts of r4274. It is best not to call ut_malloc() before srv_general_init(). mem_init(): Do not call ut_mem_init(). srv_general_init(): Initialize the memory subsystem in two phases: first ut_mem_init(), then mem_init(). This is because os_sync_init() and sync_init() depend on ut_mem_init() and mem_init() depends on os_sync_init() or sync_init(). srv_parse_data_file_paths_and_sizes(), srv_parse_log_group_home_dirs(): Remove the output parameters. Assign to the global variables directly. Allocate memory with malloc() instead of ut_malloc(), because these functions will be called before srv_general_init(). srv_free_paths_and_sizes(): New function, for cleaning up after srv_parse_data_file_paths_and_sizes() and srv_parse_log_group_home_dirs(). rb://92 approved by Sunny Bains ------------------------------------------------------------------------ r4297 | vasil | 2009-02-25 17:19:19 +0200 (Wed, 25 Feb 2009) | 4 lines branches/zip: White-space cleanup in the ChangeLog ------------------------------------------------------------------------ r4301 | vasil | 2009-02-25 21:33:32 +0200 (Wed, 25 Feb 2009) | 5 lines branches/zip: Do not output the commands that restore the environment because they depend on the state of the environment before the test starts executing. ------------------------------------------------------------------------ r4315 | vasil | 2009-02-26 09:21:20 +0200 (Thu, 26 Feb 2009) | 5 lines branches/zip: Apply any necessary patches to the mysql tree at the end of setup.sh This step was previously done manually (and sometimes forgotten). ------------------------------------------------------------------------ r4319 | marko | 2009-02-26 23:27:51 +0200 (Thu, 26 Feb 2009) | 6 lines branches/zip: btr_check_blob_fil_page_type(): Do not report FIL_PAGE_TYPE mismatch even when purging a BLOB. Heavy users may have large data files created with MySQL 5.0 or earlier, and they don not want to have the error log flooded with such messages. This fixes Issue #182. ------------------------------------------------------------------------ r4320 | inaam | 2009-02-27 02:13:19 +0200 (Fri, 27 Feb 2009) | 8 lines branches/zip This is to revert the changes made to the plug.in (r4251) as a fix for issue# 178. Changes to plug.in will not propogate to a plugin installation unless autotools are rerun which is unacceptable. A fix for issue# 178 will be committed in a separate commit. ------------------------------------------------------------------------ r4321 | inaam | 2009-02-27 02:16:46 +0200 (Fri, 27 Feb 2009) | 6 lines branches/zip This is a fix for issue#178. Instead of using UNIV_LINUX which is defined through CFLAGS we use compiler generated define __linux__ that is effective for both .c and .cc files. ------------------------------------------------------------------------ r4324 | vasil | 2009-02-27 13:27:18 +0200 (Fri, 27 Feb 2009) | 39 lines branches/zip: Add FreeBSD to the list of the operating systems that have sizeof(pthread_t) == sizeof(void*) (i.e. word size). On FreeBSD pthread_t is defined like: /usr/include/sys/_pthreadtypes.h: typedef struct pthread *pthread_t; I did the following tests (per Inaam's recommendation): a) appropriate version of GCC is available on that platform (4.1.2 or higher for atomics to be available) On FreeBSD 6.x the default compiler is 3.4.6, on FreeBSD 7.x the default one is 4.2.1. One can always install the version of choice from the ports collection. If gcc 3.x is used then HAVE_GCC_ATOMIC_BUILTINS will not be defined and thus the change I am committing will make no difference. b) find out if sizeof(pthread_t) == sizeof(long) On 32 bit both are 4 bytes, on 64 bit both are 8 bytes. c) find out the compiler generated platform define (e.g.: __aix, __sunos__ etc.) The macro is __FreeBSD__. d) patch univ.i with the appropriate platform define e) build the mysql f) ensure it is using atomic builtins (look at the err.log message at system startup. It should say we are using atomics for both mutexes and rw-locks) g) do sanity testing (keeping in view the smp changes) I ran the mysql-test suite. All tests pass. ------------------------------------------------------------------------ r4353 | vasil | 2009-03-05 09:27:29 +0200 (Thu, 05 Mar 2009) | 6 lines branches/zip: As suggested by Ken, print a message that says that the Google SMP patch (GCC atomics) is disabled if it is. Also extend the message when the patch is partially enabled to make it clear that it is partially enabled. ------------------------------------------------------------------------ r4356 | vasil | 2009-03-05 13:49:51 +0200 (Thu, 05 Mar 2009) | 4 lines branches/zip: Fix typo made in r4353. ------------------------------------------------------------------------ r4357 | vasil | 2009-03-05 16:38:59 +0200 (Thu, 05 Mar 2009) | 23 lines branches/zip: Implement a check whether pthread_t objects can be used by GCC atomic builtin functions. This check is implemented in plug.in and defines the macro HAVE_ATOMIC_PTHREAD_T. This macro is checked in univ.i and the relevant part of the code enabled (the one that uses GCC atomics against pthread_t objects). In addition to this, the same program that is compiled as part of the plug.in check is added in ut/ut0auxconf.c. In the InnoDB Plugin source archives that are shipped to the users, a generated Makefile.in is added. That Makefile.in will be modified to compile ut/ut0auxconf.c and define the macro HAVE_ATOMIC_PTHREAD_T if the compilation succeeds. I.e. Makefile.in will emulate the work that is done by plug.in. This is done in order to make the check happen and HAVE_ATOMIC_PTHREAD_T eventually defined without regenerating MySQL's ./configure from ./storage/innobase/plug.in. The point is not to ask users to install the autotools and regenerate ./configure. rb://95 Approved by: Marko ------------------------------------------------------------------------ r4360 | vasil | 2009-03-05 22:23:17 +0200 (Thu, 05 Mar 2009) | 21 lines branches/zip: Merge revisions 4287:4357 from branches/5.1: ------------------------------------------------------------------------ r4325 | sunny | 2009-03-02 02:28:52 +0200 (Mon, 02 Mar 2009) | 10 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Bug#43203: Overflow from auto incrementing causes server segv It was not a SIGSEGV but an assertion failure. The assertion was checking the invariant that *first_value passed in by MySQL doesn't contain a value that is greater than the max value for that type. The assertion has been changed to a check and if the value is greater than the max we report a generic AUTOINC failure. rb://93 Approved by Heikki ------------------------------------------------------------------------ ------------------------------------------------------------------------ r4361 | vasil | 2009-03-05 22:27:54 +0200 (Thu, 05 Mar 2009) | 30 lines branches/zip: Merge revision 4358 from branches/5.1 (resolving a conflict): ------------------------------------------------------------------------ r4358 | vasil | 2009-03-05 21:21:10 +0200 (Thu, 05 Mar 2009) | 21 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc branches/5.1: Merge a change from MySQL: ------------------------------------------------------------ revno: 2728.19.1 committer: Alfranio Correia <alfranio.correia@sun.com> branch nick: mysql-5.1-bugteam timestamp: Tue 2009-02-03 11:36:46 +0000 message: BUG#42445 Warning messages in innobase/handler/ha_innodb.cc There was a type casting problem in the storage/innobase/handler/ha_innodb.cc, (int ha_innobase::write_row(...)). Innobase uses has an internal error variable of type 'ulint' while mysql uses an 'int'. To fix the problem the function manipulates an error variable of type 'ulint' and only casts it into 'int' when needs to return the value. modified: storage/innobase/handler/ha_innodb.cc ------------------------------------------------------------------------ ------------------------------------------------------------------------ r4362 | vasil | 2009-03-05 22:29:07 +0200 (Thu, 05 Mar 2009) | 23 lines branches/zip: Merge revision 4359 from branches/5.1: ------------------------------------------------------------------------ r4359 | vasil | 2009-03-05 21:42:01 +0200 (Thu, 05 Mar 2009) | 14 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc branches/5.1: Merge a change from MySQL: ------------------------------------------------------------ revno: 2747 committer: Timothy Smith <timothy.smith@sun.com> branch nick: 51 timestamp: Fri 2009-01-16 17:49:07 +0100 message: Add another cast to ignore int/ulong difference in error types, silence warning on Win64 modified: storage/innobase/handler/ha_innodb.cc ------------------------------------------------------------------------ ------------------------------------------------------------------------ r4363 | vasil | 2009-03-05 22:31:37 +0200 (Thu, 05 Mar 2009) | 4 lines branches/zip: Add ChangeLog entry for the bugfix in c4360. ------------------------------------------------------------------------ r4378 | calvin | 2009-03-09 10:10:17 +0200 (Mon, 09 Mar 2009) | 7 lines branches/zip: remove compile flag MYSQL_SERVER for dynamic plugin The dynamic plugin on Windows used to be built with MYSQL_SERVER compile flag, while it is not the case for other platforms. r3797 assumed MYSQL_SERVER was not defined for dynamic plugin, which introduced the engine crash during dropping a database. ------------------------------------------------------------------------ r4396 | marko | 2009-03-12 09:22:27 +0200 (Thu, 12 Mar 2009) | 3 lines branches/zip: btr_store_big_rec_extern_fields(): Initialize FIL_PAGE_TYPE in a separate redo log entry. This will make ibbackup --apply-log debugging easier. ------------------------------------------------------------------------ r4397 | marko | 2009-03-12 09:26:11 +0200 (Thu, 12 Mar 2009) | 3 lines branches/zip: trx_sys_create_doublewrite_buf(): As the dummy change, initialize FIL_PAGE_TYPE. This will make it easier to write the debug assertions for ibbackup --apply-log. ------------------------------------------------------------------------ r4401 | marko | 2009-03-12 10:26:40 +0200 (Thu, 12 Mar 2009) | 19 lines branches/zip: Merge revisions 4359:4400 from branches/5.1: ------------------------------------------------------------------------ r4399 | marko | 2009-03-12 09:38:05 +0200 (Thu, 12 Mar 2009) | 2 lines branches/5.1: row_sel_get_clust_rec_for_mysql(): Store the cursor position also for unlock_row(). (Bug #39320) ------------------------------------------------------------------------ r4400 | marko | 2009-03-12 10:06:44 +0200 (Thu, 12 Mar 2009) | 5 lines branches/5.1: Fix a bug in multi-table semi-consistent reads. Remember the acquired record locks per table handle (row_prebuilt_t) rather than per transaction (trx_t), so that unlock_row should successfully unlock all non-matching rows in multi-table operations. This deficiency was found while investigating Bug #39320. ------------------------------------------------------------------------ These were submitted as rb://94 and rb://96 and approved by Heikki Tuuri. ------------------------------------------------------------------------ r4455 | marko | 2009-03-16 11:43:34 +0200 (Mon, 16 Mar 2009) | 2 lines branches/zip: UT_LIST_VALIDATE(): Add the parameter ASSERTION and adjust all callers. ------------------------------------------------------------------------ r4456 | marko | 2009-03-16 12:59:25 +0200 (Mon, 16 Mar 2009) | 6 lines branches/zip: UT_LIST_VALIDATE(): Assert that the link is non-NULL before dereferencing it. In this way, ut_list_node_313 will be pointing to the last non-NULL list item at the time of the assertion failure. (gcc-4.3.2 -O3 seems to optimize the common subexpressions and make the variable NULL, though.) ------------------------------------------------------------------------ r4457 | marko | 2009-03-16 14:12:02 +0200 (Mon, 16 Mar 2009) | 2 lines branches/zip: sync_thread_add_level(): Make the assertions about level == SYNC_BUF_BLOCK more readable. ------------------------------------------------------------------------ r4461 | vasil | 2009-03-17 09:38:19 +0200 (Tue, 17 Mar 2009) | 6 lines branches/zip: Remove mysql-test/patches/bug32625.diff because that bug was fixed in the mysql repository (1 year and 4 months after sending them the simple patch!). See http://bugs.mysql.com/32625 ------------------------------------------------------------------------ r4465 | marko | 2009-03-17 12:34:19 +0200 (Tue, 17 Mar 2009) | 1 line branches/zip: buf0buddy.c: Add and adjust some debug assertions. ------------------------------------------------------------------------ r4473 | vasil | 2009-03-17 15:50:30 +0200 (Tue, 17 Mar 2009) | 5 lines branches/zip: Increment the InnoDB Plugin version from 1.0.3 to 1.0.4 now that 1.0.3 has been released. ------------------------------------------------------------------------ r4478 | vasil | 2009-03-18 11:53:53 +0200 (Wed, 18 Mar 2009) | 5 lines branches/zip: Remove mysql-test/patches/bug41893.diff because that bug has been fixed in the MySQL repository, see http://bugs.mysql.com/41893. ------------------------------------------------------------------------ r4479 | marko | 2009-03-18 12:43:54 +0200 (Wed, 18 Mar 2009) | 2 lines branches/zip: buf_LRU_block_remove_hashed_page(): Add some debug assertions. ------------------------------------------------------------------------ r4480 | marko | 2009-03-18 14:32:13 +0200 (Wed, 18 Mar 2009) | 1 line branches/zip: buf_buddy_free_low(): Correct the function comment. ------------------------------------------------------------------------ r4482 | marko | 2009-03-19 15:23:32 +0200 (Thu, 19 Mar 2009) | 12 lines branches/zip: Merge revisions 4400:4481 from branches/5.1: ------------------------------------------------------------------------ r4481 | marko | 2009-03-19 15:01:48 +0200 (Thu, 19 Mar 2009) | 6 lines branches/5.1: row_unlock_for_mysql(): Do not unlock records that were modified by the current transaction. This bug was introduced or unmasked in r4400. rb://97 approved by Heikki Tuuri ------------------------------------------------------------------------ ------------------------------------------------------------------------ r4490 | marko | 2009-03-20 12:33:33 +0200 (Fri, 20 Mar 2009) | 4 lines branches/zip: Non-functional change for reducing dependencies in InnoDB Hot Backup: Replace srv_sys->dummy_ind1 and srv_sys->dummy_ind2 with dict_ind_redundant and dict_ind_compact, initialized in dict_init(). ------------------------------------------------------------------------ r4491 | marko | 2009-03-20 12:45:18 +0200 (Fri, 20 Mar 2009) | 2 lines branches/zip: Add const qualifiers or in/out comments to some function parameters in log0log. ------------------------------------------------------------------------ r4492 | marko | 2009-03-20 12:52:14 +0200 (Fri, 20 Mar 2009) | 5 lines branches/zip: page_validate(): Always report the space id and the name of the index. In Hot Backup, do not invoke comparison functions, as MySQL collations will be unavailable. ------------------------------------------------------------------------ r4493 | marko | 2009-03-20 13:24:06 +0200 (Fri, 20 Mar 2009) | 1 line branches/zip: Replace fil_get_space_for_id_low() with fil_space_get_by_id(). ------------------------------------------------------------------------ r4494 | marko | 2009-03-20 13:51:35 +0200 (Fri, 20 Mar 2009) | 3 lines branches/zip: fil0fil.c: Refer to fil_system directly, not via local vars. This eliminates some "unused variable" warnings when building InnoDB Hot Backup in such a way that all mutex operations are no-ops. ------------------------------------------------------------------------ r4495 | marko | 2009-03-20 14:15:52 +0200 (Fri, 20 Mar 2009) | 1 line branches/zip: innobase_get_at_most_n_mbchars(): Declare in ha_prototypes.h. ------------------------------------------------------------------------ r4496 | marko | 2009-03-20 14:48:26 +0200 (Fri, 20 Mar 2009) | 1 line branches/zip: recv_recover_page(): Remove compile-time constant parameters. ------------------------------------------------------------------------ r4497 | marko | 2009-03-20 14:56:19 +0200 (Fri, 20 Mar 2009) | 1 line branches/zip: recv_sys_init(): Remove a compile-time constant parameter. ------------------------------------------------------------------------ r4498 | marko | 2009-03-20 15:08:05 +0200 (Fri, 20 Mar 2009) | 4 lines branches/zip: Non-functional change: Add const qualifiers. log_block_checksum_is_ok_or_old_format(), recv_sys_add_to_parsing_buf(): The log block is read-only. Make it const. ------------------------------------------------------------------------ r4499 | marko | 2009-03-20 15:10:25 +0200 (Fri, 20 Mar 2009) | 1 line branches/zip: recv_scan_log_recs(): Remove a compile-time constant parameter. ------------------------------------------------------------------------ r4500 | marko | 2009-03-20 15:47:17 +0200 (Fri, 20 Mar 2009) | 1 line branches/zip: fil_init(): Add the parameter hash_size. ------------------------------------------------------------------------ r4501 | vasil | 2009-03-20 16:50:41 +0200 (Fri, 20 Mar 2009) | 4 lines branches/zip: Add any entry about the release of 1.0.3 in the ChangeLog. ------------------------------------------------------------------------ r4515 | marko | 2009-03-23 10:49:53 +0200 (Mon, 23 Mar 2009) | 1 line branches/zip: hash_table_t: adaptive: Remove from UNIV_HOTBACKUP builds. ------------------------------------------------------------------------ r4516 | marko | 2009-03-23 10:57:16 +0200 (Mon, 23 Mar 2009) | 2 lines branches/zip: Define and use ASSERT_HASH_MUTEX_OWN. Make it a no-op in UNIV_HOTBACKUP builds. ------------------------------------------------------------------------ r4517 | marko | 2009-03-23 11:07:20 +0200 (Mon, 23 Mar 2009) | 2 lines branches/zip: Define and use PAGE_ZIP_MATCH. In UNIV_HOTBACKUP builds, assume fixed allocation. ------------------------------------------------------------------------ r4521 | marko | 2009-03-23 12:05:47 +0200 (Mon, 23 Mar 2009) | 1 line branches/zip: buf_page_print(): Clean up the code #ifdef UNIV_HOTBACKUP. ------------------------------------------------------------------------ r4522 | marko | 2009-03-23 12:20:50 +0200 (Mon, 23 Mar 2009) | 2 lines branches/zip: Exclude some operating system interface code from UNIV_HOTBACKUP builds. ------------------------------------------------------------------------ r4523 | marko | 2009-03-23 13:00:43 +0200 (Mon, 23 Mar 2009) | 2 lines branches/zip: Remove the remaining references to hash_table_t::adapive from UNIV_HOTBACKUP builds. This should have been done in r4515. ------------------------------------------------------------------------ r4524 | marko | 2009-03-23 14:05:18 +0200 (Mon, 23 Mar 2009) | 2 lines branches/zip: Enclose recv_recovery_from_backup_on and recv_recovery_from_backup_is_on() in #ifdef UNIV_LOG_ARCHIVE. ------------------------------------------------------------------------ r4525 | marko | 2009-03-23 14:57:45 +0200 (Mon, 23 Mar 2009) | 2 lines branches/zip: recv_parse_or_apply_log_rec_body(): Add debug assertions ensuring that FIL_PAGE_TYPE makes sense when applying log records. ------------------------------------------------------------------------ r4526 | marko | 2009-03-23 16:21:34 +0200 (Mon, 23 Mar 2009) | 2 lines branches/zip: Remove unneeded definitions and dependencies from UNIV_HOTBACKUP builds. ------------------------------------------------------------------------ r4527 | calvin | 2009-03-23 23:15:33 +0200 (Mon, 23 Mar 2009) | 5 lines branches/zip: adjust build files on Windows Adjust the patch positions based on the latest MySQL source. Also add the patches to the .bat files for vs9. ------------------------------------------------------------------------
4300 lines
118 KiB
C
4300 lines
118 KiB
C
/*****************************************************************************
|
|
|
|
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*****************************************************************************/
|
|
|
|
/**********************************************************************
|
|
File space management
|
|
|
|
Created 11/29/1995 Heikki Tuuri
|
|
***********************************************************************/
|
|
|
|
#include "fsp0fsp.h"
|
|
|
|
#ifdef UNIV_NONINL
|
|
#include "fsp0fsp.ic"
|
|
#endif
|
|
|
|
#include "buf0buf.h"
|
|
#include "fil0fil.h"
|
|
#include "mtr0log.h"
|
|
#include "ut0byte.h"
|
|
#include "page0page.h"
|
|
#include "page0zip.h"
|
|
#ifdef UNIV_HOTBACKUP
|
|
# include "fut0lst.h"
|
|
#else /* UNIV_HOTBACKUP */
|
|
# include "sync0sync.h"
|
|
# include "fut0fut.h"
|
|
# include "srv0srv.h"
|
|
# include "ibuf0ibuf.h"
|
|
# include "btr0btr.h"
|
|
# include "btr0sea.h"
|
|
# include "dict0boot.h"
|
|
# include "log0log.h"
|
|
#endif /* UNIV_HOTBACKUP */
|
|
#include "dict0mem.h"
|
|
|
|
|
|
#define FSP_HEADER_OFFSET FIL_PAGE_DATA /* Offset of the space header
|
|
within a file page */
|
|
|
|
/* The data structures in files are defined just as byte strings in C */
|
|
typedef byte fsp_header_t;
|
|
typedef byte xdes_t;
|
|
|
|
/* SPACE HEADER
|
|
============
|
|
|
|
File space header data structure: this data structure is contained in the
|
|
first page of a space. The space for this header is reserved in every extent
|
|
descriptor page, but used only in the first. */
|
|
|
|
/*-------------------------------------*/
|
|
#define FSP_SPACE_ID 0 /* space id */
|
|
#define FSP_NOT_USED 4 /* this field contained a value up to
|
|
which we know that the modifications
|
|
in the database have been flushed to
|
|
the file space; not used now */
|
|
#define FSP_SIZE 8 /* Current size of the space in
|
|
pages */
|
|
#define FSP_FREE_LIMIT 12 /* Minimum page number for which the
|
|
free list has not been initialized:
|
|
the pages >= this limit are, by
|
|
definition, free; note that in a
|
|
single-table tablespace where size
|
|
< 64 pages, this number is 64, i.e.,
|
|
we have initialized the space
|
|
about the first extent, but have not
|
|
physically allocted those pages to the
|
|
file */
|
|
#define FSP_SPACE_FLAGS 16 /* table->flags & ~DICT_TF_COMPACT */
|
|
#define FSP_FRAG_N_USED 20 /* number of used pages in the
|
|
FSP_FREE_FRAG list */
|
|
#define FSP_FREE 24 /* list of free extents */
|
|
#define FSP_FREE_FRAG (24 + FLST_BASE_NODE_SIZE)
|
|
/* list of partially free extents not
|
|
belonging to any segment */
|
|
#define FSP_FULL_FRAG (24 + 2 * FLST_BASE_NODE_SIZE)
|
|
/* list of full extents not belonging
|
|
to any segment */
|
|
#define FSP_SEG_ID (24 + 3 * FLST_BASE_NODE_SIZE)
|
|
/* 8 bytes which give the first unused
|
|
segment id */
|
|
#define FSP_SEG_INODES_FULL (32 + 3 * FLST_BASE_NODE_SIZE)
|
|
/* list of pages containing segment
|
|
headers, where all the segment inode
|
|
slots are reserved */
|
|
#define FSP_SEG_INODES_FREE (32 + 4 * FLST_BASE_NODE_SIZE)
|
|
/* list of pages containing segment
|
|
headers, where not all the segment
|
|
header slots are reserved */
|
|
/*-------------------------------------*/
|
|
/* File space header size */
|
|
#define FSP_HEADER_SIZE (32 + 5 * FLST_BASE_NODE_SIZE)
|
|
|
|
#define FSP_FREE_ADD 4 /* this many free extents are added
|
|
to the free list from above
|
|
FSP_FREE_LIMIT at a time */
|
|
|
|
/* FILE SEGMENT INODE
|
|
==================
|
|
|
|
Segment inode which is created for each segment in a tablespace. NOTE: in
|
|
purge we assume that a segment having only one currently used page can be
|
|
freed in a few steps, so that the freeing cannot fill the file buffer with
|
|
bufferfixed file pages. */
|
|
|
|
typedef byte fseg_inode_t;
|
|
|
|
#define FSEG_INODE_PAGE_NODE FSEG_PAGE_DATA
|
|
/* the list node for linking
|
|
segment inode pages */
|
|
|
|
#define FSEG_ARR_OFFSET (FSEG_PAGE_DATA + FLST_NODE_SIZE)
|
|
/*-------------------------------------*/
|
|
#define FSEG_ID 0 /* 8 bytes of segment id: if this is
|
|
ut_dulint_zero, it means that the
|
|
header is unused */
|
|
#define FSEG_NOT_FULL_N_USED 8
|
|
/* number of used segment pages in
|
|
the FSEG_NOT_FULL list */
|
|
#define FSEG_FREE 12
|
|
/* list of free extents of this
|
|
segment */
|
|
#define FSEG_NOT_FULL (12 + FLST_BASE_NODE_SIZE)
|
|
/* list of partially free extents */
|
|
#define FSEG_FULL (12 + 2 * FLST_BASE_NODE_SIZE)
|
|
/* list of full extents */
|
|
#define FSEG_MAGIC_N (12 + 3 * FLST_BASE_NODE_SIZE)
|
|
/* magic number used in debugging */
|
|
#define FSEG_FRAG_ARR (16 + 3 * FLST_BASE_NODE_SIZE)
|
|
/* array of individual pages
|
|
belonging to this segment in fsp
|
|
fragment extent lists */
|
|
#define FSEG_FRAG_ARR_N_SLOTS (FSP_EXTENT_SIZE / 2)
|
|
/* number of slots in the array for
|
|
the fragment pages */
|
|
#define FSEG_FRAG_SLOT_SIZE 4 /* a fragment page slot contains its
|
|
page number within space, FIL_NULL
|
|
means that the slot is not in use */
|
|
/*-------------------------------------*/
|
|
#define FSEG_INODE_SIZE \
|
|
(16 + 3 * FLST_BASE_NODE_SIZE \
|
|
+ FSEG_FRAG_ARR_N_SLOTS * FSEG_FRAG_SLOT_SIZE)
|
|
|
|
#define FSP_SEG_INODES_PER_PAGE(zip_size) \
|
|
(((zip_size ? zip_size : UNIV_PAGE_SIZE) \
|
|
- FSEG_ARR_OFFSET - 10) / FSEG_INODE_SIZE)
|
|
/* Number of segment inodes which fit on a
|
|
single page */
|
|
|
|
#define FSEG_MAGIC_N_VALUE 97937874
|
|
|
|
#define FSEG_FILLFACTOR 8 /* If this value is x, then if
|
|
the number of unused but reserved
|
|
pages in a segment is less than
|
|
reserved pages * 1/x, and there are
|
|
at least FSEG_FRAG_LIMIT used pages,
|
|
then we allow a new empty extent to
|
|
be added to the segment in
|
|
fseg_alloc_free_page. Otherwise, we
|
|
use unused pages of the segment. */
|
|
|
|
#define FSEG_FRAG_LIMIT FSEG_FRAG_ARR_N_SLOTS
|
|
/* If the segment has >= this many
|
|
used pages, it may be expanded by
|
|
allocating extents to the segment;
|
|
until that only individual fragment
|
|
pages are allocated from the space */
|
|
|
|
#define FSEG_FREE_LIST_LIMIT 40 /* If the reserved size of a segment
|
|
is at least this many extents, we
|
|
allow extents to be put to the free
|
|
list of the extent: at most
|
|
FSEG_FREE_LIST_MAX_LEN many */
|
|
#define FSEG_FREE_LIST_MAX_LEN 4
|
|
|
|
|
|
/* EXTENT DESCRIPTOR
|
|
=================
|
|
|
|
File extent descriptor data structure: contains bits to tell which pages in
|
|
the extent are free and which contain old tuple version to clean. */
|
|
|
|
/*-------------------------------------*/
|
|
#define XDES_ID 0 /* The identifier of the segment
|
|
to which this extent belongs */
|
|
#define XDES_FLST_NODE 8 /* The list node data structure
|
|
for the descriptors */
|
|
#define XDES_STATE (FLST_NODE_SIZE + 8)
|
|
/* contains state information
|
|
of the extent */
|
|
#define XDES_BITMAP (FLST_NODE_SIZE + 12)
|
|
/* Descriptor bitmap of the pages
|
|
in the extent */
|
|
/*-------------------------------------*/
|
|
|
|
#define XDES_BITS_PER_PAGE 2 /* How many bits are there per page */
|
|
#define XDES_FREE_BIT 0 /* Index of the bit which tells if
|
|
the page is free */
|
|
#define XDES_CLEAN_BIT 1 /* NOTE: currently not used!
|
|
Index of the bit which tells if
|
|
there are old versions of tuples
|
|
on the page */
|
|
/* States of a descriptor */
|
|
#define XDES_FREE 1 /* extent is in free list of space */
|
|
#define XDES_FREE_FRAG 2 /* extent is in free fragment list of
|
|
space */
|
|
#define XDES_FULL_FRAG 3 /* extent is in full fragment list of
|
|
space */
|
|
#define XDES_FSEG 4 /* extent belongs to a segment */
|
|
|
|
/* File extent data structure size in bytes. */
|
|
#define XDES_SIZE \
|
|
(XDES_BITMAP + UT_BITS_IN_BYTES(FSP_EXTENT_SIZE * XDES_BITS_PER_PAGE))
|
|
|
|
/* Offset of the descriptor array on a descriptor page */
|
|
#define XDES_ARR_OFFSET (FSP_HEADER_OFFSET + FSP_HEADER_SIZE)
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
/**************************************************************************
|
|
Returns an extent to the free list of a space. */
|
|
static
|
|
void
|
|
fsp_free_extent(
|
|
/*============*/
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page, /* in: page offset in the extent */
|
|
mtr_t* mtr); /* in: mtr */
|
|
/**************************************************************************
|
|
Frees an extent of a segment to the space free list. */
|
|
static
|
|
void
|
|
fseg_free_extent(
|
|
/*=============*/
|
|
fseg_inode_t* seg_inode, /* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page, /* in: page offset in the extent */
|
|
mtr_t* mtr); /* in: mtr handle */
|
|
/**************************************************************************
|
|
Calculates the number of pages reserved by a segment, and how
|
|
many pages are currently used. */
|
|
static
|
|
ulint
|
|
fseg_n_reserved_pages_low(
|
|
/*======================*/
|
|
/* out: number of reserved pages */
|
|
fseg_inode_t* header, /* in: segment inode */
|
|
ulint* used, /* out: number of pages used (<= reserved) */
|
|
mtr_t* mtr); /* in: mtr handle */
|
|
/************************************************************************
|
|
Marks a page used. The page must reside within the extents of the given
|
|
segment. */
|
|
static
|
|
void
|
|
fseg_mark_page_used(
|
|
/*================*/
|
|
fseg_inode_t* seg_inode,/* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page, /* in: page offset */
|
|
mtr_t* mtr); /* in: mtr */
|
|
/**************************************************************************
|
|
Returns the first extent descriptor for a segment. We think of the extent
|
|
lists of the segment catenated in the order FSEG_FULL -> FSEG_NOT_FULL
|
|
-> FSEG_FREE. */
|
|
static
|
|
xdes_t*
|
|
fseg_get_first_extent(
|
|
/*==================*/
|
|
/* out: the first extent descriptor, or NULL if
|
|
none */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
mtr_t* mtr); /* in: mtr */
|
|
/**************************************************************************
|
|
Puts new extents to the free list if
|
|
there are free extents above the free limit. If an extent happens
|
|
to contain an extent descriptor page, the extent is put to
|
|
the FSP_FREE_FRAG list with the page marked as used. */
|
|
static
|
|
void
|
|
fsp_fill_free_list(
|
|
/*===============*/
|
|
ibool init_space, /* in: TRUE if this is a single-table
|
|
tablespace and we are only initing
|
|
the tablespace's first extent
|
|
descriptor page and ibuf bitmap page;
|
|
then we do not allocate more extents */
|
|
ulint space, /* in: space */
|
|
fsp_header_t* header, /* in: space header */
|
|
mtr_t* mtr); /* in: mtr */
|
|
/**************************************************************************
|
|
Allocates a single free page from a segment. This function implements
|
|
the intelligent allocation strategy which tries to minimize file space
|
|
fragmentation. */
|
|
static
|
|
ulint
|
|
fseg_alloc_free_page_low(
|
|
/*=====================*/
|
|
/* out: the allocated page number, FIL_NULL
|
|
if no page could be allocated */
|
|
ulint space, /* in: space */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
fseg_inode_t* seg_inode, /* in: segment inode */
|
|
ulint hint, /* in: hint of which page would be desirable */
|
|
byte direction, /* in: if the new page is needed because
|
|
of an index page split, and records are
|
|
inserted there in order, into which
|
|
direction they go alphabetically: FSP_DOWN,
|
|
FSP_UP, FSP_NO_DIR */
|
|
mtr_t* mtr); /* in: mtr handle */
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/**************************************************************************
|
|
Reads the file space size stored in the header page. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fsp_get_size_low(
|
|
/*=============*/
|
|
/* out: tablespace size stored in the space header */
|
|
page_t* page) /* in: header page (page 0 in the tablespace) */
|
|
{
|
|
return(mach_read_from_4(page + FSP_HEADER_OFFSET + FSP_SIZE));
|
|
}
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
/**************************************************************************
|
|
Gets a pointer to the space header and x-locks its page. */
|
|
UNIV_INLINE
|
|
fsp_header_t*
|
|
fsp_get_space_header(
|
|
/*=================*/
|
|
/* out: pointer to the space header, page x-locked */
|
|
ulint id, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
buf_block_t* block;
|
|
fsp_header_t* header;
|
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
|
ut_ad(zip_size <= UNIV_PAGE_SIZE);
|
|
ut_ad(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
|
|
ut_ad(id || !zip_size);
|
|
|
|
block = buf_page_get(id, zip_size, 0, RW_X_LATCH, mtr);
|
|
header = FSP_HEADER_OFFSET + buf_block_get_frame(block);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
ut_ad(id == mach_read_from_4(FSP_SPACE_ID + header));
|
|
ut_ad(zip_size == dict_table_flags_to_zip_size(
|
|
mach_read_from_4(FSP_SPACE_FLAGS + header)));
|
|
return(header);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Gets a descriptor bit of a page. */
|
|
UNIV_INLINE
|
|
ibool
|
|
xdes_get_bit(
|
|
/*=========*/
|
|
/* out: TRUE if free */
|
|
xdes_t* descr, /* in: descriptor */
|
|
ulint bit, /* in: XDES_FREE_BIT or XDES_CLEAN_BIT */
|
|
ulint offset, /* in: page offset within extent:
|
|
0 ... FSP_EXTENT_SIZE - 1 */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint index;
|
|
ulint byte_index;
|
|
ulint bit_index;
|
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
|
ut_ad((bit == XDES_FREE_BIT) || (bit == XDES_CLEAN_BIT));
|
|
ut_ad(offset < FSP_EXTENT_SIZE);
|
|
|
|
index = bit + XDES_BITS_PER_PAGE * offset;
|
|
|
|
byte_index = index / 8;
|
|
bit_index = index % 8;
|
|
|
|
return(ut_bit_get_nth(mtr_read_ulint(descr + XDES_BITMAP + byte_index,
|
|
MLOG_1BYTE, mtr),
|
|
bit_index));
|
|
}
|
|
|
|
/**************************************************************************
|
|
Sets a descriptor bit of a page. */
|
|
UNIV_INLINE
|
|
void
|
|
xdes_set_bit(
|
|
/*=========*/
|
|
xdes_t* descr, /* in: descriptor */
|
|
ulint bit, /* in: XDES_FREE_BIT or XDES_CLEAN_BIT */
|
|
ulint offset, /* in: page offset within extent:
|
|
0 ... FSP_EXTENT_SIZE - 1 */
|
|
ibool val, /* in: bit value */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint index;
|
|
ulint byte_index;
|
|
ulint bit_index;
|
|
ulint descr_byte;
|
|
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
|
ut_ad((bit == XDES_FREE_BIT) || (bit == XDES_CLEAN_BIT));
|
|
ut_ad(offset < FSP_EXTENT_SIZE);
|
|
|
|
index = bit + XDES_BITS_PER_PAGE * offset;
|
|
|
|
byte_index = index / 8;
|
|
bit_index = index % 8;
|
|
|
|
descr_byte = mtr_read_ulint(descr + XDES_BITMAP + byte_index,
|
|
MLOG_1BYTE, mtr);
|
|
descr_byte = ut_bit_set_nth(descr_byte, bit_index, val);
|
|
|
|
mlog_write_ulint(descr + XDES_BITMAP + byte_index, descr_byte,
|
|
MLOG_1BYTE, mtr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Looks for a descriptor bit having the desired value. Starts from hint
|
|
and scans upward; at the end of the extent the search is wrapped to
|
|
the start of the extent. */
|
|
UNIV_INLINE
|
|
ulint
|
|
xdes_find_bit(
|
|
/*==========*/
|
|
/* out: bit index of the bit, ULINT_UNDEFINED if not
|
|
found */
|
|
xdes_t* descr, /* in: descriptor */
|
|
ulint bit, /* in: XDES_FREE_BIT or XDES_CLEAN_BIT */
|
|
ibool val, /* in: desired bit value */
|
|
ulint hint, /* in: hint of which bit position would be desirable */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint i;
|
|
|
|
ut_ad(descr && mtr);
|
|
ut_ad(val <= TRUE);
|
|
ut_ad(hint < FSP_EXTENT_SIZE);
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
|
for (i = hint; i < FSP_EXTENT_SIZE; i++) {
|
|
if (val == xdes_get_bit(descr, bit, i, mtr)) {
|
|
|
|
return(i);
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < hint; i++) {
|
|
if (val == xdes_get_bit(descr, bit, i, mtr)) {
|
|
|
|
return(i);
|
|
}
|
|
}
|
|
|
|
return(ULINT_UNDEFINED);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Looks for a descriptor bit having the desired value. Scans the extent in
|
|
a direction opposite to xdes_find_bit. */
|
|
UNIV_INLINE
|
|
ulint
|
|
xdes_find_bit_downward(
|
|
/*===================*/
|
|
/* out: bit index of the bit, ULINT_UNDEFINED if not
|
|
found */
|
|
xdes_t* descr, /* in: descriptor */
|
|
ulint bit, /* in: XDES_FREE_BIT or XDES_CLEAN_BIT */
|
|
ibool val, /* in: desired bit value */
|
|
ulint hint, /* in: hint of which bit position would be desirable */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint i;
|
|
|
|
ut_ad(descr && mtr);
|
|
ut_ad(val <= TRUE);
|
|
ut_ad(hint < FSP_EXTENT_SIZE);
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
|
for (i = hint + 1; i > 0; i--) {
|
|
if (val == xdes_get_bit(descr, bit, i - 1, mtr)) {
|
|
|
|
return(i - 1);
|
|
}
|
|
}
|
|
|
|
for (i = FSP_EXTENT_SIZE - 1; i > hint; i--) {
|
|
if (val == xdes_get_bit(descr, bit, i, mtr)) {
|
|
|
|
return(i);
|
|
}
|
|
}
|
|
|
|
return(ULINT_UNDEFINED);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Returns the number of used pages in a descriptor. */
|
|
UNIV_INLINE
|
|
ulint
|
|
xdes_get_n_used(
|
|
/*============*/
|
|
/* out: number of pages used */
|
|
xdes_t* descr, /* in: descriptor */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint i;
|
|
ulint count = 0;
|
|
|
|
ut_ad(descr && mtr);
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
|
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
|
|
if (FALSE == xdes_get_bit(descr, XDES_FREE_BIT, i, mtr)) {
|
|
count++;
|
|
}
|
|
}
|
|
|
|
return(count);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Returns true if extent contains no used pages. */
|
|
UNIV_INLINE
|
|
ibool
|
|
xdes_is_free(
|
|
/*=========*/
|
|
/* out: TRUE if totally free */
|
|
xdes_t* descr, /* in: descriptor */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
if (0 == xdes_get_n_used(descr, mtr)) {
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Returns true if extent contains no free pages. */
|
|
UNIV_INLINE
|
|
ibool
|
|
xdes_is_full(
|
|
/*=========*/
|
|
/* out: TRUE if full */
|
|
xdes_t* descr, /* in: descriptor */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
if (FSP_EXTENT_SIZE == xdes_get_n_used(descr, mtr)) {
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Sets the state of an xdes. */
|
|
UNIV_INLINE
|
|
void
|
|
xdes_set_state(
|
|
/*===========*/
|
|
xdes_t* descr, /* in: descriptor */
|
|
ulint state, /* in: state to set */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ut_ad(descr && mtr);
|
|
ut_ad(state >= XDES_FREE);
|
|
ut_ad(state <= XDES_FSEG);
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
|
|
|
mlog_write_ulint(descr + XDES_STATE, state, MLOG_4BYTES, mtr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Gets the state of an xdes. */
|
|
UNIV_INLINE
|
|
ulint
|
|
xdes_get_state(
|
|
/*===========*/
|
|
/* out: state */
|
|
xdes_t* descr, /* in: descriptor */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint state;
|
|
|
|
ut_ad(descr && mtr);
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
|
|
|
state = mtr_read_ulint(descr + XDES_STATE, MLOG_4BYTES, mtr);
|
|
ut_ad(state - 1 < XDES_FSEG);
|
|
return(state);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Inits an extent descriptor to the free and clean state. */
|
|
UNIV_INLINE
|
|
void
|
|
xdes_init(
|
|
/*======*/
|
|
xdes_t* descr, /* in: descriptor */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint i;
|
|
|
|
ut_ad(descr && mtr);
|
|
ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX));
|
|
ut_ad((XDES_SIZE - XDES_BITMAP) % 4 == 0);
|
|
|
|
for (i = XDES_BITMAP; i < XDES_SIZE; i += 4) {
|
|
mlog_write_ulint(descr + i, 0xFFFFFFFFUL, MLOG_4BYTES, mtr);
|
|
}
|
|
|
|
xdes_set_state(descr, XDES_FREE, mtr);
|
|
}
|
|
|
|
/************************************************************************
|
|
Calculates the page where the descriptor of a page resides. */
|
|
UNIV_INLINE
|
|
ulint
|
|
xdes_calc_descriptor_page(
|
|
/*======================*/
|
|
/* out: descriptor page offset */
|
|
ulint zip_size, /* in: compressed page size in bytes;
|
|
0 for uncompressed pages */
|
|
ulint offset) /* in: page offset */
|
|
{
|
|
#if UNIV_PAGE_SIZE <= XDES_ARR_OFFSET \
|
|
+ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
|
|
# error
|
|
#endif
|
|
#if PAGE_ZIP_MIN_SIZE <= XDES_ARR_OFFSET \
|
|
+ (PAGE_ZIP_MIN_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE
|
|
# error
|
|
#endif
|
|
ut_ad(ut_is_2pow(zip_size));
|
|
|
|
if (!zip_size) {
|
|
return(ut_2pow_round(offset, UNIV_PAGE_SIZE));
|
|
} else {
|
|
ut_ad(zip_size > XDES_ARR_OFFSET
|
|
+ (zip_size / FSP_EXTENT_SIZE) * XDES_SIZE);
|
|
return(ut_2pow_round(offset, zip_size));
|
|
}
|
|
}
|
|
|
|
/************************************************************************
|
|
Calculates the descriptor index within a descriptor page. */
|
|
UNIV_INLINE
|
|
ulint
|
|
xdes_calc_descriptor_index(
|
|
/*=======================*/
|
|
/* out: descriptor index */
|
|
ulint zip_size, /* in: compressed page size in bytes;
|
|
0 for uncompressed pages */
|
|
ulint offset) /* in: page offset */
|
|
{
|
|
ut_ad(ut_is_2pow(zip_size));
|
|
|
|
if (!zip_size) {
|
|
return(ut_2pow_remainder(offset, UNIV_PAGE_SIZE)
|
|
/ FSP_EXTENT_SIZE);
|
|
} else {
|
|
return(ut_2pow_remainder(offset, zip_size) / FSP_EXTENT_SIZE);
|
|
}
|
|
}
|
|
|
|
/************************************************************************
|
|
Gets pointer to a the extent descriptor of a page. The page where the extent
|
|
descriptor resides is x-locked. If the page offset is equal to the free limit
|
|
of the space, adds new extents from above the free limit to the space free
|
|
list, if not free limit == space size. This adding is necessary to make the
|
|
descriptor defined, as they are uninitialized above the free limit. */
|
|
UNIV_INLINE
|
|
xdes_t*
|
|
xdes_get_descriptor_with_space_hdr(
|
|
/*===============================*/
|
|
/* out: pointer to the extent descriptor,
|
|
NULL if the page does not exist in the
|
|
space or if offset > free limit */
|
|
fsp_header_t* sp_header,/* in: space header, x-latched */
|
|
ulint space, /* in: space id */
|
|
ulint offset, /* in: page offset;
|
|
if equal to the free limit,
|
|
we try to add new extents to
|
|
the space free list */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint limit;
|
|
ulint size;
|
|
ulint zip_size;
|
|
ulint descr_page_no;
|
|
page_t* descr_page;
|
|
|
|
ut_ad(mtr);
|
|
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
|
|
MTR_MEMO_X_LOCK));
|
|
ut_ad(mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_S_FIX)
|
|
|| mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_X_FIX));
|
|
ut_ad(page_offset(sp_header) == FSP_HEADER_OFFSET);
|
|
/* Read free limit and space size */
|
|
limit = mach_read_from_4(sp_header + FSP_FREE_LIMIT);
|
|
size = mach_read_from_4(sp_header + FSP_SIZE);
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
mach_read_from_4(sp_header + FSP_SPACE_FLAGS));
|
|
|
|
/* If offset is >= size or > limit, return NULL */
|
|
|
|
if ((offset >= size) || (offset > limit)) {
|
|
|
|
return(NULL);
|
|
}
|
|
|
|
/* If offset is == limit, fill free list of the space. */
|
|
|
|
if (offset == limit) {
|
|
fsp_fill_free_list(FALSE, space, sp_header, mtr);
|
|
}
|
|
|
|
descr_page_no = xdes_calc_descriptor_page(zip_size, offset);
|
|
|
|
if (descr_page_no == 0) {
|
|
/* It is on the space header page */
|
|
|
|
descr_page = page_align(sp_header);
|
|
} else {
|
|
buf_block_t* block;
|
|
|
|
block = buf_page_get(space, zip_size, descr_page_no,
|
|
RW_X_LATCH, mtr);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
descr_page = buf_block_get_frame(block);
|
|
}
|
|
|
|
return(descr_page + XDES_ARR_OFFSET
|
|
+ XDES_SIZE * xdes_calc_descriptor_index(zip_size, offset));
|
|
}
|
|
|
|
/************************************************************************
|
|
Gets pointer to a the extent descriptor of a page. The page where the
|
|
extent descriptor resides is x-locked. If the page offset is equal to
|
|
the free limit of the space, adds new extents from above the free limit
|
|
to the space free list, if not free limit == space size. This adding
|
|
is necessary to make the descriptor defined, as they are uninitialized
|
|
above the free limit. */
|
|
static
|
|
xdes_t*
|
|
xdes_get_descriptor(
|
|
/*================*/
|
|
/* out: pointer to the extent descriptor, NULL if the
|
|
page does not exist in the space or if offset > free
|
|
limit */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint offset, /* in: page offset; if equal to the free limit,
|
|
we try to add new extents to the space free list */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
buf_block_t* block;
|
|
fsp_header_t* sp_header;
|
|
|
|
block = buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
sp_header = FSP_HEADER_OFFSET + buf_block_get_frame(block);
|
|
return(xdes_get_descriptor_with_space_hdr(sp_header, space, offset,
|
|
mtr));
|
|
}
|
|
|
|
/************************************************************************
|
|
Gets pointer to a the extent descriptor if the file address
|
|
of the descriptor list node is known. The page where the
|
|
extent descriptor resides is x-locked. */
|
|
UNIV_INLINE
|
|
xdes_t*
|
|
xdes_lst_get_descriptor(
|
|
/*====================*/
|
|
/* out: pointer to the extent descriptor */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
fil_addr_t lst_node,/* in: file address of the list node
|
|
contained in the descriptor */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
xdes_t* descr;
|
|
|
|
ut_ad(mtr);
|
|
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),
|
|
MTR_MEMO_X_LOCK));
|
|
descr = fut_get_ptr(space, zip_size, lst_node, RW_X_LATCH, mtr)
|
|
- XDES_FLST_NODE;
|
|
|
|
return(descr);
|
|
}
|
|
|
|
/************************************************************************
|
|
Returns page offset of the first page in extent described by a descriptor. */
|
|
UNIV_INLINE
|
|
ulint
|
|
xdes_get_offset(
|
|
/*============*/
|
|
/* out: offset of the first page in extent */
|
|
xdes_t* descr) /* in: extent descriptor */
|
|
{
|
|
ut_ad(descr);
|
|
|
|
return(page_get_page_no(page_align(descr))
|
|
+ ((page_offset(descr) - XDES_ARR_OFFSET) / XDES_SIZE)
|
|
* FSP_EXTENT_SIZE);
|
|
}
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/***************************************************************
|
|
Inits a file page whose prior contents should be ignored. */
|
|
static
|
|
void
|
|
fsp_init_file_page_low(
|
|
/*===================*/
|
|
buf_block_t* block) /* in: pointer to a page */
|
|
{
|
|
page_t* page = buf_block_get_frame(block);
|
|
page_zip_des_t* page_zip= buf_block_get_page_zip(block);
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
block->check_index_page_at_flush = FALSE;
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
if (UNIV_LIKELY_NULL(page_zip)) {
|
|
memset(page, 0, UNIV_PAGE_SIZE);
|
|
memset(page_zip->data, 0, page_zip_get_size(page_zip));
|
|
mach_write_to_4(page + FIL_PAGE_OFFSET,
|
|
buf_block_get_page_no(block));
|
|
mach_write_to_4(page
|
|
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
|
|
buf_block_get_space(block));
|
|
memcpy(page_zip->data + FIL_PAGE_OFFSET,
|
|
page + FIL_PAGE_OFFSET, 4);
|
|
memcpy(page_zip->data + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
|
|
page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 4);
|
|
return;
|
|
}
|
|
|
|
#ifdef UNIV_BASIC_LOG_DEBUG
|
|
memset(page, 0xff, UNIV_PAGE_SIZE);
|
|
#endif
|
|
mach_write_to_4(page + FIL_PAGE_OFFSET, buf_block_get_page_no(block));
|
|
memset(page + FIL_PAGE_LSN, 0, 8);
|
|
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
|
|
buf_block_get_space(block));
|
|
memset(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, 0, 8);
|
|
}
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
/***************************************************************
|
|
Inits a file page whose prior contents should be ignored. */
|
|
static
|
|
void
|
|
fsp_init_file_page(
|
|
/*===============*/
|
|
buf_block_t* block, /* in: pointer to a page */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
fsp_init_file_page_low(block);
|
|
|
|
mlog_write_initial_log_record(buf_block_get_frame(block),
|
|
MLOG_INIT_FILE_PAGE, mtr);
|
|
}
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/***************************************************************
|
|
Parses a redo log record of a file page init. */
|
|
UNIV_INTERN
|
|
byte*
|
|
fsp_parse_init_file_page(
|
|
/*=====================*/
|
|
/* out: end of log record or NULL */
|
|
byte* ptr, /* in: buffer */
|
|
byte* end_ptr __attribute__((unused)), /* in: buffer end */
|
|
buf_block_t* block) /* in: block or NULL */
|
|
{
|
|
ut_ad(ptr && end_ptr);
|
|
|
|
if (block) {
|
|
fsp_init_file_page_low(block);
|
|
}
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Initializes the fsp system. */
|
|
UNIV_INTERN
|
|
void
|
|
fsp_init(void)
|
|
/*==========*/
|
|
{
|
|
/* Does nothing at the moment */
|
|
}
|
|
|
|
/**************************************************************************
|
|
Writes the space id and compressed page size to a tablespace header.
|
|
This function is used past the buffer pool when we in fil0fil.c create
|
|
a new single-table tablespace. */
|
|
UNIV_INTERN
|
|
void
|
|
fsp_header_init_fields(
|
|
/*===================*/
|
|
page_t* page, /* in/out: first page in the space */
|
|
ulint space_id, /* in: space id */
|
|
ulint flags) /* in: tablespace flags (FSP_SPACE_FLAGS):
|
|
0, or table->flags if newer than COMPACT */
|
|
{
|
|
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
|
|
ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
|
|
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
|
|
format, the tablespace flags should equal table->flags. */
|
|
ut_a(flags != DICT_TF_COMPACT);
|
|
|
|
mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page,
|
|
space_id);
|
|
mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page,
|
|
flags);
|
|
}
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
/**************************************************************************
|
|
Initializes the space header of a new created space and creates also the
|
|
insert buffer tree root if space == 0. */
|
|
UNIV_INTERN
|
|
void
|
|
fsp_header_init(
|
|
/*============*/
|
|
ulint space, /* in: space id */
|
|
ulint size, /* in: current size in blocks */
|
|
mtr_t* mtr) /* in: mini-transaction handle */
|
|
{
|
|
fsp_header_t* header;
|
|
buf_block_t* block;
|
|
page_t* page;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
|
|
ut_ad(mtr);
|
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
block = buf_page_create(space, 0, zip_size, mtr);
|
|
buf_page_get(space, zip_size, 0, RW_X_LATCH, mtr);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
/* The prior contents of the file page should be ignored */
|
|
|
|
fsp_init_file_page(block, mtr);
|
|
page = buf_block_get_frame(block);
|
|
|
|
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_TYPE_FSP_HDR,
|
|
MLOG_2BYTES, mtr);
|
|
|
|
header = FSP_HEADER_OFFSET + page;
|
|
|
|
mlog_write_ulint(header + FSP_SPACE_ID, space, MLOG_4BYTES, mtr);
|
|
mlog_write_ulint(header + FSP_NOT_USED, 0, MLOG_4BYTES, mtr);
|
|
|
|
mlog_write_ulint(header + FSP_SIZE, size, MLOG_4BYTES, mtr);
|
|
mlog_write_ulint(header + FSP_FREE_LIMIT, 0, MLOG_4BYTES, mtr);
|
|
mlog_write_ulint(header + FSP_SPACE_FLAGS, flags,
|
|
MLOG_4BYTES, mtr);
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED, 0, MLOG_4BYTES, mtr);
|
|
|
|
flst_init(header + FSP_FREE, mtr);
|
|
flst_init(header + FSP_FREE_FRAG, mtr);
|
|
flst_init(header + FSP_FULL_FRAG, mtr);
|
|
flst_init(header + FSP_SEG_INODES_FULL, mtr);
|
|
flst_init(header + FSP_SEG_INODES_FREE, mtr);
|
|
|
|
mlog_write_dulint(header + FSP_SEG_ID, ut_dulint_create(0, 1), mtr);
|
|
if (space == 0) {
|
|
fsp_fill_free_list(FALSE, space, header, mtr);
|
|
btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,
|
|
0, 0, ut_dulint_add(DICT_IBUF_ID_MIN, space),
|
|
dict_ind_redundant, mtr);
|
|
} else {
|
|
fsp_fill_free_list(TRUE, space, header, mtr);
|
|
}
|
|
}
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/**************************************************************************
|
|
Reads the space id from the first page of a tablespace. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fsp_header_get_space_id(
|
|
/*====================*/
|
|
/* out: space id, ULINT UNDEFINED if error */
|
|
const page_t* page) /* in: first page of a tablespace */
|
|
{
|
|
ulint fsp_id;
|
|
ulint id;
|
|
|
|
fsp_id = mach_read_from_4(FSP_HEADER_OFFSET + page + FSP_SPACE_ID);
|
|
|
|
id = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
|
|
|
|
if (id != fsp_id) {
|
|
fprintf(stderr,
|
|
"InnoDB: Error: space id in fsp header %lu,"
|
|
" but in the page header %lu\n",
|
|
(ulong) fsp_id, (ulong) id);
|
|
|
|
return(ULINT_UNDEFINED);
|
|
}
|
|
|
|
return(id);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reads the space flags from the first page of a tablespace. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fsp_header_get_flags(
|
|
/*=================*/
|
|
/* out: flags */
|
|
const page_t* page) /* in: first page of a tablespace */
|
|
{
|
|
ut_ad(!page_offset(page));
|
|
|
|
return(mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page));
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reads the compressed page size from the first page of a tablespace. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fsp_header_get_zip_size(
|
|
/*====================*/
|
|
/* out: compressed page size in bytes,
|
|
or 0 if uncompressed */
|
|
const page_t* page) /* in: first page of a tablespace */
|
|
{
|
|
ulint flags = fsp_header_get_flags(page);
|
|
|
|
return(dict_table_flags_to_zip_size(flags));
|
|
}
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
/**************************************************************************
|
|
Increases the space size field of a space. */
|
|
UNIV_INTERN
|
|
void
|
|
fsp_header_inc_size(
|
|
/*================*/
|
|
ulint space, /* in: space id */
|
|
ulint size_inc,/* in: size increment in pages */
|
|
mtr_t* mtr) /* in: mini-transaction handle */
|
|
{
|
|
fsp_header_t* header;
|
|
ulint size;
|
|
ulint flags;
|
|
|
|
ut_ad(mtr);
|
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
|
|
|
|
header = fsp_get_space_header(space,
|
|
dict_table_flags_to_zip_size(flags),
|
|
mtr);
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
mlog_write_ulint(header + FSP_SIZE, size + size_inc, MLOG_4BYTES,
|
|
mtr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Gets the current free limit of the system tablespace. The free limit
|
|
means the place of the first page which has never been put to the the
|
|
free list for allocation. The space above that address is initialized
|
|
to zero. Sets also the global variable log_fsp_current_free_limit. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fsp_header_get_free_limit(void)
|
|
/*===========================*/
|
|
/* out: free limit in megabytes */
|
|
{
|
|
fsp_header_t* header;
|
|
ulint limit;
|
|
mtr_t mtr;
|
|
|
|
mtr_start(&mtr);
|
|
|
|
mtr_x_lock(fil_space_get_latch(0, NULL), &mtr);
|
|
|
|
header = fsp_get_space_header(0, 0, &mtr);
|
|
|
|
limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, &mtr);
|
|
|
|
limit /= ((1024 * 1024) / UNIV_PAGE_SIZE);
|
|
|
|
log_fsp_current_free_limit_set_and_checkpoint(limit);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
return(limit);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Gets the size of the system tablespace from the tablespace header. If
|
|
we do not have an auto-extending data file, this should be equal to
|
|
the size of the data files. If there is an auto-extending data file,
|
|
this can be smaller. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fsp_header_get_tablespace_size(void)
|
|
/*================================*/
|
|
/* out: size in pages */
|
|
{
|
|
fsp_header_t* header;
|
|
ulint size;
|
|
mtr_t mtr;
|
|
|
|
mtr_start(&mtr);
|
|
|
|
mtr_x_lock(fil_space_get_latch(0, NULL), &mtr);
|
|
|
|
header = fsp_get_space_header(0, 0, &mtr);
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
return(size);
|
|
}
|
|
|
|
/***************************************************************************
|
|
Tries to extend a single-table tablespace so that a page would fit in the
|
|
data file. */
|
|
static
|
|
ibool
|
|
fsp_try_extend_data_file_with_pages(
|
|
/*================================*/
|
|
/* out: TRUE if success */
|
|
ulint space, /* in: space */
|
|
ulint page_no, /* in: page number */
|
|
fsp_header_t* header, /* in: space header */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ibool success;
|
|
ulint actual_size;
|
|
ulint size;
|
|
|
|
ut_a(space != 0);
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
ut_a(page_no >= size);
|
|
|
|
success = fil_extend_space_to_desired_size(&actual_size, space,
|
|
page_no + 1);
|
|
/* actual_size now has the space size in pages; it may be less than
|
|
we wanted if we ran out of disk space */
|
|
|
|
mlog_write_ulint(header + FSP_SIZE, actual_size, MLOG_4BYTES, mtr);
|
|
|
|
return(success);
|
|
}
|
|
|
|
/***************************************************************************
|
|
Tries to extend the last data file of a tablespace if it is auto-extending. */
|
|
static
|
|
ibool
|
|
fsp_try_extend_data_file(
|
|
/*=====================*/
|
|
/* out: FALSE if not auto-extending */
|
|
ulint* actual_increase,/* out: actual increase in pages, where
|
|
we measure the tablespace size from
|
|
what the header field says; it may be
|
|
the actual file size rounded down to
|
|
megabyte */
|
|
ulint space, /* in: space */
|
|
fsp_header_t* header, /* in: space header */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint size;
|
|
ulint zip_size;
|
|
ulint new_size;
|
|
ulint old_size;
|
|
ulint size_increase;
|
|
ulint actual_size;
|
|
ibool success;
|
|
|
|
*actual_increase = 0;
|
|
|
|
if (space == 0 && !srv_auto_extend_last_data_file) {
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
mach_read_from_4(header + FSP_SPACE_FLAGS));
|
|
|
|
old_size = size;
|
|
|
|
if (space == 0) {
|
|
if (!srv_last_file_size_max) {
|
|
size_increase = SRV_AUTO_EXTEND_INCREMENT;
|
|
} else {
|
|
if (srv_last_file_size_max
|
|
< srv_data_file_sizes[srv_n_data_files - 1]) {
|
|
|
|
fprintf(stderr,
|
|
"InnoDB: Error: Last data file size"
|
|
" is %lu, max size allowed %lu\n",
|
|
(ulong) srv_data_file_sizes[
|
|
srv_n_data_files - 1],
|
|
(ulong) srv_last_file_size_max);
|
|
}
|
|
|
|
size_increase = srv_last_file_size_max
|
|
- srv_data_file_sizes[srv_n_data_files - 1];
|
|
if (size_increase > SRV_AUTO_EXTEND_INCREMENT) {
|
|
size_increase = SRV_AUTO_EXTEND_INCREMENT;
|
|
}
|
|
}
|
|
} else {
|
|
/* We extend single-table tablespaces first one extent
|
|
at a time, but for bigger tablespaces more. It is not
|
|
enough to extend always by one extent, because some
|
|
extents are frag page extents. */
|
|
ulint extent_size; /* one megabyte, in pages */
|
|
|
|
if (!zip_size) {
|
|
extent_size = FSP_EXTENT_SIZE;
|
|
} else {
|
|
extent_size = FSP_EXTENT_SIZE
|
|
* UNIV_PAGE_SIZE / zip_size;
|
|
}
|
|
|
|
if (size < extent_size) {
|
|
/* Let us first extend the file to extent_size */
|
|
success = fsp_try_extend_data_file_with_pages(
|
|
space, extent_size - 1, header, mtr);
|
|
if (!success) {
|
|
new_size = mtr_read_ulint(header + FSP_SIZE,
|
|
MLOG_4BYTES, mtr);
|
|
|
|
*actual_increase = new_size - old_size;
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
size = extent_size;
|
|
}
|
|
|
|
if (size < 32 * extent_size) {
|
|
size_increase = extent_size;
|
|
} else {
|
|
/* Below in fsp_fill_free_list() we assume
|
|
that we add at most FSP_FREE_ADD extents at
|
|
a time */
|
|
size_increase = FSP_FREE_ADD * extent_size;
|
|
}
|
|
}
|
|
|
|
if (size_increase == 0) {
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
success = fil_extend_space_to_desired_size(&actual_size, space,
|
|
size + size_increase);
|
|
/* We ignore any fragments of a full megabyte when storing the size
|
|
to the space header */
|
|
|
|
if (!zip_size) {
|
|
new_size = ut_calc_align_down(actual_size,
|
|
(1024 * 1024) / UNIV_PAGE_SIZE);
|
|
} else {
|
|
new_size = ut_calc_align_down(actual_size,
|
|
(1024 * 1024) / zip_size);
|
|
}
|
|
mlog_write_ulint(header + FSP_SIZE, new_size, MLOG_4BYTES, mtr);
|
|
|
|
*actual_increase = new_size - old_size;
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Puts new extents to the free list if there are free extents above the free
|
|
limit. If an extent happens to contain an extent descriptor page, the extent
|
|
is put to the FSP_FREE_FRAG list with the page marked as used. */
|
|
static
|
|
void
|
|
fsp_fill_free_list(
|
|
/*===============*/
|
|
ibool init_space, /* in: TRUE if this is a single-table
|
|
tablespace and we are only initing
|
|
the tablespace's first extent
|
|
descriptor page and ibuf bitmap page;
|
|
then we do not allocate more extents */
|
|
ulint space, /* in: space */
|
|
fsp_header_t* header, /* in: space header */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint limit;
|
|
ulint size;
|
|
ulint zip_size;
|
|
xdes_t* descr;
|
|
ulint count = 0;
|
|
ulint frag_n_used;
|
|
ulint actual_increase;
|
|
ulint i;
|
|
mtr_t ibuf_mtr;
|
|
|
|
ut_ad(header && mtr);
|
|
ut_ad(page_offset(header) == FSP_HEADER_OFFSET);
|
|
|
|
/* Check if we can fill free list from above the free list limit */
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES, mtr);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
mach_read_from_4(FSP_SPACE_FLAGS + header));
|
|
ut_a(ut_is_2pow(zip_size));
|
|
ut_a(zip_size <= UNIV_PAGE_SIZE);
|
|
ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
|
|
|
|
if (space == 0 && srv_auto_extend_last_data_file
|
|
&& size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) {
|
|
|
|
/* Try to increase the last data file size */
|
|
fsp_try_extend_data_file(&actual_increase, space, header, mtr);
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
}
|
|
|
|
if (space != 0 && !init_space
|
|
&& size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) {
|
|
|
|
/* Try to increase the .ibd file size */
|
|
fsp_try_extend_data_file(&actual_increase, space, header, mtr);
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
}
|
|
|
|
i = limit;
|
|
|
|
while ((init_space && i < 1)
|
|
|| ((i + FSP_EXTENT_SIZE <= size) && (count < FSP_FREE_ADD))) {
|
|
|
|
ibool init_xdes;
|
|
if (zip_size) {
|
|
init_xdes = ut_2pow_remainder(i, zip_size) == 0;
|
|
} else {
|
|
init_xdes = ut_2pow_remainder(i, UNIV_PAGE_SIZE) == 0;
|
|
}
|
|
|
|
mlog_write_ulint(header + FSP_FREE_LIMIT, i + FSP_EXTENT_SIZE,
|
|
MLOG_4BYTES, mtr);
|
|
|
|
/* Update the free limit info in the log system and make
|
|
a checkpoint */
|
|
if (space == 0) {
|
|
ut_a(!zip_size);
|
|
log_fsp_current_free_limit_set_and_checkpoint(
|
|
(i + FSP_EXTENT_SIZE)
|
|
/ ((1024 * 1024) / UNIV_PAGE_SIZE));
|
|
}
|
|
|
|
if (UNIV_UNLIKELY(init_xdes)) {
|
|
|
|
buf_block_t* block;
|
|
|
|
/* We are going to initialize a new descriptor page
|
|
and a new ibuf bitmap page: the prior contents of the
|
|
pages should be ignored. */
|
|
|
|
if (i > 0) {
|
|
block = buf_page_create(
|
|
space, i, zip_size, mtr);
|
|
buf_page_get(space, zip_size, i,
|
|
RW_X_LATCH, mtr);
|
|
buf_block_dbg_add_level(block,
|
|
SYNC_FSP_PAGE);
|
|
|
|
fsp_init_file_page(block, mtr);
|
|
mlog_write_ulint(buf_block_get_frame(block)
|
|
+ FIL_PAGE_TYPE,
|
|
FIL_PAGE_TYPE_XDES,
|
|
MLOG_2BYTES, mtr);
|
|
}
|
|
|
|
/* Initialize the ibuf bitmap page in a separate
|
|
mini-transaction because it is low in the latching
|
|
order, and we must be able to release its latch
|
|
before returning from the fsp routine */
|
|
|
|
mtr_start(&ibuf_mtr);
|
|
|
|
block = buf_page_create(space,
|
|
i + FSP_IBUF_BITMAP_OFFSET,
|
|
zip_size, &ibuf_mtr);
|
|
buf_page_get(space, zip_size,
|
|
i + FSP_IBUF_BITMAP_OFFSET,
|
|
RW_X_LATCH, &ibuf_mtr);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
fsp_init_file_page(block, &ibuf_mtr);
|
|
|
|
ibuf_bitmap_page_init(block, &ibuf_mtr);
|
|
|
|
mtr_commit(&ibuf_mtr);
|
|
}
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, i,
|
|
mtr);
|
|
xdes_init(descr, mtr);
|
|
|
|
#if UNIV_PAGE_SIZE % FSP_EXTENT_SIZE
|
|
# error "UNIV_PAGE_SIZE % FSP_EXTENT_SIZE != 0"
|
|
#endif
|
|
#if PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE
|
|
# error "PAGE_ZIP_MIN_SIZE % FSP_EXTENT_SIZE != 0"
|
|
#endif
|
|
|
|
if (UNIV_UNLIKELY(init_xdes)) {
|
|
|
|
/* The first page in the extent is a descriptor page
|
|
and the second is an ibuf bitmap page: mark them
|
|
used */
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, 0, FALSE, mtr);
|
|
xdes_set_bit(descr, XDES_FREE_BIT,
|
|
FSP_IBUF_BITMAP_OFFSET, FALSE, mtr);
|
|
xdes_set_state(descr, XDES_FREE_FRAG, mtr);
|
|
|
|
flst_add_last(header + FSP_FREE_FRAG,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED,
|
|
MLOG_4BYTES, mtr);
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED,
|
|
frag_n_used + 2, MLOG_4BYTES, mtr);
|
|
} else {
|
|
flst_add_last(header + FSP_FREE,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
count++;
|
|
}
|
|
|
|
i += FSP_EXTENT_SIZE;
|
|
}
|
|
}
|
|
|
|
/**************************************************************************
|
|
Allocates a new free extent. */
|
|
static
|
|
xdes_t*
|
|
fsp_alloc_free_extent(
|
|
/*==================*/
|
|
/* out: extent descriptor, NULL if cannot be
|
|
allocated */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint hint, /* in: hint of which extent would be desirable: any
|
|
page offset in the extent goes; the hint must not
|
|
be > FSP_FREE_LIMIT */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
fsp_header_t* header;
|
|
fil_addr_t first;
|
|
xdes_t* descr;
|
|
|
|
ut_ad(mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, mtr);
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, hint, mtr);
|
|
|
|
if (descr && (xdes_get_state(descr, mtr) == XDES_FREE)) {
|
|
/* Ok, we can take this extent */
|
|
} else {
|
|
/* Take the first extent in the free list */
|
|
first = flst_get_first(header + FSP_FREE, mtr);
|
|
|
|
if (fil_addr_is_null(first)) {
|
|
fsp_fill_free_list(FALSE, space, header, mtr);
|
|
|
|
first = flst_get_first(header + FSP_FREE, mtr);
|
|
}
|
|
|
|
if (fil_addr_is_null(first)) {
|
|
|
|
return(NULL); /* No free extents left */
|
|
}
|
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
|
|
}
|
|
|
|
flst_remove(header + FSP_FREE, descr + XDES_FLST_NODE, mtr);
|
|
|
|
return(descr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Allocates a single free page from a space. The page is marked as used. */
|
|
static
|
|
ulint
|
|
fsp_alloc_free_page(
|
|
/*================*/
|
|
/* out: the page offset, FIL_NULL if no page could
|
|
be allocated */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint hint, /* in: hint of which page would be desirable */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
fsp_header_t* header;
|
|
fil_addr_t first;
|
|
xdes_t* descr;
|
|
buf_block_t* block;
|
|
ulint free;
|
|
ulint frag_n_used;
|
|
ulint page_no;
|
|
ulint space_size;
|
|
ibool success;
|
|
|
|
ut_ad(mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, mtr);
|
|
|
|
/* Get the hinted descriptor */
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, hint, mtr);
|
|
|
|
if (descr && (xdes_get_state(descr, mtr) == XDES_FREE_FRAG)) {
|
|
/* Ok, we can take this extent */
|
|
} else {
|
|
/* Else take the first extent in free_frag list */
|
|
first = flst_get_first(header + FSP_FREE_FRAG, mtr);
|
|
|
|
if (fil_addr_is_null(first)) {
|
|
/* There are no partially full fragments: allocate
|
|
a free extent and add it to the FREE_FRAG list. NOTE
|
|
that the allocation may have as a side-effect that an
|
|
extent containing a descriptor page is added to the
|
|
FREE_FRAG list. But we will allocate our page from the
|
|
the free extent anyway. */
|
|
|
|
descr = fsp_alloc_free_extent(space, zip_size,
|
|
hint, mtr);
|
|
|
|
if (descr == NULL) {
|
|
/* No free space left */
|
|
|
|
return(FIL_NULL);
|
|
}
|
|
|
|
xdes_set_state(descr, XDES_FREE_FRAG, mtr);
|
|
flst_add_last(header + FSP_FREE_FRAG,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
} else {
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
first, mtr);
|
|
}
|
|
|
|
/* Reset the hint */
|
|
hint = 0;
|
|
}
|
|
|
|
/* Now we have in descr an extent with at least one free page. Look
|
|
for a free page in the extent. */
|
|
|
|
free = xdes_find_bit(descr, XDES_FREE_BIT, TRUE,
|
|
hint % FSP_EXTENT_SIZE, mtr);
|
|
if (free == ULINT_UNDEFINED) {
|
|
|
|
ut_print_buf(stderr, ((byte*)descr) - 500, 1000);
|
|
putc('\n', stderr);
|
|
|
|
ut_error;
|
|
}
|
|
|
|
page_no = xdes_get_offset(descr) + free;
|
|
|
|
space_size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
if (space_size <= page_no) {
|
|
/* It must be that we are extending a single-table tablespace
|
|
whose size is still < 64 pages */
|
|
|
|
ut_a(space != 0);
|
|
if (page_no >= FSP_EXTENT_SIZE) {
|
|
fprintf(stderr,
|
|
"InnoDB: Error: trying to extend a"
|
|
" single-table tablespace %lu\n"
|
|
"InnoDB: by single page(s) though the"
|
|
" space size %lu. Page no %lu.\n",
|
|
(ulong) space, (ulong) space_size,
|
|
(ulong) page_no);
|
|
return(FIL_NULL);
|
|
}
|
|
success = fsp_try_extend_data_file_with_pages(space, page_no,
|
|
header, mtr);
|
|
if (!success) {
|
|
/* No disk space left */
|
|
return(FIL_NULL);
|
|
}
|
|
}
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, free, FALSE, mtr);
|
|
|
|
/* Update the FRAG_N_USED field */
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
|
|
mtr);
|
|
frag_n_used++;
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED, frag_n_used, MLOG_4BYTES,
|
|
mtr);
|
|
if (xdes_is_full(descr, mtr)) {
|
|
/* The fragment is full: move it to another list */
|
|
flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
|
|
mtr);
|
|
xdes_set_state(descr, XDES_FULL_FRAG, mtr);
|
|
|
|
flst_add_last(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE,
|
|
mtr);
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED,
|
|
frag_n_used - FSP_EXTENT_SIZE, MLOG_4BYTES,
|
|
mtr);
|
|
}
|
|
|
|
/* Initialize the allocated page to the buffer pool, so that it can
|
|
be obtained immediately with buf_page_get without need for a disk
|
|
read. */
|
|
|
|
buf_page_create(space, page_no, zip_size, mtr);
|
|
|
|
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
/* Prior contents of the page should be ignored */
|
|
fsp_init_file_page(block, mtr);
|
|
|
|
return(page_no);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Frees a single page of a space. The page is marked as free and clean. */
|
|
static
|
|
void
|
|
fsp_free_page(
|
|
/*==========*/
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page, /* in: page offset */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
fsp_header_t* header;
|
|
xdes_t* descr;
|
|
ulint state;
|
|
ulint frag_n_used;
|
|
|
|
ut_ad(mtr);
|
|
|
|
/* fprintf(stderr, "Freeing page %lu in space %lu\n", page, space); */
|
|
|
|
header = fsp_get_space_header(space, zip_size, mtr);
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, page, mtr);
|
|
|
|
state = xdes_get_state(descr, mtr);
|
|
|
|
if (state != XDES_FREE_FRAG && state != XDES_FULL_FRAG) {
|
|
fprintf(stderr,
|
|
"InnoDB: Error: File space extent descriptor"
|
|
" of page %lu has state %lu\n",
|
|
(ulong) page,
|
|
(ulong) state);
|
|
fputs("InnoDB: Dump of descriptor: ", stderr);
|
|
ut_print_buf(stderr, ((byte*)descr) - 50, 200);
|
|
putc('\n', stderr);
|
|
|
|
if (state == XDES_FREE) {
|
|
/* We put here some fault tolerance: if the page
|
|
is already free, return without doing anything! */
|
|
|
|
return;
|
|
}
|
|
|
|
ut_error;
|
|
}
|
|
|
|
if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
|
|
fprintf(stderr,
|
|
"InnoDB: Error: File space extent descriptor"
|
|
" of page %lu says it is free\n"
|
|
"InnoDB: Dump of descriptor: ", (ulong) page);
|
|
ut_print_buf(stderr, ((byte*)descr) - 50, 200);
|
|
putc('\n', stderr);
|
|
|
|
/* We put here some fault tolerance: if the page
|
|
is already free, return without doing anything! */
|
|
|
|
return;
|
|
}
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr);
|
|
xdes_set_bit(descr, XDES_CLEAN_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr);
|
|
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
|
|
mtr);
|
|
if (state == XDES_FULL_FRAG) {
|
|
/* The fragment was full: move it to another list */
|
|
flst_remove(header + FSP_FULL_FRAG, descr + XDES_FLST_NODE,
|
|
mtr);
|
|
xdes_set_state(descr, XDES_FREE_FRAG, mtr);
|
|
flst_add_last(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
|
|
mtr);
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED,
|
|
frag_n_used + FSP_EXTENT_SIZE - 1,
|
|
MLOG_4BYTES, mtr);
|
|
} else {
|
|
ut_a(frag_n_used > 0);
|
|
mlog_write_ulint(header + FSP_FRAG_N_USED, frag_n_used - 1,
|
|
MLOG_4BYTES, mtr);
|
|
}
|
|
|
|
if (xdes_is_free(descr, mtr)) {
|
|
/* The extent has become free: move it to another list */
|
|
flst_remove(header + FSP_FREE_FRAG, descr + XDES_FLST_NODE,
|
|
mtr);
|
|
fsp_free_extent(space, zip_size, page, mtr);
|
|
}
|
|
}
|
|
|
|
/**************************************************************************
|
|
Returns an extent to the free list of a space. */
|
|
static
|
|
void
|
|
fsp_free_extent(
|
|
/*============*/
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page, /* in: page offset in the extent */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
fsp_header_t* header;
|
|
xdes_t* descr;
|
|
|
|
ut_ad(mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, mtr);
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(header, space, page, mtr);
|
|
|
|
if (xdes_get_state(descr, mtr) == XDES_FREE) {
|
|
|
|
ut_print_buf(stderr, (byte*)descr - 500, 1000);
|
|
putc('\n', stderr);
|
|
|
|
ut_error;
|
|
}
|
|
|
|
xdes_init(descr, mtr);
|
|
|
|
flst_add_last(header + FSP_FREE, descr + XDES_FLST_NODE, mtr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Returns the nth inode slot on an inode page. */
|
|
UNIV_INLINE
|
|
fseg_inode_t*
|
|
fsp_seg_inode_page_get_nth_inode(
|
|
/*=============================*/
|
|
/* out: segment inode */
|
|
page_t* page, /* in: segment inode page */
|
|
ulint i, /* in: inode index on page */
|
|
ulint zip_size __attribute__((unused)),
|
|
/* in: compressed page size, or 0 */
|
|
mtr_t* mtr __attribute__((unused)))
|
|
/* in: mini-transaction handle */
|
|
{
|
|
ut_ad(i < FSP_SEG_INODES_PER_PAGE(zip_size));
|
|
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
|
|
|
|
return(page + FSEG_ARR_OFFSET + FSEG_INODE_SIZE * i);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Looks for a used segment inode on a segment inode page. */
|
|
static
|
|
ulint
|
|
fsp_seg_inode_page_find_used(
|
|
/*=========================*/
|
|
/* out: segment inode index, or ULINT_UNDEFINED
|
|
if not found */
|
|
page_t* page, /* in: segment inode page */
|
|
ulint zip_size,/* in: compressed page size, or 0 */
|
|
mtr_t* mtr) /* in: mini-transaction handle */
|
|
{
|
|
ulint i;
|
|
fseg_inode_t* inode;
|
|
|
|
for (i = 0; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) {
|
|
|
|
inode = fsp_seg_inode_page_get_nth_inode(
|
|
page, i, zip_size, mtr);
|
|
|
|
if (!ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) {
|
|
/* This is used */
|
|
|
|
return(i);
|
|
}
|
|
}
|
|
|
|
return(ULINT_UNDEFINED);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Looks for an unused segment inode on a segment inode page. */
|
|
static
|
|
ulint
|
|
fsp_seg_inode_page_find_free(
|
|
/*=========================*/
|
|
/* out: segment inode index, or ULINT_UNDEFINED
|
|
if not found */
|
|
page_t* page, /* in: segment inode page */
|
|
ulint i, /* in: search forward starting from this index */
|
|
ulint zip_size,/* in: compressed page size, or 0 */
|
|
mtr_t* mtr) /* in: mini-transaction handle */
|
|
{
|
|
fseg_inode_t* inode;
|
|
|
|
for (; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) {
|
|
|
|
inode = fsp_seg_inode_page_get_nth_inode(
|
|
page, i, zip_size, mtr);
|
|
|
|
if (ut_dulint_is_zero(mach_read_from_8(inode + FSEG_ID))) {
|
|
/* This is unused */
|
|
|
|
return(i);
|
|
}
|
|
}
|
|
|
|
return(ULINT_UNDEFINED);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Allocates a new file segment inode page. */
|
|
static
|
|
ibool
|
|
fsp_alloc_seg_inode_page(
|
|
/*=====================*/
|
|
/* out: TRUE if could be allocated */
|
|
fsp_header_t* space_header, /* in: space header */
|
|
mtr_t* mtr) /* in: mini-transaction handle */
|
|
{
|
|
fseg_inode_t* inode;
|
|
buf_block_t* block;
|
|
page_t* page;
|
|
ulint page_no;
|
|
ulint space;
|
|
ulint zip_size;
|
|
ulint i;
|
|
|
|
ut_ad(page_offset(space_header) == FSP_HEADER_OFFSET);
|
|
|
|
space = page_get_space_id(page_align(space_header));
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
mach_read_from_4(FSP_SPACE_FLAGS + space_header));
|
|
|
|
page_no = fsp_alloc_free_page(space, zip_size, 0, mtr);
|
|
|
|
if (page_no == FIL_NULL) {
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
block->check_index_page_at_flush = FALSE;
|
|
|
|
page = buf_block_get_frame(block);
|
|
|
|
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_INODE,
|
|
MLOG_2BYTES, mtr);
|
|
|
|
for (i = 0; i < FSP_SEG_INODES_PER_PAGE(zip_size); i++) {
|
|
|
|
inode = fsp_seg_inode_page_get_nth_inode(page, i,
|
|
zip_size, mtr);
|
|
|
|
mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr);
|
|
}
|
|
|
|
flst_add_last(space_header + FSP_SEG_INODES_FREE,
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
|
return(TRUE);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Allocates a new file segment inode. */
|
|
static
|
|
fseg_inode_t*
|
|
fsp_alloc_seg_inode(
|
|
/*================*/
|
|
/* out: segment inode, or NULL if
|
|
not enough space */
|
|
fsp_header_t* space_header, /* in: space header */
|
|
mtr_t* mtr) /* in: mini-transaction handle */
|
|
{
|
|
ulint page_no;
|
|
buf_block_t* block;
|
|
page_t* page;
|
|
fseg_inode_t* inode;
|
|
ibool success;
|
|
ulint zip_size;
|
|
ulint n;
|
|
|
|
ut_ad(page_offset(space_header) == FSP_HEADER_OFFSET);
|
|
|
|
if (flst_get_len(space_header + FSP_SEG_INODES_FREE, mtr) == 0) {
|
|
/* Allocate a new segment inode page */
|
|
|
|
success = fsp_alloc_seg_inode_page(space_header, mtr);
|
|
|
|
if (!success) {
|
|
|
|
return(NULL);
|
|
}
|
|
}
|
|
|
|
page_no = flst_get_first(space_header + FSP_SEG_INODES_FREE, mtr).page;
|
|
|
|
zip_size = dict_table_flags_to_zip_size(
|
|
mach_read_from_4(FSP_SPACE_FLAGS + space_header));
|
|
block = buf_page_get(page_get_space_id(page_align(space_header)),
|
|
zip_size, page_no, RW_X_LATCH, mtr);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
page = buf_block_get_frame(block);
|
|
|
|
n = fsp_seg_inode_page_find_free(page, 0, zip_size, mtr);
|
|
|
|
ut_a(n != ULINT_UNDEFINED);
|
|
|
|
inode = fsp_seg_inode_page_get_nth_inode(page, n, zip_size, mtr);
|
|
|
|
if (ULINT_UNDEFINED == fsp_seg_inode_page_find_free(page, n + 1,
|
|
zip_size, mtr)) {
|
|
/* There are no other unused headers left on the page: move it
|
|
to another list */
|
|
|
|
flst_remove(space_header + FSP_SEG_INODES_FREE,
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
|
|
|
flst_add_last(space_header + FSP_SEG_INODES_FULL,
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
|
}
|
|
|
|
return(inode);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Frees a file segment inode. */
|
|
static
|
|
void
|
|
fsp_free_seg_inode(
|
|
/*===============*/
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
mtr_t* mtr) /* in: mini-transaction handle */
|
|
{
|
|
page_t* page;
|
|
fsp_header_t* space_header;
|
|
|
|
page = page_align(inode);
|
|
|
|
space_header = fsp_get_space_header(space, zip_size, mtr);
|
|
|
|
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
|
|
|
|
if (ULINT_UNDEFINED
|
|
== fsp_seg_inode_page_find_free(page, 0, zip_size, mtr)) {
|
|
|
|
/* Move the page to another list */
|
|
|
|
flst_remove(space_header + FSP_SEG_INODES_FULL,
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
|
|
|
flst_add_last(space_header + FSP_SEG_INODES_FREE,
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
|
}
|
|
|
|
mlog_write_dulint(inode + FSEG_ID, ut_dulint_zero, mtr);
|
|
mlog_write_ulint(inode + FSEG_MAGIC_N, 0, MLOG_4BYTES, mtr);
|
|
|
|
if (ULINT_UNDEFINED
|
|
== fsp_seg_inode_page_find_used(page, zip_size, mtr)) {
|
|
|
|
/* There are no other used headers left on the page: free it */
|
|
|
|
flst_remove(space_header + FSP_SEG_INODES_FREE,
|
|
page + FSEG_INODE_PAGE_NODE, mtr);
|
|
|
|
fsp_free_page(space, zip_size, page_get_page_no(page), mtr);
|
|
}
|
|
}
|
|
|
|
/**************************************************************************
|
|
Returns the file segment inode, page x-latched. */
|
|
static
|
|
fseg_inode_t*
|
|
fseg_inode_get(
|
|
/*===========*/
|
|
/* out: segment inode, page x-latched */
|
|
fseg_header_t* header, /* in: segment header */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
fil_addr_t inode_addr;
|
|
fseg_inode_t* inode;
|
|
|
|
inode_addr.page = mach_read_from_4(header + FSEG_HDR_PAGE_NO);
|
|
inode_addr.boffset = mach_read_from_2(header + FSEG_HDR_OFFSET);
|
|
ut_ad(space == mach_read_from_4(header + FSEG_HDR_SPACE));
|
|
|
|
inode = fut_get_ptr(space, zip_size, inode_addr, RW_X_LATCH, mtr);
|
|
|
|
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
|
|
|
|
return(inode);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Gets the page number from the nth fragment page slot. */
|
|
UNIV_INLINE
|
|
ulint
|
|
fseg_get_nth_frag_page_no(
|
|
/*======================*/
|
|
/* out: page number, FIL_NULL if not in use */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
ulint n, /* in: slot index */
|
|
mtr_t* mtr __attribute__((unused))) /* in: mtr handle */
|
|
{
|
|
ut_ad(inode && mtr);
|
|
ut_ad(n < FSEG_FRAG_ARR_N_SLOTS);
|
|
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
|
|
return(mach_read_from_4(inode + FSEG_FRAG_ARR
|
|
+ n * FSEG_FRAG_SLOT_SIZE));
|
|
}
|
|
|
|
/**************************************************************************
|
|
Sets the page number in the nth fragment page slot. */
|
|
UNIV_INLINE
|
|
void
|
|
fseg_set_nth_frag_page_no(
|
|
/*======================*/
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
ulint n, /* in: slot index */
|
|
ulint page_no,/* in: page number to set */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ut_ad(inode && mtr);
|
|
ut_ad(n < FSEG_FRAG_ARR_N_SLOTS);
|
|
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
|
|
|
|
mlog_write_ulint(inode + FSEG_FRAG_ARR + n * FSEG_FRAG_SLOT_SIZE,
|
|
page_no, MLOG_4BYTES, mtr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Finds a fragment page slot which is free. */
|
|
static
|
|
ulint
|
|
fseg_find_free_frag_page_slot(
|
|
/*==========================*/
|
|
/* out: slot index; ULINT_UNDEFINED if none
|
|
found */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint i;
|
|
ulint page_no;
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
|
|
page_no = fseg_get_nth_frag_page_no(inode, i, mtr);
|
|
|
|
if (page_no == FIL_NULL) {
|
|
|
|
return(i);
|
|
}
|
|
}
|
|
|
|
return(ULINT_UNDEFINED);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Finds a fragment page slot which is used and last in the array. */
|
|
static
|
|
ulint
|
|
fseg_find_last_used_frag_page_slot(
|
|
/*===============================*/
|
|
/* out: slot index; ULINT_UNDEFINED if none
|
|
found */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint i;
|
|
ulint page_no;
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
|
|
page_no = fseg_get_nth_frag_page_no(
|
|
inode, FSEG_FRAG_ARR_N_SLOTS - i - 1, mtr);
|
|
|
|
if (page_no != FIL_NULL) {
|
|
|
|
return(FSEG_FRAG_ARR_N_SLOTS - i - 1);
|
|
}
|
|
}
|
|
|
|
return(ULINT_UNDEFINED);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Calculates reserved fragment page slots. */
|
|
static
|
|
ulint
|
|
fseg_get_n_frag_pages(
|
|
/*==================*/
|
|
/* out: number of fragment pages */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint i;
|
|
ulint count = 0;
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
|
|
if (FIL_NULL != fseg_get_nth_frag_page_no(inode, i, mtr)) {
|
|
count++;
|
|
}
|
|
}
|
|
|
|
return(count);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Creates a new segment. */
|
|
UNIV_INTERN
|
|
buf_block_t*
|
|
fseg_create_general(
|
|
/*================*/
|
|
/* out: the block where the segment header is placed,
|
|
x-latched, NULL if could not create segment
|
|
because of lack of space */
|
|
ulint space, /* in: space id */
|
|
ulint page, /* in: page where the segment header is placed: if
|
|
this is != 0, the page must belong to another segment,
|
|
if this is 0, a new page will be allocated and it
|
|
will belong to the created segment */
|
|
ulint byte_offset, /* in: byte offset of the created segment header
|
|
on the page */
|
|
ibool has_done_reservation, /* in: TRUE if the caller has already
|
|
done the reservation for the pages with
|
|
fsp_reserve_free_extents (at least 2 extents: one for
|
|
the inode and the other for the segment) then there is
|
|
no need to do the check for this individual
|
|
operation */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint flags;
|
|
ulint zip_size;
|
|
fsp_header_t* space_header;
|
|
fseg_inode_t* inode;
|
|
dulint seg_id;
|
|
buf_block_t* block = 0; /* remove warning */
|
|
fseg_header_t* header = 0; /* remove warning */
|
|
rw_lock_t* latch;
|
|
ibool success;
|
|
ulint n_reserved;
|
|
ulint i;
|
|
|
|
ut_ad(mtr);
|
|
ut_ad(byte_offset + FSEG_HEADER_SIZE
|
|
<= UNIV_PAGE_SIZE - FIL_PAGE_DATA_END);
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
if (page != 0) {
|
|
block = buf_page_get(space, zip_size, page, RW_X_LATCH, mtr);
|
|
header = byte_offset + buf_block_get_frame(block);
|
|
}
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
if (rw_lock_get_x_lock_count(latch) == 1) {
|
|
/* This thread did not own the latch before this call: free
|
|
excess pages from the insert buffer free list */
|
|
|
|
if (space == IBUF_SPACE_ID) {
|
|
ibuf_free_excess_pages();
|
|
}
|
|
}
|
|
|
|
if (!has_done_reservation) {
|
|
success = fsp_reserve_free_extents(&n_reserved, space, 2,
|
|
FSP_NORMAL, mtr);
|
|
if (!success) {
|
|
return(NULL);
|
|
}
|
|
}
|
|
|
|
space_header = fsp_get_space_header(space, zip_size, mtr);
|
|
|
|
inode = fsp_alloc_seg_inode(space_header, mtr);
|
|
|
|
if (inode == NULL) {
|
|
|
|
goto funct_exit;
|
|
}
|
|
|
|
/* Read the next segment id from space header and increment the
|
|
value in space header */
|
|
|
|
seg_id = mtr_read_dulint(space_header + FSP_SEG_ID, mtr);
|
|
|
|
mlog_write_dulint(space_header + FSP_SEG_ID, ut_dulint_add(seg_id, 1),
|
|
mtr);
|
|
|
|
mlog_write_dulint(inode + FSEG_ID, seg_id, mtr);
|
|
mlog_write_ulint(inode + FSEG_NOT_FULL_N_USED, 0, MLOG_4BYTES, mtr);
|
|
|
|
flst_init(inode + FSEG_FREE, mtr);
|
|
flst_init(inode + FSEG_NOT_FULL, mtr);
|
|
flst_init(inode + FSEG_FULL, mtr);
|
|
|
|
mlog_write_ulint(inode + FSEG_MAGIC_N, FSEG_MAGIC_N_VALUE,
|
|
MLOG_4BYTES, mtr);
|
|
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
|
|
fseg_set_nth_frag_page_no(inode, i, FIL_NULL, mtr);
|
|
}
|
|
|
|
if (page == 0) {
|
|
page = fseg_alloc_free_page_low(space, zip_size,
|
|
inode, 0, FSP_UP, mtr);
|
|
|
|
if (page == FIL_NULL) {
|
|
|
|
fsp_free_seg_inode(space, zip_size, inode, mtr);
|
|
|
|
goto funct_exit;
|
|
}
|
|
|
|
block = buf_page_get(space, zip_size, page, RW_X_LATCH, mtr);
|
|
header = byte_offset + buf_block_get_frame(block);
|
|
mlog_write_ulint(header - byte_offset + FIL_PAGE_TYPE,
|
|
FIL_PAGE_TYPE_SYS, MLOG_2BYTES, mtr);
|
|
}
|
|
|
|
mlog_write_ulint(header + FSEG_HDR_OFFSET,
|
|
page_offset(inode), MLOG_2BYTES, mtr);
|
|
|
|
mlog_write_ulint(header + FSEG_HDR_PAGE_NO,
|
|
page_get_page_no(page_align(inode)),
|
|
MLOG_4BYTES, mtr);
|
|
|
|
mlog_write_ulint(header + FSEG_HDR_SPACE, space, MLOG_4BYTES, mtr);
|
|
|
|
funct_exit:
|
|
if (!has_done_reservation) {
|
|
|
|
fil_space_release_free_extents(space, n_reserved);
|
|
}
|
|
|
|
return(block);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Creates a new segment. */
|
|
UNIV_INTERN
|
|
buf_block_t*
|
|
fseg_create(
|
|
/*========*/
|
|
/* out: the block where the segment header is placed,
|
|
x-latched, NULL if could not create segment
|
|
because of lack of space */
|
|
ulint space, /* in: space id */
|
|
ulint page, /* in: page where the segment header is placed: if
|
|
this is != 0, the page must belong to another segment,
|
|
if this is 0, a new page will be allocated and it
|
|
will belong to the created segment */
|
|
ulint byte_offset, /* in: byte offset of the created segment header
|
|
on the page */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
return(fseg_create_general(space, page, byte_offset, FALSE, mtr));
|
|
}
|
|
|
|
/**************************************************************************
|
|
Calculates the number of pages reserved by a segment, and how many pages are
|
|
currently used. */
|
|
static
|
|
ulint
|
|
fseg_n_reserved_pages_low(
|
|
/*======================*/
|
|
/* out: number of reserved pages */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
ulint* used, /* out: number of pages used (<= reserved) */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint ret;
|
|
|
|
ut_ad(inode && used && mtr);
|
|
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
|
|
|
|
*used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr)
|
|
+ FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_FULL, mtr)
|
|
+ fseg_get_n_frag_pages(inode, mtr);
|
|
|
|
ret = fseg_get_n_frag_pages(inode, mtr)
|
|
+ FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_FREE, mtr)
|
|
+ FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_NOT_FULL, mtr)
|
|
+ FSP_EXTENT_SIZE * flst_get_len(inode + FSEG_FULL, mtr);
|
|
|
|
return(ret);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Calculates the number of pages reserved by a segment, and how many pages are
|
|
currently used. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fseg_n_reserved_pages(
|
|
/*==================*/
|
|
/* out: number of reserved pages */
|
|
fseg_header_t* header, /* in: segment header */
|
|
ulint* used, /* out: number of pages used (<= reserved) */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint ret;
|
|
fseg_inode_t* inode;
|
|
ulint space;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
rw_lock_t* latch;
|
|
|
|
space = page_get_space_id(page_align(header));
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
|
|
|
ret = fseg_n_reserved_pages_low(inode, used, mtr);
|
|
|
|
return(ret);
|
|
}
|
|
|
|
/*************************************************************************
|
|
Tries to fill the free list of a segment with consecutive free extents.
|
|
This happens if the segment is big enough to allow extents in the free list,
|
|
the free list is empty, and the extents can be allocated consecutively from
|
|
the hint onward. */
|
|
static
|
|
void
|
|
fseg_fill_free_list(
|
|
/*================*/
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint hint, /* in: hint which extent would be good as
|
|
the first extent */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
xdes_t* descr;
|
|
ulint i;
|
|
dulint seg_id;
|
|
ulint reserved;
|
|
ulint used;
|
|
|
|
ut_ad(inode && mtr);
|
|
ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
|
|
|
reserved = fseg_n_reserved_pages_low(inode, &used, mtr);
|
|
|
|
if (reserved < FSEG_FREE_LIST_LIMIT * FSP_EXTENT_SIZE) {
|
|
|
|
/* The segment is too small to allow extents in free list */
|
|
|
|
return;
|
|
}
|
|
|
|
if (flst_get_len(inode + FSEG_FREE, mtr) > 0) {
|
|
/* Free list is not empty */
|
|
|
|
return;
|
|
}
|
|
|
|
for (i = 0; i < FSEG_FREE_LIST_MAX_LEN; i++) {
|
|
descr = xdes_get_descriptor(space, zip_size, hint, mtr);
|
|
|
|
if ((descr == NULL)
|
|
|| (XDES_FREE != xdes_get_state(descr, mtr))) {
|
|
|
|
/* We cannot allocate the desired extent: stop */
|
|
|
|
return;
|
|
}
|
|
|
|
descr = fsp_alloc_free_extent(space, zip_size, hint, mtr);
|
|
|
|
xdes_set_state(descr, XDES_FSEG, mtr);
|
|
|
|
seg_id = mtr_read_dulint(inode + FSEG_ID, mtr);
|
|
mlog_write_dulint(descr + XDES_ID, seg_id, mtr);
|
|
|
|
flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr);
|
|
hint += FSP_EXTENT_SIZE;
|
|
}
|
|
}
|
|
|
|
/*************************************************************************
|
|
Allocates a free extent for the segment: looks first in the free list of the
|
|
segment, then tries to allocate from the space free list. NOTE that the extent
|
|
returned still resides in the segment free list, it is not yet taken off it! */
|
|
static
|
|
xdes_t*
|
|
fseg_alloc_free_extent(
|
|
/*===================*/
|
|
/* out: allocated extent, still placed in the
|
|
segment free list, NULL if could
|
|
not be allocated */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
xdes_t* descr;
|
|
dulint seg_id;
|
|
fil_addr_t first;
|
|
|
|
ut_ad(!((page_offset(inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
|
|
|
if (flst_get_len(inode + FSEG_FREE, mtr) > 0) {
|
|
/* Segment free list is not empty, allocate from it */
|
|
|
|
first = flst_get_first(inode + FSEG_FREE, mtr);
|
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
|
|
} else {
|
|
/* Segment free list was empty, allocate from space */
|
|
descr = fsp_alloc_free_extent(space, zip_size, 0, mtr);
|
|
|
|
if (descr == NULL) {
|
|
|
|
return(NULL);
|
|
}
|
|
|
|
seg_id = mtr_read_dulint(inode + FSEG_ID, mtr);
|
|
|
|
xdes_set_state(descr, XDES_FSEG, mtr);
|
|
mlog_write_dulint(descr + XDES_ID, seg_id, mtr);
|
|
flst_add_last(inode + FSEG_FREE, descr + XDES_FLST_NODE, mtr);
|
|
|
|
/* Try to fill the segment free list */
|
|
fseg_fill_free_list(inode, space, zip_size,
|
|
xdes_get_offset(descr) + FSP_EXTENT_SIZE,
|
|
mtr);
|
|
}
|
|
|
|
return(descr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Allocates a single free page from a segment. This function implements
|
|
the intelligent allocation strategy which tries to minimize file space
|
|
fragmentation. */
|
|
static
|
|
ulint
|
|
fseg_alloc_free_page_low(
|
|
/*=====================*/
|
|
/* out: the allocated page number, FIL_NULL
|
|
if no page could be allocated */
|
|
ulint space, /* in: space */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
fseg_inode_t* seg_inode, /* in: segment inode */
|
|
ulint hint, /* in: hint of which page would be desirable */
|
|
byte direction, /* in: if the new page is needed because
|
|
of an index page split, and records are
|
|
inserted there in order, into which
|
|
direction they go alphabetically: FSP_DOWN,
|
|
FSP_UP, FSP_NO_DIR */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
fsp_header_t* space_header;
|
|
ulint space_size;
|
|
dulint seg_id;
|
|
ulint used;
|
|
ulint reserved;
|
|
xdes_t* descr; /* extent of the hinted page */
|
|
ulint ret_page; /* the allocated page offset, FIL_NULL
|
|
if could not be allocated */
|
|
xdes_t* ret_descr; /* the extent of the allocated page */
|
|
ibool frag_page_allocated = FALSE;
|
|
ibool success;
|
|
ulint n;
|
|
|
|
ut_ad(mtr);
|
|
ut_ad((direction >= FSP_UP) && (direction <= FSP_NO_DIR));
|
|
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
|
|
== FSEG_MAGIC_N_VALUE);
|
|
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
|
seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr);
|
|
|
|
ut_ad(!ut_dulint_is_zero(seg_id));
|
|
|
|
reserved = fseg_n_reserved_pages_low(seg_inode, &used, mtr);
|
|
|
|
space_header = fsp_get_space_header(space, zip_size, mtr);
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(space_header, space,
|
|
hint, mtr);
|
|
if (descr == NULL) {
|
|
/* Hint outside space or too high above free limit: reset
|
|
hint */
|
|
hint = 0;
|
|
descr = xdes_get_descriptor(space, zip_size, hint, mtr);
|
|
}
|
|
|
|
/* In the big if-else below we look for ret_page and ret_descr */
|
|
/*-------------------------------------------------------------*/
|
|
if ((xdes_get_state(descr, mtr) == XDES_FSEG)
|
|
&& (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID,
|
|
mtr), seg_id))
|
|
&& (xdes_get_bit(descr, XDES_FREE_BIT,
|
|
hint % FSP_EXTENT_SIZE, mtr) == TRUE)) {
|
|
|
|
/* 1. We can take the hinted page
|
|
=================================*/
|
|
ret_descr = descr;
|
|
ret_page = hint;
|
|
/*-----------------------------------------------------------*/
|
|
} else if ((xdes_get_state(descr, mtr) == XDES_FREE)
|
|
&& ((reserved - used) < reserved / FSEG_FILLFACTOR)
|
|
&& (used >= FSEG_FRAG_LIMIT)) {
|
|
|
|
/* 2. We allocate the free extent from space and can take
|
|
=========================================================
|
|
the hinted page
|
|
===============*/
|
|
ret_descr = fsp_alloc_free_extent(space, zip_size, hint, mtr);
|
|
|
|
ut_a(ret_descr == descr);
|
|
|
|
xdes_set_state(ret_descr, XDES_FSEG, mtr);
|
|
mlog_write_dulint(ret_descr + XDES_ID, seg_id, mtr);
|
|
flst_add_last(seg_inode + FSEG_FREE,
|
|
ret_descr + XDES_FLST_NODE, mtr);
|
|
|
|
/* Try to fill the segment free list */
|
|
fseg_fill_free_list(seg_inode, space, zip_size,
|
|
hint + FSP_EXTENT_SIZE, mtr);
|
|
ret_page = hint;
|
|
/*-----------------------------------------------------------*/
|
|
} else if ((direction != FSP_NO_DIR)
|
|
&& ((reserved - used) < reserved / FSEG_FILLFACTOR)
|
|
&& (used >= FSEG_FRAG_LIMIT)
|
|
&& (!!(ret_descr
|
|
= fseg_alloc_free_extent(seg_inode,
|
|
space, zip_size, mtr)))) {
|
|
|
|
/* 3. We take any free extent (which was already assigned above
|
|
===============================================================
|
|
in the if-condition to ret_descr) and take the lowest or
|
|
========================================================
|
|
highest page in it, depending on the direction
|
|
==============================================*/
|
|
ret_page = xdes_get_offset(ret_descr);
|
|
|
|
if (direction == FSP_DOWN) {
|
|
ret_page += FSP_EXTENT_SIZE - 1;
|
|
}
|
|
/*-----------------------------------------------------------*/
|
|
} else if ((xdes_get_state(descr, mtr) == XDES_FSEG)
|
|
&& (0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID,
|
|
mtr), seg_id))
|
|
&& (!xdes_is_full(descr, mtr))) {
|
|
|
|
/* 4. We can take the page from the same extent as the
|
|
======================================================
|
|
hinted page (and the extent already belongs to the
|
|
==================================================
|
|
segment)
|
|
========*/
|
|
ret_descr = descr;
|
|
ret_page = xdes_get_offset(ret_descr)
|
|
+ xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE,
|
|
hint % FSP_EXTENT_SIZE, mtr);
|
|
/*-----------------------------------------------------------*/
|
|
} else if (reserved - used > 0) {
|
|
/* 5. We take any unused page from the segment
|
|
==============================================*/
|
|
fil_addr_t first;
|
|
|
|
if (flst_get_len(seg_inode + FSEG_NOT_FULL, mtr) > 0) {
|
|
first = flst_get_first(seg_inode + FSEG_NOT_FULL,
|
|
mtr);
|
|
} else if (flst_get_len(seg_inode + FSEG_FREE, mtr) > 0) {
|
|
first = flst_get_first(seg_inode + FSEG_FREE, mtr);
|
|
} else {
|
|
ut_error;
|
|
return(FIL_NULL);
|
|
}
|
|
|
|
ret_descr = xdes_lst_get_descriptor(space, zip_size,
|
|
first, mtr);
|
|
ret_page = xdes_get_offset(ret_descr)
|
|
+ xdes_find_bit(ret_descr, XDES_FREE_BIT, TRUE,
|
|
0, mtr);
|
|
/*-----------------------------------------------------------*/
|
|
} else if (used < FSEG_FRAG_LIMIT) {
|
|
/* 6. We allocate an individual page from the space
|
|
===================================================*/
|
|
ret_page = fsp_alloc_free_page(space, zip_size, hint, mtr);
|
|
ret_descr = NULL;
|
|
|
|
frag_page_allocated = TRUE;
|
|
|
|
if (ret_page != FIL_NULL) {
|
|
/* Put the page in the fragment page array of the
|
|
segment */
|
|
n = fseg_find_free_frag_page_slot(seg_inode, mtr);
|
|
ut_a(n != FIL_NULL);
|
|
|
|
fseg_set_nth_frag_page_no(seg_inode, n, ret_page,
|
|
mtr);
|
|
}
|
|
/*-----------------------------------------------------------*/
|
|
} else {
|
|
/* 7. We allocate a new extent and take its first page
|
|
======================================================*/
|
|
ret_descr = fseg_alloc_free_extent(seg_inode,
|
|
space, zip_size, mtr);
|
|
|
|
if (ret_descr == NULL) {
|
|
ret_page = FIL_NULL;
|
|
} else {
|
|
ret_page = xdes_get_offset(ret_descr);
|
|
}
|
|
}
|
|
|
|
if (ret_page == FIL_NULL) {
|
|
/* Page could not be allocated */
|
|
|
|
return(FIL_NULL);
|
|
}
|
|
|
|
if (space != 0) {
|
|
space_size = fil_space_get_size(space);
|
|
|
|
if (space_size <= ret_page) {
|
|
/* It must be that we are extending a single-table
|
|
tablespace whose size is still < 64 pages */
|
|
|
|
if (ret_page >= FSP_EXTENT_SIZE) {
|
|
fprintf(stderr,
|
|
"InnoDB: Error (2): trying to extend"
|
|
" a single-table tablespace %lu\n"
|
|
"InnoDB: by single page(s) though"
|
|
" the space size %lu. Page no %lu.\n",
|
|
(ulong) space, (ulong) space_size,
|
|
(ulong) ret_page);
|
|
return(FIL_NULL);
|
|
}
|
|
|
|
success = fsp_try_extend_data_file_with_pages(
|
|
space, ret_page, space_header, mtr);
|
|
if (!success) {
|
|
/* No disk space left */
|
|
return(FIL_NULL);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!frag_page_allocated) {
|
|
/* Initialize the allocated page to buffer pool, so that it
|
|
can be obtained immediately with buf_page_get without need
|
|
for a disk read */
|
|
buf_block_t* block;
|
|
ulint zip_size = dict_table_flags_to_zip_size(
|
|
mach_read_from_4(FSP_SPACE_FLAGS + space_header));
|
|
|
|
block = buf_page_create(space, ret_page, zip_size, mtr);
|
|
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
|
|
|
|
if (UNIV_UNLIKELY(block != buf_page_get(space, zip_size,
|
|
ret_page, RW_X_LATCH,
|
|
mtr))) {
|
|
ut_error;
|
|
}
|
|
|
|
/* The prior contents of the page should be ignored */
|
|
fsp_init_file_page(block, mtr);
|
|
|
|
/* At this point we know the extent and the page offset.
|
|
The extent is still in the appropriate list (FSEG_NOT_FULL
|
|
or FSEG_FREE), and the page is not yet marked as used. */
|
|
|
|
ut_ad(xdes_get_descriptor(space, zip_size, ret_page, mtr)
|
|
== ret_descr);
|
|
ut_ad(xdes_get_bit(ret_descr, XDES_FREE_BIT,
|
|
ret_page % FSP_EXTENT_SIZE, mtr) == TRUE);
|
|
|
|
fseg_mark_page_used(seg_inode, space, zip_size, ret_page, mtr);
|
|
}
|
|
|
|
buf_reset_check_index_page_at_flush(space, ret_page);
|
|
|
|
return(ret_page);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Allocates a single free page from a segment. This function implements
|
|
the intelligent allocation strategy which tries to minimize file space
|
|
fragmentation. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fseg_alloc_free_page_general(
|
|
/*=========================*/
|
|
/* out: allocated page offset, FIL_NULL if no
|
|
page could be allocated */
|
|
fseg_header_t* seg_header,/* in: segment header */
|
|
ulint hint, /* in: hint of which page would be desirable */
|
|
byte direction,/* in: if the new page is needed because
|
|
of an index page split, and records are
|
|
inserted there in order, into which
|
|
direction they go alphabetically: FSP_DOWN,
|
|
FSP_UP, FSP_NO_DIR */
|
|
ibool has_done_reservation, /* in: TRUE if the caller has
|
|
already done the reservation for the page
|
|
with fsp_reserve_free_extents, then there
|
|
is no need to do the check for this individual
|
|
page */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
fseg_inode_t* inode;
|
|
ulint space;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
rw_lock_t* latch;
|
|
ibool success;
|
|
ulint page_no;
|
|
ulint n_reserved;
|
|
|
|
space = page_get_space_id(page_align(seg_header));
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
if (rw_lock_get_x_lock_count(latch) == 1) {
|
|
/* This thread did not own the latch before this call: free
|
|
excess pages from the insert buffer free list */
|
|
|
|
if (space == IBUF_SPACE_ID) {
|
|
ibuf_free_excess_pages();
|
|
}
|
|
}
|
|
|
|
inode = fseg_inode_get(seg_header, space, zip_size, mtr);
|
|
|
|
if (!has_done_reservation) {
|
|
success = fsp_reserve_free_extents(&n_reserved, space, 2,
|
|
FSP_NORMAL, mtr);
|
|
if (!success) {
|
|
return(FIL_NULL);
|
|
}
|
|
}
|
|
|
|
page_no = fseg_alloc_free_page_low(space, zip_size,
|
|
inode, hint, direction, mtr);
|
|
if (!has_done_reservation) {
|
|
fil_space_release_free_extents(space, n_reserved);
|
|
}
|
|
|
|
return(page_no);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Allocates a single free page from a segment. This function implements
|
|
the intelligent allocation strategy which tries to minimize file space
|
|
fragmentation. */
|
|
UNIV_INTERN
|
|
ulint
|
|
fseg_alloc_free_page(
|
|
/*=================*/
|
|
/* out: allocated page offset, FIL_NULL if no
|
|
page could be allocated */
|
|
fseg_header_t* seg_header,/* in: segment header */
|
|
ulint hint, /* in: hint of which page would be desirable */
|
|
byte direction,/* in: if the new page is needed because
|
|
of an index page split, and records are
|
|
inserted there in order, into which
|
|
direction they go alphabetically: FSP_DOWN,
|
|
FSP_UP, FSP_NO_DIR */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
return(fseg_alloc_free_page_general(seg_header, hint, direction,
|
|
FALSE, mtr));
|
|
}
|
|
|
|
/**************************************************************************
|
|
Checks that we have at least 2 frag pages free in the first extent of a
|
|
single-table tablespace, and they are also physically initialized to the data
|
|
file. That is we have already extended the data file so that those pages are
|
|
inside the data file. If not, this function extends the tablespace with
|
|
pages. */
|
|
static
|
|
ibool
|
|
fsp_reserve_free_pages(
|
|
/*===================*/
|
|
/* out: TRUE if there were >= 3 free
|
|
pages, or we were able to extend */
|
|
ulint space, /* in: space id, must be != 0 */
|
|
fsp_header_t* space_header, /* in: header of that space,
|
|
x-latched */
|
|
ulint size, /* in: size of the tablespace in pages,
|
|
must be < FSP_EXTENT_SIZE / 2 */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
xdes_t* descr;
|
|
ulint n_used;
|
|
|
|
ut_a(space != 0);
|
|
ut_a(size < FSP_EXTENT_SIZE / 2);
|
|
|
|
descr = xdes_get_descriptor_with_space_hdr(space_header, space, 0,
|
|
mtr);
|
|
n_used = xdes_get_n_used(descr, mtr);
|
|
|
|
ut_a(n_used <= size);
|
|
|
|
if (size >= n_used + 2) {
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
return(fsp_try_extend_data_file_with_pages(space, n_used + 1,
|
|
space_header, mtr));
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reserves free pages from a tablespace. All mini-transactions which may
|
|
use several pages from the tablespace should call this function beforehand
|
|
and reserve enough free extents so that they certainly will be able
|
|
to do their operation, like a B-tree page split, fully. Reservations
|
|
must be released with function fil_space_release_free_extents!
|
|
|
|
The alloc_type below has the following meaning: FSP_NORMAL means an
|
|
operation which will probably result in more space usage, like an
|
|
insert in a B-tree; FSP_UNDO means allocation to undo logs: if we are
|
|
deleting rows, then this allocation will in the long run result in
|
|
less space usage (after a purge); FSP_CLEANING means allocation done
|
|
in a physical record delete (like in a purge) or other cleaning operation
|
|
which will result in less space usage in the long run. We prefer the latter
|
|
two types of allocation: when space is scarce, FSP_NORMAL allocations
|
|
will not succeed, but the latter two allocations will succeed, if possible.
|
|
The purpose is to avoid dead end where the database is full but the
|
|
user cannot free any space because these freeing operations temporarily
|
|
reserve some space.
|
|
|
|
Single-table tablespaces whose size is < 32 pages are a special case. In this
|
|
function we would liberally reserve several 64 page extents for every page
|
|
split or merge in a B-tree. But we do not want to waste disk space if the table
|
|
only occupies < 32 pages. That is why we apply different rules in that special
|
|
case, just ensuring that there are 3 free pages available. */
|
|
UNIV_INTERN
|
|
ibool
|
|
fsp_reserve_free_extents(
|
|
/*=====================*/
|
|
/* out: TRUE if we were able to make the reservation */
|
|
ulint* n_reserved,/* out: number of extents actually reserved; if we
|
|
return TRUE and the tablespace size is < 64 pages,
|
|
then this can be 0, otherwise it is n_ext */
|
|
ulint space, /* in: space id */
|
|
ulint n_ext, /* in: number of extents to reserve */
|
|
ulint alloc_type,/* in: FSP_NORMAL, FSP_UNDO, or FSP_CLEANING */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
fsp_header_t* space_header;
|
|
rw_lock_t* latch;
|
|
ulint n_free_list_ext;
|
|
ulint free_limit;
|
|
ulint size;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
ulint n_free;
|
|
ulint n_free_up;
|
|
ulint reserve;
|
|
ibool success;
|
|
ulint n_pages_added;
|
|
|
|
ut_ad(mtr);
|
|
*n_reserved = n_ext;
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
space_header = fsp_get_space_header(space, zip_size, mtr);
|
|
try_again:
|
|
size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, mtr);
|
|
|
|
if (size < FSP_EXTENT_SIZE / 2) {
|
|
/* Use different rules for small single-table tablespaces */
|
|
*n_reserved = 0;
|
|
return(fsp_reserve_free_pages(space, space_header, size, mtr));
|
|
}
|
|
|
|
n_free_list_ext = flst_get_len(space_header + FSP_FREE, mtr);
|
|
|
|
free_limit = mtr_read_ulint(space_header + FSP_FREE_LIMIT,
|
|
MLOG_4BYTES, mtr);
|
|
|
|
/* Below we play safe when counting free extents above the free limit:
|
|
some of them will contain extent descriptor pages, and therefore
|
|
will not be free extents */
|
|
|
|
n_free_up = (size - free_limit) / FSP_EXTENT_SIZE;
|
|
|
|
if (n_free_up > 0) {
|
|
n_free_up--;
|
|
if (!zip_size) {
|
|
n_free_up -= n_free_up
|
|
/ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE);
|
|
} else {
|
|
n_free_up -= n_free_up
|
|
/ (zip_size / FSP_EXTENT_SIZE);
|
|
}
|
|
}
|
|
|
|
n_free = n_free_list_ext + n_free_up;
|
|
|
|
if (alloc_type == FSP_NORMAL) {
|
|
/* We reserve 1 extent + 0.5 % of the space size to undo logs
|
|
and 1 extent + 0.5 % to cleaning operations; NOTE: this source
|
|
code is duplicated in the function below! */
|
|
|
|
reserve = 2 + ((size / FSP_EXTENT_SIZE) * 2) / 200;
|
|
|
|
if (n_free <= reserve + n_ext) {
|
|
|
|
goto try_to_extend;
|
|
}
|
|
} else if (alloc_type == FSP_UNDO) {
|
|
/* We reserve 0.5 % of the space size to cleaning operations */
|
|
|
|
reserve = 1 + ((size / FSP_EXTENT_SIZE) * 1) / 200;
|
|
|
|
if (n_free <= reserve + n_ext) {
|
|
|
|
goto try_to_extend;
|
|
}
|
|
} else {
|
|
ut_a(alloc_type == FSP_CLEANING);
|
|
}
|
|
|
|
success = fil_space_reserve_free_extents(space, n_free, n_ext);
|
|
|
|
if (success) {
|
|
return(TRUE);
|
|
}
|
|
try_to_extend:
|
|
success = fsp_try_extend_data_file(&n_pages_added, space,
|
|
space_header, mtr);
|
|
if (success && n_pages_added > 0) {
|
|
|
|
goto try_again;
|
|
}
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
/**************************************************************************
|
|
This function should be used to get information on how much we still
|
|
will be able to insert new data to the database without running out the
|
|
tablespace. Only free extents are taken into account and we also subtract
|
|
the safety margin required by the above function fsp_reserve_free_extents. */
|
|
UNIV_INTERN
|
|
ullint
|
|
fsp_get_available_space_in_free_extents(
|
|
/*====================================*/
|
|
/* out: available space in kB */
|
|
ulint space) /* in: space id */
|
|
{
|
|
fsp_header_t* space_header;
|
|
ulint n_free_list_ext;
|
|
ulint free_limit;
|
|
ulint size;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
ulint n_free;
|
|
ulint n_free_up;
|
|
ulint reserve;
|
|
rw_lock_t* latch;
|
|
mtr_t mtr;
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex));
|
|
|
|
mtr_start(&mtr);
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
space_header = fsp_get_space_header(space, zip_size, &mtr);
|
|
|
|
size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, &mtr);
|
|
|
|
n_free_list_ext = flst_get_len(space_header + FSP_FREE, &mtr);
|
|
|
|
free_limit = mtr_read_ulint(space_header + FSP_FREE_LIMIT,
|
|
MLOG_4BYTES, &mtr);
|
|
mtr_commit(&mtr);
|
|
|
|
if (size < FSP_EXTENT_SIZE) {
|
|
ut_a(space != 0); /* This must be a single-table
|
|
tablespace */
|
|
|
|
return(0); /* TODO: count free frag pages and
|
|
return a value based on that */
|
|
}
|
|
|
|
/* Below we play safe when counting free extents above the free limit:
|
|
some of them will contain extent descriptor pages, and therefore
|
|
will not be free extents */
|
|
|
|
n_free_up = (size - free_limit) / FSP_EXTENT_SIZE;
|
|
|
|
if (n_free_up > 0) {
|
|
n_free_up--;
|
|
if (!zip_size) {
|
|
n_free_up -= n_free_up
|
|
/ (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE);
|
|
} else {
|
|
n_free_up -= n_free_up
|
|
/ (zip_size / FSP_EXTENT_SIZE);
|
|
}
|
|
}
|
|
|
|
n_free = n_free_list_ext + n_free_up;
|
|
|
|
/* We reserve 1 extent + 0.5 % of the space size to undo logs
|
|
and 1 extent + 0.5 % to cleaning operations; NOTE: this source
|
|
code is duplicated in the function above! */
|
|
|
|
reserve = 2 + ((size / FSP_EXTENT_SIZE) * 2) / 200;
|
|
|
|
if (reserve > n_free) {
|
|
return(0);
|
|
}
|
|
|
|
if (!zip_size) {
|
|
return((ullint) (n_free - reserve)
|
|
* FSP_EXTENT_SIZE
|
|
* (UNIV_PAGE_SIZE / 1024));
|
|
} else {
|
|
return((ullint) (n_free - reserve)
|
|
* FSP_EXTENT_SIZE
|
|
* (zip_size / 1024));
|
|
}
|
|
}
|
|
|
|
/************************************************************************
|
|
Marks a page used. The page must reside within the extents of the given
|
|
segment. */
|
|
static
|
|
void
|
|
fseg_mark_page_used(
|
|
/*================*/
|
|
fseg_inode_t* seg_inode,/* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page, /* in: page offset */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
xdes_t* descr;
|
|
ulint not_full_n_used;
|
|
|
|
ut_ad(seg_inode && mtr);
|
|
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
|
|
|
descr = xdes_get_descriptor(space, zip_size, page, mtr);
|
|
|
|
ut_ad(mtr_read_ulint(seg_inode + FSEG_ID, MLOG_4BYTES, mtr)
|
|
== mtr_read_ulint(descr + XDES_ID, MLOG_4BYTES, mtr));
|
|
|
|
if (xdes_is_free(descr, mtr)) {
|
|
/* We move the extent from the free list to the
|
|
NOT_FULL list */
|
|
flst_remove(seg_inode + FSEG_FREE, descr + XDES_FLST_NODE,
|
|
mtr);
|
|
flst_add_last(seg_inode + FSEG_NOT_FULL,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
}
|
|
|
|
ut_ad(xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)
|
|
== TRUE);
|
|
/* We mark the page as used */
|
|
xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, FALSE, mtr);
|
|
|
|
not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
|
MLOG_4BYTES, mtr);
|
|
not_full_n_used++;
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED, not_full_n_used,
|
|
MLOG_4BYTES, mtr);
|
|
if (xdes_is_full(descr, mtr)) {
|
|
/* We move the extent from the NOT_FULL list to the
|
|
FULL list */
|
|
flst_remove(seg_inode + FSEG_NOT_FULL,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
flst_add_last(seg_inode + FSEG_FULL,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
|
not_full_n_used - FSP_EXTENT_SIZE,
|
|
MLOG_4BYTES, mtr);
|
|
}
|
|
}
|
|
|
|
/**************************************************************************
|
|
Frees a single page of a segment. */
|
|
static
|
|
void
|
|
fseg_free_page_low(
|
|
/*===============*/
|
|
fseg_inode_t* seg_inode, /* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page, /* in: page offset */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
xdes_t* descr;
|
|
ulint not_full_n_used;
|
|
ulint state;
|
|
dulint descr_id;
|
|
dulint seg_id;
|
|
ulint i;
|
|
|
|
ut_ad(seg_inode && mtr);
|
|
ut_ad(mach_read_from_4(seg_inode + FSEG_MAGIC_N)
|
|
== FSEG_MAGIC_N_VALUE);
|
|
ut_ad(!((page_offset(seg_inode) - FSEG_ARR_OFFSET) % FSEG_INODE_SIZE));
|
|
|
|
/* Drop search system page hash index if the page is found in
|
|
the pool and is hashed */
|
|
|
|
btr_search_drop_page_hash_when_freed(space, zip_size, page);
|
|
|
|
descr = xdes_get_descriptor(space, zip_size, page, mtr);
|
|
|
|
ut_a(descr);
|
|
if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
|
|
fputs("InnoDB: Dump of the tablespace extent descriptor: ",
|
|
stderr);
|
|
ut_print_buf(stderr, descr, 40);
|
|
|
|
fprintf(stderr, "\n"
|
|
"InnoDB: Serious error! InnoDB is trying to"
|
|
" free page %lu\n"
|
|
"InnoDB: though it is already marked as free"
|
|
" in the tablespace!\n"
|
|
"InnoDB: The tablespace free space info is corrupt.\n"
|
|
"InnoDB: You may need to dump your"
|
|
" InnoDB tables and recreate the whole\n"
|
|
"InnoDB: database!\n", (ulong) page);
|
|
crash:
|
|
fputs("InnoDB: Please refer to\n"
|
|
"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
|
|
"forcing-recovery.html\n"
|
|
"InnoDB: about forcing recovery.\n", stderr);
|
|
ut_error;
|
|
}
|
|
|
|
state = xdes_get_state(descr, mtr);
|
|
|
|
if (state != XDES_FSEG) {
|
|
/* The page is in the fragment pages of the segment */
|
|
|
|
for (i = 0;; i++) {
|
|
if (fseg_get_nth_frag_page_no(seg_inode, i, mtr)
|
|
== page) {
|
|
|
|
fseg_set_nth_frag_page_no(seg_inode, i,
|
|
FIL_NULL, mtr);
|
|
break;
|
|
}
|
|
}
|
|
|
|
fsp_free_page(space, zip_size, page, mtr);
|
|
|
|
return;
|
|
}
|
|
|
|
/* If we get here, the page is in some extent of the segment */
|
|
|
|
descr_id = mtr_read_dulint(descr + XDES_ID, mtr);
|
|
seg_id = mtr_read_dulint(seg_inode + FSEG_ID, mtr);
|
|
#if 0
|
|
fprintf(stderr,
|
|
"InnoDB: InnoDB is freeing space %lu page %lu,\n"
|
|
"InnoDB: which belongs to descr seg %lu %lu\n"
|
|
"InnoDB: segment %lu %lu.\n",
|
|
(ulong) space, (ulong) page,
|
|
(ulong) ut_dulint_get_high(descr_id),
|
|
(ulong) ut_dulint_get_low(descr_id),
|
|
(ulong) ut_dulint_get_high(seg_id),
|
|
(ulong) ut_dulint_get_low(seg_id));
|
|
#endif /* 0 */
|
|
if (0 != ut_dulint_cmp(descr_id, seg_id)) {
|
|
fputs("InnoDB: Dump of the tablespace extent descriptor: ",
|
|
stderr);
|
|
ut_print_buf(stderr, descr, 40);
|
|
fputs("\nInnoDB: Dump of the segment inode: ", stderr);
|
|
ut_print_buf(stderr, seg_inode, 40);
|
|
putc('\n', stderr);
|
|
|
|
fprintf(stderr,
|
|
"InnoDB: Serious error: InnoDB is trying to"
|
|
" free space %lu page %lu,\n"
|
|
"InnoDB: which does not belong to"
|
|
" segment %lu %lu but belongs\n"
|
|
"InnoDB: to segment %lu %lu.\n",
|
|
(ulong) space, (ulong) page,
|
|
(ulong) ut_dulint_get_high(descr_id),
|
|
(ulong) ut_dulint_get_low(descr_id),
|
|
(ulong) ut_dulint_get_high(seg_id),
|
|
(ulong) ut_dulint_get_low(seg_id));
|
|
goto crash;
|
|
}
|
|
|
|
not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
|
MLOG_4BYTES, mtr);
|
|
if (xdes_is_full(descr, mtr)) {
|
|
/* The fragment is full: move it to another list */
|
|
flst_remove(seg_inode + FSEG_FULL,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
flst_add_last(seg_inode + FSEG_NOT_FULL,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
|
not_full_n_used + FSP_EXTENT_SIZE - 1,
|
|
MLOG_4BYTES, mtr);
|
|
} else {
|
|
ut_a(not_full_n_used > 0);
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
|
not_full_n_used - 1, MLOG_4BYTES, mtr);
|
|
}
|
|
|
|
xdes_set_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr);
|
|
xdes_set_bit(descr, XDES_CLEAN_BIT, page % FSP_EXTENT_SIZE, TRUE, mtr);
|
|
|
|
if (xdes_is_free(descr, mtr)) {
|
|
/* The extent has become free: free it to space */
|
|
flst_remove(seg_inode + FSEG_NOT_FULL,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
fsp_free_extent(space, zip_size, page, mtr);
|
|
}
|
|
}
|
|
|
|
/**************************************************************************
|
|
Frees a single page of a segment. */
|
|
UNIV_INTERN
|
|
void
|
|
fseg_free_page(
|
|
/*===========*/
|
|
fseg_header_t* seg_header, /* in: segment header */
|
|
ulint space, /* in: space id */
|
|
ulint page, /* in: page offset */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint flags;
|
|
ulint zip_size;
|
|
fseg_inode_t* seg_inode;
|
|
rw_lock_t* latch;
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
seg_inode = fseg_inode_get(seg_header, space, zip_size, mtr);
|
|
|
|
fseg_free_page_low(seg_inode, space, zip_size, page, mtr);
|
|
|
|
#ifdef UNIV_DEBUG_FILE_ACCESSES
|
|
buf_page_set_file_page_was_freed(space, page);
|
|
#endif
|
|
}
|
|
|
|
/**************************************************************************
|
|
Frees an extent of a segment to the space free list. */
|
|
static
|
|
void
|
|
fseg_free_extent(
|
|
/*=============*/
|
|
fseg_inode_t* seg_inode, /* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page, /* in: a page in the extent */
|
|
mtr_t* mtr) /* in: mtr handle */
|
|
{
|
|
ulint first_page_in_extent;
|
|
xdes_t* descr;
|
|
ulint not_full_n_used;
|
|
ulint descr_n_used;
|
|
ulint i;
|
|
|
|
ut_ad(seg_inode && mtr);
|
|
|
|
descr = xdes_get_descriptor(space, zip_size, page, mtr);
|
|
|
|
ut_a(xdes_get_state(descr, mtr) == XDES_FSEG);
|
|
ut_a(0 == ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, mtr),
|
|
mtr_read_dulint(seg_inode + FSEG_ID, mtr)));
|
|
|
|
first_page_in_extent = page - (page % FSP_EXTENT_SIZE);
|
|
|
|
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
|
|
if (FALSE == xdes_get_bit(descr, XDES_FREE_BIT, i, mtr)) {
|
|
|
|
/* Drop search system page hash index if the page is
|
|
found in the pool and is hashed */
|
|
|
|
btr_search_drop_page_hash_when_freed(
|
|
space, zip_size, first_page_in_extent + i);
|
|
}
|
|
}
|
|
|
|
if (xdes_is_full(descr, mtr)) {
|
|
flst_remove(seg_inode + FSEG_FULL,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
} else if (xdes_is_free(descr, mtr)) {
|
|
flst_remove(seg_inode + FSEG_FREE,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
} else {
|
|
flst_remove(seg_inode + FSEG_NOT_FULL,
|
|
descr + XDES_FLST_NODE, mtr);
|
|
|
|
not_full_n_used = mtr_read_ulint(
|
|
seg_inode + FSEG_NOT_FULL_N_USED, MLOG_4BYTES, mtr);
|
|
|
|
descr_n_used = xdes_get_n_used(descr, mtr);
|
|
ut_a(not_full_n_used >= descr_n_used);
|
|
mlog_write_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
|
|
not_full_n_used - descr_n_used,
|
|
MLOG_4BYTES, mtr);
|
|
}
|
|
|
|
fsp_free_extent(space, zip_size, page, mtr);
|
|
|
|
#ifdef UNIV_DEBUG_FILE_ACCESSES
|
|
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
|
|
|
|
buf_page_set_file_page_was_freed(space,
|
|
first_page_in_extent + i);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
/**************************************************************************
|
|
Frees part of a segment. This function can be used to free a segment by
|
|
repeatedly calling this function in different mini-transactions. Doing
|
|
the freeing in a single mini-transaction might result in too big a
|
|
mini-transaction. */
|
|
UNIV_INTERN
|
|
ibool
|
|
fseg_free_step(
|
|
/*===========*/
|
|
/* out: TRUE if freeing completed */
|
|
fseg_header_t* header, /* in, own: segment header; NOTE: if the header
|
|
resides on the first page of the frag list
|
|
of the segment, this pointer becomes obsolete
|
|
after the last freeing step */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint n;
|
|
ulint page;
|
|
xdes_t* descr;
|
|
fseg_inode_t* inode;
|
|
ulint space;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
ulint header_page;
|
|
rw_lock_t* latch;
|
|
|
|
space = page_get_space_id(page_align(header));
|
|
header_page = page_get_page_no(page_align(header));
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
descr = xdes_get_descriptor(space, zip_size, header_page, mtr);
|
|
|
|
/* Check that the header resides on a page which has not been
|
|
freed yet */
|
|
|
|
ut_a(descr);
|
|
ut_a(xdes_get_bit(descr, XDES_FREE_BIT,
|
|
header_page % FSP_EXTENT_SIZE, mtr) == FALSE);
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
|
|
|
descr = fseg_get_first_extent(inode, space, zip_size, mtr);
|
|
|
|
if (descr != NULL) {
|
|
/* Free the extent held by the segment */
|
|
page = xdes_get_offset(descr);
|
|
|
|
fseg_free_extent(inode, space, zip_size, page, mtr);
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
/* Free a frag page */
|
|
n = fseg_find_last_used_frag_page_slot(inode, mtr);
|
|
|
|
if (n == ULINT_UNDEFINED) {
|
|
/* Freeing completed: free the segment inode */
|
|
fsp_free_seg_inode(space, zip_size, inode, mtr);
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
fseg_free_page_low(inode, space, zip_size,
|
|
fseg_get_nth_frag_page_no(inode, n, mtr), mtr);
|
|
|
|
n = fseg_find_last_used_frag_page_slot(inode, mtr);
|
|
|
|
if (n == ULINT_UNDEFINED) {
|
|
/* Freeing completed: free the segment inode */
|
|
fsp_free_seg_inode(space, zip_size, inode, mtr);
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Frees part of a segment. Differs from fseg_free_step because this function
|
|
leaves the header page unfreed. */
|
|
UNIV_INTERN
|
|
ibool
|
|
fseg_free_step_not_header(
|
|
/*======================*/
|
|
/* out: TRUE if freeing completed, except the
|
|
header page */
|
|
fseg_header_t* header, /* in: segment header which must reside on
|
|
the first fragment page of the segment */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint n;
|
|
ulint page;
|
|
xdes_t* descr;
|
|
fseg_inode_t* inode;
|
|
ulint space;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
ulint page_no;
|
|
rw_lock_t* latch;
|
|
|
|
space = page_get_space_id(page_align(header));
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
ut_ad(!mutex_own(&kernel_mutex)
|
|
|| mtr_memo_contains(mtr, latch, MTR_MEMO_X_LOCK));
|
|
|
|
mtr_x_lock(latch, mtr);
|
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
|
|
|
descr = fseg_get_first_extent(inode, space, zip_size, mtr);
|
|
|
|
if (descr != NULL) {
|
|
/* Free the extent held by the segment */
|
|
page = xdes_get_offset(descr);
|
|
|
|
fseg_free_extent(inode, space, zip_size, page, mtr);
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
/* Free a frag page */
|
|
|
|
n = fseg_find_last_used_frag_page_slot(inode, mtr);
|
|
|
|
if (n == ULINT_UNDEFINED) {
|
|
ut_error;
|
|
}
|
|
|
|
page_no = fseg_get_nth_frag_page_no(inode, n, mtr);
|
|
|
|
if (page_no == page_get_page_no(page_align(header))) {
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
fseg_free_page_low(inode, space, zip_size, page_no, mtr);
|
|
|
|
return(FALSE);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Frees a segment. The freeing is performed in several mini-transactions,
|
|
so that there is no danger of bufferfixing too many buffer pages. */
|
|
UNIV_INTERN
|
|
void
|
|
fseg_free(
|
|
/*======*/
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
ulint page_no,/* in: page number where the segment header is
|
|
placed */
|
|
ulint offset) /* in: byte offset of the segment header on that
|
|
page */
|
|
{
|
|
mtr_t mtr;
|
|
ibool finished;
|
|
fseg_header_t* header;
|
|
fil_addr_t addr;
|
|
|
|
addr.page = page_no;
|
|
addr.boffset = offset;
|
|
|
|
for (;;) {
|
|
mtr_start(&mtr);
|
|
|
|
header = fut_get_ptr(space, zip_size, addr, RW_X_LATCH, &mtr);
|
|
|
|
finished = fseg_free_step(header, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
if (finished) {
|
|
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**************************************************************************
|
|
Returns the first extent descriptor for a segment. We think of the extent
|
|
lists of the segment catenated in the order FSEG_FULL -> FSEG_NOT_FULL
|
|
-> FSEG_FREE. */
|
|
static
|
|
xdes_t*
|
|
fseg_get_first_extent(
|
|
/*==================*/
|
|
/* out: the first extent descriptor, or NULL if
|
|
none */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
ulint space, /* in: space id */
|
|
ulint zip_size,/* in: compressed page size in bytes
|
|
or 0 for uncompressed pages */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
fil_addr_t first;
|
|
xdes_t* descr;
|
|
|
|
ut_ad(inode && mtr);
|
|
|
|
ut_ad(space == page_get_space_id(page_align(inode)));
|
|
|
|
first = fil_addr_null;
|
|
|
|
if (flst_get_len(inode + FSEG_FULL, mtr) > 0) {
|
|
|
|
first = flst_get_first(inode + FSEG_FULL, mtr);
|
|
|
|
} else if (flst_get_len(inode + FSEG_NOT_FULL, mtr) > 0) {
|
|
|
|
first = flst_get_first(inode + FSEG_NOT_FULL, mtr);
|
|
|
|
} else if (flst_get_len(inode + FSEG_FREE, mtr) > 0) {
|
|
|
|
first = flst_get_first(inode + FSEG_FREE, mtr);
|
|
}
|
|
|
|
if (first.page == FIL_NULL) {
|
|
|
|
return(NULL);
|
|
}
|
|
descr = xdes_lst_get_descriptor(space, zip_size, first, mtr);
|
|
|
|
return(descr);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Validates a segment. */
|
|
static
|
|
ibool
|
|
fseg_validate_low(
|
|
/*==============*/
|
|
/* out: TRUE if ok */
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
mtr_t* mtr2) /* in: mtr */
|
|
{
|
|
ulint space;
|
|
dulint seg_id;
|
|
mtr_t mtr;
|
|
xdes_t* descr;
|
|
fil_addr_t node_addr;
|
|
ulint n_used = 0;
|
|
ulint n_used2 = 0;
|
|
|
|
ut_ad(mtr_memo_contains_page(mtr2, inode, MTR_MEMO_PAGE_X_FIX));
|
|
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
|
|
|
|
space = page_get_space_id(page_align(inode));
|
|
|
|
seg_id = mtr_read_dulint(inode + FSEG_ID, mtr2);
|
|
n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED,
|
|
MLOG_4BYTES, mtr2);
|
|
flst_validate(inode + FSEG_FREE, mtr2);
|
|
flst_validate(inode + FSEG_NOT_FULL, mtr2);
|
|
flst_validate(inode + FSEG_FULL, mtr2);
|
|
|
|
/* Validate FSEG_FREE list */
|
|
node_addr = flst_get_first(inode + FSEG_FREE, mtr2);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
ulint flags;
|
|
ulint zip_size;
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), &mtr);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
node_addr, &mtr);
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) == 0);
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
|
|
ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
|
|
seg_id));
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
}
|
|
|
|
/* Validate FSEG_NOT_FULL list */
|
|
|
|
node_addr = flst_get_first(inode + FSEG_NOT_FULL, mtr2);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
ulint flags;
|
|
ulint zip_size;
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), &mtr);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
node_addr, &mtr);
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) > 0);
|
|
ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE);
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
|
|
ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
|
|
seg_id));
|
|
|
|
n_used2 += xdes_get_n_used(descr, &mtr);
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
}
|
|
|
|
/* Validate FSEG_FULL list */
|
|
|
|
node_addr = flst_get_first(inode + FSEG_FULL, mtr2);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
ulint flags;
|
|
ulint zip_size;
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), &mtr);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
node_addr, &mtr);
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE);
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FSEG);
|
|
ut_a(!ut_dulint_cmp(mtr_read_dulint(descr + XDES_ID, &mtr),
|
|
seg_id));
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
}
|
|
|
|
ut_a(n_used == n_used2);
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Validates a segment. */
|
|
UNIV_INTERN
|
|
ibool
|
|
fseg_validate(
|
|
/*==========*/
|
|
/* out: TRUE if ok */
|
|
fseg_header_t* header, /* in: segment header */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
fseg_inode_t* inode;
|
|
ibool ret;
|
|
ulint space;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
|
|
space = page_get_space_id(page_align(header));
|
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
|
|
|
ret = fseg_validate_low(inode, mtr);
|
|
|
|
return(ret);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Writes info of a segment. */
|
|
static
|
|
void
|
|
fseg_print_low(
|
|
/*===========*/
|
|
fseg_inode_t* inode, /* in: segment inode */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint space;
|
|
ulint seg_id_low;
|
|
ulint seg_id_high;
|
|
ulint n_used;
|
|
ulint n_frag;
|
|
ulint n_free;
|
|
ulint n_not_full;
|
|
ulint n_full;
|
|
ulint reserved;
|
|
ulint used;
|
|
ulint page_no;
|
|
dulint d_var;
|
|
|
|
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
|
|
space = page_get_space_id(page_align(inode));
|
|
page_no = page_get_page_no(page_align(inode));
|
|
|
|
reserved = fseg_n_reserved_pages_low(inode, &used, mtr);
|
|
|
|
d_var = mtr_read_dulint(inode + FSEG_ID, mtr);
|
|
|
|
seg_id_low = ut_dulint_get_low(d_var);
|
|
seg_id_high = ut_dulint_get_high(d_var);
|
|
|
|
n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED,
|
|
MLOG_4BYTES, mtr);
|
|
n_frag = fseg_get_n_frag_pages(inode, mtr);
|
|
n_free = flst_get_len(inode + FSEG_FREE, mtr);
|
|
n_not_full = flst_get_len(inode + FSEG_NOT_FULL, mtr);
|
|
n_full = flst_get_len(inode + FSEG_FULL, mtr);
|
|
|
|
fprintf(stderr,
|
|
"SEGMENT id %lu %lu space %lu; page %lu;"
|
|
" res %lu used %lu; full ext %lu\n"
|
|
"fragm pages %lu; free extents %lu;"
|
|
" not full extents %lu: pages %lu\n",
|
|
(ulong) seg_id_high, (ulong) seg_id_low,
|
|
(ulong) space, (ulong) page_no,
|
|
(ulong) reserved, (ulong) used, (ulong) n_full,
|
|
(ulong) n_frag, (ulong) n_free, (ulong) n_not_full,
|
|
(ulong) n_used);
|
|
}
|
|
|
|
#ifdef UNIV_BTR_PRINT
|
|
/***********************************************************************
|
|
Writes info of a segment. */
|
|
UNIV_INTERN
|
|
void
|
|
fseg_print(
|
|
/*=======*/
|
|
fseg_header_t* header, /* in: segment header */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
fseg_inode_t* inode;
|
|
ulint space;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
|
|
space = page_get_space_id(page_align(header));
|
|
|
|
mtr_x_lock(fil_space_get_latch(space, &flags), mtr);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
inode = fseg_inode_get(header, space, zip_size, mtr);
|
|
|
|
fseg_print_low(inode, mtr);
|
|
}
|
|
#endif /* UNIV_BTR_PRINT */
|
|
|
|
/***********************************************************************
|
|
Validates the file space system and its segments. */
|
|
UNIV_INTERN
|
|
ibool
|
|
fsp_validate(
|
|
/*=========*/
|
|
/* out: TRUE if ok */
|
|
ulint space) /* in: space id */
|
|
{
|
|
fsp_header_t* header;
|
|
fseg_inode_t* seg_inode;
|
|
page_t* seg_inode_page;
|
|
rw_lock_t* latch;
|
|
ulint size;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
ulint free_limit;
|
|
ulint frag_n_used;
|
|
mtr_t mtr;
|
|
mtr_t mtr2;
|
|
xdes_t* descr;
|
|
fil_addr_t node_addr;
|
|
fil_addr_t next_node_addr;
|
|
ulint descr_count = 0;
|
|
ulint n_used = 0;
|
|
ulint n_used2 = 0;
|
|
ulint n_full_frag_pages;
|
|
ulint n;
|
|
ulint seg_inode_len_free;
|
|
ulint seg_inode_len_full;
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
ut_a(ut_is_2pow(zip_size));
|
|
ut_a(zip_size <= UNIV_PAGE_SIZE);
|
|
ut_a(!zip_size || zip_size >= PAGE_ZIP_MIN_SIZE);
|
|
|
|
/* Start first a mini-transaction mtr2 to lock out all other threads
|
|
from the fsp system */
|
|
mtr_start(&mtr2);
|
|
mtr_x_lock(latch, &mtr2);
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
|
|
free_limit = mtr_read_ulint(header + FSP_FREE_LIMIT,
|
|
MLOG_4BYTES, &mtr);
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED,
|
|
MLOG_4BYTES, &mtr);
|
|
|
|
n_full_frag_pages = FSP_EXTENT_SIZE
|
|
* flst_get_len(header + FSP_FULL_FRAG, &mtr);
|
|
|
|
if (UNIV_UNLIKELY(free_limit > size)) {
|
|
|
|
ut_a(space != 0);
|
|
ut_a(size < FSP_EXTENT_SIZE);
|
|
}
|
|
|
|
flst_validate(header + FSP_FREE, &mtr);
|
|
flst_validate(header + FSP_FREE_FRAG, &mtr);
|
|
flst_validate(header + FSP_FULL_FRAG, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
/* Validate FSP_FREE list */
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
node_addr = flst_get_first(header + FSP_FREE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
descr_count++;
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
node_addr, &mtr);
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) == 0);
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FREE);
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
}
|
|
|
|
/* Validate FSP_FREE_FRAG list */
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
node_addr = flst_get_first(header + FSP_FREE_FRAG, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
descr_count++;
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
node_addr, &mtr);
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) > 0);
|
|
ut_a(xdes_get_n_used(descr, &mtr) < FSP_EXTENT_SIZE);
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FREE_FRAG);
|
|
|
|
n_used += xdes_get_n_used(descr, &mtr);
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
}
|
|
|
|
/* Validate FSP_FULL_FRAG list */
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
node_addr = flst_get_first(header + FSP_FULL_FRAG, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
descr_count++;
|
|
descr = xdes_lst_get_descriptor(space, zip_size,
|
|
node_addr, &mtr);
|
|
|
|
ut_a(xdes_get_n_used(descr, &mtr) == FSP_EXTENT_SIZE);
|
|
ut_a(xdes_get_state(descr, &mtr) == XDES_FULL_FRAG);
|
|
|
|
node_addr = flst_get_next_addr(descr + XDES_FLST_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
}
|
|
|
|
/* Validate segments */
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
|
|
node_addr = flst_get_first(header + FSP_SEG_INODES_FULL, &mtr);
|
|
|
|
seg_inode_len_full = flst_get_len(header + FSP_SEG_INODES_FULL, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
n = 0;
|
|
do {
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
seg_inode_page = fut_get_ptr(
|
|
space, zip_size, node_addr, RW_X_LATCH, &mtr)
|
|
- FSEG_INODE_PAGE_NODE;
|
|
|
|
seg_inode = fsp_seg_inode_page_get_nth_inode(
|
|
seg_inode_page, n, zip_size, &mtr);
|
|
ut_a(!ut_dulint_is_zero(
|
|
mach_read_from_8(seg_inode + FSEG_ID)));
|
|
fseg_validate_low(seg_inode, &mtr);
|
|
|
|
descr_count += flst_get_len(seg_inode + FSEG_FREE,
|
|
&mtr);
|
|
descr_count += flst_get_len(seg_inode + FSEG_FULL,
|
|
&mtr);
|
|
descr_count += flst_get_len(seg_inode + FSEG_NOT_FULL,
|
|
&mtr);
|
|
|
|
n_used2 += fseg_get_n_frag_pages(seg_inode, &mtr);
|
|
|
|
next_node_addr = flst_get_next_addr(
|
|
seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
} while (++n < FSP_SEG_INODES_PER_PAGE(zip_size));
|
|
|
|
node_addr = next_node_addr;
|
|
}
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
|
|
node_addr = flst_get_first(header + FSP_SEG_INODES_FREE, &mtr);
|
|
|
|
seg_inode_len_free = flst_get_len(header + FSP_SEG_INODES_FREE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
n = 0;
|
|
|
|
do {
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
seg_inode_page = fut_get_ptr(
|
|
space, zip_size, node_addr, RW_X_LATCH, &mtr)
|
|
- FSEG_INODE_PAGE_NODE;
|
|
|
|
seg_inode = fsp_seg_inode_page_get_nth_inode(
|
|
seg_inode_page, n, zip_size, &mtr);
|
|
if (!ut_dulint_is_zero(
|
|
mach_read_from_8(seg_inode + FSEG_ID))) {
|
|
fseg_validate_low(seg_inode, &mtr);
|
|
|
|
descr_count += flst_get_len(
|
|
seg_inode + FSEG_FREE, &mtr);
|
|
descr_count += flst_get_len(
|
|
seg_inode + FSEG_FULL, &mtr);
|
|
descr_count += flst_get_len(
|
|
seg_inode + FSEG_NOT_FULL, &mtr);
|
|
n_used2 += fseg_get_n_frag_pages(
|
|
seg_inode, &mtr);
|
|
}
|
|
|
|
next_node_addr = flst_get_next_addr(
|
|
seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
} while (++n < FSP_SEG_INODES_PER_PAGE(zip_size));
|
|
|
|
node_addr = next_node_addr;
|
|
}
|
|
|
|
ut_a(descr_count * FSP_EXTENT_SIZE == free_limit);
|
|
if (!zip_size) {
|
|
ut_a(n_used + n_full_frag_pages
|
|
== n_used2 + 2 * ((free_limit + (UNIV_PAGE_SIZE - 1))
|
|
/ UNIV_PAGE_SIZE)
|
|
+ seg_inode_len_full + seg_inode_len_free);
|
|
} else {
|
|
ut_a(n_used + n_full_frag_pages
|
|
== n_used2 + 2 * ((free_limit + (zip_size - 1))
|
|
/ zip_size)
|
|
+ seg_inode_len_full + seg_inode_len_free);
|
|
}
|
|
ut_a(frag_n_used == n_used);
|
|
|
|
mtr_commit(&mtr2);
|
|
|
|
return(TRUE);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Prints info of a file space. */
|
|
UNIV_INTERN
|
|
void
|
|
fsp_print(
|
|
/*======*/
|
|
ulint space) /* in: space id */
|
|
{
|
|
fsp_header_t* header;
|
|
fseg_inode_t* seg_inode;
|
|
page_t* seg_inode_page;
|
|
rw_lock_t* latch;
|
|
ulint flags;
|
|
ulint zip_size;
|
|
ulint size;
|
|
ulint free_limit;
|
|
ulint frag_n_used;
|
|
fil_addr_t node_addr;
|
|
fil_addr_t next_node_addr;
|
|
ulint n_free;
|
|
ulint n_free_frag;
|
|
ulint n_full_frag;
|
|
ulint seg_id_low;
|
|
ulint seg_id_high;
|
|
ulint n;
|
|
ulint n_segs = 0;
|
|
dulint d_var;
|
|
mtr_t mtr;
|
|
mtr_t mtr2;
|
|
|
|
latch = fil_space_get_latch(space, &flags);
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
|
|
|
/* Start first a mini-transaction mtr2 to lock out all other threads
|
|
from the fsp system */
|
|
|
|
mtr_start(&mtr2);
|
|
|
|
mtr_x_lock(latch, &mtr2);
|
|
|
|
mtr_start(&mtr);
|
|
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
|
|
size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, &mtr);
|
|
|
|
free_limit = mtr_read_ulint(header + FSP_FREE_LIMIT, MLOG_4BYTES,
|
|
&mtr);
|
|
frag_n_used = mtr_read_ulint(header + FSP_FRAG_N_USED, MLOG_4BYTES,
|
|
&mtr);
|
|
n_free = flst_get_len(header + FSP_FREE, &mtr);
|
|
n_free_frag = flst_get_len(header + FSP_FREE_FRAG, &mtr);
|
|
n_full_frag = flst_get_len(header + FSP_FULL_FRAG, &mtr);
|
|
|
|
d_var = mtr_read_dulint(header + FSP_SEG_ID, &mtr);
|
|
|
|
seg_id_low = ut_dulint_get_low(d_var);
|
|
seg_id_high = ut_dulint_get_high(d_var);
|
|
|
|
fprintf(stderr,
|
|
"FILE SPACE INFO: id %lu\n"
|
|
"size %lu, free limit %lu, free extents %lu\n"
|
|
"not full frag extents %lu: used pages %lu,"
|
|
" full frag extents %lu\n"
|
|
"first seg id not used %lu %lu\n",
|
|
(ulong) space,
|
|
(ulong) size, (ulong) free_limit, (ulong) n_free,
|
|
(ulong) n_free_frag, (ulong) frag_n_used, (ulong) n_full_frag,
|
|
(ulong) seg_id_high, (ulong) seg_id_low);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
/* Print segments */
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
|
|
node_addr = flst_get_first(header + FSP_SEG_INODES_FULL, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
n = 0;
|
|
|
|
do {
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
seg_inode_page = fut_get_ptr(
|
|
space, zip_size, node_addr, RW_X_LATCH, &mtr)
|
|
- FSEG_INODE_PAGE_NODE;
|
|
|
|
seg_inode = fsp_seg_inode_page_get_nth_inode(
|
|
seg_inode_page, n, zip_size, &mtr);
|
|
ut_a(!ut_dulint_is_zero(
|
|
mach_read_from_8(seg_inode + FSEG_ID)));
|
|
fseg_print_low(seg_inode, &mtr);
|
|
|
|
n_segs++;
|
|
|
|
next_node_addr = flst_get_next_addr(
|
|
seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
} while (++n < FSP_SEG_INODES_PER_PAGE(zip_size));
|
|
|
|
node_addr = next_node_addr;
|
|
}
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
header = fsp_get_space_header(space, zip_size, &mtr);
|
|
|
|
node_addr = flst_get_first(header + FSP_SEG_INODES_FREE, &mtr);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
while (!fil_addr_is_null(node_addr)) {
|
|
|
|
n = 0;
|
|
|
|
do {
|
|
|
|
mtr_start(&mtr);
|
|
mtr_x_lock(latch, &mtr);
|
|
|
|
seg_inode_page = fut_get_ptr(
|
|
space, zip_size, node_addr, RW_X_LATCH, &mtr)
|
|
- FSEG_INODE_PAGE_NODE;
|
|
|
|
seg_inode = fsp_seg_inode_page_get_nth_inode(
|
|
seg_inode_page, n, zip_size, &mtr);
|
|
if (!ut_dulint_is_zero(
|
|
mach_read_from_8(seg_inode + FSEG_ID))) {
|
|
|
|
fseg_print_low(seg_inode, &mtr);
|
|
n_segs++;
|
|
}
|
|
|
|
next_node_addr = flst_get_next_addr(
|
|
seg_inode_page + FSEG_INODE_PAGE_NODE, &mtr);
|
|
mtr_commit(&mtr);
|
|
} while (++n < FSP_SEG_INODES_PER_PAGE(zip_size));
|
|
|
|
node_addr = next_node_addr;
|
|
}
|
|
|
|
mtr_commit(&mtr2);
|
|
|
|
fprintf(stderr, "NUMBER of file segments: %lu\n", (ulong) n_segs);
|
|
}
|
|
#endif /* !UNIV_HOTBACKUP */
|