~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/buf0buf.ic

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

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, 2011, Oracle and/or its affiliates. All Rights Reserved.
4
4
Copyright (c) 2008, Google Inc.
5
5
 
6
6
Portions of this file contain modifications contributed and copyrighted by
62
62
}
63
63
 
64
64
/********************************************************************//**
 
65
Tells if a block is still close enough to the MRU end of the LRU list
 
66
meaning that it is not in danger of getting evicted and also implying
 
67
that it has been accessed recently.
 
68
Note that this is for heuristics only and does not reserve buffer pool
 
69
mutex.
 
70
@return TRUE if block is close to MRU end of LRU */
 
71
UNIV_INLINE
 
72
ibool
 
73
buf_page_peek_if_young(
 
74
/*===================*/
 
75
        const buf_page_t*       bpage)  /*!< in: block */
 
76
{
 
77
        /* FIXME: bpage->freed_page_clock is 31 bits */
 
78
        return((buf_pool->freed_page_clock & ((1UL << 31) - 1))
 
79
               < ((ulint) bpage->freed_page_clock
 
80
                  + (buf_pool->curr_size
 
81
                     * (BUF_LRU_OLD_RATIO_DIV - buf_LRU_old_ratio)
 
82
                     / (BUF_LRU_OLD_RATIO_DIV * 4))));
 
83
}
 
84
 
 
85
/********************************************************************//**
65
86
Recommends a move of a block to the start of the LRU list if there is danger
66
87
of dropping from the buffer pool. NOTE: does not reserve the buffer pool
67
88
mutex.
89
110
                buf_pool->stat.n_pages_not_made_young++;
90
111
                return(FALSE);
91
112
        } else {
92
 
                /* FIXME: bpage->freed_page_clock is 31 bits */
93
 
                return((buf_pool->freed_page_clock & ((1UL << 31) - 1))
94
 
                       > ((ulint) bpage->freed_page_clock
95
 
                          + (buf_pool->curr_size
96
 
                             * (BUF_LRU_OLD_RATIO_DIV - buf_LRU_old_ratio)
97
 
                             / (BUF_LRU_OLD_RATIO_DIV * 4))));
 
113
                return(!buf_page_peek_if_young(bpage));
98
114
        }
99
115
}
100
116
 
715
731
}
716
732
 
717
733
/********************************************************************//**
 
734
Allocates a buf_page_t descriptor. This function must succeed. In case
 
735
of failure we assert in this function.
 
736
@return: the allocated descriptor. */
 
737
UNIV_INLINE
 
738
buf_page_t*
 
739
buf_page_alloc_descriptor(void)
 
740
/*===========================*/
 
741
{
 
742
        buf_page_t*     bpage;
 
743
 
 
744
        bpage = (buf_page_t*) ut_malloc(sizeof *bpage);
 
745
        ut_d(memset(bpage, 0, sizeof *bpage));
 
746
        UNIV_MEM_ALLOC(bpage, sizeof *bpage);
 
747
 
 
748
        return(bpage);
 
749
}
 
750
 
 
751
/********************************************************************//**
 
752
Free a buf_page_t descriptor. */
 
753
UNIV_INLINE
 
754
void
 
755
buf_page_free_descriptor(
 
756
/*=====================*/
 
757
        buf_page_t*     bpage)  /*!< in: bpage descriptor to free. */
 
758
{
 
759
        ut_free(bpage);
 
760
}
 
761
 
 
762
/********************************************************************//**
718
763
Allocates a buffer block.
719
764
@return own: the allocated block, in state BUF_BLOCK_MEMORY */
720
765
UNIV_INLINE
721
766
buf_block_t*
722
 
buf_block_alloc(
723
 
/*============*/
724
 
        ulint   zip_size)       /*!< in: compressed page size in bytes,
725
 
                                or 0 if uncompressed tablespace */
 
767
buf_block_alloc(void)
 
768
/*=================*/
726
769
{
727
770
        buf_block_t*    block;
728
771
 
729
 
        block = buf_LRU_get_free_block(zip_size);
 
772
        block = buf_LRU_get_free_block();
730
773
 
731
774
        buf_block_set_state(block, BUF_BLOCK_MEMORY);
732
775
 
1073
1116
                                where we have acquired latch */
1074
1117
        ulint           level)  /*!< in: latching order level */
1075
1118
{
1076
 
        sync_thread_add_level(&block->lock, level);
 
1119
        sync_thread_add_level(&block->lock, level, FALSE);
1077
1120
}
1078
1121
#endif /* UNIV_SYNC_DEBUG */
1079
1122
#endif /* !UNIV_HOTBACKUP */