~percona-dev/percona-server/release-5.1.51-11-fixbug658274

« back to all changes in this revision

Viewing changes to innodb_buffer_pool_shm.patch

fix bug643650: change to use ut_fold_binary_32 for checksum

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
 /********************************************************************//**
97
97
 Allocates a chunk of buffer frames.
98
98
 @return        chunk, or NULL on failure */
99
 
@@ -768,26 +835,170 @@
 
99
@@ -768,26 +835,174 @@
100
100
 {
101
101
        buf_block_t*    block;
102
102
        byte*           frame;
167
167
+                       memset(chunk->mem, '\0', chunk->mem_size);
168
168
+               }
169
169
+#endif
 
170
+               /* for ut_fold_binary_32(), these values should be 32-bit aligned */
 
171
+               ut_a(sizeof(buf_shm_info_t) % 4 == 0);
 
172
+               ut_a((ulint)chunk->mem % 4 == 0);
 
173
+               ut_a(chunk->mem_size % 4 == 0);
170
174
+
171
175
+               shm_info = chunk->mem;
172
176
+
227
231
+                       ut_a(shm_info->zip_hash_n == zip_hash_n);
228
232
+
229
233
+                       /* check checksum */
230
 
+                       checksum = ut_fold_binary((byte*)chunk->mem + sizeof(buf_shm_info_t),
 
234
+                       checksum = ut_fold_binary_32((byte*)chunk->mem + sizeof(buf_shm_info_t),
231
235
+                                                 chunk->mem_size - sizeof(buf_shm_info_t));
232
236
+                       if (shm_info->checksum != checksum) {
233
237
+                               fprintf(stderr,
267
271
 
268
272
        /* Align a pointer to the first frame.  Note that when
269
273
        os_large_page_size is smaller than UNIV_PAGE_SIZE,
270
 
@@ -795,8 +1006,13 @@
 
274
@@ -795,8 +1010,13 @@
271
275
        it is bigger, we may allocate more blocks than requested. */
272
276
 
273
277
        frame = ut_align(chunk->mem, UNIV_PAGE_SIZE);
281
285
 
282
286
        /* Subtract the space needed for block descriptors. */
283
287
        {
284
 
@@ -810,6 +1026,98 @@
 
288
@@ -810,6 +1030,98 @@
285
289
                chunk->size = size;
286
290
        }
287
291
 
380
384
        /* Init block structs and assign frames for them. Then we
381
385
        assign the frames to the first blocks (we already mapped the
382
386
        memory above). */
383
 
@@ -833,6 +1141,11 @@
 
387
@@ -833,6 +1145,11 @@
384
388
                block++;
385
389
                frame += UNIV_PAGE_SIZE;
386
390
        }
392
396
 
393
397
        return(chunk);
394
398
 }
395
 
@@ -1014,6 +1327,8 @@
 
399
@@ -1014,6 +1331,8 @@
396
400
                UNIV_MEM_UNDESC(block);
397
401
        }
398
402
 
401
405
        os_mem_free_large(chunk->mem, chunk->mem_size);
402
406
 }
403
407
 
404
 
@@ -1063,7 +1378,10 @@
 
408
@@ -1063,7 +1382,10 @@
405
409
        srv_buf_pool_curr_size = buf_pool->curr_size * UNIV_PAGE_SIZE;
406
410
 
407
411
        buf_pool->page_hash = hash_create(2 * buf_pool->curr_size);
412
416
 
413
417
        buf_pool->last_printout_time = time(NULL);
414
418
 
415
 
@@ -1078,6 +1396,86 @@
 
419
@@ -1078,6 +1400,86 @@
416
420
        --------------------------- */
417
421
        /* All fields are initialized by mem_zalloc(). */
418
422
 
499
503
        mutex_exit(&LRU_list_mutex);
500
504
        rw_lock_x_unlock(&page_hash_latch);
501
505
        buf_pool_mutex_exit();
502
 
@@ -1102,6 +1500,30 @@
 
506
@@ -1102,6 +1504,30 @@
503
507
        buf_chunk_t*    chunk;
504
508
        buf_chunk_t*    chunks;
505
509
 
520
524
+               memcpy(&(shm_info->chunk_backup), chunk, sizeof(buf_chunk_t));
521
525
+
522
526
+               if (srv_fast_shutdown < 2) {
523
 
+                       shm_info->checksum = ut_fold_binary((byte*)chunk->mem + sizeof(buf_shm_info_t),
 
527
+                       shm_info->checksum = ut_fold_binary_32((byte*)chunk->mem + sizeof(buf_shm_info_t),
524
528
+                                                           chunk->mem_size - sizeof(buf_shm_info_t));
525
529
+                       shm_info->clean = TRUE;
526
530
+               }
530
534
        chunks = buf_pool->chunks;
531
535
        chunk = chunks + buf_pool->n_chunks;
532
536
 
533
 
@@ -1110,10 +1532,13 @@
 
537
@@ -1110,10 +1536,13 @@
534
538
                would fail at shutdown. */
535
539
                os_mem_free_large(chunk->mem, chunk->mem_size);
536
540
        }
544
548
        mem_free(buf_pool);
545
549
        buf_pool = NULL;
546
550
 }
547
 
@@ -1308,6 +1733,11 @@
 
551
@@ -1308,6 +1737,11 @@
548
552
        //buf_pool_mutex_enter();
549
553
        mutex_enter(&LRU_list_mutex);
550
554
 
556
560
 shrink_again:
557
561
        if (buf_pool->n_chunks <= 1) {
558
562
 
559
 
@@ -1551,6 +1981,11 @@
 
563
@@ -1551,6 +1985,11 @@
560
564
 buf_pool_resize(void)
561
565
 /*=================*/
562
566
 {