~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Eric Herman
  • Date: 2008-12-07 15:29:44 UTC
  • mto: (656.1.14 devel)
  • mto: This revision was merged to the branch mainline in revision 670.
  • Revision ID: eric@mysql.com-20081207152944-cq1nx1cyi0huqj0f
Added pointer to online version of the FAQ

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
 
Place, Suite 330, Boston, MA 02111-1307 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
1
/******************************************************
20
2
The database buffer replacement algorithm
21
3
 
 
4
(c) 1995 Innobase Oy
 
5
 
22
6
Created 11/5/1995 Heikki Tuuri
23
7
*******************************************************/
24
8
 
42
26
#include "buf0flu.h"
43
27
#include "buf0rea.h"
44
28
#include "btr0sea.h"
45
 
#include "ibuf0ibuf.h"
46
29
#include "os0file.h"
47
30
#include "page0zip.h"
48
31
#include "log0recv.h"
267
250
                        if (num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE) {
268
251
                                goto next_page;
269
252
                        }
270
 
                        /* Array full. We release the buf_pool_mutex to
 
253
                        /* Array full. We release the buf_pool->mutex to
271
254
                        obey the latching order. */
272
255
                        buf_pool_mutex_exit();
273
256
 
316
299
        ulint   id)     /* in: space id */
317
300
{
318
301
        buf_page_t*     bpage;
 
302
        ulint           page_no;
319
303
        ibool           all_freed;
320
304
 
321
305
        /* Before we attempt to drop pages one by one we first
366
350
#endif
367
351
                        if (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE
368
352
                            && ((buf_block_t*) bpage)->is_hashed) {
369
 
                                ulint   page_no;
370
 
                                ulint   zip_size;
 
353
                                page_no = buf_page_get_page_no(bpage);
371
354
 
372
355
                                buf_pool_mutex_exit();
373
 
 
374
 
                                zip_size = buf_page_get_zip_size(bpage);
375
 
                                page_no = buf_page_get_page_no(bpage);
376
 
 
377
356
                                mutex_exit(block_mutex);
378
357
 
379
358
                                /* Note that the following call will acquire
380
359
                                an S-latch on the page */
381
360
 
382
361
                                btr_search_drop_page_hash_when_freed(
383
 
                                        id, zip_size, page_no);
 
362
                                        id,
 
363
                                        buf_page_get_zip_size(bpage),
 
364
                                        page_no);
384
365
                                goto scan_again;
385
366
                        }
386
367
 
395
376
                                buf_LRU_block_free_hashed_page((buf_block_t*)
396
377
                                                               bpage);
397
378
                        } else {
398
 
                                /* The block_mutex should have been
399
 
                                released by buf_LRU_block_remove_hashed_page()
400
 
                                when it returns BUF_BLOCK_ZIP_FREE. */
401
 
                                ut_ad(block_mutex == &buf_pool_zip_mutex);
402
 
                                ut_ad(!mutex_own(block_mutex));
403
 
 
404
379
                                /* The compressed block descriptor
405
380
                                (bpage) has been deallocated and
406
381
                                block_mutex released.  Also,
1312
1287
 
1313
1288
/**********************************************************************
1314
1289
Try to free a block.  If bpage is a descriptor of a compressed-only
1315
 
page, the descriptor object will be freed as well.
1316
 
 
1317
 
NOTE: If this function returns BUF_LRU_FREED, it will not temporarily
1318
 
release buf_pool_mutex.  Furthermore, the page frame will no longer be
1319
 
accessible via bpage.
1320
 
 
1321
 
The caller must hold buf_pool_mutex and buf_page_get_mutex(bpage) and
1322
 
release these two mutexes after the call.  No other
1323
 
buf_page_get_mutex() may be held when calling this function. */
 
1290
page, the descriptor object will be freed as well.  If this function
 
1291
returns BUF_LRU_FREED, it will not temporarily release
 
1292
buf_pool_mutex. */
1324
1293
UNIV_INTERN
1325
1294
enum buf_lru_free_block_status
1326
1295
buf_LRU_free_block(
1352
1321
                return(BUF_LRU_NOT_FREED);
1353
1322
        }
1354
1323
 
1355
 
#ifdef UNIV_IBUF_COUNT_DEBUG
1356
 
        ut_a(ibuf_count_get(bpage->space, bpage->offset) == 0);
1357
 
#endif /* UNIV_IBUF_COUNT_DEBUG */
1358
 
 
1359
1324
        if (zip || !bpage->zip.data) {
1360
1325
                /* This would completely free the block. */
1361
1326
                /* Do not completely free dirty blocks. */
1565
1530
 
1566
1531
                buf_LRU_block_free_hashed_page((buf_block_t*) bpage);
1567
1532
        } else {
1568
 
                /* The block_mutex should have been released by
1569
 
                buf_LRU_block_remove_hashed_page() when it returns
1570
 
                BUF_BLOCK_ZIP_FREE. */
1571
 
                ut_ad(block_mutex == &buf_pool_zip_mutex);
1572
1533
                mutex_enter(block_mutex);
1573
1534
        }
1574
1535
 
1585
1546
{
1586
1547
        void*   data;
1587
1548
 
1588
 
        ut_ad(block);
1589
1549
        ut_ad(buf_pool_mutex_own());
1590
1550
        ut_ad(mutex_own(&block->mutex));
 
1551
        ut_ad(block);
1591
1552
 
1592
1553
        switch (buf_block_get_state(block)) {
1593
1554
        case BUF_BLOCK_MEMORY:
1597
1558
                ut_error;
1598
1559
        }
1599
1560
 
1600
 
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
1601
 
        ut_a(block->n_pointers == 0);
1602
 
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
 
1561
        ut_ad(block->n_pointers == 0);
1603
1562
        ut_ad(!block->page.in_free_list);
1604
1563
        ut_ad(!block->page.in_flush_list);
1605
1564
        ut_ad(!block->page.in_LRU_list);
1807
1766
                        bpage->zip.data = NULL;
1808
1767
 
1809
1768
                        mutex_exit(&((buf_block_t*) bpage)->mutex);
1810
 
                        buf_pool_mutex_exit_forbid();
1811
1769
                        buf_buddy_free(data, page_zip_get_size(&bpage->zip));
1812
 
                        buf_pool_mutex_exit_allow();
1813
1770
                        mutex_enter(&((buf_block_t*) bpage)->mutex);
1814
1771
                        page_zip_set_size(&bpage->zip, 0);
1815
1772
                }