summaryrefslogtreecommitdiffstats
path: root/sys/fs/pseudofs/pseudofs_vncache.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2007-04-14 14:08:30 +0000
committerdes <des@FreeBSD.org>2007-04-14 14:08:30 +0000
commit8dea6eb551705418618e5d68bee96d521d326dc6 (patch)
tree8776799c42c10769a373413b3de276bdb92b7d60 /sys/fs/pseudofs/pseudofs_vncache.c
parent5953cee02a231f279bc2d4cf8fdf52d332e94a29 (diff)
downloadFreeBSD-src-8dea6eb551705418618e5d68bee96d521d326dc6.zip
FreeBSD-src-8dea6eb551705418618e5d68bee96d521d326dc6.tar.gz
Further pseudofs improvements:
The pfs_info mutex is only needed to lock pi_unrhdr. Everything else in struct pfs_info is modified only while Giant is held (during vfs_init() / vfs_uninit()); add assertions to that effect. Simplify pfs_destroy somewhat. Remove superfluous arguments from pfs_fileno_{alloc,free}(), and the assertions which were added in the previous commit to ensure they were consistent. Assert that Giant is held while the vnode cache is initialized and destroyed. Also assert that the cache is empty when it is destroyed. Rename the vnode cache mutex for consistency. Fix a long-standing bug in pfs_getattr(): it would uncritically return the node's pn_fileno as st_ino. This would result in st_ino being 0 if the node had not previously been visited by readdir(), and also in an incorrect st_ino for process directories and any files contained therein. Correct this by abstracting the fileno manipulations previously done in pfs_readdir() into a new function, pfs_fileno(), which is used by both pfs_getattr() and pfs_readdir().
Diffstat (limited to 'sys/fs/pseudofs/pseudofs_vncache.c')
-rw-r--r--sys/fs/pseudofs/pseudofs_vncache.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/fs/pseudofs/pseudofs_vncache.c b/sys/fs/pseudofs/pseudofs_vncache.c
index e4d8db8..7544cb1 100644
--- a/sys/fs/pseudofs/pseudofs_vncache.c
+++ b/sys/fs/pseudofs/pseudofs_vncache.c
@@ -83,7 +83,9 @@ extern struct vop_vector pfs_vnodeops; /* XXX -> .h file */
void
pfs_vncache_load(void)
{
- mtx_init(&pfs_vncache_mutex, "pseudofs_vncache", NULL, MTX_DEF);
+
+ mtx_assert(&Giant, MA_OWNED);
+ mtx_init(&pfs_vncache_mutex, "pfs_vncache", NULL, MTX_DEF);
pfs_exit_tag = EVENTHANDLER_REGISTER(process_exit, pfs_exit, NULL,
EVENTHANDLER_PRI_ANY);
}
@@ -94,10 +96,11 @@ pfs_vncache_load(void)
void
pfs_vncache_unload(void)
{
+
+ mtx_assert(&Giant, MA_OWNED);
EVENTHANDLER_DEREGISTER(process_exit, pfs_exit_tag);
- if (pfs_vncache_entries != 0)
- printf("pfs_vncache_unload(): %d entries remaining\n",
- pfs_vncache_entries);
+ KASSERT(pfs_vncache_entries == 0,
+ ("%d vncache entries remaining", pfs_vncache_entries));
mtx_destroy(&pfs_vncache_mutex);
}
OpenPOWER on IntegriCloud