~longbow/percona-server/ps55_log_slow_rate_limit

« back to all changes in this revision

Viewing changes to innodb_split_buf_pool_mutex.patch

  • Committer: Stewart Smith
  • Date: 2011-06-24 04:56:14 UTC
  • mfrom: (131.2.1 5.5.13-tmp)
  • Revision ID: stewart@flamingspork.com-20110624045614-60ijn09a51kbsr6w
merge fix of valgrind errors in various federated test cases on 32bit valgrind.

Show diffs side-by-side

added added

removed removed

Lines of Context:
592
592
 UNIV_INTERN mysql_pfs_key_t    flush_list_mutex_key;
593
593
 #endif /* UNIV_PFS_MUTEX */
594
594
 
595
 
@@ -881,9 +886,9 @@
 
595
@@ -881,9 +886,13 @@
596
596
        block->page.in_zip_hash = FALSE;
597
597
        block->page.in_flush_list = FALSE;
598
598
        block->page.in_free_list = FALSE;
599
599
-       block->in_unzip_LRU_list = FALSE;
600
600
 #endif /* UNIV_DEBUG */
 
601
+       block->page.flush_list.prev = NULL;
 
602
+       block->page.flush_list.next = NULL;
 
603
+       block->page.zip_list.prev = NULL;
 
604
+       block->page.zip_list.next = NULL;
601
605
        block->page.in_LRU_list = FALSE;
602
606
+       block->in_unzip_LRU_list = FALSE;
603
607
 #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
604
608
        block->n_pointers = 0;
605
609
 #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
606
 
@@ -981,9 +986,11 @@
 
610
@@ -981,9 +990,11 @@
607
611
                memset(block->frame, '\0', UNIV_PAGE_SIZE);
608
612
 #endif
609
613
                /* Add the block to the free list */
616
620
                ut_ad(buf_pool_from_block(block) == buf_pool);
617
621
 
618
622
                block++;
619
 
@@ -1038,7 +1045,8 @@
 
623
@@ -1038,7 +1049,8 @@
620
624
        buf_chunk_t*    chunk = buf_pool->chunks;
621
625
 
622
626
        ut_ad(buf_pool);
626
630
        for (n = buf_pool->n_chunks; n--; chunk++) {
627
631
 
628
632
                buf_block_t* block = buf_chunk_contains_zip(chunk, data);
629
 
@@ -1138,7 +1146,7 @@
 
633
@@ -1138,7 +1150,7 @@
630
634
        buf_block_t*            block;
631
635
        const buf_block_t*      block_end;
632
636
 
635
639
 
636
640
        block_end = chunk->blocks + chunk->size;
637
641
 
638
 
@@ -1150,8 +1158,10 @@
 
642
@@ -1150,8 +1162,10 @@
639
643
                ut_ad(!block->in_unzip_LRU_list);
640
644
                ut_ad(!block->page.in_flush_list);
641
645
                /* Remove the block from the free list. */
647
651
 
648
652
                /* Free the latches. */
649
653
                mutex_free(&block->mutex);
650
 
@@ -1208,9 +1218,21 @@
 
654
@@ -1208,9 +1222,21 @@
651
655
        ------------------------------- */
652
656
        mutex_create(buf_pool_mutex_key,
653
657
                     &buf_pool->mutex, SYNC_BUF_POOL);
669
673
        buf_pool_mutex_enter(buf_pool);
670
674
 
671
675
        if (buf_pool_size > 0) {
672
 
@@ -1223,6 +1245,8 @@
 
676
@@ -1223,6 +1249,8 @@
673
677
                        mem_free(chunk);
674
678
                        mem_free(buf_pool);
675
679
 
678
682
                        buf_pool_mutex_exit(buf_pool);
679
683
 
680
684
                        return(DB_ERROR);
681
 
@@ -1253,6 +1277,8 @@
 
685
@@ -1253,6 +1281,8 @@
682
686
 
683
687
        /* All fields are initialized by mem_zalloc(). */
684
688
 
687
691
        buf_pool_mutex_exit(buf_pool);
688
692
 
689
693
        return(DB_SUCCESS);
690
 
@@ -1467,7 +1493,11 @@
 
694
@@ -1467,7 +1497,11 @@
691
695
        ulint           fold;
692
696
        buf_pool_t*     buf_pool = buf_pool_from_bpage(bpage);
693
697
 
700
704
        ut_ad(mutex_own(buf_page_get_mutex(bpage)));
701
705
        ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE);
702
706
        ut_a(bpage->buf_fix_count == 0);
703
 
@@ -1554,7 +1584,8 @@
 
707
@@ -1554,7 +1588,8 @@
704
708
 
705
709
 try_again:
706
710
        btr_search_disable(); /* Empty the adaptive hash index again */
710
714
 
711
715
 shrink_again:
712
716
        if (buf_pool->n_chunks <= 1) {
713
 
@@ -1625,7 +1656,7 @@
 
717
@@ -1625,7 +1660,7 @@
714
718
 
715
719
                                buf_LRU_make_block_old(&block->page);
716
720
                                dirty++;
719
723
                                   != BUF_LRU_FREED) {
720
724
                                nonfree++;
721
725
                        }
722
 
@@ -1633,7 +1664,8 @@
 
726
@@ -1633,7 +1668,8 @@
723
727
                        mutex_exit(&block->mutex);
724
728
                }
725
729
 
729
733
 
730
734
                /* Request for a flush of the chunk if it helps.
731
735
                Do not flush if there are non-free blocks, since
732
 
@@ -1683,7 +1715,8 @@
 
736
@@ -1683,7 +1719,8 @@
733
737
 func_done:
734
738
        buf_pool->old_pool_size = buf_pool->curr_pool_size;
735
739
 func_exit:
739
743
        btr_search_enable();
740
744
 }
741
745
 
742
 
@@ -1724,7 +1757,9 @@
 
746
@@ -1724,7 +1761,9 @@
743
747
        hash_table_t*   zip_hash;
744
748
        hash_table_t*   page_hash;
745
749
 
750
754
 
751
755
        /* Free, create, and populate the hash table. */
752
756
        hash_table_free(buf_pool->page_hash);
753
 
@@ -1765,8 +1800,9 @@
 
757
@@ -1765,8 +1804,9 @@
754
758
        All such blocks are either in buf_pool->zip_clean or
755
759
        in buf_pool->flush_list. */
756
760
 
761
765
                ut_a(buf_page_get_state(b) == BUF_BLOCK_ZIP_PAGE);
762
766
                ut_ad(!b->in_flush_list);
763
767
                ut_ad(b->in_LRU_list);
764
 
@@ -1776,10 +1812,11 @@
 
768
@@ -1776,10 +1816,11 @@
765
769
                HASH_INSERT(buf_page_t, hash, page_hash,
766
770
                            buf_page_address_fold(b->space, b->offset), b);
767
771
        }
774
778
                ut_ad(b->in_flush_list);
775
779
                ut_ad(b->in_LRU_list);
776
780
                ut_ad(b->in_page_hash);
777
 
@@ -1806,7 +1843,9 @@
 
781
@@ -1806,7 +1847,9 @@
778
782
        }
779
783
 
780
784
        buf_flush_list_mutex_exit(buf_pool);
785
789
 }
786
790
 
787
791
 /********************************************************************
788
 
@@ -1853,21 +1892,32 @@
 
792
@@ -1853,21 +1896,32 @@
789
793
        buf_page_t*     bpage;
790
794
        ulint           i;
791
795
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
819
823
        for (i = 0; i < BUF_POOL_WATCH_SIZE; i++) {
820
824
                bpage = &buf_pool->watch[i];
821
825
 
822
 
@@ -1891,10 +1941,12 @@
 
826
@@ -1891,10 +1945,12 @@
823
827
                        bpage->space = space;
824
828
                        bpage->offset = offset;
825
829
                        bpage->buf_fix_count = 1;
833
837
                        return(NULL);
834
838
                case BUF_BLOCK_ZIP_PAGE:
835
839
                        ut_ad(bpage->in_page_hash);
836
 
@@ -1912,6 +1964,8 @@
 
840
@@ -1912,6 +1968,8 @@
837
841
        ut_error;
838
842
 
839
843
        /* Fix compiler warning */
842
846
        return(NULL);
843
847
 }
844
848
 
845
 
@@ -1941,6 +1995,8 @@
 
849
@@ -1941,6 +1999,8 @@
846
850
        buf_chunk_t*    chunks;
847
851
        buf_chunk_t*    chunk;
848
852
 
851
855
        buf_pool_mutex_enter(buf_pool);
852
856
        chunks = mem_alloc((buf_pool->n_chunks + 1) * sizeof *chunks);
853
857
 
854
 
@@ -1959,6 +2015,8 @@
 
858
@@ -1959,6 +2019,8 @@
855
859
                buf_pool->n_chunks++;
856
860
        }
857
861
 
860
864
        buf_pool_mutex_exit(buf_pool);
861
865
 }
862
866
 
863
 
@@ -2046,7 +2104,11 @@
 
867
@@ -2046,7 +2108,11 @@
864
868
                                        space, offset) */
865
869
        buf_page_t*     watch)          /*!< in/out: sentinel for watch */
866
870
 {
873
877
 
874
878
        HASH_DELETE(buf_page_t, hash, buf_pool->page_hash, fold, watch);
875
879
        ut_d(watch->in_page_hash = FALSE);
876
 
@@ -2068,28 +2130,31 @@
 
880
@@ -2068,28 +2134,31 @@
877
881
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
878
882
        ulint           fold = buf_page_address_fold(space, offset);
879
883
 
909
913
 }
910
914
 
911
915
 /****************************************************************//**
912
 
@@ -2109,14 +2174,16 @@
 
916
@@ -2109,14 +2178,16 @@
913
917
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
914
918
        ulint           fold    = buf_page_address_fold(space, offset);
915
919
 
928
932
 
929
933
        return(ret);
930
934
 }
931
 
@@ -2133,13 +2200,15 @@
 
935
@@ -2133,13 +2204,15 @@
932
936
 {
933
937
        buf_pool_t*     buf_pool = buf_pool_from_bpage(bpage);
934
938
 
946
950
 }
947
951
 
948
952
 /********************************************************************//**
949
 
@@ -2163,14 +2232,20 @@
 
953
@@ -2163,14 +2236,20 @@
950
954
        ut_a(buf_page_in_file(bpage));
951
955
 
952
956
        if (buf_page_peek_if_too_old(bpage)) {
971
975
        }
972
976
 }
973
977
 
974
 
@@ -2187,7 +2262,8 @@
 
978
@@ -2187,7 +2266,8 @@
975
979
        buf_block_t*    block;
976
980
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
977
981
 
981
985
 
982
986
        block = (buf_block_t*) buf_page_hash_get(buf_pool, space, offset);
983
987
 
984
 
@@ -2196,7 +2272,8 @@
 
988
@@ -2196,7 +2276,8 @@
985
989
                block->check_index_page_at_flush = FALSE;
986
990
        }
987
991
 
991
995
 }
992
996
 
993
997
 /********************************************************************//**
994
 
@@ -2215,7 +2292,8 @@
 
998
@@ -2215,7 +2296,8 @@
995
999
        ibool           is_hashed;
996
1000
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
997
1001
 
1001
1005
 
1002
1006
        block = (buf_block_t*) buf_page_hash_get(buf_pool, space, offset);
1003
1007
 
1004
 
@@ -2226,7 +2304,8 @@
 
1008
@@ -2226,7 +2308,8 @@
1005
1009
                is_hashed = block->is_hashed;
1006
1010
        }
1007
1011
 
1011
1015
 
1012
1016
        return(is_hashed);
1013
1017
 }
1014
 
@@ -2248,7 +2327,8 @@
 
1018
@@ -2248,7 +2331,8 @@
1015
1019
        buf_page_t*     bpage;
1016
1020
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
1017
1021
 
1021
1025
 
1022
1026
        bpage = buf_page_hash_get(buf_pool, space, offset);
1023
1027
 
1024
 
@@ -2259,7 +2339,8 @@
 
1028
@@ -2259,7 +2343,8 @@
1025
1029
                bpage->file_page_was_freed = TRUE;
1026
1030
        }
1027
1031
 
1031
1035
 
1032
1036
        return(bpage);
1033
1037
 }
1034
 
@@ -2280,7 +2361,8 @@
 
1038
@@ -2280,7 +2365,8 @@
1035
1039
        buf_page_t*     bpage;
1036
1040
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
1037
1041
 
1041
1045
 
1042
1046
        bpage = buf_page_hash_get(buf_pool, space, offset);
1043
1047
 
1044
 
@@ -2289,7 +2371,8 @@
 
1048
@@ -2289,7 +2375,8 @@
1045
1049
                bpage->file_page_was_freed = FALSE;
1046
1050
        }
1047
1051
 
1051
1055
 
1052
1056
        return(bpage);
1053
1057
 }
1054
 
@@ -2321,8 +2404,9 @@
 
1058
@@ -2321,8 +2408,9 @@
1055
1059
        buf_pool->stat.n_page_gets++;
1056
1060
 
1057
1061
        for (;;) {
1062
1066
                bpage = buf_page_hash_get(buf_pool, space, offset);
1063
1067
                if (bpage) {
1064
1068
                        ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage));
1065
 
@@ -2331,7 +2415,8 @@
 
1069
@@ -2331,7 +2419,8 @@
1066
1070
 
1067
1071
                /* Page not in buf_pool: needs to be read from file */
1068
1072
 
1072
1076
 
1073
1077
                buf_read_page(space, zip_size, offset);
1074
1078
 
1075
 
@@ -2343,10 +2428,15 @@
 
1079
@@ -2343,10 +2432,15 @@
1076
1080
        if (UNIV_UNLIKELY(!bpage->zip.data)) {
1077
1081
                /* There is no compressed page. */
1078
1082
 err_exit:
1089
1093
        ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage));
1090
1094
 
1091
1095
        switch (buf_page_get_state(bpage)) {
1092
 
@@ -2355,19 +2445,19 @@
 
1096
@@ -2355,19 +2449,19 @@
1093
1097
        case BUF_BLOCK_MEMORY:
1094
1098
        case BUF_BLOCK_REMOVE_HASH:
1095
1099
        case BUF_BLOCK_ZIP_FREE:
1114
1118
 
1115
1119
                        mutex_exit(block_mutex);
1116
1120
                        goto lookup;
1117
 
@@ -2385,7 +2475,7 @@
 
1121
@@ -2385,7 +2479,7 @@
1118
1122
        must_read = buf_page_get_io_fix(bpage) == BUF_IO_READ;
1119
1123
        access_time = buf_page_is_accessed(bpage);
1120
1124
 
1123
1127
 
1124
1128
        mutex_exit(block_mutex);
1125
1129
 
1126
 
@@ -2697,7 +2787,7 @@
 
1130
@@ -2697,7 +2791,7 @@
1127
1131
        const buf_block_t*      block)          /*!< in: pointer to block,
1128
1132
                                                not dereferenced */
1129
1133
 {
1132
1136
 
1133
1137
        if (UNIV_UNLIKELY((((ulint) block) % sizeof *block) != 0)) {
1134
1138
                /* The pointer should be aligned. */
1135
 
@@ -2733,6 +2823,7 @@
 
1139
@@ -2733,6 +2827,7 @@
1136
1140
        ulint           fix_type;
1137
1141
        ibool           must_read;
1138
1142
        ulint           retries = 0;
1140
1144
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
1141
1145
 
1142
1146
        ut_ad(mtr);
1143
 
@@ -2765,9 +2856,11 @@
 
1147
@@ -2765,9 +2860,11 @@
1144
1148
        fold = buf_page_address_fold(space, offset);
1145
1149
 loop:
1146
1150
        block = guess;
1153
1157
                /* If the guess is a compressed page descriptor that
1154
1158
                has been allocated by buf_buddy_alloc(), it may have
1155
1159
                been invalidated by buf_buddy_relocate().  In that
1156
 
@@ -2776,11 +2869,15 @@
 
1160
@@ -2776,11 +2873,15 @@
1157
1161
                the guess may be pointing to a buffer pool chunk that
1158
1162
                has been released when resizing the buffer pool. */
1159
1163
 
1170
1174
                        block = guess = NULL;
1171
1175
                } else {
1172
1176
                        ut_ad(!block->page.in_zip_hash);
1173
 
@@ -2789,12 +2886,19 @@
 
1177
@@ -2789,12 +2890,19 @@
1174
1178
        }
1175
1179
 
1176
1180
        if (block == NULL) {
1190
1194
                block = NULL;
1191
1195
        }
1192
1196
 
1193
 
@@ -2806,12 +2910,14 @@
 
1197
@@ -2806,12 +2914,14 @@
1194
1198
                                space, offset, fold);
1195
1199
 
1196
1200
                        if (UNIV_LIKELY_NULL(block)) {
1207
1211
 
1208
1212
                if (mode == BUF_GET_IF_IN_POOL
1209
1213
                    || mode == BUF_PEEK_IF_IN_POOL
1210
 
@@ -2861,7 +2967,8 @@
 
1214
@@ -2861,7 +2971,8 @@
1211
1215
                /* The page is being read to buffer pool,
1212
1216
                but we cannot wait around for the read to
1213
1217
                complete. */
1217
1221
 
1218
1222
                return(NULL);
1219
1223
        }
1220
 
@@ -2871,38 +2978,49 @@
 
1224
@@ -2871,38 +2982,49 @@
1221
1225
                ibool           success;
1222
1226
 
1223
1227
        case BUF_BLOCK_FILE_PAGE:
1274
1278
 
1275
1279
                {
1276
1280
                        buf_page_t*     hash_bpage;
1277
 
@@ -2915,35 +3033,47 @@
 
1281
@@ -2915,35 +3037,47 @@
1278
1282
                                while buf_pool->mutex was released.
1279
1283
                                Free the block that was allocated. */
1280
1284
 
1328
1332
                buf_block_init_low(block);
1329
1333
                block->lock_hash_val = lock_rec_hash(space, offset);
1330
1334
 
1331
 
@@ -2952,7 +3082,7 @@
 
1335
@@ -2952,7 +3086,7 @@
1332
1336
 
1333
1337
                if (buf_page_get_state(&block->page)
1334
1338
                    == BUF_BLOCK_ZIP_PAGE) {
1337
1341
                                       &block->page);
1338
1342
                        ut_ad(!block->page.in_flush_list);
1339
1343
                } else {
1340
 
@@ -2969,20 +3099,25 @@
 
1344
@@ -2969,20 +3103,25 @@
1341
1345
                /* Insert at the front of unzip_LRU list */
1342
1346
                buf_unzip_LRU_add_block(block, FALSE);
1343
1347
 
1366
1370
 
1367
1371
                /* Decompress the page and apply buffered operations
1368
1372
                while not holding buf_pool->mutex or block->mutex. */
1369
 
@@ -2995,12 +3130,15 @@
 
1373
@@ -2995,12 +3134,15 @@
1370
1374
                }
1371
1375
 
1372
1376
                /* Unfix and unlatch the block. */
1385
1389
                rw_lock_x_unlock(&block->lock);
1386
1390
 
1387
1391
                break;
1388
 
@@ -3016,7 +3154,7 @@
 
1392
@@ -3016,7 +3158,7 @@
1389
1393
 
1390
1394
        ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
1391
1395
 
1394
1398
 #if UNIV_WORD_SIZE == 4
1395
1399
        /* On 32-bit systems, there is no padding in buf_page_t.  On
1396
1400
        other systems, Valgrind could complain about uninitialized pad
1397
 
@@ -3029,8 +3167,8 @@
 
1401
@@ -3029,8 +3171,8 @@
1398
1402
                /* Try to evict the block from the buffer pool, to use the
1399
1403
                insert buffer (change buffer) as much as possible. */
1400
1404
 
1405
1409
                        if (mode == BUF_GET_IF_IN_POOL_OR_WATCH) {
1406
1410
                                /* Set the watch, as it would have
1407
1411
                                been set if the page were not in the
1408
 
@@ -3039,6 +3177,9 @@
 
1412
@@ -3039,6 +3181,9 @@
1409
1413
                                        space, offset, fold);
1410
1414
 
1411
1415
                                if (UNIV_LIKELY_NULL(block)) {
1415
1419
 
1416
1420
                                        /* The page entered the buffer
1417
1421
                                        pool for some reason. Try to
1418
 
@@ -3046,7 +3187,7 @@
 
1422
@@ -3046,7 +3191,7 @@
1419
1423
                                        goto got_block;
1420
1424
                                }
1421
1425
                        }
1424
1428
                        fprintf(stderr,
1425
1429
                                "innodb_change_buffering_debug evict %u %u\n",
1426
1430
                                (unsigned) space, (unsigned) offset);
1427
 
@@ -3065,13 +3206,14 @@
 
1431
@@ -3065,13 +3210,14 @@
1428
1432
 
1429
1433
        buf_block_buf_fix_inc(block, file, line);
1430
1434
 
1441
1445
 
1442
1446
        if (UNIV_LIKELY(mode != BUF_PEEK_IF_IN_POOL)) {
1443
1447
                buf_page_set_accessed_make_young(&block->page, access_time);
1444
 
@@ -3308,9 +3450,11 @@
 
1448
@@ -3308,9 +3454,11 @@
1445
1449
        buf_pool = buf_pool_from_block(block);
1446
1450
 
1447
1451
        if (mode == BUF_MAKE_YOUNG && buf_page_peek_if_too_old(&block->page)) {
1455
1459
        } else if (!buf_page_is_accessed(&block->page)) {
1456
1460
                /* Above, we do a dirty read on purpose, to avoid
1457
1461
                mutex contention.  The field buf_page_t::access_time
1458
 
@@ -3318,9 +3462,11 @@
 
1462
@@ -3318,9 +3466,11 @@
1459
1463
                field must be protected by mutex, however. */
1460
1464
                ulint   time_ms = ut_time_ms();
1461
1465
 
1469
1473
        }
1470
1474
 
1471
1475
        ut_ad(!ibuf_inside(mtr) || mode == BUF_KEEP_OLD);
1472
 
@@ -3387,18 +3533,21 @@
 
1476
@@ -3387,18 +3537,21 @@
1473
1477
        ut_ad(mtr);
1474
1478
        ut_ad(mtr->state == MTR_ACTIVE);
1475
1479
 
1494
1498
 
1495
1499
 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1496
1500
        ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
1497
 
@@ -3487,7 +3636,10 @@
 
1501
@@ -3487,7 +3640,10 @@
1498
1502
        buf_page_t*     hash_page;
1499
1503
        buf_pool_t*     buf_pool = buf_pool_get(space, offset);
1500
1504
 
1506
1510
        ut_ad(mutex_own(&(block->mutex)));
1507
1511
        ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
1508
1512
 
1509
 
@@ -3516,11 +3668,14 @@
 
1513
@@ -3516,11 +3672,14 @@
1510
1514
        if (UNIV_LIKELY(!hash_page)) {
1511
1515
        } else if (buf_pool_watch_is_sentinel(buf_pool, hash_page)) {
1512
1516
                /* Preserve the reference count. */
1522
1526
        } else {
1523
1527
                fprintf(stderr,
1524
1528
                        "InnoDB: Error: page %lu %lu already found"
1525
 
@@ -3530,7 +3685,8 @@
 
1529
@@ -3530,7 +3689,8 @@
1526
1530
                        (const void*) hash_page, (const void*) block);
1527
1531
 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1528
1532
                mutex_exit(&block->mutex);
1532
1536
                buf_print();
1533
1537
                buf_LRU_print();
1534
1538
                buf_validate();
1535
 
@@ -3613,7 +3769,9 @@
 
1539
@@ -3613,7 +3773,9 @@
1536
1540
 
1537
1541
        fold = buf_page_address_fold(space, offset);
1538
1542
 
1543
1547
 
1544
1548
        watch_page = buf_page_hash_get_low(buf_pool, space, offset, fold);
1545
1549
        if (watch_page && !buf_pool_watch_is_sentinel(buf_pool, watch_page)) {
1546
 
@@ -3622,9 +3780,15 @@
 
1550
@@ -3622,9 +3784,15 @@
1547
1551
 err_exit:
1548
1552
                if (block) {
1549
1553
                        mutex_enter(&block->mutex);
1560
1564
 
1561
1565
                bpage = NULL;
1562
1566
                goto func_exit;
1563
 
@@ -3647,6 +3811,8 @@
 
1567
@@ -3647,6 +3815,8 @@
1564
1568
 
1565
1569
                buf_page_init(space, offset, fold, block);
1566
1570
 
1569
1573
                /* The block must be put to the LRU list, to the old blocks */
1570
1574
                buf_LRU_add_block(bpage, TRUE/* to old blocks */);
1571
1575
 
1572
 
@@ -3674,7 +3840,7 @@
 
1576
@@ -3674,7 +3844,7 @@
1573
1577
                        been added to buf_pool->LRU and
1574
1578
                        buf_pool->page_hash. */
1575
1579
                        mutex_exit(&block->mutex);
1578
1582
                        mutex_enter(&block->mutex);
1579
1583
                        block->page.zip.data = data;
1580
1584
 
1581
 
@@ -3687,6 +3853,7 @@
 
1585
@@ -3687,6 +3857,7 @@
1582
1586
                        buf_unzip_LRU_add_block(block, TRUE);
1583
1587
                }
1584
1588
 
1586
1590
                mutex_exit(&block->mutex);
1587
1591
        } else {
1588
1592
                /* Defer buf_buddy_alloc() until after the block has
1589
 
@@ -3698,8 +3865,8 @@
 
1593
@@ -3698,8 +3869,8 @@
1590
1594
                control block (bpage), in order to avoid the
1591
1595
                invocation of buf_buddy_relocate_block() on
1592
1596
                uninitialized data. */
1597
1601
 
1598
1602
                /* Initialize the buf_pool pointer. */
1599
1603
                bpage->buf_pool_index = buf_pool_index(buf_pool);
1600
 
@@ -3719,8 +3886,11 @@
 
1604
@@ -3719,8 +3890,11 @@
1601
1605
                                /* The block was added by some other thread. */
1602
1606
                                watch_page = NULL;
1603
1607
                                bpage->state = BUF_BLOCK_ZIP_FREE;
1611
1615
 
1612
1616
                                bpage = NULL;
1613
1617
                                goto func_exit;
1614
 
@@ -3764,18 +3934,24 @@
 
1618
@@ -3764,18 +3938,24 @@
1615
1619
                HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, fold,
1616
1620
                            bpage);
1617
1621
 
1637
1641
 
1638
1642
        if (mode == BUF_READ_IBUF_PAGES_ONLY) {
1639
1643
 
1640
 
@@ -3817,7 +3993,9 @@
 
1644
@@ -3817,7 +3997,9 @@
1641
1645
 
1642
1646
        fold = buf_page_address_fold(space, offset);
1643
1647
 
1648
1652
 
1649
1653
        block = (buf_block_t*) buf_page_hash_get_low(
1650
1654
                buf_pool, space, offset, fold);
1651
 
@@ -3833,7 +4011,9 @@
 
1655
@@ -3833,7 +4015,9 @@
1652
1656
 #endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
1653
1657
 
1654
1658
                /* Page can be found in buf_pool */
1659
1663
 
1660
1664
                buf_block_free(free_block);
1661
1665
 
1662
 
@@ -3855,6 +4035,7 @@
 
1666
@@ -3855,6 +4039,7 @@
1663
1667
        mutex_enter(&block->mutex);
1664
1668
 
1665
1669
        buf_page_init(space, offset, fold, block);
1667
1671
 
1668
1672
        /* The block must be put to the LRU list */
1669
1673
        buf_LRU_add_block(&block->page, FALSE);
1670
 
@@ -3881,7 +4062,7 @@
 
1674
@@ -3881,7 +4066,7 @@
1671
1675
                the reacquisition of buf_pool->mutex.  We also must
1672
1676
                defer this operation until after the block descriptor
1673
1677
                has been added to buf_pool->LRU and buf_pool->page_hash. */
1676
1680
                mutex_enter(&block->mutex);
1677
1681
                block->page.zip.data = data;
1678
1682
 
1679
 
@@ -3899,7 +4080,8 @@
 
1683
@@ -3899,7 +4084,8 @@
1680
1684
 
1681
1685
        buf_page_set_accessed(&block->page, time_ms);
1682
1686
 
1686
1690
 
1687
1691
        mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX);
1688
1692
 
1689
 
@@ -3950,6 +4132,8 @@
 
1693
@@ -3950,6 +4136,8 @@
1690
1694
        buf_pool_t*     buf_pool = buf_pool_from_bpage(bpage);
1691
1695
        const ibool     uncompressed = (buf_page_get_state(bpage)
1692
1696
                                        == BUF_BLOCK_FILE_PAGE);
1695
1699
 
1696
1700
        ut_a(buf_page_in_file(bpage));
1697
1701
 
1698
 
@@ -4083,8 +4267,26 @@
 
1702
@@ -4083,8 +4271,26 @@
1699
1703
                }
1700
1704
        }
1701
1705
 
1723
1727
 
1724
1728
 #ifdef UNIV_IBUF_COUNT_DEBUG
1725
1729
        if (io_type == BUF_IO_WRITE || uncompressed) {
1726
 
@@ -4107,6 +4309,7 @@
 
1730
@@ -4107,6 +4313,7 @@
1727
1731
                the x-latch to this OS thread: do not let this confuse you in
1728
1732
                debugging! */
1729
1733
 
1731
1735
                ut_ad(buf_pool->n_pend_reads > 0);
1732
1736
                buf_pool->n_pend_reads--;
1733
1737
                buf_pool->stat.n_pages_read++;
1734
 
@@ -4124,6 +4327,9 @@
 
1738
@@ -4124,6 +4331,9 @@
1735
1739
 
1736
1740
                buf_flush_write_complete(bpage);
1737
1741
 
1741
1745
                if (uncompressed) {
1742
1746
                        rw_lock_s_unlock_gen(&((buf_block_t*) bpage)->lock,
1743
1747
                                             BUF_IO_WRITE);
1744
 
@@ -4146,8 +4352,8 @@
 
1748
@@ -4146,8 +4356,8 @@
1745
1749
        }
1746
1750
 #endif /* UNIV_DEBUG */
1747
1751
 
1751
1755
 }
1752
1756
 
1753
1757
 /*********************************************************************//**
1754
 
@@ -4164,7 +4370,9 @@
 
1758
@@ -4164,7 +4374,9 @@
1755
1759
 
1756
1760
        ut_ad(buf_pool);
1757
1761
 
1762
1766
 
1763
1767
        chunk = buf_pool->chunks;
1764
1768
 
1765
 
@@ -4181,7 +4389,9 @@
 
1769
@@ -4181,7 +4393,9 @@
1766
1770
                }
1767
1771
        }
1768
1772
 
1773
1777
 
1774
1778
        return(TRUE);
1775
1779
 }
1776
 
@@ -4229,7 +4439,8 @@
 
1780
@@ -4229,7 +4443,8 @@
1777
1781
                freed = buf_LRU_search_and_free_block(buf_pool, 100);
1778
1782
        }
1779
1783
 
1783
1787
 
1784
1788
        ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0);
1785
1789
        ut_ad(UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0);
1786
 
@@ -4242,7 +4453,8 @@
 
1790
@@ -4242,7 +4457,8 @@
1787
1791
        memset(&buf_pool->stat, 0x00, sizeof(buf_pool->stat));
1788
1792
        buf_refresh_io_stats(buf_pool);
1789
1793
 
1793
1797
 }
1794
1798
 
1795
1799
 /*********************************************************************//**
1796
 
@@ -4284,7 +4496,10 @@
 
1800
@@ -4284,7 +4500,10 @@
1797
1801
 
1798
1802
        ut_ad(buf_pool);
1799
1803
 
1805
1809
 
1806
1810
        chunk = buf_pool->chunks;
1807
1811
 
1808
 
@@ -4379,7 +4594,7 @@
 
1812
@@ -4379,7 +4598,7 @@
1809
1813
        /* Check clean compressed-only blocks. */
1810
1814
 
1811
1815
        for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b;
1814
1818
                ut_a(buf_page_get_state(b) == BUF_BLOCK_ZIP_PAGE);
1815
1819
                switch (buf_page_get_io_fix(b)) {
1816
1820
                case BUF_IO_NONE:
1817
 
@@ -4410,7 +4625,7 @@
 
1821
@@ -4410,7 +4629,7 @@
1818
1822
 
1819
1823
        buf_flush_list_mutex_enter(buf_pool);
1820
1824
        for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b;
1823
1827
                ut_ad(b->in_flush_list);
1824
1828
                ut_a(b->oldest_modification);
1825
1829
                n_flush++;
1826
 
@@ -4469,6 +4684,8 @@
 
1830
@@ -4469,6 +4688,8 @@
1827
1831
        }
1828
1832
 
1829
1833
        ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
1832
1836
        if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
1833
1837
                fprintf(stderr, "Free list len %lu, free blocks %lu\n",
1834
1838
                        (ulong) UT_LIST_GET_LEN(buf_pool->free),
1835
 
@@ -4479,8 +4696,11 @@
 
1839
@@ -4479,8 +4700,11 @@
1836
1840
        ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush);
1837
1841
        ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush);
1838
1842
        ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush);
1845
1849
 
1846
1850
        ut_a(buf_LRU_validate());
1847
1851
        ut_a(buf_flush_validate(buf_pool));
1848
 
@@ -4536,7 +4756,9 @@
 
1852
@@ -4536,7 +4760,9 @@
1849
1853
        index_ids = mem_alloc(size * sizeof *index_ids);
1850
1854
        counts = mem_alloc(sizeof(ulint) * size);
1851
1855
 
1856
1860
        buf_flush_list_mutex_enter(buf_pool);
1857
1861
 
1858
1862
        fprintf(stderr,
1859
 
@@ -4605,7 +4827,9 @@
 
1863
@@ -4605,7 +4831,9 @@
1860
1864
                }
1861
1865
        }
1862
1866
 
1867
1871
 
1868
1872
        for (i = 0; i < n_found; i++) {
1869
1873
                index = dict_index_get_if_in_cache(index_ids[i]);
1870
 
@@ -4662,7 +4886,7 @@
 
1874
@@ -4662,7 +4890,7 @@
1871
1875
        buf_chunk_t*    chunk;
1872
1876
        ulint           fixed_pages_number = 0;
1873
1877
 
1876
1880
 
1877
1881
        chunk = buf_pool->chunks;
1878
1882
 
1879
 
@@ -4696,7 +4920,7 @@
 
1883
@@ -4696,7 +4924,7 @@
1880
1884
        /* Traverse the lists of clean and dirty compressed-only blocks. */
1881
1885
 
1882
1886
        for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b;
1885
1889
                ut_a(buf_page_get_state(b) == BUF_BLOCK_ZIP_PAGE);
1886
1890
                ut_a(buf_page_get_io_fix(b) != BUF_IO_WRITE);
1887
1891
 
1888
 
@@ -4708,7 +4932,7 @@
 
1892
@@ -4708,7 +4936,7 @@
1889
1893
 
1890
1894
        buf_flush_list_mutex_enter(buf_pool);
1891
1895
        for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b;
1894
1898
                ut_ad(b->in_flush_list);
1895
1899
 
1896
1900
                switch (buf_page_get_state(b)) {
1897
 
@@ -4734,7 +4958,7 @@
 
1901
@@ -4734,7 +4962,7 @@
1898
1902
 
1899
1903
        buf_flush_list_mutex_exit(buf_pool);
1900
1904
        mutex_exit(&buf_pool->zip_mutex);
1903
1907
 
1904
1908
        return(fixed_pages_number);
1905
1909
 }
1906
 
@@ -4890,6 +5114,8 @@
 
1910
@@ -4890,6 +5118,8 @@
1907
1911
        /* Find appropriate pool_info to store stats for this buffer pool */
1908
1912
        pool_info = &all_pool_info[pool_id];
1909
1913
 
1912
1916
        buf_pool_mutex_enter(buf_pool);
1913
1917
        buf_flush_list_mutex_enter(buf_pool);
1914
1918
 
1915
 
@@ -5000,6 +5226,8 @@
 
1919
@@ -5000,6 +5230,8 @@
1916
1920
        pool_info->unzip_cur = buf_LRU_stat_cur.unzip;
1917
1921
 
1918
1922
        buf_refresh_io_stats(buf_pool);
1921
1925
        buf_pool_mutex_exit(buf_pool);
1922
1926
 }
1923
1927
 
1924
 
@@ -5241,11 +5469,13 @@
 
1928
@@ -5241,11 +5473,13 @@
1925
1929
 {
1926
1930
        ulint   len;
1927
1931