[Libsysio-commit] HEAD: libsysio/src inode.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2008-07-11 16:48:05
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8234/src Modified Files: inode.c Log Message: Added per-directory name cache, replacing the global names cache. This involved: 1) Adding a root node for the binary tree to the path_base record. 2) Removing the global names cache from inode.c 3) Altering the implementation of ncache_{insert,delete} to use the parent node's names root as root. 4) Altering ncache_lookup to take the parent node and use it's root to find the key. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -w -b -B -p -r1.43 -r1.44 --- inode.c 17 Jun 2008 17:18:57 -0000 1.43 +++ inode.c 11 Jul 2008 16:48:01 -0000 1.44 @@ -76,23 +76,6 @@ struct inodes_head _sysio_inodes; static size_t n_inodes = 0; /* - * System table for rapid access to component names. - */ -static struct tree_node *names[NAMES_TABLE_LEN]; - -/* - * Return slot index in names table given pointer to path base key. - */ -#define ncache_key_index(pbk) \ - ((pbk)->pbk_name.hashval % NAMES_TABLE_LEN) - -/* - * Return ptr to slot in names table given hash value. - */ -#define ncache_slot(h) \ - (names[(h)] % NAMES_TABLE_LEN) - -/* * Number of names tracked by the system. */ static size_t n_names = 0; @@ -154,13 +137,9 @@ ino_cstats_init() int _sysio_i_init() { - unsigned i; TAILQ_INIT(&_sysio_inodes); - for (i = 0; i < NAMES_TABLE_LEN; i++) - names[i] = NULL; - TAILQ_INIT(&_sysio_idle_pnodes); max_names = desired_names; @@ -467,8 +446,9 @@ static void ncache_insert(struct pnode_base *pb) { + assert(pb->pb_key.pbk_parent); if (_sysio_tree_search(&pb->pb_tentry, - &names[ncache_key_index(&pb->pb_key)], + &pb->pb_key.pbk_parent->pb_ncache, (int (*)(const void *, const void *))compar_pb_key) != &pb->pb_tentry) @@ -482,8 +462,9 @@ static void ncache_delete(struct pnode_base *pb) { + assert(pb->pb_key.pbk_parent); if (_sysio_tree_delete(&pb->pb_key, - &names[ncache_key_index(&pb->pb_key)], + &pb->pb_key.pbk_parent->pb_ncache, (int (*)(const void *, const void *))compar_pb_key) != &pb->pb_tentry) @@ -494,13 +475,13 @@ ncache_delete(struct pnode_base *pb) * Lookup path base node in the system name cache given key info. */ static struct pnode_base * -ncache_lookup(struct pnode_base_key *pbk) +ncache_lookup(struct pnode_base *pb, struct pnode_base_key *pbk) { struct tree_node *tn; tn = _sysio_tree_find(pbk, - &names[ncache_key_index(pbk)], + &pb->pb_ncache, (int (*)(const void *, const void *))compar_pb_key); return tn ? TREE_ENTRY(tn, pnode_base, pb_tentry) : NULL; @@ -936,7 +917,7 @@ _sysio_p_find_alias(struct pnode *parent INO_CST_UPDCNT(pbprobes); key.pbk_name = *name; key.pbk_parent = parent->p_base; - pb = ncache_lookup(&key); + pb = ncache_lookup(key.pbk_parent, &key); if (pb) { PB_GET(pb); INO_CST_UPDCNT(pbhits); |