@@ -1834,6 +1834,50 @@ buf_pool_init_instance(
18341834 buf_pool->watch [i].buf_pool_index = buf_pool->instance_no ;
18351835 }
18361836
1837+ /* mijin */
1838+ buf_pool->need_to_flush_twb = false ;
1839+ buf_pool->batch_running = false ;
1840+ buf_pool->flush_running = false ;
1841+
1842+ buf_pool->b_event = os_event_create (0 );
1843+ buf_pool->f_event = os_event_create (0 );
1844+
1845+ buf_pool->total_entry = srv_LRU_scan_depth;
1846+ buf_pool->first_free = 0 ;
1847+
1848+ /* Initialize the temporary write buffer. */
1849+ buf_pool->write_buf_unaligned = static_cast <byte*>(
1850+ ut_malloc_nokey ((1 + buf_pool->total_entry ) * UNIV_PAGE_SIZE));
1851+
1852+ buf_pool->write_buf = static_cast <byte*>(
1853+ ut_align (buf_pool->write_buf_unaligned ,
1854+ UNIV_PAGE_SIZE));
1855+
1856+ /* Initialize hash structure for copy pool. */
1857+ srv_n_twb_hash_locks = static_cast <ulong>(
1858+ ut_2_power_up (srv_n_twb_hash_locks));
1859+
1860+ buf_pool->twb_hash = ib_create (
1861+ 2 * buf_pool->total_entry ,
1862+ LATCH_ID_HASH_TABLE_RW_LOCK,
1863+ srv_n_twb_hash_locks,
1864+ MEM_HEAP_FOR_TWB_HASH);
1865+
1866+ /* Initialize a block and page structure. */
1867+ buf_pool->twb_block_arr = static_cast <buf_block_t *>(
1868+ ut_zalloc_nokey (buf_pool->total_entry * sizeof (buf_block_t )));
1869+
1870+ for (i = 0 ; i < buf_pool->total_entry ; i++) {
1871+ mutex_create (LATCH_ID_BUF_BLOCK_MUTEX,
1872+ &(buf_pool->copy_block_arr [i]).mutex );
1873+ rw_lock_create (PFS_NOT_INSTRUMENTED,
1874+ &(buf_pool->copy_block_arr [i]).lock , SYNC_LEVEL_VARYING);
1875+
1876+ assert (!posix_memalign ((void **) &(buf_pool->copy_block_arr [i]).frame ,
1877+ 4096 , UNIV_PAGE_SIZE));
1878+ }
1879+ /* end */
1880+
18371881 /* All fields are initialized by ut_zalloc_nokey(). */
18381882
18391883 buf_pool->try_LRU_scan = TRUE ;
@@ -1922,6 +1966,17 @@ buf_pool_free_instance(
19221966 hash_table_free (buf_pool->page_hash );
19231967 hash_table_free (buf_pool->zip_hash );
19241968
1969+ /* mijin */
1970+ os_event_destroy (buf_pool->b_event );
1971+ os_event_destroy (buf_pool->f_event );
1972+
1973+ ut_free (buf_pool->write_buf_unaligned );
1974+ ut_free (buf_pool->twb_block_arr );
1975+
1976+ ha_clear (buf_pool->twb_hash );
1977+ hash_table_free (buf_pool->twb_hash );
1978+ /* end */
1979+
19251980 buf_pool->allocator .~ut_allocator ();
19261981}
19271982
@@ -5000,6 +5055,10 @@ buf_page_init_low(
50005055 HASH_INVALIDATE (bpage, hash);
50015056
50025057 ut_d (bpage->file_page_was_freed = FALSE );
5058+
5059+ /* mijin */
5060+ bpage->copy_target = false ;
5061+ /* end */
50035062}
50045063
50055064/* * Inits a page to the buffer buf_pool.
@@ -5882,6 +5941,30 @@ buf_page_io_complete(
58825941
58835942 buf_pool->stat .n_pages_written ++;
58845943
5944+ /* mijin: TODO: NEED TO BE FIXED!!!*/
5945+ if (bpage->copy_target ) {
5946+ twb_meta_dir_t * entry = NULL ;
5947+ ulint fold;
5948+
5949+ fold = bpage->id .fold ();
5950+
5951+ rw_lock_s_lock (buf_pool->twb_hash_lock );
5952+ HASH_SEARCH (hash, buf_pool->copy_pool_cache , fold, copy_pool_meta_dir_t *, entry, ut_ad (1 ),
5953+ entry->space == bpage->space && entry->offset == bpage->offset );
5954+ rw_lock_s_unlock (buf_pool->copy_pool_cache_hash_lock );
5955+
5956+ if (entry) {
5957+ rw_lock_x_lock (buf_pool->copy_pool_cache_hash_lock );
5958+ HASH_DELETE (copy_pool_meta_dir_t , hash, buf_pool->copy_pool_cache , fold, entry);
5959+ rw_lock_x_unlock (buf_pool->copy_pool_cache_hash_lock );
5960+
5961+ free (entry);
5962+ }
5963+ }
5964+ /* end */
5965+
5966+
5967+
58855968 /* We decide whether or not to evict the page from the
58865969 LRU list based on the flush_type.
58875970 * BUF_FLUSH_LIST: don't evict
0 commit comments