~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/buf/buf0lru.c

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file buf/buf0lru.c
20
21
The database buffer replacement algorithm
21
22
 
22
23
Created 11/5/1995 Heikki Tuuri
48
49
#include "log0recv.h"
49
50
#include "srv0srv.h"
50
51
 
51
 
/* The number of blocks from the LRU_old pointer onward, including the block
 
52
/** The number of blocks from the LRU_old pointer onward, including the block
52
53
pointed to, must be 3/8 of the whole LRU list length, except that the
53
54
tolerance defined below is allowed. Note that the tolerance must be small
54
55
enough such that for even the BUF_LRU_OLD_MIN_LEN long LRU list, the
56
57
 
57
58
#define BUF_LRU_OLD_TOLERANCE   20
58
59
 
59
 
/* The whole LRU list length is divided by this number to determine an
 
60
/** The whole LRU list length is divided by this number to determine an
60
61
initial segment in buf_LRU_get_recent_limit */
61
62
 
62
63
#define BUF_LRU_INITIAL_RATIO   8
63
64
 
64
 
/* When dropping the search hash index entries before deleting an ibd
 
65
/** When dropping the search hash index entries before deleting an ibd
65
66
file, we build a local array of pages belonging to that tablespace
66
67
in the buffer pool. Following is the size of that array. */
67
68
#define BUF_LRU_DROP_SEARCH_HASH_SIZE   1024
68
69
 
69
 
/* If we switch on the InnoDB monitor because there are too few available
 
70
/** If we switch on the InnoDB monitor because there are too few available
70
71
frames in the buffer pool, we set this to TRUE */
71
 
UNIV_INTERN ibool       buf_lru_switched_on_innodb_mon  = FALSE;
 
72
static ibool    buf_lru_switched_on_innodb_mon  = FALSE;
72
73
 
73
 
/**********************************************************************
 
74
/******************************************************************//**
74
75
These statistics are not 'of' LRU but 'for' LRU.  We keep count of I/O
75
76
and page_zip_decompress() operations.  Based on the statistics,
76
77
buf_LRU_evict_from_unzip_LRU() decides if we want to evict from
79
80
the regular LRU, we will evict the entire block (i.e.: both the
80
81
uncompressed and compressed data), which must be clean. */
81
82
 
82
 
/* Number of intervals for which we keep the history of these stats.
 
83
/* @{ */
 
84
 
 
85
/** Number of intervals for which we keep the history of these stats.
83
86
Each interval is 1 second, defined by the rate at which
84
87
srv_error_monitor_thread() calls buf_LRU_stat_update(). */
85
88
#define BUF_LRU_STAT_N_INTERVAL 50
86
89
 
87
 
/* Co-efficient with which we multiply I/O operations to equate them
 
90
/** Co-efficient with which we multiply I/O operations to equate them
88
91
with page_zip_decompress() operations. */
89
92
#define BUF_LRU_IO_TO_UNZIP_FACTOR 50
90
93
 
91
 
/* Sampled values buf_LRU_stat_cur.
 
94
/** Sampled values buf_LRU_stat_cur.
92
95
Protected by buf_pool_mutex.  Updated by buf_LRU_stat_update(). */
93
96
static buf_LRU_stat_t           buf_LRU_stat_arr[BUF_LRU_STAT_N_INTERVAL];
94
 
/* Cursor to buf_LRU_stat_arr[] that is updated in a round-robin fashion. */
 
97
/** Cursor to buf_LRU_stat_arr[] that is updated in a round-robin fashion. */
95
98
static ulint                    buf_LRU_stat_arr_ind;
96
99
 
97
 
/* Current operation counters.  Not protected by any mutex.  Cleared
 
100
/** Current operation counters.  Not protected by any mutex.  Cleared
98
101
by buf_LRU_stat_update(). */
99
102
UNIV_INTERN buf_LRU_stat_t      buf_LRU_stat_cur;
100
103
 
101
 
/* Running sum of past values of buf_LRU_stat_cur.
 
104
/** Running sum of past values of buf_LRU_stat_cur.
102
105
Updated by buf_LRU_stat_update().  Protected by buf_pool_mutex. */
103
106
UNIV_INTERN buf_LRU_stat_t      buf_LRU_stat_sum;
104
107
 
105
 
/**********************************************************************
 
108
/* @} */
 
109
 
 
110
/******************************************************************//**
106
111
Takes a block out of the LRU list and page hash table.
107
112
If the block is compressed-only (BUF_BLOCK_ZIP_PAGE),
108
113
the object will be freed and buf_pool_zip_mutex will be released.
109
114
 
110
115
If a compressed page or a compressed-only block descriptor is freed,
111
116
other compressed pages or compressed-only block descriptors may be
112
 
relocated. */
 
117
relocated.
 
118
@return the new state of the block (BUF_BLOCK_ZIP_FREE if the state
 
119
was BUF_BLOCK_ZIP_PAGE, or BUF_BLOCK_REMOVE_HASH otherwise) */
113
120
static
114
121
enum buf_page_state
115
122
buf_LRU_block_remove_hashed_page(
116
123
/*=============================*/
117
 
                                /* out: the new state of the block
118
 
                                (BUF_BLOCK_ZIP_FREE if the state was
119
 
                                BUF_BLOCK_ZIP_PAGE, or BUF_BLOCK_REMOVE_HASH
120
 
                                otherwise) */
121
 
        buf_page_t*     bpage,  /* in: block, must contain a file page and
 
124
        buf_page_t*     bpage,  /*!< in: block, must contain a file page and
122
125
                                be in a state where it can be freed; there
123
126
                                may or may not be a hash index to the page */
124
 
        ibool           zip);   /* in: TRUE if should remove also the
 
127
        ibool           zip);   /*!< in: TRUE if should remove also the
125
128
                                compressed page of an uncompressed page */
126
 
/**********************************************************************
 
129
/******************************************************************//**
127
130
Puts a file page whose has no hash index to the free list. */
128
131
static
129
132
void
130
133
buf_LRU_block_free_hashed_page(
131
134
/*===========================*/
132
 
        buf_block_t*    block); /* in: block, must contain a file page and
 
135
        buf_block_t*    block); /*!< in: block, must contain a file page and
133
136
                                be in a state where it can be freed */
134
137
 
135
 
/**********************************************************************
 
138
/******************************************************************//**
136
139
Determines if the unzip_LRU list should be used for evicting a victim
137
 
instead of the general LRU list. */
 
140
instead of the general LRU list.
 
141
@return TRUE if should use unzip_LRU */
138
142
UNIV_INLINE
139
143
ibool
140
144
buf_LRU_evict_from_unzip_LRU(void)
141
145
/*==============================*/
142
 
                                /* out: TRUE if should use unzip_LRU */
143
146
{
144
147
        ulint   io_avg;
145
148
        ulint   unzip_avg;
179
182
        return(unzip_avg <= io_avg * BUF_LRU_IO_TO_UNZIP_FACTOR);
180
183
}
181
184
 
182
 
/**********************************************************************
 
185
/******************************************************************//**
183
186
Attempts to drop page hash index on a batch of pages belonging to a
184
187
particular space id. */
185
188
static
186
189
void
187
190
buf_LRU_drop_page_hash_batch(
188
191
/*=========================*/
189
 
        ulint           space_id,       /* in: space id */
190
 
        ulint           zip_size,       /* in: compressed page size in bytes
 
192
        ulint           space_id,       /*!< in: space id */
 
193
        ulint           zip_size,       /*!< in: compressed page size in bytes
191
194
                                        or 0 for uncompressed pages */
192
 
        const ulint*    arr,            /* in: array of page_no */
193
 
        ulint           count)          /* in: number of entries in array */
 
195
        const ulint*    arr,            /*!< in: array of page_no */
 
196
        ulint           count)          /*!< in: number of entries in array */
194
197
{
195
198
        ulint   i;
196
199
 
203
206
        }
204
207
}
205
208
 
206
 
/**********************************************************************
 
209
/******************************************************************//**
207
210
When doing a DROP TABLE/DISCARD TABLESPACE we have to drop all page
208
211
hash index entries belonging to that table. This function tries to
209
212
do that in batch. Note that this is a 'best effort' attempt and does
212
215
void
213
216
buf_LRU_drop_page_hash_for_tablespace(
214
217
/*==================================*/
215
 
        ulint   id)     /* in: space id */
 
218
        ulint   id)     /*!< in: space id */
216
219
{
217
220
        buf_page_t*     bpage;
218
221
        ulint*          page_arr;
306
309
        ut_free(page_arr);
307
310
}
308
311
 
309
 
/**********************************************************************
 
312
/******************************************************************//**
310
313
Invalidates all pages belonging to a given tablespace when we are deleting
311
314
the data file(s) of that tablespace. */
312
315
UNIV_INTERN
313
316
void
314
317
buf_LRU_invalidate_tablespace(
315
318
/*==========================*/
316
 
        ulint   id)     /* in: space id */
 
319
        ulint   id)     /*!< in: space id */
317
320
{
318
321
        buf_page_t*     bpage;
319
322
        ibool           all_freed;
425
428
        }
426
429
}
427
430
 
428
 
/**********************************************************************
 
431
/******************************************************************//**
429
432
Gets the minimum LRU_position field for the blocks in an initial segment
430
433
(determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not
431
 
guaranteed to be precise, because the ulint_clock may wrap around. */
 
434
guaranteed to be precise, because the ulint_clock may wrap around.
 
435
@return the limit; zero if could not determine it */
432
436
UNIV_INTERN
433
437
ulint
434
438
buf_LRU_get_recent_limit(void)
435
439
/*==========================*/
436
 
                        /* out: the limit; zero if could not determine it */
437
440
{
438
441
        const buf_page_t*       bpage;
439
442
        ulint                   len;
453
456
 
454
457
        bpage = UT_LIST_GET_FIRST(buf_pool->LRU);
455
458
 
456
 
        limit = buf_page_get_LRU_position(bpage) - len / BUF_LRU_INITIAL_RATIO;
 
459
        limit = buf_page_get_LRU_position(bpage);
 
460
        len /= BUF_LRU_INITIAL_RATIO;
457
461
 
458
462
        buf_pool_mutex_exit();
459
463
 
460
 
        return(limit);
 
464
        return(limit > len ? (limit - len) : 0);
461
465
}
462
466
 
463
 
/************************************************************************
 
467
/********************************************************************//**
464
468
Insert a compressed block into buf_pool->zip_clean in the LRU order. */
465
469
UNIV_INTERN
466
470
void
467
471
buf_LRU_insert_zip_clean(
468
472
/*=====================*/
469
 
        buf_page_t*     bpage)  /* in: pointer to the block in question */
 
473
        buf_page_t*     bpage)  /*!< in: pointer to the block in question */
470
474
{
471
475
        buf_page_t*     b;
472
476
 
492
496
        }
493
497
}
494
498
 
495
 
/**********************************************************************
 
499
/******************************************************************//**
496
500
Try to free an uncompressed page of a compressed block from the unzip
497
 
LRU list.  The compressed page is preserved, and it need not be clean. */
 
501
LRU list.  The compressed page is preserved, and it need not be clean.
 
502
@return TRUE if freed */
498
503
UNIV_INLINE
499
504
ibool
500
505
buf_LRU_free_from_unzip_LRU_list(
501
506
/*=============================*/
502
 
                                /* out: TRUE if freed */
503
 
        ulint   n_iterations)   /* in: how many times this has been called
 
507
        ulint   n_iterations)   /*!< in: how many times this has been called
504
508
                                repeatedly without result: a high value means
505
509
                                that we should search farther; we will search
506
510
                                n_iterations / 5 of the unzip_LRU list,
564
568
        return(FALSE);
565
569
}
566
570
 
567
 
/**********************************************************************
568
 
Try to free a clean page from the common LRU list. */
 
571
/******************************************************************//**
 
572
Try to free a clean page from the common LRU list.
 
573
@return TRUE if freed */
569
574
UNIV_INLINE
570
575
ibool
571
576
buf_LRU_free_from_common_LRU_list(
572
577
/*==============================*/
573
 
                                /* out: TRUE if freed */
574
 
        ulint   n_iterations)   /* in: how many times this has been called
 
578
        ulint   n_iterations)   /*!< in: how many times this has been called
575
579
                                repeatedly without result: a high value means
576
580
                                that we should search farther; if
577
581
                                n_iterations < 10, then we search
623
627
        return(FALSE);
624
628
}
625
629
 
626
 
/**********************************************************************
627
 
Try to free a replaceable block. */
 
630
/******************************************************************//**
 
631
Try to free a replaceable block.
 
632
@return TRUE if found and freed */
628
633
UNIV_INTERN
629
634
ibool
630
635
buf_LRU_search_and_free_block(
631
636
/*==========================*/
632
 
                                /* out: TRUE if found and freed */
633
 
        ulint   n_iterations)   /* in: how many times this has been called
 
637
        ulint   n_iterations)   /*!< in: how many times this has been called
634
638
                                repeatedly without result: a high value means
635
639
                                that we should search farther; if
636
640
                                n_iterations < 10, then we search
660
664
        return(freed);
661
665
}
662
666
 
663
 
/**********************************************************************
 
667
/******************************************************************//**
664
668
Tries to remove LRU flushed blocks from the end of the LRU list and put them
665
669
to the free list. This is beneficial for the efficiency of the insert buffer
666
670
operation, as flushed pages from non-unique non-clustered indexes are here
687
691
        buf_pool_mutex_exit();
688
692
}
689
693
 
690
 
/**********************************************************************
 
694
/******************************************************************//**
691
695
Returns TRUE if less than 25 % of the buffer pool is available. This can be
692
696
used in heuristics to prevent huge transactions eating up the whole buffer
693
 
pool for their locks. */
 
697
pool for their locks.
 
698
@return TRUE if less than 25 % of buffer pool left */
694
699
UNIV_INTERN
695
700
ibool
696
701
buf_LRU_buf_pool_running_out(void)
697
702
/*==============================*/
698
 
                                /* out: TRUE if less than 25 % of buffer pool
699
 
                                left */
700
703
{
701
704
        ibool   ret     = FALSE;
702
705
 
713
716
        return(ret);
714
717
}
715
718
 
716
 
/**********************************************************************
 
719
/******************************************************************//**
717
720
Returns a free block from the buf_pool.  The block is taken off the
718
 
free list.  If it is empty, returns NULL. */
 
721
free list.  If it is empty, returns NULL.
 
722
@return a free control block, or NULL if the buf_block->free list is empty */
719
723
UNIV_INTERN
720
724
buf_block_t*
721
725
buf_LRU_get_free_only(void)
722
726
/*=======================*/
723
 
                                /* out: a free control block, or NULL
724
 
                                if the buf_block->free list is empty */
725
727
{
726
728
        buf_block_t*    block;
727
729
 
748
750
        return(block);
749
751
}
750
752
 
751
 
/**********************************************************************
 
753
/******************************************************************//**
752
754
Returns a free block from the buf_pool. The block is taken off the
753
755
free list. If it is empty, blocks are moved from the end of the
754
 
LRU list to the free list. */
 
756
LRU list to the free list.
 
757
@return the free control block, in state BUF_BLOCK_READY_FOR_USE */
755
758
UNIV_INTERN
756
759
buf_block_t*
757
760
buf_LRU_get_free_block(
758
761
/*===================*/
759
 
                                /* out: the free control block,
760
 
                                in state BUF_BLOCK_READY_FOR_USE */
761
 
        ulint   zip_size)       /* in: compressed page size in bytes,
 
762
        ulint   zip_size)       /*!< in: compressed page size in bytes,
762
763
                                or 0 if uncompressed tablespace */
763
764
{
764
765
        buf_block_t*    block           = NULL;
939
940
        goto loop;
940
941
}
941
942
 
942
 
/***********************************************************************
 
943
/*******************************************************************//**
943
944
Moves the LRU_old pointer so that the length of the old blocks list
944
945
is inside the allowed limits. */
945
946
UNIV_INLINE
999
1000
        }
1000
1001
}
1001
1002
 
1002
 
/***********************************************************************
 
1003
/*******************************************************************//**
1003
1004
Initializes the old blocks pointer in the LRU list. This function should be
1004
1005
called when the LRU list grows to BUF_LRU_OLD_MIN_LEN length. */
1005
1006
static
1030
1031
        buf_LRU_old_adjust_len();
1031
1032
}
1032
1033
 
1033
 
/**********************************************************************
 
1034
/******************************************************************//**
1034
1035
Remove a block from the unzip_LRU list if it belonged to the list. */
1035
1036
static
1036
1037
void
1037
1038
buf_unzip_LRU_remove_block_if_needed(
1038
1039
/*=================================*/
1039
 
        buf_page_t*     bpage)  /* in/out: control block */
 
1040
        buf_page_t*     bpage)  /*!< in/out: control block */
1040
1041
{
1041
1042
        ut_ad(buf_pool);
1042
1043
        ut_ad(bpage);
1053
1054
        }
1054
1055
}
1055
1056
 
1056
 
/**********************************************************************
 
1057
/******************************************************************//**
1057
1058
Removes a block from the LRU list. */
1058
1059
UNIV_INLINE
1059
1060
void
1060
1061
buf_LRU_remove_block(
1061
1062
/*=================*/
1062
 
        buf_page_t*     bpage)  /* in: control block */
 
1063
        buf_page_t*     bpage)  /*!< in: control block */
1063
1064
{
1064
1065
        ut_ad(buf_pool);
1065
1066
        ut_ad(bpage);
1114
1115
        buf_LRU_old_adjust_len();
1115
1116
}
1116
1117
 
1117
 
/**********************************************************************
 
1118
/******************************************************************//**
1118
1119
Adds a block to the LRU list of decompressed zip pages. */
1119
1120
UNIV_INTERN
1120
1121
void
1121
1122
buf_unzip_LRU_add_block(
1122
1123
/*====================*/
1123
 
        buf_block_t*    block,  /* in: control block */
1124
 
        ibool           old)    /* in: TRUE if should be put to the end
 
1124
        buf_block_t*    block,  /*!< in: control block */
 
1125
        ibool           old)    /*!< in: TRUE if should be put to the end
1125
1126
                                of the list, else put to the start */
1126
1127
{
1127
1128
        ut_ad(buf_pool);
1140
1141
        }
1141
1142
}
1142
1143
 
1143
 
/**********************************************************************
 
1144
/******************************************************************//**
1144
1145
Adds a block to the LRU list end. */
1145
1146
UNIV_INLINE
1146
1147
void
1147
1148
buf_LRU_add_block_to_end_low(
1148
1149
/*=========================*/
1149
 
        buf_page_t*     bpage)  /* in: control block */
 
1150
        buf_page_t*     bpage)  /*!< in: control block */
1150
1151
{
1151
1152
        buf_page_t*     last_bpage;
1152
1153
 
1198
1199
        }
1199
1200
}
1200
1201
 
1201
 
/**********************************************************************
 
1202
/******************************************************************//**
1202
1203
Adds a block to the LRU list. */
1203
1204
UNIV_INLINE
1204
1205
void
1205
1206
buf_LRU_add_block_low(
1206
1207
/*==================*/
1207
 
        buf_page_t*     bpage,  /* in: control block */
1208
 
        ibool           old)    /* in: TRUE if should be put to the old blocks
 
1208
        buf_page_t*     bpage,  /*!< in: control block */
 
1209
        ibool           old)    /*!< in: TRUE if should be put to the old blocks
1209
1210
                                in the LRU list, else put to the start; if the
1210
1211
                                LRU list is very short, the block is added to
1211
1212
                                the start, regardless of this parameter */
1270
1271
        }
1271
1272
}
1272
1273
 
1273
 
/**********************************************************************
 
1274
/******************************************************************//**
1274
1275
Adds a block to the LRU list. */
1275
1276
UNIV_INTERN
1276
1277
void
1277
1278
buf_LRU_add_block(
1278
1279
/*==============*/
1279
 
        buf_page_t*     bpage,  /* in: control block */
1280
 
        ibool           old)    /* in: TRUE if should be put to the old
 
1280
        buf_page_t*     bpage,  /*!< in: control block */
 
1281
        ibool           old)    /*!< in: TRUE if should be put to the old
1281
1282
                                blocks in the LRU list, else put to the start;
1282
1283
                                if the LRU list is very short, the block is
1283
1284
                                added to the start, regardless of this
1286
1287
        buf_LRU_add_block_low(bpage, old);
1287
1288
}
1288
1289
 
1289
 
/**********************************************************************
 
1290
/******************************************************************//**
1290
1291
Moves a block to the start of the LRU list. */
1291
1292
UNIV_INTERN
1292
1293
void
1293
1294
buf_LRU_make_block_young(
1294
1295
/*=====================*/
1295
 
        buf_page_t*     bpage)  /* in: control block */
 
1296
        buf_page_t*     bpage)  /*!< in: control block */
1296
1297
{
1297
1298
        buf_LRU_remove_block(bpage);
1298
1299
        buf_LRU_add_block_low(bpage, FALSE);
1299
1300
}
1300
1301
 
1301
 
/**********************************************************************
 
1302
/******************************************************************//**
1302
1303
Moves a block to the end of the LRU list. */
1303
1304
UNIV_INTERN
1304
1305
void
1305
1306
buf_LRU_make_block_old(
1306
1307
/*===================*/
1307
 
        buf_page_t*     bpage)  /* in: control block */
 
1308
        buf_page_t*     bpage)  /*!< in: control block */
1308
1309
{
1309
1310
        buf_LRU_remove_block(bpage);
1310
1311
        buf_LRU_add_block_to_end_low(bpage);
1311
1312
}
1312
1313
 
1313
 
/**********************************************************************
 
1314
/******************************************************************//**
1314
1315
Try to free a block.  If bpage is a descriptor of a compressed-only
1315
1316
page, the descriptor object will be freed as well.
1316
1317
 
1320
1321
 
1321
1322
The caller must hold buf_pool_mutex and buf_page_get_mutex(bpage) and
1322
1323
release these two mutexes after the call.  No other
1323
 
buf_page_get_mutex() may be held when calling this function. */
 
1324
buf_page_get_mutex() may be held when calling this function.
 
1325
@return BUF_LRU_FREED if freed, BUF_LRU_CANNOT_RELOCATE or
 
1326
BUF_LRU_NOT_FREED otherwise. */
1324
1327
UNIV_INTERN
1325
1328
enum buf_lru_free_block_status
1326
1329
buf_LRU_free_block(
1327
1330
/*===============*/
1328
 
                                /* out: BUF_LRU_FREED if freed,
1329
 
                                BUF_LRU_CANNOT_RELOCATE or
1330
 
                                BUF_LRU_NOT_FREED otherwise. */
1331
 
        buf_page_t*     bpage,  /* in: block to be freed */
1332
 
        ibool           zip,    /* in: TRUE if should remove also the
 
1331
        buf_page_t*     bpage,  /*!< in: block to be freed */
 
1332
        ibool           zip,    /*!< in: TRUE if should remove also the
1333
1333
                                compressed page of an uncompressed page */
1334
1334
        ibool*          buf_pool_mutex_released)
1335
 
                                /* in: pointer to a variable that will
 
1335
                                /*!< in: pointer to a variable that will
1336
1336
                                be assigned TRUE if buf_pool_mutex
1337
1337
                                was temporarily released, or NULL */
1338
1338
{
1575
1575
        return(BUF_LRU_FREED);
1576
1576
}
1577
1577
 
1578
 
/**********************************************************************
 
1578
/******************************************************************//**
1579
1579
Puts a block back to the free list. */
1580
1580
UNIV_INTERN
1581
1581
void
1582
1582
buf_LRU_block_free_non_file_page(
1583
1583
/*=============================*/
1584
 
        buf_block_t*    block)  /* in: block, must not contain a file page */
 
1584
        buf_block_t*    block)  /*!< in: block, must not contain a file page */
1585
1585
{
1586
1586
        void*   data;
1587
1587
 
1633
1633
        UNIV_MEM_ASSERT_AND_FREE(block->frame, UNIV_PAGE_SIZE);
1634
1634
}
1635
1635
 
1636
 
/**********************************************************************
 
1636
/******************************************************************//**
1637
1637
Takes a block out of the LRU list and page hash table.
1638
1638
If the block is compressed-only (BUF_BLOCK_ZIP_PAGE),
1639
1639
the object will be freed and buf_pool_zip_mutex will be released.
1640
1640
 
1641
1641
If a compressed page or a compressed-only block descriptor is freed,
1642
1642
other compressed pages or compressed-only block descriptors may be
1643
 
relocated. */
 
1643
relocated.
 
1644
@return the new state of the block (BUF_BLOCK_ZIP_FREE if the state
 
1645
was BUF_BLOCK_ZIP_PAGE, or BUF_BLOCK_REMOVE_HASH otherwise) */
1644
1646
static
1645
1647
enum buf_page_state
1646
1648
buf_LRU_block_remove_hashed_page(
1647
1649
/*=============================*/
1648
 
                                /* out: the new state of the block
1649
 
                                (BUF_BLOCK_ZIP_FREE if the state was
1650
 
                                BUF_BLOCK_ZIP_PAGE, or BUF_BLOCK_REMOVE_HASH
1651
 
                                otherwise) */
1652
 
        buf_page_t*     bpage,  /* in: block, must contain a file page and
 
1650
        buf_page_t*     bpage,  /*!< in: block, must contain a file page and
1653
1651
                                be in a state where it can be freed; there
1654
1652
                                may or may not be a hash index to the page */
1655
 
        ibool           zip)    /* in: TRUE if should remove also the
 
1653
        ibool           zip)    /*!< in: TRUE if should remove also the
1656
1654
                                compressed page of an uncompressed page */
1657
1655
{
1658
1656
        const buf_page_t*       hashed_bpage;
1806
1804
                        void*   data = bpage->zip.data;
1807
1805
                        bpage->zip.data = NULL;
1808
1806
 
 
1807
                        ut_ad(!bpage->in_free_list);
 
1808
                        ut_ad(!bpage->in_flush_list);
 
1809
                        ut_ad(!bpage->in_LRU_list);
1809
1810
                        mutex_exit(&((buf_block_t*) bpage)->mutex);
1810
1811
                        buf_pool_mutex_exit_forbid();
1811
1812
                        buf_buddy_free(data, page_zip_get_size(&bpage->zip));
1829
1830
        return(BUF_BLOCK_ZIP_FREE);
1830
1831
}
1831
1832
 
1832
 
/**********************************************************************
 
1833
/******************************************************************//**
1833
1834
Puts a file page whose has no hash index to the free list. */
1834
1835
static
1835
1836
void
1836
1837
buf_LRU_block_free_hashed_page(
1837
1838
/*===========================*/
1838
 
        buf_block_t*    block)  /* in: block, must contain a file page and
 
1839
        buf_block_t*    block)  /*!< in: block, must contain a file page and
1839
1840
                                be in a state where it can be freed */
1840
1841
{
1841
1842
        ut_ad(buf_pool_mutex_own());
1846
1847
        buf_LRU_block_free_non_file_page(block);
1847
1848
}
1848
1849
 
1849
 
/************************************************************************
 
1850
/********************************************************************//**
1850
1851
Update the historical stats that we are collecting for LRU eviction
1851
1852
policy at the end of each interval. */
1852
1853
UNIV_INTERN
1883
1884
}
1884
1885
 
1885
1886
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1886
 
/**************************************************************************
1887
 
Validates the LRU list. */
 
1887
/**********************************************************************//**
 
1888
Validates the LRU list.
 
1889
@return TRUE */
1888
1890
UNIV_INTERN
1889
1891
ibool
1890
1892
buf_LRU_validate(void)
1908
1910
                ut_a(old_len <= new_len + BUF_LRU_OLD_TOLERANCE);
1909
1911
        }
1910
1912
 
1911
 
        UT_LIST_VALIDATE(LRU, buf_page_t, buf_pool->LRU);
 
1913
        UT_LIST_VALIDATE(LRU, buf_page_t, buf_pool->LRU,
 
1914
                         ut_ad(ut_list_node_313->in_LRU_list));
1912
1915
 
1913
1916
        bpage = UT_LIST_GET_FIRST(buf_pool->LRU);
1914
1917
 
1956
1959
                ut_a(buf_pool->LRU_old_len == old_len);
1957
1960
        }
1958
1961
 
1959
 
        UT_LIST_VALIDATE(list, buf_page_t, buf_pool->free);
 
1962
        UT_LIST_VALIDATE(list, buf_page_t, buf_pool->free,
 
1963
                         ut_ad(ut_list_node_313->in_free_list));
1960
1964
 
1961
1965
        for (bpage = UT_LIST_GET_FIRST(buf_pool->free);
1962
1966
             bpage != NULL;
1965
1969
                ut_a(buf_page_get_state(bpage) == BUF_BLOCK_NOT_USED);
1966
1970
        }
1967
1971
 
1968
 
        UT_LIST_VALIDATE(unzip_LRU, buf_block_t, buf_pool->unzip_LRU);
 
1972
        UT_LIST_VALIDATE(unzip_LRU, buf_block_t, buf_pool->unzip_LRU,
 
1973
                         ut_ad(ut_list_node_313->in_unzip_LRU_list
 
1974
                               && ut_list_node_313->page.in_LRU_list));
1969
1975
 
1970
1976
        for (block = UT_LIST_GET_FIRST(buf_pool->unzip_LRU);
1971
1977
             block;
1982
1988
#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */
1983
1989
 
1984
1990
#if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
1985
 
/**************************************************************************
 
1991
/**********************************************************************//**
1986
1992
Prints the LRU list. */
1987
1993
UNIV_INTERN
1988
1994
void