~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/buf0buf.h

Merge Stewart - Update innobase plugin to be based on innodb 1.1.4 from MySQL 5.5.8 

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
#define BUF_POOL_WATCH_SIZE 1           /*!< Maximum number of concurrent
70
70
                                        buffer pool watches */
71
71
 
72
 
extern  buf_pool_t*     buf_pool_ptr[MAX_BUFFER_POOLS]; /*!< The buffer pools
 
72
extern  buf_pool_t*     buf_pool_ptr;   /*!< The buffer pools
73
73
                                        of the database */
74
74
#ifdef UNIV_DEBUG
75
75
extern ibool            buf_debug_prints;/*!< If this is set TRUE, the program
92
92
        BUF_BLOCK_ZIP_FREE = 0,         /*!< contains a free
93
93
                                        compressed page */
94
94
        BUF_BLOCK_POOL_WATCH = 0,       /*!< a sentinel for the buffer pool
95
 
                                        watch, element of buf_pool_watch[] */
 
95
                                        watch, element of buf_pool->watch[] */
96
96
        BUF_BLOCK_ZIP_PAGE,             /*!< contains a clean
97
97
                                        compressed page */
98
98
        BUF_BLOCK_ZIP_DIRTY,            /*!< contains a compressed
1030
1030
        ulint   space,  /*!< in: space id */
1031
1031
        ulint   offset) /*!< in: offset of the page within space */
1032
1032
        __attribute__((const));
 
1033
/********************************************************************//**
 
1034
Calculates the index of a buffer pool to the buf_pool[] array.
 
1035
@return the position of the buffer pool in buf_pool[] */
 
1036
UNIV_INLINE
 
1037
ulint
 
1038
buf_pool_index(
 
1039
/*===========*/
 
1040
        const buf_pool_t*       buf_pool)       /*!< in: buffer pool */
 
1041
        __attribute__((nonnull, const));
1033
1042
/******************************************************************//**
1034
1043
Returns the buffer pool instance given a page instance
1035
1044
@return buf_pool */
1061
1070
UNIV_INLINE
1062
1071
buf_pool_t*
1063
1072
buf_pool_from_array(
1064
 
/*====================*/
1065
 
        ulint   index); /*!< in: array index to get buffer pool instance from */
 
1073
/*================*/
 
1074
        ulint   index);         /*!< in: array index to get
 
1075
                                buffer pool instance from */
1066
1076
/******************************************************************//**
1067
1077
Returns the control block of a file page, NULL if not found.
1068
1078
@return block, NULL if not found */
1200
1210
        unsigned        io_fix:2;       /*!< type of pending I/O operation;
1201
1211
                                        also protected by buf_pool->mutex
1202
1212
                                        @see enum buf_io_fix */
1203
 
        unsigned        buf_fix_count:25;/*!< count of how manyfold this block
 
1213
        unsigned        buf_fix_count:19;/*!< count of how manyfold this block
1204
1214
                                        is currently bufferfixed */
 
1215
        unsigned        buf_pool_index:6;/*!< index number of the buffer pool
 
1216
                                        that this block belongs to */
 
1217
# if MAX_BUFFER_POOLS > 64
 
1218
#  error "MAX_BUFFER_POOLS > 64; redefine buf_pool_index:6"
 
1219
# endif
1205
1220
        /* @} */
1206
1221
#endif /* !UNIV_HOTBACKUP */
1207
1222
        page_zip_des_t  zip;            /*!< compressed page; zip.data
1208
1223
                                        (but not the data it points to) is
1209
 
                                        also protected by buf_pool_mutex;
 
1224
                                        also protected by buf_pool->mutex;
1210
1225
                                        state == BUF_BLOCK_ZIP_PAGE and
1211
1226
                                        zip.data == NULL means an active
1212
 
                                        buf_pool_watch */
 
1227
                                        buf_pool->watch */
1213
1228
#ifndef UNIV_HOTBACKUP
1214
1229
        buf_page_t*     hash;           /*!< node used in chaining to
1215
1230
                                        buf_pool->page_hash or
1220
1235
#endif /* UNIV_DEBUG */
1221
1236
 
1222
1237
        /** @name Page flushing fields
1223
 
        All these are protected by buf_pool_mutex. */
 
1238
        All these are protected by buf_pool->mutex. */
1224
1239
        /* @{ */
1225
1240
 
1226
1241
        UT_LIST_NODE_T(buf_page_t) list;
1227
1242
                                        /*!< based on state, this is a
1228
1243
                                        list node, protected either by
1229
 
                                        buf_pool_mutex or by
1230
 
                                        flush_list_mutex, in one of the
1231
 
                                        following lists in buf_pool:
 
1244
                                        buf_pool->mutex or by
 
1245
                                        buf_pool->flush_list_mutex,
 
1246
                                        in one of the following lists in
 
1247
                                        buf_pool:
1232
1248
 
1233
1249
                                        - BUF_BLOCK_NOT_USED:   free
1234
1250
                                        - BUF_BLOCK_FILE_PAGE:  flush_list
1238
1254
 
1239
1255
                                        If bpage is part of flush_list
1240
1256
                                        then the node pointers are
1241
 
                                        covered by flush_list_mutex.
 
1257
                                        covered by buf_pool->flush_list_mutex.
1242
1258
                                        Otherwise these pointers are
1243
 
                                        protected by buf_pool_mutex.
 
1259
                                        protected by buf_pool->mutex.
1244
1260
 
1245
1261
                                        The contents of the list node
1246
1262
                                        is undefined if !in_flush_list
1252
1268
 
1253
1269
#ifdef UNIV_DEBUG
1254
1270
        ibool           in_flush_list;  /*!< TRUE if in buf_pool->flush_list;
1255
 
                                        when flush_list_mutex is free, the
1256
 
                                        following should hold: in_flush_list
 
1271
                                        when buf_pool->flush_list_mutex is
 
1272
                                        free, the following should hold:
 
1273
                                        in_flush_list
1257
1274
                                        == (state == BUF_BLOCK_FILE_PAGE
1258
1275
                                            || state == BUF_BLOCK_ZIP_DIRTY)
1259
1276
                                        Writes to this field must be
1260
1277
                                        covered by both block->mutex
1261
 
                                        and flush_list_mutex. Hence
 
1278
                                        and buf_pool->flush_list_mutex. Hence
1262
1279
                                        reads can happen while holding
1263
1280
                                        any one of the two mutexes */
1264
1281
        ibool           in_free_list;   /*!< TRUE if in buf_pool->free; when
1265
 
                                        buf_pool_mutex is free, the following
 
1282
                                        buf_pool->mutex is free, the following
1266
1283
                                        should hold: in_free_list
1267
1284
                                        == (state == BUF_BLOCK_NOT_USED) */
1268
1285
#endif /* UNIV_DEBUG */
1282
1299
                                        modifications are on disk.
1283
1300
                                        Writes to this field must be
1284
1301
                                        covered by both block->mutex
1285
 
                                        and flush_list_mutex. Hence
 
1302
                                        and buf_pool->flush_list_mutex. Hence
1286
1303
                                        reads can happen while holding
1287
1304
                                        any one of the two mutexes */
1288
1305
        /* @} */
1318
1335
                                        frees a page in buffer pool */
1319
1336
# endif /* UNIV_DEBUG_FILE_ACCESSES */
1320
1337
#endif /* !UNIV_HOTBACKUP */
1321
 
        buf_pool_t*     buf_pool;       /*!< buffer pool instance this
1322
 
                                        page belongs to */
1323
1338
};
1324
1339
 
1325
1340
/** The buffer control block structure */
1657
1672
        /* @} */
1658
1673
};
1659
1674
 
1660
 
/** mutex protecting the buffer pool struct and control blocks, except the
1661
 
read-write lock in them */
1662
 
extern mutex_t  buf_pool_mutex;
1663
 
/** mutex protecting the control blocks of compressed-only pages
1664
 
(of type buf_page_t, not buf_block_t) */
1665
 
extern mutex_t  buf_pool_zip_mutex;
1666
 
 
1667
 
/** @name Accessors for buf_pool_mutex.
1668
 
Use these instead of accessing buf_pool_mutex directly. */
 
1675
/** @name Accessors for buf_pool->mutex.
 
1676
Use these instead of accessing buf_pool->mutex directly. */
1669
1677
/* @{ */
1670
1678
 
1671
 
/** Test if buf_pool_mutex is owned. */
 
1679
/** Test if a buffer pool mutex is owned. */
1672
1680
#define buf_pool_mutex_own(b) mutex_own(&b->mutex)
1673
 
/** Acquire the buffer pool mutex. */
 
1681
/** Acquire a buffer pool mutex. */
1674
1682
#define buf_pool_mutex_enter(b) do {            \
1675
1683
        ut_ad(!mutex_own(&b->zip_mutex));       \
1676
1684
        mutex_enter(&b->mutex);         \