~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

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