~percona-dev/percona-server/release-5.1.47-12

1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
1
diff -ruN a/storage/innodb_plugin/buf/buf0buf.c b/storage/innodb_plugin/buf/buf0buf.c
2
--- a/storage/innodb_plugin/buf/buf0buf.c	2010-04-30 16:31:04.000000000 +0900
3
+++ b/storage/innodb_plugin/buf/buf0buf.c	2010-04-30 16:32:03.000000000 +0900
4
@@ -351,6 +351,27 @@
5
 	return(checksum);
6
 }
7
 
8
+UNIV_INTERN
9
+ulint
10
+buf_calc_page_new_checksum_32(
11
+/*==========================*/
12
+	const byte*	page)	/*!< in: buffer page */
13
+{
14
+	ulint checksum;
15
+
16
+	checksum = ut_fold_binary(page + FIL_PAGE_OFFSET,
17
+				  FIL_PAGE_FILE_FLUSH_LSN - FIL_PAGE_OFFSET)
18
+		+ ut_fold_binary(page + FIL_PAGE_DATA,
19
+				 FIL_PAGE_DATA_ALIGN_32 - FIL_PAGE_DATA)
20
+		+ ut_fold_binary_32(page + FIL_PAGE_DATA_ALIGN_32,
21
+				    UNIV_PAGE_SIZE - FIL_PAGE_DATA_ALIGN_32
22
+				    - FIL_PAGE_END_LSN_OLD_CHKSUM);
23
+
24
+	checksum = checksum & 0xFFFFFFFFUL;
25
+
26
+	return(checksum);
27
+}
28
+
29
 /********************************************************************//**
30
 In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only
31
 looked at the first few bytes of the page. This calculates that old
32
@@ -465,9 +486,21 @@
33
 		/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
34
 		(always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
35
 
36
-		if (checksum_field != 0
37
+		if (!srv_fast_checksum
38
+		    && checksum_field != 0
39
+		    && checksum_field != BUF_NO_CHECKSUM_MAGIC
40
+		    && checksum_field
41
+		    != buf_calc_page_new_checksum(read_buf)) {
42
+
43
+			return(TRUE);
44
+		}
45
+
46
+		if (srv_fast_checksum
47
+		    && checksum_field != 0
48
 		    && checksum_field != BUF_NO_CHECKSUM_MAGIC
49
 		    && checksum_field
50
+		    != buf_calc_page_new_checksum_32(read_buf)
51
+		    && checksum_field
52
 		    != buf_calc_page_new_checksum(read_buf)) {
53
 
54
 			return(TRUE);
55
@@ -491,6 +524,7 @@
56
 	dict_index_t*	index;
57
 #endif /* !UNIV_HOTBACKUP */
58
 	ulint		checksum;
59
+	ulint		checksum_32;
60
 	ulint		old_checksum;
61
 	ulint		size	= zip_size;
62
 
63
@@ -577,12 +611,14 @@
64
 
65
 	checksum = srv_use_checksums
66
 		? buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
67
+	checksum_32 = srv_use_checksums
68
+		? buf_calc_page_new_checksum_32(read_buf) : BUF_NO_CHECKSUM_MAGIC;
69
 	old_checksum = srv_use_checksums
70
 		? buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
71
 
72
 	ut_print_timestamp(stderr);
73
 	fprintf(stderr,
74
-		"  InnoDB: Page checksum %lu, prior-to-4.0.14-form"
75
+		"  InnoDB: Page checksum %lu (32bit_calc: %lu), prior-to-4.0.14-form"
76
 		" checksum %lu\n"
77
 		"InnoDB: stored checksum %lu, prior-to-4.0.14-form"
78
 		" stored checksum %lu\n"
79
@@ -591,7 +627,7 @@
80
 		"InnoDB: Page number (if stored to page already) %lu,\n"
81
 		"InnoDB: space id (if created with >= MySQL-4.1.1"
82
 		" and stored already) %lu\n",
83
-		(ulong) checksum, (ulong) old_checksum,
84
+		(ulong) checksum, (ulong) checksum_32, (ulong) old_checksum,
85
 		(ulong) mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM),
86
 		(ulong) mach_read_from_4(read_buf + UNIV_PAGE_SIZE
87
 					 - FIL_PAGE_END_LSN_OLD_CHKSUM),
88
diff -ruN a/storage/innodb_plugin/buf/buf0flu.c b/storage/innodb_plugin/buf/buf0flu.c
89
--- a/storage/innodb_plugin/buf/buf0flu.c	2010-04-30 14:13:25.000000000 +0900
90
+++ b/storage/innodb_plugin/buf/buf0flu.c	2010-04-30 16:32:03.000000000 +0900
9 by kinoyasu
port for 5.1.47-1.0.8
91
@@ -926,7 +926,9 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
92
 
93
 	mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
94
 			srv_use_checksums
95
-			? buf_calc_page_new_checksum(page)
96
+			? (!srv_fast_checksum
97
+			   ? buf_calc_page_new_checksum(page)
98
+			   : buf_calc_page_new_checksum_32(page))
99
 			: BUF_NO_CHECKSUM_MAGIC);
100
 
101
 	/* We overwrite the first 4 bytes of the end lsn field to store
102
diff -ruN a/storage/innodb_plugin/fil/fil0fil.c b/storage/innodb_plugin/fil/fil0fil.c
103
--- a/storage/innodb_plugin/fil/fil0fil.c	2010-04-30 16:31:04.000000000 +0900
104
+++ b/storage/innodb_plugin/fil/fil0fil.c	2010-04-30 16:32:03.000000000 +0900
105
@@ -3066,7 +3066,9 @@
106
 			mach_write_ull(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
107
 		mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
108
 				srv_use_checksums
109
-				? buf_calc_page_new_checksum(page)
110
+				? (!srv_fast_checksum
111
+				   ? buf_calc_page_new_checksum(page)
112
+				   : buf_calc_page_new_checksum_32(page))
113
 						: BUF_NO_CHECKSUM_MAGIC);
114
 		mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
115
 				srv_use_checksums
116
@@ -3178,7 +3180,8 @@
117
 					goto skip_write;
118
 				}
119
 
120
-				if (checksum_field != 0
121
+				if (!srv_fast_checksum
122
+				    && checksum_field != 0
123
 				    && checksum_field != BUF_NO_CHECKSUM_MAGIC
124
 				    && checksum_field
125
 				    != buf_calc_page_new_checksum(page)) {
126
@@ -3186,6 +3189,17 @@
127
 					goto skip_write;
128
 				}
129
 
130
+				if (srv_fast_checksum
131
+				    && checksum_field != 0
132
+				    && checksum_field != BUF_NO_CHECKSUM_MAGIC
133
+				    && checksum_field
134
+				    != buf_calc_page_new_checksum_32(page)
135
+				    && checksum_field
136
+				    != buf_calc_page_new_checksum(page)) {
137
+
138
+					goto skip_write;
139
+				}
140
+
141
 				if (mach_read_from_4(page + FIL_PAGE_OFFSET) || !offset) {
142
 					mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, id);
143
 
144
@@ -3260,7 +3274,9 @@
145
 
146
 					mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
147
 							srv_use_checksums
148
-							? buf_calc_page_new_checksum(page)
149
+							? (!srv_fast_checksum
150
+							   ? buf_calc_page_new_checksum(page)
151
+							   : buf_calc_page_new_checksum_32(page))
152
 									: BUF_NO_CHECKSUM_MAGIC);
153
 					mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
154
 							srv_use_checksums
155
diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
156
--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-30 16:31:04.000000000 +0900
157
+++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-30 16:32:03.000000000 +0900
9 by kinoyasu
port for 5.1.47-1.0.8
158
@@ -185,6 +185,7 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
159
 #endif /* UNIV_LOG_ARCHIVE */
160
 static my_bool	innobase_use_doublewrite		= TRUE;
161
 static my_bool	innobase_use_checksums			= TRUE;
162
+static my_bool	innobase_fast_checksum			= FALSE;
163
 static my_bool	innobase_extra_undoslots		= FALSE;
46 by kinoyasu
revive innodb_fast_recovery option only for comparibility
164
 static my_bool	innobase_fast_recovery			= FALSE;
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
165
 static my_bool	innobase_recovery_stats			= TRUE;
46 by kinoyasu
revive innodb_fast_recovery option only for comparibility
166
@@ -2339,6 +2340,7 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
167
 
168
 	srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
169
 	srv_use_checksums = (ibool) innobase_use_checksums;
170
+	srv_fast_checksum = (ibool) innobase_fast_checksum;
171
 
172
 #ifdef HAVE_LARGE_PAGES
173
         if ((os_use_large_pages = (ibool) my_use_large_pages))
46 by kinoyasu
revive innodb_fast_recovery option only for comparibility
174
@@ -10860,6 +10862,15 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
175
   "Disable with --skip-innodb-checksums.",
176
   NULL, NULL, TRUE);
177
 
178
+static MYSQL_SYSVAR_BOOL(fast_checksum, innobase_fast_checksum,
179
+  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
180
+  "Change the algorithm of checksum for the whole of datapage to 4-bytes word based. "
181
+  "The original checksum is checked after the new one. It may be slow for reading page"
182
+  " which has orginal checksum. Overwrite the page or recreate the InnoDB database, "
183
+  "if you want the entire benefit for performance at once. "
184
+  "#### Attention: The checksum is not compatible for normal or disabled version! ####",
185
+  NULL, NULL, FALSE);
186
+
187
 static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
188
   PLUGIN_VAR_READONLY,
189
   "The common part for InnoDB table spaces.",
46 by kinoyasu
revive innodb_fast_recovery option only for comparibility
190
@@ -11329,6 +11340,7 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
191
   MYSQL_SYSVAR(autoextend_increment),
192
   MYSQL_SYSVAR(buffer_pool_size),
193
   MYSQL_SYSVAR(checksums),
194
+  MYSQL_SYSVAR(fast_checksum),
195
   MYSQL_SYSVAR(commit_concurrency),
196
   MYSQL_SYSVAR(concurrency_tickets),
197
   MYSQL_SYSVAR(data_file_path),
198
diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
199
--- a/storage/innodb_plugin/handler/innodb_patch_info.h	2010-04-30 16:31:04.000000000 +0900
200
+++ b/storage/innodb_plugin/handler/innodb_patch_info.h	2010-04-30 16:32:03.000000000 +0900
10 by kinoyasu
Bug#53986 not seem to bug. intended. So, relax_table_creation option is removed.
201
@@ -44,5 +44,6 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
202
 {"innodb_lru_dump_restore","Dump and restore command for content of buffer pool","","http://www.percona.com/docs/wiki/percona-xtradb"},
9 by kinoyasu
port for 5.1.47-1.0.8
203
 {"innodb_separate_doublewrite","Add option 'innodb_doublewrite_file' to separate doublewrite dedicated tablespace","","http://www.percona.com/docs/wiki/percona-xtradb"},
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
204
 {"innodb_pass_corrupt_table","Treat tables as corrupt instead of crash, when meet corrupt blocks","","http://www.percona.com/docs/wiki/percona-xtradb"},
205
+{"innodb_fast_checksum","Using the checksum on 32bit-unit calculation","incompatible for unpatched ver.","http://www.percona.com/docs/wiki/percona-xtradb"},
206
 {NULL, NULL, NULL, NULL}
207
 };
208
diff -ruN a/storage/innodb_plugin/include/buf0buf.h b/storage/innodb_plugin/include/buf0buf.h
209
--- a/storage/innodb_plugin/include/buf0buf.h	2010-04-30 16:31:04.000000000 +0900
210
+++ b/storage/innodb_plugin/include/buf0buf.h	2010-04-30 16:32:03.000000000 +0900
211
@@ -477,6 +477,11 @@
212
 buf_calc_page_new_checksum(
213
 /*=======================*/
214
 	const byte*	page);	/*!< in: buffer page */
215
+UNIV_INTERN
216
+ulint
217
+buf_calc_page_new_checksum_32(
218
+/*==========================*/
219
+	const byte*	page);	/*!< in: buffer page */
220
 /********************************************************************//**
221
 In versions < 4.0.14 and < 4.1.1 there was a bug that the checksum only
222
 looked at the first few bytes of the page. This calculates that old
223
diff -ruN a/storage/innodb_plugin/include/fil0fil.h b/storage/innodb_plugin/include/fil0fil.h
224
--- a/storage/innodb_plugin/include/fil0fil.h	2010-04-30 16:31:04.000000000 +0900
225
+++ b/storage/innodb_plugin/include/fil0fil.h	2010-04-30 16:32:03.000000000 +0900
226
@@ -117,6 +117,7 @@
227
 #define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID  34 /*!< starting from 4.1.x this
228
 					contains the space id of the page */
229
 #define FIL_PAGE_DATA		38	/*!< start of the data on the page */
230
+#define FIL_PAGE_DATA_ALIGN_32	40
231
 /* @} */
232
 /** File page trailer @{ */
233
 #define FIL_PAGE_END_LSN_OLD_CHKSUM 8	/*!< the low 4 bytes of this are used
234
diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
235
--- a/storage/innodb_plugin/include/srv0srv.h	2010-04-30 16:31:04.000000000 +0900
236
+++ b/storage/innodb_plugin/include/srv0srv.h	2010-04-30 16:32:03.000000000 +0900
9 by kinoyasu
port for 5.1.47-1.0.8
237
@@ -210,6 +210,7 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
238
 
239
 extern ibool	srv_use_doublewrite_buf;
240
 extern ibool	srv_use_checksums;
241
+extern ibool	srv_fast_checksum;
242
 
243
 extern ibool	srv_set_thread_priorities;
244
 extern int	srv_query_thread_priority;
245
diff -ruN a/storage/innodb_plugin/include/ut0rnd.h b/storage/innodb_plugin/include/ut0rnd.h
246
--- a/storage/innodb_plugin/include/ut0rnd.h	2010-04-06 23:07:13.000000000 +0900
247
+++ b/storage/innodb_plugin/include/ut0rnd.h	2010-04-30 16:32:03.000000000 +0900
248
@@ -124,6 +124,13 @@
249
 	const byte*	str,	/*!< in: string of bytes */
250
 	ulint		len)	/*!< in: length */
251
 	__attribute__((pure));
252
+UNIV_INLINE
253
+ulint
254
+ut_fold_binary_32(
255
+/*==============*/
256
+	const byte*	str,	/*!< in: string of bytes */
257
+	ulint		len)	/*!< in: length */
258
+	__attribute__((pure));
259
 /***********************************************************//**
260
 Looks for a prime number slightly greater than the given argument.
261
 The prime is chosen so that it is not near any power of 2.
262
diff -ruN a/storage/innodb_plugin/include/ut0rnd.ic b/storage/innodb_plugin/include/ut0rnd.ic
263
--- a/storage/innodb_plugin/include/ut0rnd.ic	2010-04-06 23:07:13.000000000 +0900
264
+++ b/storage/innodb_plugin/include/ut0rnd.ic	2010-04-30 16:32:03.000000000 +0900
265
@@ -229,3 +229,28 @@
266
 
267
 	return(fold);
268
 }
269
+
270
+UNIV_INLINE
271
+ulint
272
+ut_fold_binary_32(
273
+/*==============*/
274
+	const byte*	str,	/*!< in: string of bytes */
275
+	ulint		len)	/*!< in: length */
276
+{
277
+	const ib_uint32_t*	str_end = (const ib_uint32_t*) (str + len);
278
+	const ib_uint32_t*	str_32 = (const ib_uint32_t*) str;
279
+	ulint			fold = 0;
280
+
281
+	ut_ad(str);
282
+	/* This function is only for word-aligned data */
283
+	ut_ad(len % 4 == 0);
284
+	ut_ad((ulint)str % 4 == 0);
285
+
286
+	while (str_32 < str_end) {
287
+		fold = ut_fold_ulint_pair(fold, (ulint)(*str_32));
288
+
289
+		str_32++;
290
+	}
291
+
292
+	return(fold);
293
+}
294
diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
295
--- a/storage/innodb_plugin/srv/srv0srv.c	2010-04-30 16:31:04.000000000 +0900
296
+++ b/storage/innodb_plugin/srv/srv0srv.c	2010-04-30 16:32:03.000000000 +0900
9 by kinoyasu
port for 5.1.47-1.0.8
297
@@ -379,6 +379,7 @@
1 by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7
298
 
299
 UNIV_INTERN ibool	srv_use_doublewrite_buf	= TRUE;
300
 UNIV_INTERN ibool	srv_use_checksums = TRUE;
301
+UNIV_INTERN ibool	srv_fast_checksum = FALSE;
302
 
303
 UNIV_INTERN ibool	srv_set_thread_priorities = TRUE;
304
 UNIV_INTERN int	srv_query_thread_priority = 0;