Skip to content

Commit

Permalink
FS-Cache: Allow the current state of all objects to be dumped
Browse files Browse the repository at this point in the history
Allow the current state of all fscache objects to be dumped by doing:

	cat /proc/fs/fscache/objects

By default, all objects and all fields will be shown.  This can be restricted
by adding a suitable key to one of the caller's keyrings (such as the session
keyring):

	keyctl add user fscache:objlist "<restrictions>" @s

The <restrictions> are:

	K	Show hexdump of object key (don't show if not given)
	A	Show hexdump of object aux data (don't show if not given)

And paired restrictions:

	C	Show objects that have a cookie
	c	Show objects that don't have a cookie
	B	Show objects that are busy
	b	Show objects that aren't busy
	W	Show objects that have pending writes
	w	Show objects that don't have pending writes
	R	Show objects that have outstanding reads
	r	Show objects that don't have outstanding reads
	S	Show objects that have slow work queued
	s	Show objects that don't have slow work queued

If neither side of a restriction pair is given, then both are implied.  For
example:

	keyctl add user fscache:objlist KB @s

shows objects that are busy, and lists their object keys, but does not dump
their auxiliary data.  It also implies "CcWwRrSs", but as 'B' is given, 'b' is
not implied.

Signed-off-by: David Howells <[email protected]>
  • Loading branch information
dhowells committed Nov 19, 2009
1 parent 440f0af commit 4fbf429
Show file tree
Hide file tree
Showing 14 changed files with 578 additions and 3 deletions.
81 changes: 81 additions & 0 deletions Documentation/filesystems/caching/fscache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,87 @@ proc files.
jiffy range covered, and the SECS field the equivalent number of seconds.


===========
OBJECT LIST
===========

If CONFIG_FSCACHE_OBJECT_LIST is enabled, the FS-Cache facility will maintain a
list of all the objects currently allocated and allow them to be viewed
through:

/proc/fs/fscache/objects

This will look something like:

[root@andromeda ~]# head /proc/fs/fscache/objects
OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS EM EV F S | NETFS_COOKIE_DEF TY FL NETFS_DATA OBJECT_KEY, AUX_DATA
======== ======== ==== ===== === === === == ===== == == = = | ================ == == ================ ================
17e4b 2 ACTV 0 0 0 0 0 0 7b 4 0 8 | NFS.fh DT 0 ffff88001dd82820 010006017edcf8bbc93b43298fdfbe71e50b57b13a172c0117f38472, e567634700000000000000000000000063f2404a000000000000000000000000c9030000000000000000000063f2404a
1693a 2 ACTV 0 0 0 0 0 0 7b 4 0 8 | NFS.fh DT 0 ffff88002db23380 010006017edcf8bbc93b43298fdfbe71e50b57b1e0162c01a2df0ea6, 420ebc4a000000000000000000000000420ebc4a0000000000000000000000000e1801000000000000000000420ebc4a

where the first set of columns before the '|' describe the object:

COLUMN DESCRIPTION
======= ===============================================================
OBJECT Object debugging ID (appears as OBJ%x in some debug messages)
PARENT Debugging ID of parent object
STAT Object state
CHLDN Number of child objects of this object
OPS Number of outstanding operations on this object
OOP Number of outstanding child object management operations
IPR
EX Number of outstanding exclusive operations
READS Number of outstanding read operations
EM Object's event mask
EV Events raised on this object
F Object flags
S Object slow-work work item flags

and the second set of columns describe the object's cookie, if present:

COLUMN DESCRIPTION
=============== =======================================================
NETFS_COOKIE_DEF Name of netfs cookie definition
TY Cookie type (IX - index, DT - data, hex - special)
FL Cookie flags
NETFS_DATA Netfs private data stored in the cookie
OBJECT_KEY Object key } 1 column, with separating comma
AUX_DATA Object aux data } presence may be configured

The data shown may be filtered by attaching the a key to an appropriate keyring
before viewing the file. Something like:

keyctl add user fscache:objlist <restrictions> @s

where <restrictions> are a selection of the following letters:

K Show hexdump of object key (don't show if not given)
A Show hexdump of object aux data (don't show if not given)

and the following paired letters:

C Show objects that have a cookie
c Show objects that don't have a cookie
B Show objects that are busy
b Show objects that aren't busy
W Show objects that have pending writes
w Show objects that don't have pending writes
R Show objects that have outstanding reads
r Show objects that don't have outstanding reads
S Show objects that have slow work queued
s Show objects that don't have slow work queued

If neither side of a letter pair is given, then both are implied. For example:

keyctl add user fscache:objlist KB @s

shows objects that are busy, and lists their object keys, but does not dump
their auxiliary data. It also implies "CcWwRrSs", but as 'B' is given, 'b' is
not implied.

By default all objects and all fields will be shown.


=========
DEBUGGING
=========
Expand Down
1 change: 1 addition & 0 deletions fs/cachefiles/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ static void cachefiles_put_object(struct fscache_object *_object)
}

cache = object->fscache.cache;
fscache_object_destroy(&object->fscache);
kmem_cache_free(cachefiles_object_jar, object);
fscache_object_destroyed(cache);
}
Expand Down
6 changes: 4 additions & 2 deletions fs/cachefiles/rdwr.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,

shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;

op->op.flags = FSCACHE_OP_FAST;
op->op.flags &= FSCACHE_OP_KEEP_FLAGS;
op->op.flags |= FSCACHE_OP_FAST;
op->op.processor = cachefiles_read_copier;

pagevec_init(&pagevec, 0);
Expand Down Expand Up @@ -639,7 +640,8 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,

pagevec_init(&pagevec, 0);

op->op.flags = FSCACHE_OP_FAST;
op->op.flags &= FSCACHE_OP_KEEP_FLAGS;
op->op.flags |= FSCACHE_OP_FAST;
op->op.processor = cachefiles_read_copier;

INIT_LIST_HEAD(&backpages);
Expand Down
7 changes: 7 additions & 0 deletions fs/fscache/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ config FSCACHE_DEBUG
enabled by setting bits in /sys/modules/fscache/parameter/debug.

See Documentation/filesystems/caching/fscache.txt for more information.

config FSCACHE_OBJECT_LIST
bool "Maintain global object list for debugging purposes"
depends on FSCACHE && PROC_FS
help
Maintain a global list of active fscache objects that can be
retrieved through /proc/fs/fscache/objects for debugging purposes
1 change: 1 addition & 0 deletions fs/fscache/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ fscache-y := \
fscache-$(CONFIG_PROC_FS) += proc.o
fscache-$(CONFIG_FSCACHE_STATS) += stats.o
fscache-$(CONFIG_FSCACHE_HISTOGRAM) += histogram.o
fscache-$(CONFIG_FSCACHE_OBJECT_LIST) += object-list.o

obj-$(CONFIG_FSCACHE) := fscache.o
1 change: 1 addition & 0 deletions fs/fscache/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ int fscache_add_cache(struct fscache_cache *cache,
spin_lock(&cache->object_list_lock);
list_add_tail(&ifsdef->cache_link, &cache->object_list);
spin_unlock(&cache->object_list_lock);
fscache_objlist_add(ifsdef);

/* add the cache's netfs definition index object to the top level index
* cookie as a known backing object */
Expand Down
2 changes: 2 additions & 0 deletions fs/fscache/cookie.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ static int fscache_attach_object(struct fscache_cookie *cookie,
object->cookie = cookie;
atomic_inc(&cookie->usage);
hlist_add_head(&object->cookie_link, &cookie->backing_objects);

fscache_objlist_add(object);
ret = 0;

cant_attach_object:
Expand Down
13 changes: 13 additions & 0 deletions fs/fscache/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,23 @@ extern int fscache_wait_bit_interruptible(void *);
/*
* object.c
*/
extern const char fscache_object_states_short[FSCACHE_OBJECT__NSTATES][5];

extern void fscache_withdrawing_object(struct fscache_cache *,
struct fscache_object *);
extern void fscache_enqueue_object(struct fscache_object *);

/*
* object-list.c
*/
#ifdef CONFIG_FSCACHE_OBJECT_LIST
extern const struct file_operations fscache_objlist_fops;

extern void fscache_objlist_add(struct fscache_object *);
#else
#define fscache_objlist_add(object) do {} while(0)
#endif

/*
* operation.c
*/
Expand Down
Loading

0 comments on commit 4fbf429

Please sign in to comment.