Merge lp:~gaul/percona-data-recovery-tool-for-innodb/innochecksum-write-page-only-once into lp:percona-data-recovery-tool-for-innodb

Proposed by Andrew Gaul
Status: Merged
Merged at revision: 67
Proposed branch: lp:~gaul/percona-data-recovery-tool-for-innodb/innochecksum-write-page-only-once
Merge into: lp:percona-data-recovery-tool-for-innodb
Diff against target: 81 lines (+17/-27)
1 file modified
innochecksum.c (+17/-27)
To merge this branch: bzr merge lp:~gaul/percona-data-recovery-tool-for-innodb/innochecksum-write-page-only-once
Reviewer Review Type Date Requested Status
Percona developers Pending
Review via email: mp+119064@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'innochecksum.c'
2--- innochecksum.c 2012-08-07 20:36:41 +0000
3+++ innochecksum.c 2012-08-10 00:00:29 +0000
4@@ -172,6 +172,8 @@
5 lastt= 0;
6 while (!feof(f))
7 {
8+ int modified = 0;
9+
10 fgetpos(f, &pos);
11 bytes= fread(p, 1, UNIV_PAGE_SIZE, f);
12 if (!bytes && feof(f)) return 0;
13@@ -195,15 +197,7 @@
14 buf_lsn = mach_read_from_4((uchar*)&fixed_lsn);
15 memcpy(p + FIL_PAGE_LSN + 4, &buf_lsn, sizeof(buf_lsn));
16 memcpy(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4, &buf_lsn, sizeof(buf_lsn));
17- // move to beginning of the page
18- if(0 != fsetpos(f, &pos)){
19- perror("couldn't set a position to the start of the page");
20- return 1;
21- }
22- if(1 != fwrite(p, UNIV_PAGE_SIZE, 1, f)){
23- perror("couldn't update the page");
24- return 1;
25- }
26+ modified = 1;
27 }
28 else{
29 return 1;
30@@ -224,15 +218,7 @@
31 // rewite recorded checksum with calculated one
32 fixed_chksum = mach_read_from_4((uchar*)&csum);
33 memcpy(p + FIL_PAGE_SPACE_OR_CHKSUM, &fixed_chksum, sizeof(fixed_chksum));
34- // move to beginning of the page
35- if(0 != fsetpos(f, &pos)){
36- perror("couldn't set a position to the start of the page");
37- return 1;
38- }
39- if(1 != fwrite(p, UNIV_PAGE_SIZE, 1, f)){
40- perror("couldn't update the page");
41- return 1;
42- }
43+ modified = 1;
44 }
45 else{
46 return 1;
47@@ -253,21 +239,25 @@
48 // rewite recorded checksum with calculated one
49 fixed_chksum = mach_read_from_4((uchar*)&oldcsum);
50 memcpy(p + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, &fixed_chksum, sizeof(fixed_chksum));
51- // move to the beginning of the page
52- if(0 != fsetpos(f, &pos)){
53- perror("couldn't set a position to the start of the page");
54- return 1;
55- }
56- if(1 != fwrite(p, UNIV_PAGE_SIZE, 1, f)){
57- perror("couldn't update the page");
58- return 1;
59- }
60+ modified = 1;
61 }
62 else{
63 return 1;
64 }
65 }
66
67+ if (modified) {
68+ // move to the beginning of the page
69+ if(0 != fsetpos(f, &pos)) {
70+ perror("couldn't set a position to the start of the page");
71+ return 1;
72+ }
73+ if(1 != fwrite(p, UNIV_PAGE_SIZE, 1, f)) {
74+ perror("couldn't update the page");
75+ return 1;
76+ }
77+ }
78+
79 /* end if this was the last page we were supposed to check */
80 if (use_end_page && (ct >= end_page))
81 return 0;

Subscribers

People subscribed via source and target branches