Merge lp:~gaul/percona-data-recovery-tool-for-innodb/calculate-new-checksum-first into lp:percona-data-recovery-tool-for-innodb

Proposed by Andrew Gaul
Status: Merged
Merged at revision: 60
Proposed branch: lp:~gaul/percona-data-recovery-tool-for-innodb/calculate-new-checksum-first
Merge into: lp:percona-data-recovery-tool-for-innodb
Diff against target: 94 lines (+37/-29)
2 files modified
include/innochecksum.h (+8/-0)
innochecksum.c (+29/-29)
To merge this branch: bzr merge lp:~gaul/percona-data-recovery-tool-for-innodb/calculate-new-checksum-first
Reviewer Review Type Date Requested Status
Aleksandr Kuzminsky (community) Approve
Review via email: mp+118011@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aleksandr Kuzminsky (akuzminsky) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/innochecksum.h'
2--- include/innochecksum.h 2010-09-21 07:54:13 +0000
3+++ include/innochecksum.h 2012-08-02 22:57:21 +0000
4@@ -134,6 +134,14 @@
5 return(checksum);
6 }
7
8+/********************************************************************//**
9+In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only
10+looked at the first few bytes of the page. This calculates that old
11+checksum.
12+NOTE: we must first store the new formula checksum to
13+FIL_PAGE_SPACE_OR_CHKSUM before calculating and storing this old checksum
14+because this takes that field as an input!
15+@return checksum */
16 ulint
17 buf_calc_page_old_checksum(
18 /*=======================*/
19
20=== modified file 'innochecksum.c'
21--- innochecksum.c 2010-09-21 07:54:13 +0000
22+++ innochecksum.c 2012-08-02 22:57:21 +0000
23@@ -208,6 +208,35 @@
24 }
25 }
26
27+ /* now check the new method */
28+ csum= buf_calc_page_new_checksum(p);
29+ csumfield= mach_read_from_4(p + FIL_PAGE_SPACE_OR_CHKSUM);
30+ if (debug)
31+ printf("page %lu: new style: calculated = %lu; recorded = %lu\n", ct, csum, csumfield);
32+ if (csumfield != 0 && csum != csumfield)
33+ {
34+ fprintf(stderr, "page %lu invalid (fails new style checksum)\n", ct);
35+ fprintf(stderr, "page %lu: new style: calculated = 0x%X; recorded = 0x%X\n", ct, csum, csumfield);
36+ if(fix_checksum){
37+ fprintf(stderr, "fixing new checksum of page %lu\n", ct);
38+ // rewite recorded checksum with calculated one
39+ fixed_chksum = mach_read_from_4((uchar*)&csum);
40+ memcpy(p + FIL_PAGE_SPACE_OR_CHKSUM, &fixed_chksum, sizeof(fixed_chksum));
41+ // move to beginning of the page
42+ if(0 != fsetpos(f, &pos)){
43+ perror("couldn't set a position to the start of the page");
44+ return 1;
45+ }
46+ if(1 != fwrite(p, UNIV_PAGE_SIZE, 1, f)){
47+ perror("couldn't update the page");
48+ return 1;
49+ }
50+ }
51+ else{
52+ return 1;
53+ }
54+ }
55+
56 /* check old method of checksumming */
57 oldcsum= buf_calc_page_old_checksum(p);
58 oldcsumfield= mach_read_from_4(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
59@@ -238,35 +267,6 @@
60 }
61 }
62
63- /* now check the new method */
64- csum= buf_calc_page_new_checksum(p);
65- csumfield= mach_read_from_4(p + FIL_PAGE_SPACE_OR_CHKSUM);
66- if (debug)
67- printf("page %lu: new style: calculated = %lu; recorded = %lu\n", ct, csum, csumfield);
68- if (csumfield != 0 && csum != csumfield)
69- {
70- fprintf(stderr, "page %lu invalid (fails new style checksum)\n", ct);
71- fprintf(stderr, "page %lu: new style: calculated = 0x%X; recorded = 0x%X\n", ct, csum, csumfield);
72- if(fix_checksum){
73- fprintf(stderr, "fixing new checksum of page %lu\n", ct);
74- // rewite recorded checksum with calculated one
75- fixed_chksum = mach_read_from_4((uchar*)&csum);
76- memcpy(p + FIL_PAGE_SPACE_OR_CHKSUM, &fixed_chksum, sizeof(fixed_chksum));
77- // move to beginning of the page
78- if(0 != fsetpos(f, &pos)){
79- perror("couldn't set a position to the start of the page");
80- return 1;
81- }
82- if(1 != fwrite(p, UNIV_PAGE_SIZE, 1, f)){
83- perror("couldn't update the page");
84- return 1;
85- }
86- }
87- else{
88- return 1;
89- }
90- }
91-
92 /* end if this was the last page we were supposed to check */
93 if (use_end_page && (ct >= end_page))
94 return 0;

Subscribers

People subscribed via source and target branches