~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/buf0buddy.h

  • Committer: Lee
  • Date: 2009-01-01 03:07:33 UTC
  • mto: (758.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: lbieber@lbieber-desktop-20090101030733-fb411b55f07vij8q
more header file cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 2006, 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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/buf0buddy.h
 
1
/******************************************************
21
2
Binary buddy allocator for compressed pages
22
3
 
 
4
(c) 2006 Innobase Oy
 
5
 
23
6
Created December 2006 by Marko Makela
24
7
*******************************************************/
25
8
 
34
17
#include "univ.i"
35
18
#include "buf0types.h"
36
19
 
37
 
/**********************************************************************//**
 
20
/**************************************************************************
38
21
Allocate a block.  The thread calling this function must hold
39
 
buf_pool->mutex and must not hold buf_pool->zip_mutex or any
40
 
block->mutex.  The buf_pool->mutex may only be released and reacquired
 
22
buf_pool_mutex and must not hold buf_pool_zip_mutex or any
 
23
block->mutex.  The buf_pool_mutex may only be released and reacquired
41
24
if lru != NULL.  This function should only be used for allocating
42
25
compressed page frames or control blocks (buf_page_t).  Allocated
43
26
control blocks must be properly initialized immediately after
44
27
buf_buddy_alloc() has returned the memory, before releasing
45
 
buf_pool->mutex.
46
 
@return allocated block, possibly NULL if lru == NULL */
 
28
buf_pool_mutex. */
47
29
UNIV_INLINE
48
30
void*
49
31
buf_buddy_alloc(
50
32
/*============*/
51
 
        buf_pool_t*     buf_pool,
52
 
                        /*!< buffer pool in which the block resides */
53
 
        ulint   size,   /*!< in: block size, up to UNIV_PAGE_SIZE */
54
 
        ibool*  lru)    /*!< in: pointer to a variable that will be assigned
 
33
                        /* out: allocated block,
 
34
                        possibly NULL if lru == NULL */
 
35
        ulint   size,   /* in: block size, up to UNIV_PAGE_SIZE */
 
36
        ibool*  lru)    /* in: pointer to a variable that will be assigned
55
37
                        TRUE if storage was allocated from the LRU list
56
 
                        and buf_pool->mutex was temporarily released,
 
38
                        and buf_pool_mutex was temporarily released,
57
39
                        or NULL if the LRU list should not be used */
58
40
        __attribute__((malloc));
59
41
 
60
 
/**********************************************************************//**
 
42
/**************************************************************************
61
43
Release a block. */
62
44
UNIV_INLINE
63
45
void
64
46
buf_buddy_free(
65
47
/*===========*/
66
 
        buf_pool_t*     buf_pool,
67
 
                        /*!< buffer pool in which the block resides */
68
 
        void*   buf,    /*!< in: block to be freed, must not be
 
48
        void*   buf,    /* in: block to be freed, must not be
69
49
                        pointed to by the buffer pool */
70
 
        ulint   size)   /*!< in: block size, up to UNIV_PAGE_SIZE */
 
50
        ulint   size)   /* in: block size, up to UNIV_PAGE_SIZE */
71
51
        __attribute__((nonnull));
72
52
 
 
53
/** Statistics of buddy blocks of a given size. */
 
54
struct buf_buddy_stat_struct {
 
55
        /** Number of blocks allocated from the buddy system. */
 
56
        ulint           used;
 
57
        /** Number of blocks relocated by the buddy system. */
 
58
        ib_uint64_t     relocated;
 
59
        /** Total duration of block relocations, in microseconds. */
 
60
        ib_uint64_t     relocated_usec;
 
61
};
 
62
 
 
63
typedef struct buf_buddy_stat_struct buf_buddy_stat_t;
 
64
 
 
65
/** Statistics of the buddy system, indexed by block size.
 
66
Protected by buf_pool_mutex. */
 
67
extern buf_buddy_stat_t buf_buddy_stat[BUF_BUDDY_SIZES + 1];
 
68
 
73
69
#ifndef UNIV_NONINL
74
70
# include "buf0buddy.ic"
75
71
#endif