12 #define FSCACHE_DEBUG_LEVEL COOKIE
13 #include <linux/module.h>
15 #include <linux/slab.h>
20 static struct rb_root fscache_object_list;
25 #define FSCACHE_OBJLIST_CONFIG_KEY 0x00000001
26 #define FSCACHE_OBJLIST_CONFIG_AUX 0x00000002
27 #define FSCACHE_OBJLIST_CONFIG_COOKIE 0x00000004
28 #define FSCACHE_OBJLIST_CONFIG_NOCOOKIE 0x00000008
29 #define FSCACHE_OBJLIST_CONFIG_BUSY 0x00000010
30 #define FSCACHE_OBJLIST_CONFIG_IDLE 0x00000020
31 #define FSCACHE_OBJLIST_CONFIG_PENDWR 0x00000040
32 #define FSCACHE_OBJLIST_CONFIG_NOPENDWR 0x00000080
33 #define FSCACHE_OBJLIST_CONFIG_READS 0x00000100
34 #define FSCACHE_OBJLIST_CONFIG_NOREADS 0x00000200
35 #define FSCACHE_OBJLIST_CONFIG_EVENTS 0x00000400
36 #define FSCACHE_OBJLIST_CONFIG_NOEVENTS 0x00000800
37 #define FSCACHE_OBJLIST_CONFIG_WORK 0x00001000
38 #define FSCACHE_OBJLIST_CONFIG_NOWORK 0x00002000
67 rb_link_node(&obj->objlist_link,
parent, p);
84 rb_erase(&obj->objlist_link, &fscache_object_list);
99 if (*_pos >= (
unsigned long) ERR_PTR(-
ENOENT))
111 p = fscache_object_list.rb_node;
115 if (!minobj || minobj > obj)
118 }
else if (pobj > obj) {
129 else if (minobj != obj)
130 *_pos = (
unsigned long) minobj;
137 static void *fscache_objlist_start(
struct seq_file *
m, loff_t *_pos)
141 return fscache_objlist_lookup(_pos);
147 static void *fscache_objlist_next(
struct seq_file *
m,
void *
v, loff_t *_pos)
150 return fscache_objlist_lookup(_pos);
156 static void fscache_objlist_stop(
struct seq_file *
m,
void *
v)
165 static int fscache_objlist_show(
struct seq_file *
m,
void *
v)
171 char _type[3], *
type;
175 if ((
unsigned long) v == 1) {
176 seq_puts(m,
"OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS"
178 " | NETFS_COOKIE_DEF TY FL NETFS_DATA");
184 if ((config & (FSCACHE_OBJLIST_CONFIG_KEY |
194 if ((
unsigned long) v == 2) {
195 seq_puts(m,
"======== ======== ==== ===== === === === == ====="
197 " | ================ == == ================");
198 if (config & (FSCACHE_OBJLIST_CONFIG_KEY |
206 #define FILTER(criterion, _yes, _no) \
208 unsigned long yes = FSCACHE_OBJLIST_CONFIG_##_yes; \
209 unsigned long no = FSCACHE_OBJLIST_CONFIG_##_no; \
211 if (!(config & yes)) \
214 if (!(config & no)) \
238 "%8x %8x %s %5u %3u %3u %3u %2u %5u %2lx %2lx %1lx %1x | ",
256 spin_lock(&obj->
lock);
258 switch (obj->
cookie->def->type) {
278 if (obj->
cookie->def->get_key &&
279 config & FSCACHE_OBJLIST_CONFIG_KEY)
280 keylen = obj->
cookie->def->get_key(
284 if (obj->
cookie->def->get_aux &&
286 auxlen = obj->
cookie->def->get_aux(
288 buf + keylen, 512 - keylen);
292 spin_unlock(&obj->
lock);
294 if (!no_cookie && (keylen > 0 || auxlen > 0)) {
296 for (p = buf; keylen > 0; keylen--)
299 if (config & FSCACHE_OBJLIST_CONFIG_KEY)
301 for (; auxlen > 0; auxlen--)
315 .start = fscache_objlist_start,
316 .stop = fscache_objlist_stop,
317 .next = fscache_objlist_next,
318 .show = fscache_objlist_show,
340 confkey = key->payload.
data;
343 for (len = confkey->
datalen - 1; len >= 0; len--) {
394 ret =
seq_open(file, &fscache_objlist_ops);
408 fscache_objlist_config(data);
417 static int fscache_objlist_release(
struct inode *inode,
struct file *file)
428 .open = fscache_objlist_open,
431 .release = fscache_objlist_release,