Server IP : 172.67.216.182 / Your IP : 162.158.88.135 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/server/mysql/src/storage/innobase/include/ |
Upload File : |
/***************************************************************************** Copyright (c) 1995, 2023, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as published by the Free Software Foundation. This program is also distributed with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in included license documentation. The authors of MySQL hereby grant you an additional permission to link the program and your derivative works with the separately licensed software that they have included with MySQL. 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, version 2.0, 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ /**************************************************//** @file include/fsp0fsp.ic File space management Created 12/18/1995 Heikki Tuuri *******************************************************/ #ifndef UNIV_INNOCHECKSUM /** Checks if a page address is an extent descriptor page address. @param[in] page_id page id @param[in] page_size page size @return TRUE if a descriptor page */ UNIV_INLINE ibool fsp_descr_page( const page_id_t& page_id, const page_size_t& page_size) { return((page_id.page_no() & (page_size.physical() - 1)) == FSP_XDES_OFFSET); } /** Determine if the tablespace is compressed from tablespace flags. @param[in] flags Tablespace flags @return true if compressed, false if not compressed */ UNIV_INLINE bool fsp_flags_is_compressed( ulint flags) { return(FSP_FLAGS_GET_ZIP_SSIZE(flags) != 0); } #define ACTUAL_SSIZE(ssize) (0 == ssize ? UNIV_PAGE_SSIZE_ORIG : ssize) /** Determine if two tablespaces are equivalent or compatible. @param[in] flags1 First tablespace flags @param[in] flags2 Second tablespace flags @return true the flags are compatible, false if not */ UNIV_INLINE bool fsp_flags_are_equal( ulint flags1, ulint flags2) { /* If either one of these flags is ULINT_UNDEFINED, then they are not equal */ if (flags1 == ULINT_UNDEFINED || flags2 == ULINT_UNDEFINED) { return(false); } if (!fsp_is_shared_tablespace(flags1) || !fsp_is_shared_tablespace(flags2)) { /* At least one of these is a single-table tablespaces so all flags must match. */ return(flags1 == flags2); } /* Both are shared tablespaces which can contain all formats. But they must have the same logical and physical page size. Once InnoDB can support multiple page sizes together, the logical page size will not matter. */ ulint zip_ssize1 = ACTUAL_SSIZE(FSP_FLAGS_GET_ZIP_SSIZE(flags1)); ulint zip_ssize2 = ACTUAL_SSIZE(FSP_FLAGS_GET_ZIP_SSIZE(flags2)); ulint page_ssize1 = ACTUAL_SSIZE(FSP_FLAGS_GET_PAGE_SSIZE(flags1)); ulint page_ssize2 = ACTUAL_SSIZE(FSP_FLAGS_GET_PAGE_SSIZE(flags2)); return(zip_ssize1 == zip_ssize2 && page_ssize1 == page_ssize2); } /** Convert a page size, which is a power of 2, to an ssize, which is the number of bit shifts from 512 to make that page size. @param[in] page_size compressed page size in bytes @return an ssize created from the page size provided. */ UNIV_INLINE ulint page_size_to_ssize( ulint page_size) { ulint ssize; for (ssize = UNIV_ZIP_SIZE_SHIFT_MIN; ((ulint) 1 << ssize) < page_size; ssize++) {}; return(ssize - UNIV_ZIP_SIZE_SHIFT_MIN + 1); } /** Add the compressed page size to the tablespace flags. @param[in] flags Tablespace flags @param[in] page_size page sizes in bytes and compression flag. @return tablespace flags after zip size is added */ UNIV_INLINE ulint fsp_flags_set_zip_size( ulint flags, const page_size_t& page_size) { if (!page_size.is_compressed()) { return(flags); } /* Zip size should be a power of 2 between UNIV_ZIP_SIZE_MIN and UNIV_ZIP_SIZE_MAX */ ut_ad(page_size.physical() >= UNIV_ZIP_SIZE_MIN); ut_ad(page_size.physical() <= UNIV_ZIP_SIZE_MAX); ut_ad(ut_is_2pow(page_size.physical())); ulint ssize = page_size_to_ssize(page_size.physical()); ut_ad(ssize > 0); ut_ad(ssize <= UNIV_PAGE_SSIZE_MAX); flags |= (ssize << FSP_FLAGS_POS_ZIP_SSIZE); ut_ad(fsp_flags_is_valid(flags)); return(flags); } /** Add the page size to the tablespace flags. @param[in] flags Tablespace flags @param[in] page_size page sizes in bytes and compression flag. @return tablespace flags after page size is added */ UNIV_INLINE ulint fsp_flags_set_page_size( ulint flags, const page_size_t& page_size) { /* Page size should be a power of two between UNIV_PAGE_SIZE_MIN and UNIV_PAGE_SIZE */ ut_ad(page_size.logical() >= UNIV_PAGE_SIZE_MIN); ut_ad(page_size.logical() <= UNIV_PAGE_SIZE_MAX); ut_ad(ut_is_2pow(page_size.logical())); /* Remove this assert once we add support for different page size per tablespace. Currently all tablespaces must have a page size that is equal to innodb-page-size */ ut_ad(page_size.logical() == UNIV_PAGE_SIZE); if (page_size.logical() == UNIV_PAGE_SIZE_ORIG) { ut_ad(0 == FSP_FLAGS_GET_PAGE_SSIZE(flags)); } else { ulint ssize = page_size_to_ssize(page_size.logical()); ut_ad(ssize); ut_ad(ssize <= UNIV_PAGE_SSIZE_MAX); flags |= (ssize << FSP_FLAGS_POS_PAGE_SSIZE); } ut_ad(fsp_flags_is_valid(flags)); return(flags); } /** Initialize an FSP flags integer. @param[in] page_size page sizes in bytes and compression flag. @param[in] atomic_blobs Used by Dynammic and Compressed. @param[in] has_data_dir This tablespace is in a remote location. @param[in] is_shared This tablespace can be shared by many tables. @param[in] is_temporary This tablespace is temporary. @param[in] is_encrypted This tablespace is encrypted. @return tablespace flags after initialization */ UNIV_INLINE ulint fsp_flags_init( const page_size_t& page_size, bool atomic_blobs, bool has_data_dir, bool is_shared, bool is_temporary, bool is_encrypted) { ut_ad(page_size.physical() <= page_size.logical()); ut_ad(!page_size.is_compressed() || atomic_blobs); /* Page size should be a power of two between UNIV_PAGE_SIZE_MIN and UNIV_PAGE_SIZE, but zip_size may be 0 if not compressed. */ ulint flags = fsp_flags_set_page_size(0, page_size); if (atomic_blobs) { flags |= FSP_FLAGS_MASK_POST_ANTELOPE | FSP_FLAGS_MASK_ATOMIC_BLOBS; } /* If the zip_size is explicit and different from the default, compressed row format is implied. */ flags = fsp_flags_set_zip_size(flags, page_size); if (has_data_dir) { flags |= FSP_FLAGS_MASK_DATA_DIR; } /* Shared tablespaces can hold all row formats, so we only mark the POST_ANTELOPE and ATOMIC_BLOB bits if it is compressed. */ if (is_shared) { ut_ad(!has_data_dir); flags |= FSP_FLAGS_MASK_SHARED; } if (is_temporary) { ut_ad(!has_data_dir); flags |= FSP_FLAGS_MASK_TEMPORARY; } if (is_encrypted) { flags |= FSP_FLAGS_MASK_ENCRYPTION; } return(flags); } /** Calculates the descriptor index within a descriptor page. @param[in] page_size page size @param[in] offset page offset @return descriptor index */ UNIV_INLINE ulint xdes_calc_descriptor_index( const page_size_t& page_size, ulint offset) { return(ut_2pow_remainder(offset, page_size.physical()) / FSP_EXTENT_SIZE); } /**********************************************************************//** Gets a descriptor bit of a page. @return TRUE if free */ UNIV_INLINE ibool xdes_get_bit( /*=========*/ const 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 */ { ut_ad(offset < FSP_EXTENT_SIZE); ut_ad(bit == XDES_FREE_BIT || bit == XDES_CLEAN_BIT); ulint index = bit + XDES_BITS_PER_PAGE * offset; ulint bit_index = index % 8; ulint byte_index = index / 8; return(ut_bit_get_nth( mach_read_ulint(descr + XDES_BITMAP + byte_index, MLOG_1BYTE), bit_index)); } /** Calculates the page where the descriptor of a page resides. @param[in] page_size page size @param[in] offset page offset @return descriptor page offset */ UNIV_INLINE ulint xdes_calc_descriptor_page( const page_size_t& page_size, ulint offset) { #ifndef DOXYGEN /* Doxygen gets confused by these */ # if UNIV_PAGE_SIZE_MAX <= XDES_ARR_OFFSET \ + (UNIV_PAGE_SIZE_MAX / FSP_EXTENT_SIZE_MAX) \ * XDES_SIZE_MAX # error # endif # if UNIV_ZIP_SIZE_MIN <= XDES_ARR_OFFSET \ + (UNIV_ZIP_SIZE_MIN / FSP_EXTENT_SIZE_MIN) \ * XDES_SIZE_MIN # error # endif #endif /* !DOXYGEN */ ut_ad(UNIV_PAGE_SIZE > XDES_ARR_OFFSET + (UNIV_PAGE_SIZE / FSP_EXTENT_SIZE) * XDES_SIZE); ut_ad(UNIV_ZIP_SIZE_MIN > XDES_ARR_OFFSET + (UNIV_ZIP_SIZE_MIN / FSP_EXTENT_SIZE) * XDES_SIZE); #ifdef UNIV_DEBUG if (page_size.is_compressed()) { ut_a(page_size.physical() > XDES_ARR_OFFSET + (page_size.physical() / FSP_EXTENT_SIZE) * XDES_SIZE); } #endif /* UNIV_DEBUG */ return(ut_2pow_round(offset, page_size.physical())); } /** Calculates the descriptor array size. @param[in] page_size page size @return size of descriptor array */ UNIV_INLINE ulint xdes_arr_size( const page_size_t& page_size) { return(page_size.physical()/FSP_EXTENT_SIZE); } #endif /* !UNIV_INNOCHECKSUM */