@@ -1409,6 +1409,95 @@ buf_LRU_get_free_block(
1409
1409
os_thread_sleep (10000 );
1410
1410
}
1411
1411
1412
+ /* mijin */
1413
+ buf_pool_mutex_enter (buf_pool);
1414
+
1415
+ if (buf_pool->batch_running
1416
+ /* || (buf_pool->first_free == buf_pool->total_entry)*/ ) {
1417
+ buf_pool_mutex_exit (buf_pool);
1418
+ goto loop;
1419
+ }
1420
+
1421
+ if (buf_pool->flush_running ) {
1422
+ /* Another thread is running the flush right now. Wait
1423
+ for it to finish. */
1424
+ ib_int64_t sig_count = os_event_reset (buf_pool->f_event );
1425
+ buf_pool_mutex_exit (buf_pool);
1426
+
1427
+ os_event_wait_low (buf_pool->f_event , sig_count);
1428
+ goto loop;
1429
+ }
1430
+
1431
+ ulint scanned = 0 ;
1432
+ ulint total_copied = 0 ;
1433
+ ulint failed = 0 ;
1434
+ ulint first_free;
1435
+ bool evict_zip;
1436
+
1437
+ buf_pool->need_to_flush_twb = true ;
1438
+ buf_pool->batch_running = true ;
1439
+
1440
+ for (buf_page_t * bpage = buf_pool->lru_scan_itr .start ();
1441
+ bpage != NULL && scanned < srv_LRU_scan_depth /* && buf_pool->first_free < buf_pool->total_entry*/ ;
1442
+ ++scanned, bpage = buf_pool->lru_scan_itr .get ()) {
1443
+
1444
+ buf_page_t * prev = UT_LIST_GET_PREV (LRU, bpage);
1445
+ buf_pool->lru_scan_itr .set (prev);
1446
+
1447
+ /* If the target page is io-fixed or already freed, skip the
1448
+ copy process. */
1449
+ if (!buf_page_can_relocate (bpage) || (bpage->state != BUF_BLOCK_FILE_PAGE)) {
1450
+ continue ;
1451
+ } else if (bpage->oldest_modification == 0 ) {
1452
+ /* Target page is a clean page! */
1453
+ evict_zip = !buf_LRU_evict_from_unzip_LRU (buf_pool);;
1454
+ buf_LRU_free_page (bpage, evict_zip);
1455
+
1456
+ continue ;
1457
+ }
1458
+
1459
+ ib_uint32_t space = bpage->id .space ();
1460
+ ib_uint32_t offset = bpage->id .page_no ();
1461
+ ulint fold = bpage->id .fold ();
1462
+
1463
+ first_free = buf_pool->first_free ;
1464
+ buf_pool->first_free ++;
1465
+
1466
+ /* Copy the buffer frame into the copy pool. */
1467
+ memcpy (buf_pool->write_buf
1468
+ + UNIV_PAGE_SIZE * first_free,
1469
+ ((buf_block_t *) bpage)->frame , UNIV_PAGE_SIZE);
1470
+
1471
+ bpage->copy_target = true ;
1472
+ evict_zip = !buf_LRU_evict_from_unzip_LRU (buf_pool);;
1473
+
1474
+ /* Free the target page from the buffer pool. */
1475
+ if (buf_LRU_free_page (bpage, evict_zip)) {
1476
+ twb_meta_dir_t * new_entry = (twb_meta_dir_t *) malloc (sizeof (twb_meta_dir_t ));
1477
+
1478
+ new_entry->space = space;
1479
+ new_entry->offset = offset;
1480
+
1481
+ rw_lock_x_lock (buf_pool->twb_hash_lock );
1482
+ HASH_INSERT (twb_meta_dir_t , hash, buf_pool->twb_hash , fold, new_entry);
1483
+ rw_lock_x_unlock (buf_pool->twb_hash_lock );
1484
+
1485
+ total_copied++;
1486
+ } else {
1487
+ failed++;
1488
+ }
1489
+ }
1490
+
1491
+ buf_pool->batch_running = false ;
1492
+ os_event_set (buf_pool->b_event );
1493
+
1494
+ buf_pool_mutex_exit (buf_pool);
1495
+
1496
+ if (total_copied) {
1497
+ goto loop;
1498
+ }
1499
+ /* end */
1500
+
1412
1501
/* No free block was found: try to flush the LRU list.
1413
1502
This call will flush one page from the LRU and put it on the
1414
1503
free list. That means that the free block is up for grabs for
@@ -1616,6 +1705,22 @@ buf_LRU_remove_block(
1616
1705
UT_LIST_REMOVE (buf_pool->LRU , bpage);
1617
1706
ut_d (bpage->in_LRU_list = FALSE );
1618
1707
1708
+ /* mijin: TODO: need to fix this part! */
1709
+ if (bpage->copy_target ) {
1710
+ buf_flush_list_mutex_enter (buf_pool);
1711
+ buf_pool->flush_hp .adjust (bpage);
1712
+
1713
+ UT_LIST_REMOVE (buf_pool->flush_list , bpage);
1714
+
1715
+ if ((buf_pool->flush_list_hp == bpage)) {
1716
+ buf_pool->flush_list_hp = bpage;
1717
+ MONITOR_INC (MONITOR_FLUSH_HP_RESCAN);
1718
+ }
1719
+
1720
+ buf_flush_list_mutex_exit (buf_pool);
1721
+ }
1722
+ /* end */
1723
+
1619
1724
buf_pool->stat .LRU_bytes -= bpage->size .physical ();
1620
1725
1621
1726
buf_unzip_LRU_remove_block_if_needed (bpage);
0 commit comments