Skip to content

Commit ca501ff

Browse files
committed
MDEV-26195: Use a 32-bit data type for some tablespace fields
In the InnoDB data files, we allocate 32 bits for tablespace identifiers and page numbers as well as tablespace flags. But, in main memory data structures we allocate 32 or 64 bits, depending on the register width of the processor. Let us always use 32-bit fields to eliminate a mismatch and reduce the memory footprint on 64-bit systems.
1 parent cee37b5 commit ca501ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+692
-934
lines changed

extra/innochecksum.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static my_bool per_page_details;
7070
static ulint n_merge;
7171
static ulint physical_page_size; /* Page size in bytes on disk. */
7272
ulong srv_page_size;
73-
ulong srv_page_size_shift;
73+
uint32_t srv_page_size_shift;
7474
/* Current page number (0 based). */
7575
unsigned long long cur_page_num;
7676
/* Current space. */

extra/mariabackup/backup_mysql.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ bool get_mysql_vars(MYSQL *connection)
514514

515515
if (innodb_undo_tablespaces_var)
516516
{
517-
srv_undo_tablespaces= strtoul(innodb_undo_tablespaces_var, &endptr, 10);
517+
srv_undo_tablespaces= static_cast<uint32_t>
518+
(strtoul(innodb_undo_tablespaces_var, &endptr, 10));
518519
ut_ad(*endptr == 0);
519520
}
520521

extra/mariabackup/common.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ static inline ATTRIBUTE_FORMAT(printf, 1,2) ATTRIBUTE_NORETURN void die(const ch
149149
/***********************************************************************
150150
Computes bit shift for a given value. If the argument is not a power
151151
of 2, returns 0.*/
152-
static inline size_t
153-
get_bit_shift(size_t value)
152+
static inline unsigned get_bit_shift(size_t value)
154153
{
155-
size_t shift;
154+
unsigned shift;
156155

157156
if (value == 0)
158157
return 0;

extra/mariabackup/ds_local.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ static void init_ibd_data(ds_local_file_t *local_file, const uchar *buf, size_t
181181
return;
182182
}
183183

184-
ulint flags = mach_read_from_4(&buf[FIL_PAGE_DATA + FSP_SPACE_FLAGS]);
185-
ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
184+
auto flags = mach_read_from_4(&buf[FIL_PAGE_DATA + FSP_SPACE_FLAGS]);
185+
auto ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags);
186186
local_file->pagesize= ssize == 0 ? UNIV_PAGE_SIZE_ORIG : ((UNIV_ZIP_SIZE_MIN >> 1) << ssize);
187187
local_file->compressed = fil_space_t::full_crc32(flags)
188188
? fil_space_t::is_compressed(flags)

extra/mariabackup/fil_cur.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ xb_fil_cur_open(
232232
mysql_mutex_unlock(&fil_system.mutex);
233233
}
234234

235-
cursor->space_size = (ulint)(cursor->statinfo.st_size
236-
/ cursor->page_size);
235+
cursor->space_size = uint32_t(cursor->statinfo.st_size
236+
/ cursor->page_size);
237237

238238
cursor->read_filter = read_filter;
239239
cursor->read_filter->init(&cursor->read_filter_ctxt, cursor,
@@ -441,8 +441,8 @@ xb_fil_cur_result_t xb_fil_cur_read(xb_fil_cur_t* cursor,
441441
"corrupted.%s", cursor->abs_path, ignore_corruption_warn);
442442
ut_print_buf(stderr, page, page_size);
443443
if (opt_log_innodb_page_corruption) {
444-
corrupted_pages.add_page(cursor->node->name, cursor->node->space->id,
445-
page_no);
444+
corrupted_pages.add_page(cursor->node->name,
445+
{cursor->node->space->id, page_no});
446446
retry_count = 1;
447447
}
448448
else {
@@ -465,8 +465,9 @@ xb_fil_cur_result_t xb_fil_cur_read(xb_fil_cur_t* cursor,
465465
unsigned corrupted_page_no =
466466
static_cast<unsigned>(strtoul(dbug_val, NULL, 10));
467467
if (page_no == corrupted_page_no)
468-
corrupted_pages.add_page(cursor->node->name, cursor->node->space->id,
469-
corrupted_page_no);
468+
corrupted_pages.add_page(cursor->node->name,
469+
{cursor->node->space->id,
470+
corrupted_page_no});
470471
});
471472
cursor->buf_read += page_size;
472473
cursor->buf_npages++;

extra/mariabackup/fil_cur.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ struct xb_fil_cur_t {
5656
unsigned buf_page_no; /*!< number of the first page in
5757
buffer */
5858
uint thread_n; /*!< thread number for diagnostics */
59-
ulint space_id; /*!< ID of tablespace */
60-
ulint space_size; /*!< space size in pages */
59+
uint32_t space_id; /*!< ID of tablespace */
60+
uint32_t space_size; /*!< space size in pages */
6161

6262
/** @return whether this is not a file-per-table tablespace */
6363
bool is_system() const

extra/mariabackup/read_filt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
2727

2828
#include "changed_page_bitmap.h"
2929

30-
typedef ulint space_id_t;
30+
typedef uint32_t space_id_t;
3131

3232
struct xb_fil_cur_t;
3333

extra/mariabackup/write_filt.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ wf_incremental_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
124124
i++, page += page_size) {
125125

126126
if ((!cp->corrupted_pages ||
127-
!cp->corrupted_pages->contains(cursor->node->space->id,
128-
cursor->buf_page_no + i)) &&
127+
!cp->corrupted_pages->contains({cursor->node->space->id,
128+
cursor->buf_page_no + i})) &&
129129
incremental_lsn >= mach_read_from_8(page + FIL_PAGE_LSN))
130130
continue;
131131

0 commit comments

Comments
 (0)