11
11
#include "buf0rea.h"
12
12
#include "mtr0mtr.h"
15
extern ulint buf_dbg_counter; /* This is used to insert validation
16
operations in execution in the
18
#endif /* UNIV_DEBUG */
14
/************************************************************************
15
Reads the freed_page_clock of a buffer block. */
18
buf_page_get_freed_page_clock(
19
/*==========================*/
20
/* out: freed_page_clock */
21
const buf_page_t* bpage) /* in: block */
23
return(bpage->freed_page_clock);
26
/************************************************************************
27
Reads the freed_page_clock of a buffer block. */
30
buf_block_get_freed_page_clock(
31
/*===========================*/
32
/* out: freed_page_clock */
33
const buf_block_t* block) /* in: block */
35
return(buf_page_get_freed_page_clock(&block->page));
19
38
/************************************************************************
20
39
Recommends a move of a block to the start of the LRU list if there is danger
21
40
of dropping from the buffer pool. NOTE: does not reserve the buffer pool
25
buf_block_peek_if_too_old(
26
/*======================*/
27
/* out: TRUE if should be made younger */
28
buf_block_t* block) /* in: block to make younger */
44
buf_page_peek_if_too_old(
45
/*=====================*/
46
/* out: TRUE if should be made
48
const buf_page_t* bpage) /* in: block to make younger */
30
return(buf_pool->freed_page_clock >= block->freed_page_clock
50
return(buf_pool->freed_page_clock
51
>= buf_page_get_freed_page_clock(bpage)
31
52
+ 1 + (buf_pool->curr_size / 4));
34
55
/*************************************************************************
35
Gets the current size of buffer buf_pool in bytes. In the case of AWE, the
36
size of AWE window (= the frames). */
56
Gets the current size of buffer buf_pool in bytes. */
39
59
buf_pool_get_curr_size(void)
40
60
/*========================*/
41
61
/* out: size in bytes */
43
return((buf_pool->n_frames) * UNIV_PAGE_SIZE);
46
/*************************************************************************
47
Gets the maximum size of buffer buf_pool in bytes. In the case of AWE, the
48
size of AWE window (= the frames). */
51
buf_pool_get_max_size(void)
52
/*=======================*/
53
/* out: size in bytes */
55
return((buf_pool->n_frames) * UNIV_PAGE_SIZE);
58
/***********************************************************************
59
Accessor function for block array. */
62
buf_pool_get_nth_block(
63
/*===================*/
64
/* out: pointer to block */
65
buf_pool_t* buf_pool,/* in: buf_pool */
66
ulint i) /* in: index of the block */
69
ut_ad(i < buf_pool->max_size);
71
return(i + buf_pool->blocks);
74
/***********************************************************************
75
Checks if a pointer points to the block array of the buffer pool (blocks, not
81
/* out: TRUE if pointer to block */
82
void* ptr) /* in: pointer to memory */
84
if ((buf_pool->blocks <= (buf_block_t*)ptr)
85
&& ((buf_block_t*)ptr < buf_pool->blocks
86
+ buf_pool->max_size)) {
63
return(buf_pool->curr_size * UNIV_PAGE_SIZE);
94
66
/************************************************************************
95
67
Gets the smallest oldest_modification lsn for any page in the pool. Returns
96
ut_dulint_zero if all modified pages have been flushed to disk. */
68
zero if all modified pages have been flushed to disk. */
99
71
buf_pool_get_oldest_modification(void)
100
72
/*==================================*/
101
73
/* out: oldest modification in pool,
102
ut_dulint_zero if none */
107
mutex_enter(&(buf_pool->mutex));
109
block = UT_LIST_GET_LAST(buf_pool->flush_list);
112
lsn = ut_dulint_zero;
79
buf_pool_mutex_enter();
81
bpage = UT_LIST_GET_LAST(buf_pool->flush_list);
114
lsn = block->oldest_modification;
86
ut_ad(bpage->in_flush_list);
87
lsn = bpage->oldest_modification;
117
mutex_exit(&(buf_pool->mutex));
90
buf_pool_mutex_exit();
138
111
/*************************************************************************
112
Gets the state of a block. */
118
const buf_page_t* bpage) /* in: pointer to the control block */
120
enum buf_page_state state = (enum buf_page_state) bpage->state;
124
case BUF_BLOCK_ZIP_FREE:
125
case BUF_BLOCK_ZIP_PAGE:
126
case BUF_BLOCK_ZIP_DIRTY:
127
case BUF_BLOCK_NOT_USED:
128
case BUF_BLOCK_READY_FOR_USE:
129
case BUF_BLOCK_FILE_PAGE:
130
case BUF_BLOCK_MEMORY:
131
case BUF_BLOCK_REMOVE_HASH:
136
#endif /* UNIV_DEBUG */
140
/*************************************************************************
141
Gets the state of a block. */
147
const buf_block_t* block) /* in: pointer to the control block */
149
return(buf_page_get_state(&block->page));
151
/*************************************************************************
152
Sets the state of a block. */
157
buf_page_t* bpage, /* in/out: pointer to control block */
158
enum buf_page_state state) /* in: state */
161
enum buf_page_state old_state = buf_page_get_state(bpage);
164
case BUF_BLOCK_ZIP_FREE:
167
case BUF_BLOCK_ZIP_PAGE:
168
ut_a(state == BUF_BLOCK_ZIP_DIRTY);
170
case BUF_BLOCK_ZIP_DIRTY:
171
ut_a(state == BUF_BLOCK_ZIP_PAGE);
173
case BUF_BLOCK_NOT_USED:
174
ut_a(state == BUF_BLOCK_READY_FOR_USE);
176
case BUF_BLOCK_READY_FOR_USE:
177
ut_a(state == BUF_BLOCK_MEMORY
178
|| state == BUF_BLOCK_FILE_PAGE
179
|| state == BUF_BLOCK_NOT_USED);
181
case BUF_BLOCK_MEMORY:
182
ut_a(state == BUF_BLOCK_NOT_USED);
184
case BUF_BLOCK_FILE_PAGE:
185
ut_a(state == BUF_BLOCK_NOT_USED
186
|| state == BUF_BLOCK_REMOVE_HASH);
188
case BUF_BLOCK_REMOVE_HASH:
189
ut_a(state == BUF_BLOCK_MEMORY);
192
#endif /* UNIV_DEBUG */
193
bpage->state = state;
194
ut_ad(buf_page_get_state(bpage) == state);
197
/*************************************************************************
198
Sets the state of a block. */
203
buf_block_t* block, /* in/out: pointer to control block */
204
enum buf_page_state state) /* in: state */
206
buf_page_set_state(&block->page, state);
209
/*************************************************************************
210
Determines if a block is mapped to a tablespace. */
215
/* out: TRUE if mapped */
216
const buf_page_t* bpage) /* in: pointer to control block */
218
switch (buf_page_get_state(bpage)) {
219
case BUF_BLOCK_ZIP_FREE:
220
/* This is a free page in buf_pool->zip_free[].
221
Such pages should only be accessed by the buddy allocator. */
224
case BUF_BLOCK_ZIP_PAGE:
225
case BUF_BLOCK_ZIP_DIRTY:
226
case BUF_BLOCK_FILE_PAGE:
228
case BUF_BLOCK_NOT_USED:
229
case BUF_BLOCK_READY_FOR_USE:
230
case BUF_BLOCK_MEMORY:
231
case BUF_BLOCK_REMOVE_HASH:
238
/*************************************************************************
239
Determines if a block should be on unzip_LRU list. */
242
buf_page_belongs_to_unzip_LRU(
243
/*==========================*/
244
/* out: TRUE if block belongs
246
const buf_page_t* bpage) /* in: pointer to control block */
248
ut_ad(buf_page_in_file(bpage));
250
return(bpage->zip.data
251
&& buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
254
/*************************************************************************
255
Determine the approximate LRU list position of a block. */
258
buf_page_get_LRU_position(
259
/*======================*/
260
/* out: LRU list position */
261
const buf_page_t* bpage) /* in: control block */
263
ut_ad(buf_page_in_file(bpage));
265
return(bpage->LRU_position);
268
/*************************************************************************
269
Gets the mutex of a block. */
274
/* out: pointer to mutex
276
const buf_page_t* bpage) /* in: pointer to control block */
278
switch (buf_page_get_state(bpage)) {
279
case BUF_BLOCK_ZIP_FREE:
282
case BUF_BLOCK_ZIP_PAGE:
283
case BUF_BLOCK_ZIP_DIRTY:
284
return(&buf_pool_zip_mutex);
286
return(&((buf_block_t*) bpage)->mutex);
290
/*************************************************************************
291
Get the flush type of a page. */
294
buf_page_get_flush_type(
295
/*====================*/
296
/* out: flush type */
297
const buf_page_t* bpage) /* in: buffer page */
299
enum buf_flush flush_type = (enum buf_flush) bpage->flush_type;
302
switch (flush_type) {
304
case BUF_FLUSH_SINGLE_PAGE:
307
case BUF_FLUSH_N_TYPES:
311
#endif /* UNIV_DEBUG */
314
/*************************************************************************
315
Set the flush type of a page. */
318
buf_page_set_flush_type(
319
/*====================*/
320
buf_page_t* bpage, /* in: buffer page */
321
enum buf_flush flush_type) /* in: flush type */
323
bpage->flush_type = flush_type;
324
ut_ad(buf_page_get_flush_type(bpage) == flush_type);
327
/*************************************************************************
328
Map a block to a file page. */
331
buf_block_set_file_page(
332
/*====================*/
333
buf_block_t* block, /* in/out: pointer to control block */
334
ulint space, /* in: tablespace id */
335
ulint page_no)/* in: page number */
337
buf_block_set_state(block, BUF_BLOCK_FILE_PAGE);
338
block->page.space = space;
339
block->page.offset = page_no;
342
/*************************************************************************
343
Gets the io_fix state of a block. */
348
/* out: io_fix state */
349
const buf_page_t* bpage) /* in: pointer to the control block */
351
enum buf_io_fix io_fix = (enum buf_io_fix) bpage->io_fix;
360
#endif /* UNIV_DEBUG */
364
/*************************************************************************
365
Gets the io_fix state of a block. */
368
buf_block_get_io_fix(
370
/* out: io_fix state */
371
const buf_block_t* block) /* in: pointer to the control block */
373
return(buf_page_get_io_fix(&block->page));
376
/*************************************************************************
377
Sets the io_fix state of a block. */
382
buf_page_t* bpage, /* in/out: control block */
383
enum buf_io_fix io_fix) /* in: io_fix state */
385
ut_ad(buf_pool_mutex_own());
386
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
388
bpage->io_fix = io_fix;
389
ut_ad(buf_page_get_io_fix(bpage) == io_fix);
392
/*************************************************************************
393
Sets the io_fix state of a block. */
396
buf_block_set_io_fix(
397
/*=================*/
398
buf_block_t* block, /* in/out: control block */
399
enum buf_io_fix io_fix) /* in: io_fix state */
401
buf_page_set_io_fix(&block->page, io_fix);
404
/************************************************************************
405
Determine if a buffer block can be relocated in memory. The block
406
can be dirty, but it must not be I/O-fixed or bufferfixed. */
409
buf_page_can_relocate(
410
/*==================*/
411
const buf_page_t* bpage) /* control block being relocated */
413
ut_ad(buf_pool_mutex_own());
414
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
415
ut_ad(buf_page_in_file(bpage));
416
ut_ad(bpage->in_LRU_list);
418
return(buf_page_get_io_fix(bpage) == BUF_IO_NONE
419
&& bpage->buf_fix_count == 0);
422
/*************************************************************************
423
Determine if a block has been flagged old. */
428
/* out: TRUE if old */
429
const buf_page_t* bpage) /* in: control block */
431
ut_ad(buf_page_in_file(bpage));
436
/*************************************************************************
442
buf_page_t* bpage, /* in/out: control block */
443
ibool old) /* in: old */
445
ut_a(buf_page_in_file(bpage));
446
ut_ad(buf_pool_mutex_own());
451
/*************************************************************************
452
Determine if a block has been accessed in the buffer pool. */
455
buf_page_is_accessed(
456
/*=================*/
457
/* out: TRUE if accessed */
458
const buf_page_t* bpage) /* in: control block */
460
ut_ad(buf_page_in_file(bpage));
462
return(bpage->accessed);
465
/*************************************************************************
466
Flag a block accessed. */
469
buf_page_set_accessed(
470
/*==================*/
471
buf_page_t* bpage, /* in/out: control block */
472
ibool accessed) /* in: accessed */
474
ut_a(buf_page_in_file(bpage));
475
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
477
bpage->accessed = accessed;
480
/*************************************************************************
481
Gets the buf_block_t handle of a buffered file block if an uncompressed
482
page frame exists, or NULL. */
487
/* out: control block, or NULL */
488
buf_page_t* bpage) /* in: control block, or NULL */
490
if (UNIV_LIKELY(bpage != NULL)) {
491
ut_ad(buf_page_in_file(bpage));
493
if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE) {
494
return((buf_block_t*) bpage);
502
/*************************************************************************
139
503
Gets a pointer to the memory frame of a block. */
142
506
buf_block_get_frame(
143
507
/*================*/
144
/* out: pointer to the frame */
145
buf_block_t* block) /* in: pointer to the control block */
508
/* out: pointer to the frame */
509
const buf_block_t* block) /* in: pointer to the control block */
148
ut_ad(block >= buf_pool->blocks);
149
ut_ad(block < buf_pool->blocks + buf_pool->max_size);
150
ut_ad(block->state != BUF_BLOCK_NOT_USED);
151
ut_ad((block->state != BUF_BLOCK_FILE_PAGE)
152
|| (block->buf_fix_count > 0));
154
return(block->frame);
513
switch (buf_block_get_state(block)) {
514
case BUF_BLOCK_ZIP_FREE:
515
case BUF_BLOCK_ZIP_PAGE:
516
case BUF_BLOCK_ZIP_DIRTY:
517
case BUF_BLOCK_NOT_USED:
520
case BUF_BLOCK_FILE_PAGE:
521
ut_a(block->page.buf_fix_count > 0);
523
case BUF_BLOCK_READY_FOR_USE:
524
case BUF_BLOCK_MEMORY:
525
case BUF_BLOCK_REMOVE_HASH:
530
return((buf_frame_t*) block->frame);
532
#endif /* UNIV_DEBUG */
534
/*************************************************************************
535
Gets the space id of a block. */
541
const buf_page_t* bpage) /* in: pointer to the control block */
544
ut_a(buf_page_in_file(bpage));
546
return(bpage->space);
157
549
/*************************************************************************
179
583
buf_block_get_page_no(
180
584
/*==================*/
181
/* out: page number */
182
buf_block_t* block) /* in: pointer to the control block */
585
/* out: page number */
586
const buf_block_t* block) /* in: pointer to the control block */
185
ut_ad(block >= buf_pool->blocks);
186
ut_ad(block < buf_pool->blocks + buf_pool->max_size);
187
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
188
ut_ad(block->buf_fix_count > 0);
190
return(block->offset);
589
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
591
return(block->page.offset);
594
/*************************************************************************
595
Gets the compressed page size of a block. */
598
buf_page_get_zip_size(
599
/*==================*/
600
/* out: compressed page size, or 0 */
601
const buf_page_t* bpage) /* in: pointer to the control block */
603
return(bpage->zip.ssize ? 512 << bpage->zip.ssize : 0);
606
/*************************************************************************
607
Gets the compressed page size of a block. */
610
buf_block_get_zip_size(
611
/*===================*/
612
/* out: compressed page size, or 0 */
613
const buf_block_t* block) /* in: pointer to the control block */
615
return(block->page.zip.ssize ? 512 << block->page.zip.ssize : 0);
618
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
193
619
/***********************************************************************
194
620
Gets the block to whose frame the pointer is pointing to. */
199
/* out: pointer to block */
200
byte* ptr) /* in: pointer to a frame */
625
/* out: pointer to block */
626
const byte* ptr) /* in: pointer to a frame */
203
buf_frame_t* frame_zero;
207
frame_zero = buf_pool->frame_zero;
209
if (UNIV_UNLIKELY((ulint)ptr < (ulint)frame_zero)
210
|| UNIV_UNLIKELY((ulint)ptr > (ulint)(buf_pool->high_end))) {
212
ut_print_timestamp(stderr);
214
"InnoDB: Error: trying to access a stray pointer %p\n"
215
"InnoDB: buf pool start is at %p, end at %p\n"
216
"InnoDB: Probable reason is database corruption"
218
"InnoDB: corruption. If this happens in an"
219
" InnoDB database recovery, see\n"
220
"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
221
"forcing-recovery.html\n"
222
"InnoDB: how to force recovery.\n",
228
block = *(buf_pool->blocks_of_frames + (((ulint)(ptr - frame_zero))
229
>> UNIV_PAGE_SIZE_SHIFT));
628
const buf_block_t* block;
629
ulint space_id, page_no;
631
ptr = (const byte*) ut_align_down(ptr, UNIV_PAGE_SIZE);
632
page_no = mach_read_from_4(ptr + FIL_PAGE_OFFSET);
633
space_id = mach_read_from_4(ptr + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
635
block = (const buf_block_t*) buf_page_hash_get(space_id, page_no);
637
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
638
ut_ad(block->frame == ptr);
233
/***********************************************************************
234
Gets the frame the pointer is pointing to. */
239
/* out: pointer to frame */
240
byte* ptr) /* in: pointer to a frame */
246
frame = ut_align_down(ptr, UNIV_PAGE_SIZE);
248
if (UNIV_UNLIKELY((ulint)frame < (ulint)(buf_pool->frame_zero))
249
|| UNIV_UNLIKELY((ulint)frame >= (ulint)(buf_pool->high_end))) {
251
ut_print_timestamp(stderr);
253
"InnoDB: Error: trying to access a stray pointer %p\n"
254
"InnoDB: buf pool start is at %p, end at %p\n"
255
"InnoDB: Probable reason is database corruption"
257
"InnoDB: corruption. If this happens in an"
258
" InnoDB database recovery, see\n"
259
"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
260
"forcing-recovery.html\n"
261
"InnoDB: how to force recovery.\n",
262
ptr, buf_pool->frame_zero,
270
/**************************************************************************
271
Gets the page number of a pointer pointing within a buffer frame containing
275
buf_frame_get_page_no(
276
/*==================*/
277
/* out: page number */
278
byte* ptr) /* in: pointer to within a buffer frame */
280
return(buf_block_get_page_no(buf_block_align(ptr)));
283
/**************************************************************************
284
Gets the space id of a pointer pointing within a buffer frame containing a
288
buf_frame_get_space_id(
642
/*************************************************************************
643
Gets the compressed page descriptor corresponding to an uncompressed page
646
const page_zip_des_t*
647
buf_frame_get_page_zip(
289
648
/*===================*/
291
byte* ptr) /* in: pointer to within a buffer frame */
649
/* out: compressed page descriptor, or NULL */
650
const byte* ptr) /* in: pointer to the page */
293
return(buf_block_get_space(buf_block_align(ptr)));
652
const page_zip_des_t* page_zip;
653
buf_pool_mutex_enter();
654
page_zip = buf_block_get_page_zip(buf_block_align(ptr));
655
buf_pool_mutex_exit();
658
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
296
660
/**************************************************************************
297
661
Gets the space id, page offset, and byte offset within page of a
386
769
buf_page_io_query(
387
770
/*==============*/
388
771
/* out: TRUE if io going on */
389
buf_block_t* block) /* in: buf_pool block, must be bufferfixed */
772
buf_page_t* bpage) /* in: buf_pool block, must be bufferfixed */
391
mutex_enter(&(buf_pool->mutex));
393
ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
394
ut_ad(block->buf_fix_count > 0);
396
if (block->io_fix != 0) {
397
mutex_exit(&(buf_pool->mutex));
402
mutex_exit(&(buf_pool->mutex));
776
buf_pool_mutex_enter();
778
ut_ad(buf_page_in_file(bpage));
779
ut_ad(bpage->buf_fix_count > 0);
781
io_fixed = buf_page_get_io_fix(bpage) != BUF_IO_NONE;
782
buf_pool_mutex_exit();
407
787
/************************************************************************
408
Gets the youngest modification log sequence number for a frame. Returns zero
409
if not a file page or no modification occurred yet. */
788
Gets the youngest modification log sequence number for a frame.
789
Returns zero if not file page or no modification occurred yet. */
412
buf_frame_get_newest_modification(
413
/*==============================*/
414
/* out: newest modification to the page */
415
buf_frame_t* frame) /* in: pointer to a frame */
792
buf_page_get_newest_modification(
793
/*=============================*/
794
/* out: newest modification to page */
795
const buf_page_t* bpage) /* in: block containing the
422
block = buf_block_align(frame);
424
mutex_enter(&(buf_pool->mutex));
426
if (block->state == BUF_BLOCK_FILE_PAGE) {
427
lsn = block->newest_modification;
800
buf_pool_mutex_enter();
802
if (buf_page_in_file(bpage)) {
803
lsn = bpage->newest_modification;
429
lsn = ut_dulint_zero;
432
mutex_exit(&(buf_pool->mutex));
808
buf_pool_mutex_exit();
500
847
return(block->modify_clock);
503
#ifdef UNIV_SYNC_DEBUG
504
850
/***********************************************************************
505
851
Increments the bufferfix count. */
508
buf_block_buf_fix_inc_debug(
509
/*========================*/
510
buf_block_t* block, /* in: block to bufferfix */
511
const char* file __attribute__ ((unused)), /* in: file name */
512
ulint line __attribute__ ((unused))) /* in: line */
854
buf_block_buf_fix_inc_func(
855
/*=======================*/
856
#ifdef UNIV_SYNC_DEBUG
857
const char* file, /* in: file name */
858
ulint line, /* in: line */
859
#endif /* UNIV_SYNC_DEBUG */
860
buf_block_t* block) /* in: block to bufferfix */
862
#ifdef UNIV_SYNC_DEBUG
516
865
ret = rw_lock_s_lock_func_nowait(&(block->debug_latch), file, line);
867
#endif /* UNIV_SYNC_DEBUG */
868
ut_ad(mutex_own(&block->mutex));
519
ut_ad(mutex_own(&block->mutex));
520
block->buf_fix_count++;
870
block->page.buf_fix_count++;
872
#ifdef UNIV_SYNC_DEBUG
873
# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(f,l,b)
522
874
#else /* UNIV_SYNC_DEBUG */
875
# define buf_block_buf_fix_inc(b,f,l) buf_block_buf_fix_inc_func(b)
876
#endif /* UNIV_SYNC_DEBUG */
523
878
/***********************************************************************
524
Increments the bufferfix count. */
879
Decrements the bufferfix count. */
527
buf_block_buf_fix_inc(
882
buf_block_buf_fix_dec(
528
883
/*==================*/
529
buf_block_t* block) /* in: block to bufferfix */
884
buf_block_t* block) /* in: block to bufferunfix */
531
886
ut_ad(mutex_own(&block->mutex));
533
block->buf_fix_count++;
888
block->page.buf_fix_count--;
889
#ifdef UNIV_SYNC_DEBUG
890
rw_lock_s_unlock(&block->debug_latch);
535
#endif /* UNIV_SYNC_DEBUG */
536
894
/**********************************************************************
537
895
Returns the control block of a file page, NULL if not found. */
540
898
buf_page_hash_get(
541
899
/*==============*/
542
900
/* out: block, NULL if not found */
543
901
ulint space, /* in: space id */
544
902
ulint offset) /* in: offset of the page within space */
550
ut_ad(mutex_own(&(buf_pool->mutex)));
908
ut_ad(buf_pool_mutex_own());
552
910
/* Look for the page in the hash table */
554
912
fold = buf_page_address_fold(space, offset);
556
HASH_SEARCH(hash, buf_pool->page_hash, fold, block,
557
(block->space == space) && (block->offset == offset));
558
ut_a(block == NULL || block->state == BUF_BLOCK_FILE_PAGE);
563
/************************************************************************
564
Tries to get the page, but if file io is required, releases all latches
565
in mtr down to the given savepoint. If io is required, this function
566
retrieves the page to buffer buf_pool, but does not bufferfix it or latch
570
buf_page_get_release_on_io(
571
/*=======================*/
572
/* out: pointer to the frame, or NULL
573
if not in buffer buf_pool */
574
ulint space, /* in: space id */
575
ulint offset, /* in: offset of the page within space
576
in units of a page */
577
buf_frame_t* guess, /* in: guessed frame or NULL */
578
ulint rw_latch, /* in: RW_X_LATCH, RW_S_LATCH,
580
ulint savepoint, /* in: mtr savepoint */
581
mtr_t* mtr) /* in: mtr */
585
frame = buf_page_get_gen(space, offset, rw_latch, guess,
594
/* The page was not in the buffer buf_pool: release the latches
595
down to the savepoint */
597
mtr_rollback_to_savepoint(mtr, savepoint);
599
buf_page_get(space, offset, RW_S_LATCH, mtr);
601
/* When we get here, the page is in buffer, but we release
602
the latches again down to the savepoint, before returning */
604
mtr_rollback_to_savepoint(mtr, savepoint);
914
HASH_SEARCH(hash, buf_pool->page_hash, fold, buf_page_t*, bpage,
915
bpage->space == space && bpage->offset == offset);
917
ut_a(buf_page_in_file(bpage));
918
ut_ad(bpage->in_page_hash);
919
ut_ad(!bpage->in_zip_hash);
920
UNIV_MEM_ASSERT_RW(bpage, sizeof *bpage);
926
/**********************************************************************
927
Returns the control block of a file page, NULL if not found
928
or an uncompressed page frame does not exist. */
933
/* out: block, NULL if not found */
934
ulint space, /* in: space id */
935
ulint offset) /* in: offset of the page within space */
937
return(buf_page_get_block(buf_page_hash_get(space, offset)));
940
/************************************************************************
941
Returns TRUE if the page can be found in the buffer pool hash table. NOTE
942
that it is possible that the page is not yet read from disk, though. */
947
/* out: TRUE if found from page hash table,
948
NOTE that the page is not necessarily yet read
950
ulint space, /* in: space id */
951
ulint offset) /* in: page number */
953
const buf_page_t* bpage;
955
buf_pool_mutex_enter();
957
bpage = buf_page_hash_get(space, offset);
959
buf_pool_mutex_exit();
961
return(bpage != NULL);
964
/************************************************************************
965
Releases a compressed-only page acquired with buf_page_get_zip(). */
968
buf_page_release_zip(
969
/*=================*/
970
buf_page_t* bpage) /* in: buffer block */
975
ut_a(bpage->buf_fix_count > 0);
977
switch (buf_page_get_state(bpage)) {
978
case BUF_BLOCK_ZIP_PAGE:
979
case BUF_BLOCK_ZIP_DIRTY:
980
mutex_enter(&buf_pool_zip_mutex);
981
bpage->buf_fix_count--;
982
mutex_exit(&buf_pool_zip_mutex);
984
case BUF_BLOCK_FILE_PAGE:
985
block = (buf_block_t*) bpage;
986
mutex_enter(&block->mutex);
987
#ifdef UNIV_SYNC_DEBUG
988
rw_lock_s_unlock(&block->debug_latch);
990
bpage->buf_fix_count--;
991
mutex_exit(&block->mutex);
993
case BUF_BLOCK_ZIP_FREE:
994
case BUF_BLOCK_NOT_USED:
995
case BUF_BLOCK_READY_FOR_USE:
996
case BUF_BLOCK_MEMORY:
997
case BUF_BLOCK_REMOVE_HASH:
609
1004
/************************************************************************