2009-11-19 19:11:04 +01:00
|
|
|
/* Global fscache object list maintainer and viewer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Red Hat, Inc. All Rights Reserved.
|
|
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public Licence
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the Licence, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define FSCACHE_DEBUG_LEVEL COOKIE
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/seq_file.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2009-11-19 19:11:04 +01:00
|
|
|
#include <linux/key.h>
|
|
|
|
#include <keys/user-type.h>
|
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
static struct rb_root fscache_object_list;
|
|
|
|
static DEFINE_RWLOCK(fscache_object_list_lock);
|
|
|
|
|
|
|
|
struct fscache_objlist_data {
|
|
|
|
unsigned long config; /* display configuration */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_KEY 0x00000001 /* show object keys */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_AUX 0x00000002 /* show object auxdata */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_COOKIE 0x00000004 /* show objects with cookies */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_NOCOOKIE 0x00000008 /* show objects without cookies */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_BUSY 0x00000010 /* show busy objects */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_IDLE 0x00000020 /* show idle objects */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_PENDWR 0x00000040 /* show objects with pending writes */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_NOPENDWR 0x00000080 /* show objects without pending writes */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_READS 0x00000100 /* show objects with active reads */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_NOREADS 0x00000200 /* show objects without active reads */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_EVENTS 0x00000400 /* show objects with events */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_NOEVENTS 0x00000800 /* show objects without no events */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_WORK 0x00001000 /* show objects with slow work */
|
|
|
|
#define FSCACHE_OBJLIST_CONFIG_NOWORK 0x00002000 /* show objects without slow work */
|
|
|
|
|
|
|
|
u8 buf[512]; /* key and aux data buffer */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add an object to the object list
|
|
|
|
* - we use the address of the fscache_object structure as the key into the
|
|
|
|
* tree
|
|
|
|
*/
|
|
|
|
void fscache_objlist_add(struct fscache_object *obj)
|
|
|
|
{
|
|
|
|
struct fscache_object *xobj;
|
|
|
|
struct rb_node **p = &fscache_object_list.rb_node, *parent = NULL;
|
|
|
|
|
|
|
|
write_lock(&fscache_object_list_lock);
|
|
|
|
|
|
|
|
while (*p) {
|
|
|
|
parent = *p;
|
|
|
|
xobj = rb_entry(parent, struct fscache_object, objlist_link);
|
|
|
|
|
|
|
|
if (obj < xobj)
|
|
|
|
p = &(*p)->rb_left;
|
|
|
|
else if (obj > xobj)
|
|
|
|
p = &(*p)->rb_right;
|
|
|
|
else
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
|
|
|
|
rb_link_node(&obj->objlist_link, parent, p);
|
|
|
|
rb_insert_color(&obj->objlist_link, &fscache_object_list);
|
|
|
|
|
|
|
|
write_unlock(&fscache_object_list_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* fscache_object_destroy - Note that a cache object is about to be destroyed
|
|
|
|
* @object: The object to be destroyed
|
|
|
|
*
|
|
|
|
* Note the imminent destruction and deallocation of a cache object record.
|
|
|
|
*/
|
|
|
|
void fscache_object_destroy(struct fscache_object *obj)
|
|
|
|
{
|
|
|
|
write_lock(&fscache_object_list_lock);
|
|
|
|
|
|
|
|
BUG_ON(RB_EMPTY_ROOT(&fscache_object_list));
|
|
|
|
rb_erase(&obj->objlist_link, &fscache_object_list);
|
|
|
|
|
|
|
|
write_unlock(&fscache_object_list_lock);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(fscache_object_destroy);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* find the object in the tree on or after the specified index
|
|
|
|
*/
|
|
|
|
static struct fscache_object *fscache_objlist_lookup(loff_t *_pos)
|
|
|
|
{
|
2009-12-16 01:47:46 +01:00
|
|
|
struct fscache_object *pobj, *obj = NULL, *minobj = NULL;
|
2009-11-19 19:11:04 +01:00
|
|
|
struct rb_node *p;
|
|
|
|
unsigned long pos;
|
|
|
|
|
|
|
|
if (*_pos >= (unsigned long) ERR_PTR(-ENOENT))
|
|
|
|
return NULL;
|
|
|
|
pos = *_pos;
|
|
|
|
|
|
|
|
/* banners (can't represent line 0 by pos 0 as that would involve
|
|
|
|
* returning a NULL pointer) */
|
|
|
|
if (pos == 0)
|
2010-05-26 08:43:02 +02:00
|
|
|
return (struct fscache_object *)(long)++(*_pos);
|
2009-11-19 19:11:04 +01:00
|
|
|
if (pos < 3)
|
|
|
|
return (struct fscache_object *)pos;
|
|
|
|
|
|
|
|
pobj = (struct fscache_object *)pos;
|
|
|
|
p = fscache_object_list.rb_node;
|
|
|
|
while (p) {
|
|
|
|
obj = rb_entry(p, struct fscache_object, objlist_link);
|
|
|
|
if (pobj < obj) {
|
|
|
|
if (!minobj || minobj > obj)
|
|
|
|
minobj = obj;
|
|
|
|
p = p->rb_left;
|
|
|
|
} else if (pobj > obj) {
|
|
|
|
p = p->rb_right;
|
|
|
|
} else {
|
|
|
|
minobj = obj;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
obj = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!minobj)
|
|
|
|
*_pos = (unsigned long) ERR_PTR(-ENOENT);
|
|
|
|
else if (minobj != obj)
|
|
|
|
*_pos = (unsigned long) minobj;
|
|
|
|
return minobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set up the iterator to start reading from the first line
|
|
|
|
*/
|
|
|
|
static void *fscache_objlist_start(struct seq_file *m, loff_t *_pos)
|
|
|
|
__acquires(&fscache_object_list_lock)
|
|
|
|
{
|
|
|
|
read_lock(&fscache_object_list_lock);
|
|
|
|
return fscache_objlist_lookup(_pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* move to the next line
|
|
|
|
*/
|
|
|
|
static void *fscache_objlist_next(struct seq_file *m, void *v, loff_t *_pos)
|
|
|
|
{
|
|
|
|
(*_pos)++;
|
|
|
|
return fscache_objlist_lookup(_pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clean up after reading
|
|
|
|
*/
|
|
|
|
static void fscache_objlist_stop(struct seq_file *m, void *v)
|
|
|
|
__releases(&fscache_object_list_lock)
|
|
|
|
{
|
|
|
|
read_unlock(&fscache_object_list_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* display an object
|
|
|
|
*/
|
|
|
|
static int fscache_objlist_show(struct seq_file *m, void *v)
|
|
|
|
{
|
|
|
|
struct fscache_objlist_data *data = m->private;
|
|
|
|
struct fscache_object *obj = v;
|
|
|
|
unsigned long config = data->config;
|
|
|
|
uint16_t keylen, auxlen;
|
|
|
|
char _type[3], *type;
|
|
|
|
bool no_cookie;
|
|
|
|
u8 *buf = data->buf, *p;
|
|
|
|
|
|
|
|
if ((unsigned long) v == 1) {
|
|
|
|
seq_puts(m, "OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS"
|
|
|
|
" EM EV F S"
|
|
|
|
" | NETFS_COOKIE_DEF TY FL NETFS_DATA");
|
|
|
|
if (config & (FSCACHE_OBJLIST_CONFIG_KEY |
|
|
|
|
FSCACHE_OBJLIST_CONFIG_AUX))
|
|
|
|
seq_puts(m, " ");
|
|
|
|
if (config & FSCACHE_OBJLIST_CONFIG_KEY)
|
|
|
|
seq_puts(m, "OBJECT_KEY");
|
|
|
|
if ((config & (FSCACHE_OBJLIST_CONFIG_KEY |
|
|
|
|
FSCACHE_OBJLIST_CONFIG_AUX)) ==
|
|
|
|
(FSCACHE_OBJLIST_CONFIG_KEY | FSCACHE_OBJLIST_CONFIG_AUX))
|
|
|
|
seq_puts(m, ", ");
|
|
|
|
if (config & FSCACHE_OBJLIST_CONFIG_AUX)
|
|
|
|
seq_puts(m, "AUX_DATA");
|
|
|
|
seq_puts(m, "\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((unsigned long) v == 2) {
|
|
|
|
seq_puts(m, "======== ======== ==== ===== === === === == ====="
|
|
|
|
" == == = ="
|
|
|
|
" | ================ == == ================");
|
|
|
|
if (config & (FSCACHE_OBJLIST_CONFIG_KEY |
|
|
|
|
FSCACHE_OBJLIST_CONFIG_AUX))
|
|
|
|
seq_puts(m, " ================");
|
|
|
|
seq_puts(m, "\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* filter out any unwanted objects */
|
|
|
|
#define FILTER(criterion, _yes, _no) \
|
|
|
|
do { \
|
|
|
|
unsigned long yes = FSCACHE_OBJLIST_CONFIG_##_yes; \
|
|
|
|
unsigned long no = FSCACHE_OBJLIST_CONFIG_##_no; \
|
|
|
|
if (criterion) { \
|
|
|
|
if (!(config & yes)) \
|
|
|
|
return 0; \
|
|
|
|
} else { \
|
|
|
|
if (!(config & no)) \
|
|
|
|
return 0; \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
if (~config) {
|
|
|
|
FILTER(obj->cookie,
|
|
|
|
COOKIE, NOCOOKIE);
|
|
|
|
FILTER(obj->state != FSCACHE_OBJECT_ACTIVE ||
|
|
|
|
obj->n_ops != 0 ||
|
|
|
|
obj->n_obj_ops != 0 ||
|
|
|
|
obj->flags ||
|
|
|
|
!list_empty(&obj->dependents),
|
|
|
|
BUSY, IDLE);
|
|
|
|
FILTER(test_bit(FSCACHE_OBJECT_PENDING_WRITE, &obj->flags),
|
|
|
|
PENDWR, NOPENDWR);
|
|
|
|
FILTER(atomic_read(&obj->n_reads),
|
|
|
|
READS, NOREADS);
|
|
|
|
FILTER(obj->events & obj->event_mask,
|
|
|
|
EVENTS, NOEVENTS);
|
|
|
|
FILTER(obj->work.flags & ~(1UL << SLOW_WORK_VERY_SLOW),
|
|
|
|
WORK, NOWORK);
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_printf(m,
|
|
|
|
"%8x %8x %s %5u %3u %3u %3u %2u %5u %2lx %2lx %1lx %1lx | ",
|
|
|
|
obj->debug_id,
|
|
|
|
obj->parent ? obj->parent->debug_id : -1,
|
|
|
|
fscache_object_states_short[obj->state],
|
|
|
|
obj->n_children,
|
|
|
|
obj->n_ops,
|
|
|
|
obj->n_obj_ops,
|
|
|
|
obj->n_in_progress,
|
|
|
|
obj->n_exclusive,
|
|
|
|
atomic_read(&obj->n_reads),
|
|
|
|
obj->event_mask & FSCACHE_OBJECT_EVENTS_MASK,
|
|
|
|
obj->events,
|
|
|
|
obj->flags,
|
|
|
|
obj->work.flags);
|
|
|
|
|
|
|
|
no_cookie = true;
|
|
|
|
keylen = auxlen = 0;
|
|
|
|
if (obj->cookie) {
|
|
|
|
spin_lock(&obj->lock);
|
|
|
|
if (obj->cookie) {
|
|
|
|
switch (obj->cookie->def->type) {
|
|
|
|
case 0:
|
|
|
|
type = "IX";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
type = "DT";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sprintf(_type, "%02u",
|
|
|
|
obj->cookie->def->type);
|
|
|
|
type = _type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_printf(m, "%-16s %s %2lx %16p",
|
|
|
|
obj->cookie->def->name,
|
|
|
|
type,
|
|
|
|
obj->cookie->flags,
|
|
|
|
obj->cookie->netfs_data);
|
|
|
|
|
|
|
|
if (obj->cookie->def->get_key &&
|
|
|
|
config & FSCACHE_OBJLIST_CONFIG_KEY)
|
|
|
|
keylen = obj->cookie->def->get_key(
|
|
|
|
obj->cookie->netfs_data,
|
|
|
|
buf, 400);
|
|
|
|
|
|
|
|
if (obj->cookie->def->get_aux &&
|
|
|
|
config & FSCACHE_OBJLIST_CONFIG_AUX)
|
|
|
|
auxlen = obj->cookie->def->get_aux(
|
|
|
|
obj->cookie->netfs_data,
|
|
|
|
buf + keylen, 512 - keylen);
|
|
|
|
|
|
|
|
no_cookie = false;
|
|
|
|
}
|
|
|
|
spin_unlock(&obj->lock);
|
|
|
|
|
|
|
|
if (!no_cookie && (keylen > 0 || auxlen > 0)) {
|
|
|
|
seq_printf(m, " ");
|
|
|
|
for (p = buf; keylen > 0; keylen--)
|
|
|
|
seq_printf(m, "%02x", *p++);
|
|
|
|
if (auxlen > 0) {
|
|
|
|
if (config & FSCACHE_OBJLIST_CONFIG_KEY)
|
|
|
|
seq_printf(m, ", ");
|
|
|
|
for (; auxlen > 0; auxlen--)
|
|
|
|
seq_printf(m, "%02x", *p++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (no_cookie)
|
|
|
|
seq_printf(m, "<no_cookie>\n");
|
|
|
|
else
|
|
|
|
seq_printf(m, "\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct seq_operations fscache_objlist_ops = {
|
|
|
|
.start = fscache_objlist_start,
|
|
|
|
.stop = fscache_objlist_stop,
|
|
|
|
.next = fscache_objlist_next,
|
|
|
|
.show = fscache_objlist_show,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get the configuration for filtering the list
|
|
|
|
*/
|
|
|
|
static void fscache_objlist_config(struct fscache_objlist_data *data)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_KEYS
|
|
|
|
struct user_key_payload *confkey;
|
|
|
|
unsigned long config;
|
|
|
|
struct key *key;
|
|
|
|
const char *buf;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
key = request_key(&key_type_user, "fscache:objlist", NULL);
|
|
|
|
if (IS_ERR(key))
|
|
|
|
goto no_config;
|
|
|
|
|
|
|
|
config = 0;
|
|
|
|
rcu_read_lock();
|
|
|
|
|
|
|
|
confkey = key->payload.data;
|
|
|
|
buf = confkey->data;
|
|
|
|
|
|
|
|
for (len = confkey->datalen - 1; len >= 0; len--) {
|
|
|
|
switch (buf[len]) {
|
|
|
|
case 'K': config |= FSCACHE_OBJLIST_CONFIG_KEY; break;
|
|
|
|
case 'A': config |= FSCACHE_OBJLIST_CONFIG_AUX; break;
|
|
|
|
case 'C': config |= FSCACHE_OBJLIST_CONFIG_COOKIE; break;
|
|
|
|
case 'c': config |= FSCACHE_OBJLIST_CONFIG_NOCOOKIE; break;
|
|
|
|
case 'B': config |= FSCACHE_OBJLIST_CONFIG_BUSY; break;
|
|
|
|
case 'b': config |= FSCACHE_OBJLIST_CONFIG_IDLE; break;
|
|
|
|
case 'W': config |= FSCACHE_OBJLIST_CONFIG_PENDWR; break;
|
|
|
|
case 'w': config |= FSCACHE_OBJLIST_CONFIG_NOPENDWR; break;
|
|
|
|
case 'R': config |= FSCACHE_OBJLIST_CONFIG_READS; break;
|
|
|
|
case 'r': config |= FSCACHE_OBJLIST_CONFIG_NOREADS; break;
|
|
|
|
case 'S': config |= FSCACHE_OBJLIST_CONFIG_WORK; break;
|
|
|
|
case 's': config |= FSCACHE_OBJLIST_CONFIG_NOWORK; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
key_put(key);
|
|
|
|
|
|
|
|
if (!(config & (FSCACHE_OBJLIST_CONFIG_COOKIE | FSCACHE_OBJLIST_CONFIG_NOCOOKIE)))
|
|
|
|
config |= FSCACHE_OBJLIST_CONFIG_COOKIE | FSCACHE_OBJLIST_CONFIG_NOCOOKIE;
|
|
|
|
if (!(config & (FSCACHE_OBJLIST_CONFIG_BUSY | FSCACHE_OBJLIST_CONFIG_IDLE)))
|
|
|
|
config |= FSCACHE_OBJLIST_CONFIG_BUSY | FSCACHE_OBJLIST_CONFIG_IDLE;
|
|
|
|
if (!(config & (FSCACHE_OBJLIST_CONFIG_PENDWR | FSCACHE_OBJLIST_CONFIG_NOPENDWR)))
|
|
|
|
config |= FSCACHE_OBJLIST_CONFIG_PENDWR | FSCACHE_OBJLIST_CONFIG_NOPENDWR;
|
|
|
|
if (!(config & (FSCACHE_OBJLIST_CONFIG_READS | FSCACHE_OBJLIST_CONFIG_NOREADS)))
|
|
|
|
config |= FSCACHE_OBJLIST_CONFIG_READS | FSCACHE_OBJLIST_CONFIG_NOREADS;
|
|
|
|
if (!(config & (FSCACHE_OBJLIST_CONFIG_EVENTS | FSCACHE_OBJLIST_CONFIG_NOEVENTS)))
|
|
|
|
config |= FSCACHE_OBJLIST_CONFIG_EVENTS | FSCACHE_OBJLIST_CONFIG_NOEVENTS;
|
|
|
|
if (!(config & (FSCACHE_OBJLIST_CONFIG_WORK | FSCACHE_OBJLIST_CONFIG_NOWORK)))
|
|
|
|
config |= FSCACHE_OBJLIST_CONFIG_WORK | FSCACHE_OBJLIST_CONFIG_NOWORK;
|
|
|
|
|
|
|
|
data->config = config;
|
|
|
|
return;
|
|
|
|
|
|
|
|
no_config:
|
|
|
|
#endif
|
|
|
|
data->config = ULONG_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* open "/proc/fs/fscache/objects" to provide a list of active objects
|
|
|
|
* - can be configured by a user-defined key added to the caller's keyrings
|
|
|
|
*/
|
|
|
|
static int fscache_objlist_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
struct fscache_objlist_data *data;
|
|
|
|
struct seq_file *m;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = seq_open(file, &fscache_objlist_ops);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
m = file->private_data;
|
|
|
|
|
|
|
|
/* buffer for key extraction */
|
|
|
|
data = kmalloc(sizeof(struct fscache_objlist_data), GFP_KERNEL);
|
|
|
|
if (!data) {
|
|
|
|
seq_release(inode, file);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the configuration key */
|
|
|
|
fscache_objlist_config(data);
|
|
|
|
|
|
|
|
m->private = data;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clean up on close
|
|
|
|
*/
|
|
|
|
static int fscache_objlist_release(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
struct seq_file *m = file->private_data;
|
|
|
|
|
|
|
|
kfree(m->private);
|
|
|
|
m->private = NULL;
|
|
|
|
return seq_release(inode, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct file_operations fscache_objlist_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = fscache_objlist_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = fscache_objlist_release,
|
|
|
|
};
|