You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
4.5 KiB

20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
  1. /******************************************************
  2. The database buffer pool flush algorithm
  3. (c) 1995 Innobase Oy
  4. Created 11/5/1995 Heikki Tuuri
  5. *******************************************************/
  6. #ifndef buf0flu_h
  7. #define buf0flu_h
  8. #include "univ.i"
  9. #include "buf0types.h"
  10. #include "ut0byte.h"
  11. #include "mtr0types.h"
  12. /************************************************************************
  13. Updates the flush system data structures when a write is completed. */
  14. void
  15. buf_flush_write_complete(
  16. /*=====================*/
  17. buf_page_t* bpage); /* in: pointer to the block in question */
  18. /*************************************************************************
  19. Flushes pages from the end of the LRU list if there is too small
  20. a margin of replaceable pages there. */
  21. void
  22. buf_flush_free_margin(void);
  23. /*=======================*/
  24. /************************************************************************
  25. Initializes a page for writing to the tablespace. */
  26. void
  27. buf_flush_init_for_writing(
  28. /*=======================*/
  29. byte* page, /* in/out: page */
  30. void* page_zip_, /* in/out: compressed page, or NULL */
  31. ib_uint64_t newest_lsn); /* in: newest modification lsn
  32. to the page */
  33. /***********************************************************************
  34. This utility flushes dirty blocks from the end of the LRU list or flush_list.
  35. NOTE 1: in the case of an LRU flush the calling thread may own latches to
  36. pages: to avoid deadlocks, this function must be written so that it cannot
  37. end up waiting for these latches! NOTE 2: in the case of a flush list flush,
  38. the calling thread is not allowed to own any latches on pages! */
  39. ulint
  40. buf_flush_batch(
  41. /*============*/
  42. /* out: number of blocks for which the
  43. write request was queued;
  44. ULINT_UNDEFINED if there was a flush
  45. of the same type already running */
  46. enum buf_flush flush_type, /* in: BUF_FLUSH_LRU or
  47. BUF_FLUSH_LIST; if BUF_FLUSH_LIST,
  48. then the caller must not own any
  49. latches on pages */
  50. ulint min_n, /* in: wished minimum mumber of blocks
  51. flushed (it is not guaranteed that the
  52. actual number is that big, though) */
  53. ib_uint64_t lsn_limit); /* in the case BUF_FLUSH_LIST all
  54. blocks whose oldest_modification is
  55. smaller than this should be flushed
  56. (if their number does not exceed
  57. min_n), otherwise ignored */
  58. /**********************************************************************
  59. Waits until a flush batch of the given type ends */
  60. void
  61. buf_flush_wait_batch_end(
  62. /*=====================*/
  63. enum buf_flush type); /* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
  64. /************************************************************************
  65. This function should be called at a mini-transaction commit, if a page was
  66. modified in it. Puts the block to the list of modified blocks, if it not
  67. already in it. */
  68. UNIV_INLINE
  69. void
  70. buf_flush_note_modification(
  71. /*========================*/
  72. buf_block_t* block, /* in: block which is modified */
  73. mtr_t* mtr); /* in: mtr */
  74. /************************************************************************
  75. This function should be called when recovery has modified a buffer page. */
  76. UNIV_INLINE
  77. void
  78. buf_flush_recv_note_modification(
  79. /*=============================*/
  80. buf_block_t* block, /* in: block which is modified */
  81. ib_uint64_t start_lsn, /* in: start lsn of the first mtr in a
  82. set of mtr's */
  83. ib_uint64_t end_lsn); /* in: end lsn of the last mtr in the
  84. set of mtr's */
  85. /************************************************************************
  86. Returns TRUE if the file page block is immediately suitable for replacement,
  87. i.e., transition FILE_PAGE => NOT_USED allowed. */
  88. ibool
  89. buf_flush_ready_for_replace(
  90. /*========================*/
  91. /* out: TRUE if can replace immediately */
  92. buf_page_t* bpage); /* in: buffer control block, must be
  93. buf_page_in_file(bpage) and in the LRU list */
  94. #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
  95. /**********************************************************************
  96. Validates the flush list. */
  97. ibool
  98. buf_flush_validate(void);
  99. /*====================*/
  100. /* out: TRUE if ok */
  101. #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
  102. /* When buf_flush_free_margin is called, it tries to make this many blocks
  103. available to replacement in the free list and at the end of the LRU list (to
  104. make sure that a read-ahead batch can be read efficiently in a single
  105. sweep). */
  106. #define BUF_FLUSH_FREE_BLOCK_MARGIN (5 + BUF_READ_AHEAD_AREA)
  107. #define BUF_FLUSH_EXTRA_MARGIN (BUF_FLUSH_FREE_BLOCK_MARGIN / 4 + 100)
  108. #ifndef UNIV_NONINL
  109. #include "buf0flu.ic"
  110. #endif
  111. #endif