bec3d234018bb451fa6c9a36d3dda9b8e0f3c5af
[linux-flexiantxendom0-3.2.10.git] / fs / xfs / pagebuf / page_buf_internal.h
1 /*
2  * Copyright (c) 2002 Silicon Graphics, Inc.  All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of version 2 of the GNU General Public License as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it would be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * Further, this software is distributed without any warranty that it is
13  * free of the rightful claim of any third person regarding infringement
14  * or the like.  Any license provided herein, whether implied or
15  * otherwise, applies only to this software file.  Patent licenses, if
16  * any, provided herein do not apply to combinations of this program with
17  * other software, or any other product whatsoever.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write the Free Software Foundation, Inc., 59
21  * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22  *
23  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24  * Mountain View, CA  94043, or:
25  *
26  * http://www.sgi.com
27  *
28  * For further information regarding this notice, see:
29  *
30  * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31  */
32
33 /*
34  * Written by Steve Lord at SGI
35  */
36
37 #ifndef __PAGE_BUF_PRIVATE_H__
38 #define __PAGE_BUF_PRIVATE_H__
39
40 #include "page_buf.h"
41
42 #define _PAGE_BUF_INTERNAL_
43 #define PB_DEFINE_TRACES
44 #include "page_buf_trace.h"
45
46 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,9)
47 #define page_buffers(page)      ((page)->buffers)
48 #define page_has_buffers(page)  ((page)->buffers)
49 #endif
50
51 #ifdef PAGEBUF_LOCK_TRACKING
52 #define PB_SET_OWNER(pb)        (pb->pb_last_holder = current->pid)
53 #define PB_CLEAR_OWNER(pb)      (pb->pb_last_holder = -1)
54 #define PB_GET_OWNER(pb)        (pb->pb_last_holder)
55 #else
56 #define PB_SET_OWNER(pb)
57 #define PB_CLEAR_OWNER(pb)
58 #define PB_GET_OWNER(pb)
59 #endif /* PAGEBUF_LOCK_TRACKING */
60
61 /* Tracing utilities for pagebuf */
62 typedef struct {
63         int                     event;
64         unsigned long           pb;
65         page_buf_flags_t        flags;
66         unsigned short          hold;
67         unsigned short          lock_value;
68         void                    *task;
69         void                    *misc;
70         void                    *ra;
71         loff_t                  offset;
72         size_t                  size;
73 } pagebuf_trace_t;
74
75 struct pagebuf_trace_buf {
76         pagebuf_trace_t         *buf;
77         volatile int            start;
78         volatile int            end;
79 };
80
81 #define PB_TRACE_BUFSIZE        1024
82 #define CIRC_INC(i)     (((i) + 1) & (PB_TRACE_BUFSIZE - 1))
83
84 /*
85  * Tunable pagebuf parameters
86  */
87
88 typedef struct pb_sysctl_val {
89         ulong min;
90         ulong val;
91         ulong max;
92 } pb_sysctl_val_t;
93
94 typedef struct pagebuf_param {
95         pb_sysctl_val_t flush_interval; /* interval between runs of the
96                                          * delwri flush daemon.  */
97         pb_sysctl_val_t age_buffer;     /* time for buffer to age before
98                                          * we flush it.  */
99         pb_sysctl_val_t stats_clear;    /* clear the pagebuf stats */
100         pb_sysctl_val_t debug;          /* debug tracing on or off */
101 } pagebuf_param_t;
102
103 enum {
104         PB_FLUSH_INT = 1,
105         PB_FLUSH_AGE = 2,
106         PB_STATS_CLEAR = 3,
107         PB_DEBUG = 4
108 };
109
110 extern pagebuf_param_t  pb_params;
111
112 /*
113  * Pagebuf statistics
114  */
115
116 struct pbstats {
117         u_int32_t       pb_get;
118         u_int32_t       pb_create;
119         u_int32_t       pb_get_locked;
120         u_int32_t       pb_get_locked_waited;
121         u_int32_t       pb_busy_locked;
122         u_int32_t       pb_miss_locked;
123         u_int32_t       pb_page_retries;
124         u_int32_t       pb_page_found;
125         u_int32_t       pb_get_read;
126 };
127
128 extern struct pbstats pbstats;
129
130 #define PB_STATS_INC(count)     ( count ++ )
131
132 #ifndef STATIC
133 # define STATIC static
134 #endif
135
136 #endif /* __PAGE_BUF_PRIVATE_H__ */