~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/buf0buf.h

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
41
41
/* @{ */
42
42
#define BUF_GET                 10      /*!< get always */
43
43
#define BUF_GET_IF_IN_POOL      11      /*!< get if in pool */
 
44
#define BUF_PEEK_IF_IN_POOL     12      /*!< get if in pool, do not make
 
45
                                        the block young in the LRU list */
44
46
#define BUF_GET_NO_LATCH        14      /*!< get and bufferfix, but
45
47
                                        set no latch; we have
46
48
                                        separated this case, because
118
120
/*===============*/
119
121
 
120
122
/********************************************************************//**
121
 
Drops the adaptive hash index.  To prevent a livelock, this function
122
 
is only to be called while holding btr_search_latch and while
123
 
btr_search_enabled == FALSE. */
 
123
Clears the adaptive hash index on all pages in the buffer pool. */
124
124
UNIV_INTERN
125
125
void
126
 
buf_pool_drop_hash_index(void);
127
 
/*==========================*/
 
126
buf_pool_clear_hash_index(void);
 
127
/*===========================*/
128
128
 
129
129
/********************************************************************//**
130
130
Relocate a buffer control block.  Relocates the block on the LRU list
139
139
                                BUF_BLOCK_ZIP_DIRTY or BUF_BLOCK_ZIP_PAGE */
140
140
        buf_page_t*     dpage)  /*!< in/out: destination control block */
141
141
        __attribute__((nonnull));
142
 
/********************************************************************//**
143
 
Resizes the buffer pool. */
144
 
UNIV_INTERN
145
 
void
146
 
buf_pool_resize(void);
147
 
/*=================*/
148
142
/*********************************************************************//**
149
143
Gets the current size of buffer buf_pool in bytes.
150
144
@return size in bytes */
161
155
buf_pool_get_oldest_modification(void);
162
156
/*==================================*/
163
157
/********************************************************************//**
 
158
Allocates a buf_page_t descriptor. This function must succeed. In case
 
159
of failure we assert in this function. */
 
160
UNIV_INLINE
 
161
buf_page_t*
 
162
buf_page_alloc_descriptor(void)
 
163
/*===========================*/
 
164
        __attribute__((malloc));
 
165
/********************************************************************//**
 
166
Free a buf_page_t descriptor. */
 
167
UNIV_INLINE
 
168
void
 
169
buf_page_free_descriptor(
 
170
/*=====================*/
 
171
        buf_page_t*     bpage)  /*!< in: bpage descriptor to free. */
 
172
        __attribute__((nonnull));
 
173
 
 
174
/********************************************************************//**
164
175
Allocates a buffer block.
165
176
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
166
177
UNIV_INLINE
167
178
buf_block_t*
168
 
buf_block_alloc(
169
 
/*============*/
170
 
        ulint   zip_size);      /*!< in: compressed page size in bytes,
171
 
                                or 0 if uncompressed tablespace */
 
179
buf_block_alloc(void);
 
180
/*=================*/
172
181
/********************************************************************//**
173
182
Frees a buffer block which does not contain a file page. */
174
183
UNIV_INLINE
286
295
        ulint           rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */
287
296
        buf_block_t*    guess,  /*!< in: guessed block or NULL */
288
297
        ulint           mode,   /*!< in: BUF_GET, BUF_GET_IF_IN_POOL,
289
 
                                BUF_GET_NO_LATCH */
 
298
                                BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH */
290
299
        const char*     file,   /*!< in: file name */
291
300
        ulint           line,   /*!< in: line where called */
292
301
        mtr_t*          mtr);   /*!< in: mini-transaction */
361
370
/*==========*/
362
371
        ulint   space,  /*!< in: space id */
363
372
        ulint   offset);/*!< in: page number */
364
 
/********************************************************************//**
365
 
Resets the check_index_page_at_flush field of a page if found in the buffer
366
 
pool. */
367
 
UNIV_INTERN
368
 
void
369
 
buf_reset_check_index_page_at_flush(
370
 
/*================================*/
371
 
        ulint   space,  /*!< in: space id */
372
 
        ulint   offset);/*!< in: page number */
373
 
#ifdef UNIV_DEBUG_FILE_ACCESSES
 
373
#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
374
374
/********************************************************************//**
375
375
Sets file_page_was_freed TRUE if the page is found in the buffer pool.
376
376
This function should be called when we free a file page and want the
395
395
/*===============================*/
396
396
        ulint   space,  /*!< in: space id */
397
397
        ulint   offset);        /*!< in: page number */
398
 
#endif /* UNIV_DEBUG_FILE_ACCESSES */
 
398
#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
399
399
/********************************************************************//**
400
400
Reads the freed_page_clock of a buffer block.
401
401
@return freed_page_clock */
416
416
        __attribute__((pure));
417
417
 
418
418
/********************************************************************//**
 
419
Tells if a block is still close enough to the MRU end of the LRU list
 
420
meaning that it is not in danger of getting evicted and also implying
 
421
that it has been accessed recently.
 
422
Note that this is for heuristics only and does not reserve buffer pool
 
423
mutex.
 
424
@return TRUE if block is close to MRU end of LRU */
 
425
UNIV_INLINE
 
426
ibool
 
427
buf_page_peek_if_young(
 
428
/*===================*/
 
429
        const buf_page_t*       bpage); /*!< in: block */
 
430
/********************************************************************//**
419
431
Recommends a move of a block to the start of the LRU list if there is danger
420
432
of dropping from the buffer pool. NOTE: does not reserve the buffer pool
421
433
mutex.
426
438
/*=====================*/
427
439
        const buf_page_t*       bpage); /*!< in: block to make younger */
428
440
/********************************************************************//**
429
 
Returns the current state of is_hashed of a page. FALSE if the page is
430
 
not in the pool. NOTE that this operation does not fix the page in the
431
 
pool if it is found there.
432
 
@return TRUE if page hash index is built in search system */
433
 
UNIV_INTERN
434
 
ibool
435
 
buf_page_peek_if_search_hashed(
436
 
/*===========================*/
437
 
        ulint   space,  /*!< in: space id */
438
 
        ulint   offset);/*!< in: page number */
439
 
/********************************************************************//**
440
441
Gets the youngest modification log sequence number for a frame.
441
442
Returns zero if not file page or no modification occurred yet.
442
443
@return newest modification to page */
1137
1138
                                        0 if the block was never accessed
1138
1139
                                        in the buffer pool */
1139
1140
        /* @} */
1140
 
# ifdef UNIV_DEBUG_FILE_ACCESSES
 
1141
# if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
1141
1142
        ibool           file_page_was_freed;
1142
1143
                                        /*!< this is set to TRUE when fsp
1143
1144
                                        frees a page in buffer pool */
1144
 
# endif /* UNIV_DEBUG_FILE_ACCESSES */
 
1145
# endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
1145
1146
#endif /* !UNIV_HOTBACKUP */
1146
1147
};
1147
1148
 
1228
1229
        /* @} */
1229
1230
 
1230
1231
        /** @name Hash search fields
1231
 
        These 6 fields may only be modified when we have
 
1232
        These 5 fields may only be modified when we have
1232
1233
        an x-latch on btr_search_latch AND
1233
1234
        - we are holding an s-latch or x-latch on buf_block_struct::lock or
1234
1235
        - we know that buf_block_struct::buf_fix_count == 0.
1235
1236
 
1236
1237
        An exception to this is when we init or create a page
1237
 
        in the buffer pool in buf0buf.c. */
 
1238
        in the buffer pool in buf0buf.c.
 
1239
 
 
1240
        Another exception is that assigning block->index = NULL
 
1241
        is allowed whenever holding an x-latch on btr_search_latch. */
1238
1242
 
1239
1243
        /* @{ */
1240
1244
 
1243
1247
                                        pointers in the adaptive hash index
1244
1248
                                        pointing to this frame */
1245
1249
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
1246
 
        unsigned        is_hashed:1;    /*!< TRUE if hash index has
1247
 
                                        already been built on this
1248
 
                                        page; note that it does not
1249
 
                                        guarantee that the index is
1250
 
                                        complete, though: there may
1251
 
                                        have been hash collisions,
1252
 
                                        record deletions, etc. */
1253
1250
        unsigned        curr_n_fields:10;/*!< prefix length for hash indexing:
1254
1251
                                        number of full fields */
1255
1252
        unsigned        curr_n_bytes:15;/*!< number of bytes in hash
1256
1253
                                        indexing */
1257
1254
        unsigned        curr_left_side:1;/*!< TRUE or FALSE in hash indexing */
1258
 
        dict_index_t*   index;          /*!< Index for which the adaptive
1259
 
                                        hash index has been created. */
 
1255
        dict_index_t*   index;          /*!< Index for which the
 
1256
                                        adaptive hash index has been
 
1257
                                        created, or NULL if the page
 
1258
                                        does not exist in the
 
1259
                                        index. Note that it does not
 
1260
                                        guarantee that the index is
 
1261
                                        complete, though: there may
 
1262
                                        have been hash collisions,
 
1263
                                        record deletions, etc. */
1260
1264
        /* @} */
1261
1265
# ifdef UNIV_SYNC_DEBUG
1262
1266
        /** @name Debug fields */
1298
1302
        ulint   n_pages_written;/*!< number write operations */
1299
1303
        ulint   n_pages_created;/*!< number of pages created
1300
1304
                                in the pool with no read */
 
1305
        ulint   n_ra_pages_read_rnd;/*!< number of pages read in
 
1306
                                as part of random read ahead */
1301
1307
        ulint   n_ra_pages_read;/*!< number of pages read in
1302
1308
                                as part of read ahead */
1303
1309
        ulint   n_ra_pages_evicted;/*!< number of read ahead
1421
1427
        frames and buf_page_t descriptors of blocks that exist
1422
1428
        in the buffer pool only in compressed form. */
1423
1429
        /* @{ */
 
1430
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1424
1431
        UT_LIST_BASE_NODE_T(buf_page_t) zip_clean;
1425
1432
                                        /*!< unmodified compressed pages */
 
1433
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
1426
1434
        UT_LIST_BASE_NODE_T(buf_page_t) zip_free[BUF_BUDDY_SIZES];
1427
1435
                                        /*!< buddy free lists */
1428
1436
#if BUF_BUDDY_HIGH != UNIV_PAGE_SIZE