~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Lee Bieber
  • Date: 2010-12-03 01:16:19 UTC
  • mfrom: (1819.9.81 update-innobase)
  • Revision ID: kalebral@gmail.com-20101203011619-n6v584rijwdet05b
Merge Stewart - update Innobase plugin based on InnoDB 1.1.2

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, 2010, Innobase Oy. 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
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;   /*!< The buffer pools
 
72
extern  buf_pool_t*     buf_pool_ptr[MAX_BUFFER_POOLS]; /*!< 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));
1042
1033
/******************************************************************//**
1043
1034
Returns the buffer pool instance given a page instance
1044
1035
@return buf_pool */
1070
1061
UNIV_INLINE
1071
1062
buf_pool_t*
1072
1063
buf_pool_from_array(
1073
 
/*================*/
1074
 
        ulint   index);         /*!< in: array index to get
1075
 
                                buffer pool instance from */
 
1064
/*====================*/
 
1065
        ulint   index); /*!< in: array index to get buffer pool instance from */
1076
1066
/******************************************************************//**
1077
1067
Returns the control block of a file page, NULL if not found.
1078
1068
@return block, NULL if not found */
1210
1200
        unsigned        io_fix:2;       /*!< type of pending I/O operation;
1211
1201
                                        also protected by buf_pool->mutex
1212
1202
                                        @see enum buf_io_fix */
1213
 
        unsigned        buf_fix_count:19;/*!< count of how manyfold this block
 
1203
        unsigned        buf_fix_count:25;/*!< count of how manyfold this block
1214
1204
                                        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
1220
1205
        /* @} */
1221
1206
#endif /* !UNIV_HOTBACKUP */
1222
1207
        page_zip_des_t  zip;            /*!< compressed page; zip.data
1223
1208
                                        (but not the data it points to) is
1224
 
                                        also protected by buf_pool->mutex;
 
1209
                                        also protected by buf_pool_mutex;
1225
1210
                                        state == BUF_BLOCK_ZIP_PAGE and
1226
1211
                                        zip.data == NULL means an active
1227
 
                                        buf_pool->watch */
 
1212
                                        buf_pool_watch */
1228
1213
#ifndef UNIV_HOTBACKUP
1229
1214
        buf_page_t*     hash;           /*!< node used in chaining to
1230
1215
                                        buf_pool->page_hash or
1235
1220
#endif /* UNIV_DEBUG */
1236
1221
 
1237
1222
        /** @name Page flushing fields
1238
 
        All these are protected by buf_pool->mutex. */
 
1223
        All these are protected by buf_pool_mutex. */
1239
1224
        /* @{ */
1240
1225
 
1241
1226
        UT_LIST_NODE_T(buf_page_t) list;
1242
1227
                                        /*!< based on state, this is a
1243
1228
                                        list node, protected either by
1244
 
                                        buf_pool->mutex or by
1245
 
                                        buf_pool->flush_list_mutex,
1246
 
                                        in one of the following lists in
1247
 
                                        buf_pool:
 
1229
                                        buf_pool_mutex or by
 
1230
                                        flush_list_mutex, in one of the
 
1231
                                        following lists in buf_pool:
1248
1232
 
1249
1233
                                        - BUF_BLOCK_NOT_USED:   free
1250
1234
                                        - BUF_BLOCK_FILE_PAGE:  flush_list
1254
1238
 
1255
1239
                                        If bpage is part of flush_list
1256
1240
                                        then the node pointers are
1257
 
                                        covered by buf_pool->flush_list_mutex.
 
1241
                                        covered by flush_list_mutex.
1258
1242
                                        Otherwise these pointers are
1259
 
                                        protected by buf_pool->mutex.
 
1243
                                        protected by buf_pool_mutex.
1260
1244
 
1261
1245
                                        The contents of the list node
1262
1246
                                        is undefined if !in_flush_list
1268
1252
 
1269
1253
#ifdef UNIV_DEBUG
1270
1254
        ibool           in_flush_list;  /*!< TRUE if in buf_pool->flush_list;
1271
 
                                        when buf_pool->flush_list_mutex is
1272
 
                                        free, the following should hold:
1273
 
                                        in_flush_list
 
1255
                                        when flush_list_mutex is free, the
 
1256
                                        following should hold: in_flush_list
1274
1257
                                        == (state == BUF_BLOCK_FILE_PAGE
1275
1258
                                            || state == BUF_BLOCK_ZIP_DIRTY)
1276
1259
                                        Writes to this field must be
1277
1260
                                        covered by both block->mutex
1278
 
                                        and buf_pool->flush_list_mutex. Hence
 
1261
                                        and flush_list_mutex. Hence
1279
1262
                                        reads can happen while holding
1280
1263
                                        any one of the two mutexes */
1281
1264
        ibool           in_free_list;   /*!< TRUE if in buf_pool->free; when
1282
 
                                        buf_pool->mutex is free, the following
 
1265
                                        buf_pool_mutex is free, the following
1283
1266
                                        should hold: in_free_list
1284
1267
                                        == (state == BUF_BLOCK_NOT_USED) */
1285
1268
#endif /* UNIV_DEBUG */
1299
1282
                                        modifications are on disk.
1300
1283
                                        Writes to this field must be
1301
1284
                                        covered by both block->mutex
1302
 
                                        and buf_pool->flush_list_mutex. Hence
 
1285
                                        and flush_list_mutex. Hence
1303
1286
                                        reads can happen while holding
1304
1287
                                        any one of the two mutexes */
1305
1288
        /* @} */
1335
1318
                                        frees a page in buffer pool */
1336
1319
# endif /* UNIV_DEBUG_FILE_ACCESSES */
1337
1320
#endif /* !UNIV_HOTBACKUP */
 
1321
        buf_pool_t*     buf_pool;       /*!< buffer pool instance this
 
1322
                                        page belongs to */
1338
1323
};
1339
1324
 
1340
1325
/** The buffer control block structure */
1672
1657
        /* @} */
1673
1658
};
1674
1659
 
1675
 
/** @name Accessors for buf_pool->mutex.
1676
 
Use these instead of accessing buf_pool->mutex directly. */
 
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. */
1677
1669
/* @{ */
1678
1670
 
1679
 
/** Test if a buffer pool mutex is owned. */
 
1671
/** Test if buf_pool_mutex is owned. */
1680
1672
#define buf_pool_mutex_own(b) mutex_own(&b->mutex)
1681
 
/** Acquire a buffer pool mutex. */
 
1673
/** Acquire the buffer pool mutex. */
1682
1674
#define buf_pool_mutex_enter(b) do {            \
1683
1675
        ut_ad(!mutex_own(&b->zip_mutex));       \
1684
1676
        mutex_enter(&b->mutex);         \