Skip to content

Commit

Permalink
MDEV-25361 innochecksum must not report errors for freed pages
Browse files Browse the repository at this point in the history
Store and maintain xdes pages always. And doesn't verify checksums for
freed pages.

innochecksum can work only with the first space file of multiple ones.
Tell about it and abort in case of not the first file.
  • Loading branch information
kevgs committed Jul 20, 2021
1 parent 5f8651a commit 1918bdf
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions extra/innochecksum.cc
Expand Up @@ -817,6 +817,16 @@ write_file(
return(true);
}

// checks using current xdes page whether the page is free
static bool page_is_free(const byte *xdes, page_size_t page_size,
size_t page_no)
{
const byte *des=
xdes + XDES_ARR_OFFSET +
XDES_SIZE * ((page_no & (page_size.physical() - 1)) / FSP_EXTENT_SIZE);
return xdes_get_bit(des, XDES_FREE_BIT, page_no % FSP_EXTENT_SIZE);
}

/*
Parse the page and collect/dump the information about page type
@param [in] page buffer page
Expand Down Expand Up @@ -908,11 +918,7 @@ parse_page(
std::map<unsigned long long, per_index_stats>::iterator it;
it = index_ids.find(id);
per_index_stats &index = (it->second);
const byte* des = xdes + XDES_ARR_OFFSET
+ XDES_SIZE * ((page_no & (page_size.physical() - 1))
/ FSP_EXTENT_SIZE);
if (xdes_get_bit(des, XDES_FREE_BIT,
page_no % FSP_EXTENT_SIZE)) {
if (page_is_free(xdes, page_size, page_no)) {
index.free_pages++;
return;
}
Expand Down Expand Up @@ -1072,7 +1078,6 @@ parse_page(

case FIL_PAGE_TYPE_FSP_HDR:
page_type.n_fil_page_type_fsp_hdr++;
memcpy(xdes, page, page_size.physical());
if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tFile Space "
"Header\t\t|\t%s\n", cur_page_num, str);
Expand All @@ -1081,7 +1086,6 @@ parse_page(

case FIL_PAGE_TYPE_XDES:
page_type.n_fil_page_type_xdes++;
memcpy(xdes, page, page_size.physical());
if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tExtent descriptor "
"page\t\t|\t%s\n", cur_page_num, str);
Expand Down Expand Up @@ -1814,6 +1818,8 @@ int main(
printf("page %llu ", cur_page_num);
}

memcpy(xdes, buf, physical_page_size);

if (page_type_summary || page_type_dump) {
parse_page(buf, xdes, fil_page_type, page_size, is_encrypted);
}
Expand Down Expand Up @@ -1992,6 +1998,7 @@ int main(
/* If no-check is enabled, skip the
checksum verification.*/
if (!no_check
&& !page_is_free(xdes, page_size, cur_page_num)
&& !skip_page
&& (exit_status = verify_checksum(
buf, page_size,
Expand All @@ -2014,6 +2021,10 @@ int main(
printf("page %llu ", cur_page_num);
}

if (page_get_page_no(buf) % physical_page_size == 0) {
memcpy(xdes, buf, physical_page_size);
}

if (page_type_summary || page_type_dump) {
parse_page(buf, xdes, fil_page_type, page_size, is_encrypted);
}
Expand Down

0 comments on commit 1918bdf

Please sign in to comment.