FS-Cache: Fix lock misorder in fscache_write_op()
[linux-2.6.git] / fs / fscache / stats.c
1 /* FS-Cache statistics
2  *
3  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version
9  * 2 of the License, or (at your option) any later version.
10  */
11
12 #define FSCACHE_DEBUG_LEVEL THREAD
13 #include <linux/module.h>
14 #include <linux/proc_fs.h>
15 #include <linux/seq_file.h>
16 #include "internal.h"
17
18 /*
19  * operation counters
20  */
21 atomic_t fscache_n_op_pend;
22 atomic_t fscache_n_op_run;
23 atomic_t fscache_n_op_enqueue;
24 atomic_t fscache_n_op_requeue;
25 atomic_t fscache_n_op_deferred_release;
26 atomic_t fscache_n_op_release;
27 atomic_t fscache_n_op_gc;
28 atomic_t fscache_n_op_cancelled;
29
30 atomic_t fscache_n_attr_changed;
31 atomic_t fscache_n_attr_changed_ok;
32 atomic_t fscache_n_attr_changed_nobufs;
33 atomic_t fscache_n_attr_changed_nomem;
34 atomic_t fscache_n_attr_changed_calls;
35
36 atomic_t fscache_n_allocs;
37 atomic_t fscache_n_allocs_ok;
38 atomic_t fscache_n_allocs_wait;
39 atomic_t fscache_n_allocs_nobufs;
40 atomic_t fscache_n_allocs_intr;
41 atomic_t fscache_n_alloc_ops;
42 atomic_t fscache_n_alloc_op_waits;
43
44 atomic_t fscache_n_retrievals;
45 atomic_t fscache_n_retrievals_ok;
46 atomic_t fscache_n_retrievals_wait;
47 atomic_t fscache_n_retrievals_nodata;
48 atomic_t fscache_n_retrievals_nobufs;
49 atomic_t fscache_n_retrievals_intr;
50 atomic_t fscache_n_retrievals_nomem;
51 atomic_t fscache_n_retrieval_ops;
52 atomic_t fscache_n_retrieval_op_waits;
53
54 atomic_t fscache_n_stores;
55 atomic_t fscache_n_stores_ok;
56 atomic_t fscache_n_stores_again;
57 atomic_t fscache_n_stores_nobufs;
58 atomic_t fscache_n_stores_oom;
59 atomic_t fscache_n_store_ops;
60 atomic_t fscache_n_store_calls;
61 atomic_t fscache_n_store_pages;
62 atomic_t fscache_n_store_radix_deletes;
63 atomic_t fscache_n_store_pages_over_limit;
64
65 atomic_t fscache_n_marks;
66 atomic_t fscache_n_uncaches;
67
68 atomic_t fscache_n_acquires;
69 atomic_t fscache_n_acquires_null;
70 atomic_t fscache_n_acquires_no_cache;
71 atomic_t fscache_n_acquires_ok;
72 atomic_t fscache_n_acquires_nobufs;
73 atomic_t fscache_n_acquires_oom;
74
75 atomic_t fscache_n_updates;
76 atomic_t fscache_n_updates_null;
77 atomic_t fscache_n_updates_run;
78
79 atomic_t fscache_n_relinquishes;
80 atomic_t fscache_n_relinquishes_null;
81 atomic_t fscache_n_relinquishes_waitcrt;
82
83 atomic_t fscache_n_cookie_index;
84 atomic_t fscache_n_cookie_data;
85 atomic_t fscache_n_cookie_special;
86
87 atomic_t fscache_n_object_alloc;
88 atomic_t fscache_n_object_no_alloc;
89 atomic_t fscache_n_object_lookups;
90 atomic_t fscache_n_object_lookups_negative;
91 atomic_t fscache_n_object_lookups_positive;
92 atomic_t fscache_n_object_created;
93 atomic_t fscache_n_object_avail;
94 atomic_t fscache_n_object_dead;
95
96 atomic_t fscache_n_checkaux_none;
97 atomic_t fscache_n_checkaux_okay;
98 atomic_t fscache_n_checkaux_update;
99 atomic_t fscache_n_checkaux_obsolete;
100
101 atomic_t fscache_n_cop_alloc_object;
102 atomic_t fscache_n_cop_lookup_object;
103 atomic_t fscache_n_cop_lookup_complete;
104 atomic_t fscache_n_cop_grab_object;
105 atomic_t fscache_n_cop_update_object;
106 atomic_t fscache_n_cop_drop_object;
107 atomic_t fscache_n_cop_put_object;
108 atomic_t fscache_n_cop_sync_cache;
109 atomic_t fscache_n_cop_attr_changed;
110 atomic_t fscache_n_cop_read_or_alloc_page;
111 atomic_t fscache_n_cop_read_or_alloc_pages;
112 atomic_t fscache_n_cop_allocate_page;
113 atomic_t fscache_n_cop_allocate_pages;
114 atomic_t fscache_n_cop_write_page;
115 atomic_t fscache_n_cop_uncache_page;
116 atomic_t fscache_n_cop_dissociate_pages;
117
118 /*
119  * display the general statistics
120  */
121 static int fscache_stats_show(struct seq_file *m, void *v)
122 {
123         seq_puts(m, "FS-Cache statistics\n");
124
125         seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
126                    atomic_read(&fscache_n_cookie_index),
127                    atomic_read(&fscache_n_cookie_data),
128                    atomic_read(&fscache_n_cookie_special));
129
130         seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
131                    atomic_read(&fscache_n_object_alloc),
132                    atomic_read(&fscache_n_object_no_alloc),
133                    atomic_read(&fscache_n_object_avail),
134                    atomic_read(&fscache_n_object_dead));
135         seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
136                    atomic_read(&fscache_n_checkaux_none),
137                    atomic_read(&fscache_n_checkaux_okay),
138                    atomic_read(&fscache_n_checkaux_update),
139                    atomic_read(&fscache_n_checkaux_obsolete));
140
141         seq_printf(m, "Pages  : mrk=%u unc=%u\n",
142                    atomic_read(&fscache_n_marks),
143                    atomic_read(&fscache_n_uncaches));
144
145         seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
146                    " oom=%u\n",
147                    atomic_read(&fscache_n_acquires),
148                    atomic_read(&fscache_n_acquires_null),
149                    atomic_read(&fscache_n_acquires_no_cache),
150                    atomic_read(&fscache_n_acquires_ok),
151                    atomic_read(&fscache_n_acquires_nobufs),
152                    atomic_read(&fscache_n_acquires_oom));
153
154         seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u\n",
155                    atomic_read(&fscache_n_object_lookups),
156                    atomic_read(&fscache_n_object_lookups_negative),
157                    atomic_read(&fscache_n_object_lookups_positive),
158                    atomic_read(&fscache_n_object_created));
159
160         seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
161                    atomic_read(&fscache_n_updates),
162                    atomic_read(&fscache_n_updates_null),
163                    atomic_read(&fscache_n_updates_run));
164
165         seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u\n",
166                    atomic_read(&fscache_n_relinquishes),
167                    atomic_read(&fscache_n_relinquishes_null),
168                    atomic_read(&fscache_n_relinquishes_waitcrt));
169
170         seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
171                    atomic_read(&fscache_n_attr_changed),
172                    atomic_read(&fscache_n_attr_changed_ok),
173                    atomic_read(&fscache_n_attr_changed_nobufs),
174                    atomic_read(&fscache_n_attr_changed_nomem),
175                    atomic_read(&fscache_n_attr_changed_calls));
176
177         seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
178                    atomic_read(&fscache_n_allocs),
179                    atomic_read(&fscache_n_allocs_ok),
180                    atomic_read(&fscache_n_allocs_wait),
181                    atomic_read(&fscache_n_allocs_nobufs),
182                    atomic_read(&fscache_n_allocs_intr));
183         seq_printf(m, "Allocs : ops=%u owt=%u\n",
184                    atomic_read(&fscache_n_alloc_ops),
185                    atomic_read(&fscache_n_alloc_op_waits));
186
187         seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
188                    " int=%u oom=%u\n",
189                    atomic_read(&fscache_n_retrievals),
190                    atomic_read(&fscache_n_retrievals_ok),
191                    atomic_read(&fscache_n_retrievals_wait),
192                    atomic_read(&fscache_n_retrievals_nodata),
193                    atomic_read(&fscache_n_retrievals_nobufs),
194                    atomic_read(&fscache_n_retrievals_intr),
195                    atomic_read(&fscache_n_retrievals_nomem));
196         seq_printf(m, "Retrvls: ops=%u owt=%u\n",
197                    atomic_read(&fscache_n_retrieval_ops),
198                    atomic_read(&fscache_n_retrieval_op_waits));
199
200         seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
201                    atomic_read(&fscache_n_stores),
202                    atomic_read(&fscache_n_stores_ok),
203                    atomic_read(&fscache_n_stores_again),
204                    atomic_read(&fscache_n_stores_nobufs),
205                    atomic_read(&fscache_n_stores_oom));
206         seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
207                    atomic_read(&fscache_n_store_ops),
208                    atomic_read(&fscache_n_store_calls),
209                    atomic_read(&fscache_n_store_pages),
210                    atomic_read(&fscache_n_store_radix_deletes),
211                    atomic_read(&fscache_n_store_pages_over_limit));
212
213         seq_printf(m, "Ops    : pend=%u run=%u enq=%u can=%u\n",
214                    atomic_read(&fscache_n_op_pend),
215                    atomic_read(&fscache_n_op_run),
216                    atomic_read(&fscache_n_op_enqueue),
217                    atomic_read(&fscache_n_op_cancelled));
218         seq_printf(m, "Ops    : dfr=%u rel=%u gc=%u\n",
219                    atomic_read(&fscache_n_op_deferred_release),
220                    atomic_read(&fscache_n_op_release),
221                    atomic_read(&fscache_n_op_gc));
222
223         seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
224                    atomic_read(&fscache_n_cop_alloc_object),
225                    atomic_read(&fscache_n_cop_lookup_object),
226                    atomic_read(&fscache_n_cop_lookup_complete),
227                    atomic_read(&fscache_n_cop_grab_object));
228         seq_printf(m, "CacheOp: upo=%d dro=%d pto=%d atc=%d syn=%d\n",
229                    atomic_read(&fscache_n_cop_update_object),
230                    atomic_read(&fscache_n_cop_drop_object),
231                    atomic_read(&fscache_n_cop_put_object),
232                    atomic_read(&fscache_n_cop_attr_changed),
233                    atomic_read(&fscache_n_cop_sync_cache));
234         seq_printf(m, "CacheOp: rap=%d ras=%d alp=%d als=%d wrp=%d ucp=%d dsp=%d\n",
235                    atomic_read(&fscache_n_cop_read_or_alloc_page),
236                    atomic_read(&fscache_n_cop_read_or_alloc_pages),
237                    atomic_read(&fscache_n_cop_allocate_page),
238                    atomic_read(&fscache_n_cop_allocate_pages),
239                    atomic_read(&fscache_n_cop_write_page),
240                    atomic_read(&fscache_n_cop_uncache_page),
241                    atomic_read(&fscache_n_cop_dissociate_pages));
242         return 0;
243 }
244
245 /*
246  * open "/proc/fs/fscache/stats" allowing provision of a statistical summary
247  */
248 static int fscache_stats_open(struct inode *inode, struct file *file)
249 {
250         return single_open(file, fscache_stats_show, NULL);
251 }
252
253 const struct file_operations fscache_stats_fops = {
254         .owner          = THIS_MODULE,
255         .open           = fscache_stats_open,
256         .read           = seq_read,
257         .llseek         = seq_lseek,
258         .release        = seq_release,
259 };