726
# if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
727
/**********************************************************************
728
Writes a flushable page asynchronously from the buffer pool to a file.
729
NOTE: buf_pool_mutex and block->mutex must be held upon entering this
730
function, and they will be released by this function after flushing.
731
This is loosely based on buf_flush_batch() and buf_flush_try_page(). */
736
/* out: TRUE if flushed and
738
buf_block_t* block) /*!< in/out: buffer control block */
740
ut_ad(mutex_own(&buf_pool->mutex));
741
ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
742
ut_ad(mutex_own(&block->mutex));
744
if (!buf_flush_ready_for_flush(block, BUF_FLUSH_LRU)) {
748
if (buf_pool->n_flush[BUF_FLUSH_LRU] > 0
749
|| buf_pool->init_flush[BUF_FLUSH_LRU]) {
750
/* There is already a flush batch of the same type running */
754
buf_pool->init_flush[BUF_FLUSH_LRU] = TRUE;
756
block->io_fix = BUF_IO_WRITE;
757
block->flush_type = BUF_FLUSH_LRU;
759
if (buf_pool->n_flush[BUF_FLUSH_LRU]++ == 0) {
761
os_event_reset(buf_pool->no_flush[BUF_FLUSH_LRU]);
765
Because any thread may call the LRU flush, even when owning
766
locks on pages, to avoid deadlocks, we must make sure that the
767
s-lock is acquired on the page without waiting: this is
768
accomplished because buf_flush_ready_for_flush() must hold,
769
and that requires the page not to be bufferfixed. */
771
rw_lock_s_lock_gen(&block->lock, BUF_IO_WRITE);
773
/* Note that the s-latch is acquired before releasing the
774
buf_pool mutex: this ensures that the latch is acquired
777
mutex_exit(&block->mutex);
778
mutex_exit(&buf_pool->mutex);
780
/* Even though block is not protected by any mutex at this
781
point, it is safe to access block, because it is io_fixed and
782
oldest_modification != 0. Thus, it cannot be relocated in the
783
buffer pool or removed from flush_list or LRU_list. */
785
buf_flush_write_block_low(block);
787
mutex_enter(&buf_pool->mutex);
788
buf_pool->init_flush[BUF_FLUSH_LRU] = FALSE;
790
if (buf_pool->n_flush[BUF_FLUSH_LRU] == 0) {
791
/* The running flush batch has ended */
792
os_event_set(buf_pool->no_flush[BUF_FLUSH_LRU]);
795
mutex_exit(&buf_pool->mutex);
796
buf_flush_buffered_writes();
800
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
726
802
/***************************************************************
727
803
Flushes to disk all flushable pages within the flush area. */
913
988
mutex_exit(&block->mutex);
914
989
mutex_exit(&(buf_pool->mutex));
916
old_page_count = page_count;
918
991
/* Try to flush also all the neighbors */
919
992
page_count += buf_flush_try_neighbors(
920
993
space, offset, flush_type);
922
"Flush type %lu, page no %lu, neighb %lu\n",
924
page_count - old_page_count); */
926
995
mutex_enter(&(buf_pool->mutex));