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

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/buf0buddy.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) 2006, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 2006, 2011, Oracle and/or its affiliates. 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
36
36
/**********************************************************************//**
37
37
Allocate a block.  The thread calling this function must hold
38
38
buf_pool_mutex and must not hold buf_pool_zip_mutex or any block->mutex.
39
 
The buf_pool_mutex may only be released and reacquired if lru != NULL.
40
 
@return allocated block, possibly NULL if lru==NULL */
 
39
The buf_pool_mutex may be released and reacquired.
 
40
@return allocated block, never NULL */
41
41
UNIV_INTERN
42
42
void*
43
43
buf_buddy_alloc_low(
46
46
                        or BUF_BUDDY_SIZES */
47
47
        ibool*  lru)    /*!< in: pointer to a variable that will be assigned
48
48
                        TRUE if storage was allocated from the LRU list
49
 
                        and buf_pool_mutex was temporarily released,
50
 
                        or NULL if the LRU list should not be used */
51
 
        __attribute__((malloc));
 
49
                        and buf_pool_mutex was temporarily released */
 
50
        __attribute__((malloc, nonnull));
52
51
 
53
52
/**********************************************************************//**
54
53
Deallocate a block. */
74
73
        ulint   i;
75
74
        ulint   s;
76
75
 
 
76
        ut_ad(size >= PAGE_ZIP_MIN_SIZE);
 
77
 
77
78
        for (i = 0, s = BUF_BUDDY_LOW; s < size; i++, s <<= 1) {
78
79
        }
79
80
 
84
85
/**********************************************************************//**
85
86
Allocate a block.  The thread calling this function must hold
86
87
buf_pool_mutex and must not hold buf_pool_zip_mutex or any
87
 
block->mutex.  The buf_pool_mutex may only be released and reacquired
88
 
if lru != NULL.  This function should only be used for allocating
89
 
compressed page frames or control blocks (buf_page_t).  Allocated
90
 
control blocks must be properly initialized immediately after
91
 
buf_buddy_alloc() has returned the memory, before releasing
92
 
buf_pool_mutex.
93
 
@return allocated block, possibly NULL if lru == NULL */
 
88
block->mutex.  The buf_pool_mutex may be released and reacquired.
 
89
This function should only be used for allocating compressed page frames.
 
90
@return allocated block, never NULL */
94
91
UNIV_INLINE
95
92
void*
96
93
buf_buddy_alloc(
97
94
/*============*/
98
 
        ulint   size,   /*!< in: block size, up to UNIV_PAGE_SIZE */
 
95
        ulint   size,   /*!< in: compressed page size
 
96
                        (between PAGE_ZIP_MIN_SIZE and UNIV_PAGE_SIZE) */
99
97
        ibool*  lru)    /*!< in: pointer to a variable that will be assigned
100
98
                        TRUE if storage was allocated from the LRU list
101
 
                        and buf_pool_mutex was temporarily released,
102
 
                        or NULL if the LRU list should not be used */
 
99
                        and buf_pool_mutex was temporarily released */
103
100
{
104
101
        ut_ad(buf_pool_mutex_own());
 
102
        ut_ad(ut_is_2pow(size));
 
103
        ut_ad(size >= PAGE_ZIP_MIN_SIZE);
 
104
        ut_ad(size <= UNIV_PAGE_SIZE);
105
105
 
106
 
        return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru));
 
106
        return((byte*) buf_buddy_alloc_low(buf_buddy_get_slot(size), lru));
107
107
}
108
108
 
109
109
/**********************************************************************//**
117
117
        ulint   size)   /*!< in: block size, up to UNIV_PAGE_SIZE */
118
118
{
119
119
        ut_ad(buf_pool_mutex_own());
 
120
        ut_ad(ut_is_2pow(size));
 
121
        ut_ad(size >= PAGE_ZIP_MIN_SIZE);
 
122
        ut_ad(size <= UNIV_PAGE_SIZE);
120
123
 
121
124
        buf_buddy_free_low(buf, buf_buddy_get_slot(size));
122
125
}