[Libsysio-commit] HEAD: libsysio/src inode.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2009-01-05 19:19:37
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10773/src Modified Files: inode.c Log Message: We no longer reclaim i_nodes directly. Instead, as path-base nodes are released by the path node reclamation, the i-node is dismissed directly. It served no useful purpose to retain these beyond the life of the set of associated path-base nodes. As well, if PB_DEBUG is defined then a list of leaf path-base nodes is kept and reported when we are dbugging reclamation. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -w -b -B -p -r1.50 -r1.51 --- inode.c 15 Dec 2008 19:55:54 -0000 1.50 +++ inode.c 5 Jan 2009 19:19:29 -0000 1.51 @@ -73,6 +73,7 @@ */ #define P_RECLAIM_MIN 511 #if P_RECLAIM_MIN > (NAMES_TABLE_LEN / 4) +#undef P_RECLAIM_MIN #define P_RECLAIM_MIN (NAMES_TABLE_LEN / 4) #endif @@ -92,8 +93,8 @@ static size_t n_names = 0; */ struct pnodes_head _sysio_idle_pnodes; -#ifdef P_RECLAIM_DEBUG -static TAILQ_HEAD(, pnode_base) pbnodes; +#ifdef PB_DEBUG +static TAILQ_HEAD(, pnode_base) pb_leaf_nodes; #endif /* @@ -105,11 +106,6 @@ struct pnode *_sysio_root = NULL; static struct { unsigned long long cst_iprobes; unsigned long long cst_ihits; -#if 0 - unsigned long long cst_ireclaims; - unsigned long long cst_iexamined; - unsigned long long cst_idismissed; -#endif unsigned long long cst_pbprobes; unsigned long long cst_pbhits; unsigned long long cst_preclaims; @@ -122,11 +118,6 @@ ino_cstats_init() { cstats.cst_iprobes = cstats.cst_ihits = 0; -#if 0 - cstats.cst_ireclaims = - cstats.cst_iexamined = - cstats.cst_idismissed = 0; -#endif cstats.cst_pbprobes = cstats.cst_pbhits = 0; cstats.cst_preclaims = cstats.cst_pexamined = @@ -151,7 +142,9 @@ _sysio_i_init() { TAILQ_INIT(&_sysio_inodes); - +#ifdef PB_DEBUG + TAILQ_INIT(&pb_leaf_nodes); +#endif TAILQ_INIT(&_sysio_idle_pnodes); #ifdef INO_CACHE_STATS @@ -161,33 +154,6 @@ _sysio_i_init() return 0; } -#if 0 -/* - * Garbage-collect idle i-nodes. - */ -static void -i_reclaim() -{ - struct inode *next, *ino; - size_t t; - - INO_CST_UPDCNT(ireclaims); - t = n_inodes - n_inodes / 10; - next = _sysio_inodes.tqh_first; - while (next) { - ino = next; - next = ino->i_nodes.tqe_next; - INO_CST_UPDCNT(iexamined); - if (ino->i_ref || (ino->i_immune && !ino->i_zombie)) - continue; - INO_CST_UPDCNT(idismissed); - _sysio_i_gone(ino); - if (n_inodes < t) - break; - } -} -#endif - /* * Compare two file identifiers, returning -1 if length of first is * less than the second, or 1 if length of first greater than then the @@ -273,17 +239,6 @@ _sysio_i_new(struct filesys *fs, struct inode *ino; struct inode_ops operations; -#if 0 - if (n_inodes > n_names) { - /* - * This has become pretty badly skewed relative to - * the number of active nodes in the system. Try to - * correct that, now. - */ - i_reclaim(); - } -#endif - ino = malloc(sizeof(struct inode)); if (!ino) return NULL; @@ -374,7 +329,7 @@ _sysio_i_undead(struct inode *ino) icache_delete(ino); } -#ifdef P_RECLAIM_DEBUG +#ifdef PB_DEBUG static void p_reclaim_debug() { @@ -385,7 +340,7 @@ p_reclaim_debug() npbleaves = 0; npborphans = 0; - nxt = pbnodes.tqh_first; + nxt = pb_leaf_nodes.tqh_first; while ((pb = nxt)) { nxt = pb->pb_links.tqe_next; npb++; @@ -410,10 +365,6 @@ p_reclaim(unsigned limit) struct pnode *next, *pno; struct pnode_base *pb; -#ifdef P_RECLAIM_DEBUG - p_reclaim_debug(); -#endif - INO_CST_UPDCNT(preclaims); next = _sysio_idle_pnodes.tqh_first; if (!next) @@ -536,6 +487,17 @@ _sysio_pb_new(struct qstr *name, struct struct pnode_base *pb; static struct qstr noname = { NULL, 0, 0 }; + if (n_names > NAMES_TABLE_LEN) { + unsigned n; + /* + * Limit growth. + */ + n = n_names - NAMES_TABLE_LEN; + if (n < P_RECLAIM_MIN) + n = P_RECLAIM_MIN; + p_reclaim(n); + } + pb = malloc(sizeof(struct pnode_base) + name->len); if (!pb) return NULL; @@ -547,8 +509,18 @@ _sysio_pb_new(struct qstr *name, struct I_REF(ino); PB_LOCK(pb); - if (parent) + if (pb->pb_key.pbk_parent) { +#if defined(PB_DEBUG) + if (!parent->pb_children.lh_first) { + /* + * The parent is no longer a leaf. We + * need to remove it from that list. + */ + TAILQ_REMOVE(&pb_leaf_nodes, parent, pb_links); + } +#endif LIST_INSERT_HEAD(&parent->pb_children, pb, pb_sibs); + } if (pb->pb_key.pbk_name.len) { char *cp; @@ -563,8 +535,8 @@ _sysio_pb_new(struct qstr *name, struct pb->pb_key.pbk_name.name = cp; ncache_insert(pb); } -#ifdef P_RECLAIM_DEBUG - TAILQ_INSERT_HEAD(&pbnodes, pb, pb_links); +#ifdef PB_DEBUG + TAILQ_INSERT_TAIL(&pb_leaf_nodes, pb, pb_links); #endif PB_GET(pb); PB_UNLOCK(pb); @@ -572,17 +544,6 @@ _sysio_pb_new(struct qstr *name, struct n_names++; assert(n_names); - if (n_names > NAMES_TABLE_LEN) { - unsigned n; - /* - * Limit growth. - */ - n = n_names - NAMES_TABLE_LEN; - if (n < P_RECLAIM_MIN) - n = P_RECLAIM_MIN; - p_reclaim(n); - } - return pb; } @@ -602,10 +563,22 @@ _sysio_pb_gone(struct pnode_base *pb) if (pb->pb_key.pbk_name.len) ncache_delete(pb); - if (pb->pb_key.pbk_parent) + if (pb->pb_key.pbk_parent) { LIST_REMOVE(pb, pb_sibs); -#ifdef P_RECLAIM_DEBUG - TAILQ_REMOVE(&pbnodes, pb, pb_links); +#if defined(PB_DEBUG) + /* + * If we just removed the last child, put the parent on + * the list of leaves. + */ + if (!pb->pb_key.pbk_parent->pb_children.lh_first) { + TAILQ_INSERT_TAIL(&pb_leaf_nodes, + pb->pb_key.pbk_parent, + pb_links); + } +#endif + } +#ifdef PB_DEBUG + TAILQ_REMOVE(&pb_leaf_nodes, pb, pb_links); #endif ino = pb->pb_ino; if (ino) @@ -653,12 +626,6 @@ _sysio_i_shutdown() _sysio_cprintf("inode: probe %llu, hit %llu\n", cstats.cst_iprobes, cstats.cst_ihits); -#if 0 - _sysio_cprintf("inode: reclaims %llu, examined %llu dismissed %llu\n", - cstats.cst_ireclaims, - cstats.cst_iexamined, - cstats.cst_idismissed); -#endif _sysio_cprintf("pbnode: probe %llu, hit %llu\n", cstats.cst_pbprobes, cstats.cst_pbhits); |