libsysio-commit Mailing List for libsysio (Page 10)
Brought to you by:
lward
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(25) |
May
(28) |
Jun
(25) |
Jul
(30) |
Aug
(60) |
Sep
(52) |
Oct
(100) |
Nov
(15) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(89) |
Feb
(48) |
Mar
(22) |
Apr
(59) |
May
(16) |
Jun
(15) |
Jul
(50) |
Aug
(26) |
Sep
(40) |
Oct
(27) |
Nov
(12) |
Dec
|
2005 |
Jan
(24) |
Feb
(11) |
Mar
|
Apr
|
May
(3) |
Jun
(6) |
Jul
|
Aug
(14) |
Sep
(21) |
Oct
(10) |
Nov
|
Dec
|
2006 |
Jan
(8) |
Feb
(5) |
Mar
(2) |
Apr
(6) |
May
(11) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2007 |
Jan
(3) |
Feb
(5) |
Mar
(20) |
Apr
(41) |
May
(21) |
Jun
(3) |
Jul
(5) |
Aug
(12) |
Sep
(21) |
Oct
(5) |
Nov
(16) |
Dec
|
2008 |
Jan
|
Feb
(2) |
Mar
(4) |
Apr
(23) |
May
|
Jun
(22) |
Jul
(13) |
Aug
|
Sep
|
Oct
(9) |
Nov
(3) |
Dec
(13) |
2009 |
Jan
(14) |
Feb
(10) |
Mar
(2) |
Apr
(11) |
May
(7) |
Jun
(1) |
Jul
(1) |
Aug
(36) |
Sep
(12) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Lee W. <lw...@us...> - 2007-09-24 19:00:19
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10952/drivers/yod Modified Files: fs_yod.c Log Message: All the drivers, in their mount routines, do something like: rootpb = _sysio_pb_new(&noname, NULL, rootino); err = _sysio_do_mount(..., rootpb, ...); This is clumsy. Crafted a convenience function called _sysio_mounti to do this for them. This simplifies the whole process a bit. Don't have to clean up the root pb node on error, for instance. The function is called exactly like _sysio_do_mount but with a ptr to the root inode instead of a ptr to the root pb node. Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -w -b -B -p -r1.22 -r1.23 --- fs_yod.c 4 Aug 2005 20:17:10 -0000 1.22 +++ fs_yod.c 24 Sep 2007 19:00:03 -0000 1.23 @@ -343,8 +343,6 @@ create_internal_namespace() int err; struct mount *mnt; struct inode *rootino; - struct pnode_base *rootpb; - static struct qstr noname = { NULL, 0, 0 }; struct filesys *fs; struct intnl_stat stbuf; @@ -362,7 +360,6 @@ create_internal_namespace() */ mnt = NULL; rootino = NULL; - rootpb = NULL; fs = _sysio_fs_new(&yod_inodesys_ops, 0, NULL); if (!fs) { err = -ENOMEM; @@ -382,19 +379,10 @@ create_internal_namespace() } /* - * Generate base path-node for root. - */ - rootpb = _sysio_pb_new(&noname, NULL, rootino); - if (!rootpb) { - err = -ENOMEM; - goto error; - } - - /* * Mount it. This name space is disconnected from the * rest of the system -- Only available within this driver. */ - err = _sysio_do_mount(fs, rootpb, 0, NULL, &mnt); + err = _sysio_mounti(fs, rootino, 0, NULL, &mnt); if (err) goto error; @@ -405,11 +393,8 @@ error: if (_sysio_do_unmount(mnt) != 0) abort(); fs = NULL; - rootpb = NULL; rootino = NULL; } - if (rootpb) - _sysio_pb_gone(rootpb); if (fs) { FS_RELE(fs); } |
From: Lee W. <lw...@us...> - 2007-09-24 18:04:06
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8912 Modified Files: inode.c Log Message: The path base node disconnect routine was passing the wrong pointer to the tree deletion routine. Fixed this by abstracting the name cache manipulation everywhere and crafting the necessary routines. Added ncache_insert, ncache_delete, and ncache_lookup. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- inode.c 21 Sep 2007 20:12:55 -0000 1.30 +++ inode.c 24 Sep 2007 17:33:00 -0000 1.31 @@ -58,7 +58,7 @@ #include "inode.h" #include "dev.h" -/* #define I_STATS */ +#define I_STATS /* * Support for path and index nodes. @@ -83,6 +83,18 @@ static size_t n_inodes = 0; 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; @@ -411,6 +423,52 @@ compar_pb_key(const struct pnode_base_ke } /* + * Insert a path base node into the system name cache. + */ +static void +ncache_insert(struct pnode_base *pb) +{ + + if (_sysio_tree_search(&pb->pb_tentry, + &names[ncache_key_index(&pb->pb_key)], + (int (*)(const void *, + const void *))compar_pb_key) != + &pb->pb_tentry) + abort(); +} + +/* + * Delete path base node from the system name cache. + */ +static void +ncache_delete(struct pnode_base *pb) +{ + + if (_sysio_tree_delete(&pb->pb_key, + &names[ncache_key_index(&pb->pb_key)], + (int (*)(const void *, + const void *))compar_pb_key) != + &pb->pb_tentry) + abort(); +} + +/* + * Lookup path base node in the system name cache given key info. + */ +static struct pnode_base * +ncache_lookup(struct pnode_base_key *pbk) +{ + struct tree_node *tn; + + tn = + _sysio_tree_find(pbk, + &names[ncache_key_index(pbk)], + (int (*)(const void *, + const void *))compar_pb_key); + return tn ? TREE_ENTRY(tn, pnode_base, pb_tentry) : NULL; +} + +/* * Allocate and initialize a new base path node. */ struct pnode_base * @@ -446,13 +504,7 @@ _sysio_pb_new(struct qstr *name, struct (void )strncpy(cp, name->name, name->len); pb->pb_key.pbk_name.name = cp; pb->pb_key.pbk_name.hashval = name->hashval; - if (_sysio_tree_search(&pb->pb_tentry, - &names[pb->pb_key.pbk_name.hashval % - NAMES_TABLE_LEN], - (int (*)(const void *, - const void *))compar_pb_key) != - &pb->pb_tentry) - abort(); + ncache_insert(pb); } pb->pb_ino = ino; @@ -475,7 +527,6 @@ _sysio_pb_new(struct qstr *name, struct static void pb_destroy(struct pnode_base *pb) { - struct tree_node *tn; assert(n_names); n_names--; @@ -483,16 +534,8 @@ pb_destroy(struct pnode_base *pb) assert(!pb->pb_aliases.lh_first); assert(!pb->pb_children.lh_first); assert(!pb->pb_ino); - if (pb->pb_key.pbk_name.len) { - tn = - _sysio_tree_delete(&pb->pb_key, - &names[pb->pb_key.pbk_name.hashval % - NAMES_TABLE_LEN], - (int (*)(const void *, - const void *))compar_pb_key); - if (TREE_ENTRY(tn, pnode_base, pb_tentry) != pb) - abort(); - } + if (pb->pb_key.pbk_name.len) + ncache_delete(pb); if (pb->pb_key.pbk_parent) LIST_REMOVE(pb, pb_sibs); @@ -523,7 +566,6 @@ static void _sysio_pb_disconnect(struct pnode_base *pb) { struct pnode *pno; - struct tree_node *tn; /* * Disconnect all aliases associated with the referenced base node. @@ -536,16 +578,10 @@ _sysio_pb_disconnect(struct pnode_base * * Remove name from the names cache so that it can't * be found anymore. */ - if (pb->pb_key.pbk_name.len) { - tn = - _sysio_tree_delete(&pb->pb_tentry, - &names[pb->pb_key.pbk_name.hashval % - NAMES_TABLE_LEN], - (int (*)(const void *, - const void *))compar_pb_key); - if (TREE_ENTRY(tn, pnode_base, pb_tentry) != pb) + if (pb->pb_key.pbk_name.len) + ncache_delete(pb); + else abort(); - } pb->pb_key.pbk_name.len = 0; } @@ -557,6 +593,12 @@ void _sysio_i_shutdown() { +#ifdef I_STATS + _sysio_cprintf("inode: probe %lu, hit %lu\n", i_probes, i_hits); + _sysio_cprintf("pbnode: probe %lu, hit %lu\n", pb_probes, pb_hits); + _sysio_cprintf("pnode: reclaims %lu, examined %lu dismissed %lu\n", + p_reclaims, p_examined, p_dismissed); +#endif max_names = desired_names; return; @@ -649,7 +691,6 @@ _sysio_p_find_alias(struct pnode *parent { struct pnode_base *pb; struct pnode_base_key key; - struct tree_node *tn; int err; struct pnode *pno; @@ -669,19 +710,12 @@ _sysio_p_find_alias(struct pnode *parent #endif key.pbk_name = *name; key.pbk_parent = parent->p_base; - tn = - _sysio_tree_find(&key, - &names[key.pbk_name.hashval % - NAMES_TABLE_LEN], - (int (*)(const void *, - const void *))compar_pb_key); - if (tn) { - pb = TREE_ENTRY(tn, pnode_base, pb_tentry); + pb = ncache_lookup(&key); #ifdef I_STATS + if (pb) pb_hits++; #endif } - } if (!pb) { /* * None found, create new child. |
From: Lee W. <lw...@us...> - 2007-09-24 18:00:43
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19475 Modified Files: inode.c Log Message: Oops. Don't want I_STATS defined in the tree. That should only be enabled per site. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -w -b -B -p -r1.31 -r1.32 --- inode.c 24 Sep 2007 17:33:00 -0000 1.31 +++ inode.c 24 Sep 2007 18:00:39 -0000 1.32 @@ -58,7 +58,7 @@ #include "inode.h" #include "dev.h" -#define I_STATS +/* #define I_STATS */ /* * Support for path and index nodes. |
From: Lee W. <lw...@us...> - 2007-09-21 20:12:58
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv14759/src Modified Files: inode.c Log Message: - No longer maintain a list of all pnodes in the system. + Introduce a list of idle pnodes for use by the garbage collector. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -w -b -B -p -r1.29 -r1.30 --- inode.c 21 Sep 2007 19:41:37 -0000 1.29 +++ inode.c 21 Sep 2007 20:12:55 -0000 1.30 @@ -93,9 +93,9 @@ static size_t desired_names = (3 * NAMES static size_t max_names; /* - * List of all path-nodes (aliases) referenced by any tree. + * List of all path-nodes (aliases) that are not currently referenced. */ -struct pnodes_head _sysio_pnodes; +struct pnodes_head _sysio_idle_pnodes; /* * The system root -- Aka `/'. @@ -122,7 +122,7 @@ _sysio_i_init() for (i = 0; i < NAMES_TABLE_LEN; i++) names[i] = NULL; - TAILQ_INIT(&_sysio_pnodes); + TAILQ_INIT(&_sysio_idle_pnodes); max_names = desired_names; @@ -335,7 +335,7 @@ p_reclaim(unsigned count) #ifdef I_STATS p_reclaims++; #endif - next = _sysio_pnodes.tqh_first; + next = _sysio_idle_pnodes.tqh_first; if (!next) return; t = n_names / 2; @@ -344,9 +344,9 @@ p_reclaim(unsigned count) p_examined++; #endif pno = next; - next = pno->p_nodes.tqe_next; + next = pno->p_idle.tqe_next; if (pno->p_ref) - continue; + abort(); if (pno->p_mount->mnt_root == pno) { /* * We never reclaim mount points, here. @@ -586,7 +586,6 @@ _sysio_p_new_alias(struct pnode *parent, pno->p_mount = mnt; pno->p_cover = NULL; LIST_INSERT_HEAD(&pb->pb_aliases, pno, p_links); - TAILQ_INSERT_TAIL(&_sysio_pnodes, pno, p_nodes); return pno; } @@ -600,7 +599,7 @@ _sysio_p_gone(struct pnode *pno) assert(!pno->p_ref); assert(!pno->p_cover); - TAILQ_REMOVE(&_sysio_pnodes, pno, p_nodes); + TAILQ_REMOVE(&_sysio_idle_pnodes, pno, p_idle); LIST_REMOVE(pno, p_links); free(pno); |
From: Lee W. <lw...@us...> - 2007-09-21 20:12:58
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv14759/include Modified Files: inode.h Log Message: - No longer maintain a list of all pnodes in the system. + Introduce a list of idle pnodes for use by the garbage collector. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -w -b -B -p -r1.33 -r1.34 --- inode.h 21 Sep 2007 19:41:37 -0000 1.33 +++ inode.h 21 Sep 2007 20:12:55 -0000 1.34 @@ -259,7 +259,7 @@ struct pnode { struct mount *p_mount; /* mount info */ struct pnode *p_cover; /* covering pnode */ LIST_ENTRY(pnode) p_links; /* other aliases */ - TAILQ_ENTRY(pnode) p_nodes; /* all nodes links */ + TAILQ_ENTRY(pnode) p_idle; /* idle list links */ }; /* @@ -267,9 +267,8 @@ struct pnode { */ #define P_REF(pno) \ do { \ - TAILQ_REMOVE(&_sysio_pnodes, (pno), p_nodes); \ - TAILQ_INSERT_TAIL(&_sysio_pnodes, (pno), p_nodes); \ - (pno)->p_ref++; \ + if (!(pno)->p_ref++) \ + TAILQ_REMOVE(&_sysio_idle_pnodes, (pno), p_idle); \ assert((pno)->p_ref); \ } while (0) @@ -279,7 +278,8 @@ struct pnode { #define P_RELE(pno) \ do { \ assert((pno)->p_ref); \ - --(pno)->p_ref; \ + if (!--(pno)->p_ref) \ + TAILQ_INSERT_TAIL(&_sysio_idle_pnodes, (pno), p_idle); \ } while (0) /* @@ -487,7 +487,7 @@ struct ioctx { extern struct pnode *_sysio_root; extern TAILQ_HEAD(inodes_head, inode) _sysio_inodes; -extern TAILQ_HEAD(pnodes_head, pnode) _sysio_pnodes; +extern TAILQ_HEAD(pnodes_head, pnode) _sysio_idle_pnodes; extern int _sysio_i_init(void); #ifdef ZERO_SUM_MEMORY |
From: Lee W. <lw...@us...> - 2007-09-21 19:41:41
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv759/src Modified Files: chdir.c inode.c mount.c Log Message: The pnode base name cache is now maintained as a hashed table of trees, instead of lists. The pnode base record was re-organized. The qstr name record and parent were grouped under a pnodE_base_key sub-record and the new field named pb_key. As well, the LIST_ENTRY for pb_names was removed and a struct tree record added, reflecting the conversion to trees from lists in the hash table slots. + Fixed an issue in inode.c where the pnode base nodes were being reclaimed wholesale, instead of partially, on every call to the garbage collector. Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- chdir.c 2 Jul 2007 18:58:15 -0000 1.30 +++ chdir.c 21 Sep 2007 19:41:37 -0000 1.31 @@ -183,10 +183,10 @@ _sysio_p_path(struct pnode *pno, char ** * Add length of this component to running sum and * account for this vertex. */ - assert((len >= pno->p_base->pb_name.len && - (size_t )~0 - pno->p_base->pb_name.len > len) || - (size_t )~0 - len > pno->p_base->pb_name.len); - len += pno->p_base->pb_name.len; + assert((len >= pno->p_base->pb_key.pbk_name.len && + (size_t )~0 - pno->p_base->pb_key.pbk_name.len > len) || + (size_t )~0 - len > pno->p_base->pb_key.pbk_name.len); + len += pno->p_base->pb_key.pbk_name.len; n++; assert(n); pno = pno->p_parent; @@ -226,9 +226,9 @@ _sysio_p_path(struct pnode *pno, char ** /* * Add component and separator. */ - cp -= pno->p_base->pb_name.len; - (void )memcpy(cp, pno->p_base->pb_name.name, - pno->p_base->pb_name.len); + cp -= pno->p_base->pb_key.pbk_name.len; + (void )memcpy(cp, pno->p_base->pb_key.pbk_name.name, + pno->p_base->pb_key.pbk_name.len); *--cp = PATH_SEPARATOR; pno = pno->p_parent; Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -w -b -B -p -r1.28 -r1.29 --- inode.c 28 Aug 2007 17:41:56 -0000 1.28 +++ inode.c 21 Sep 2007 19:41:37 -0000 1.29 @@ -41,6 +41,9 @@ * le...@sa... */ +#include <stdio.h> + +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <errno.h> @@ -55,6 +58,8 @@ #include "inode.h" #include "dev.h" +/* #define I_STATS */ + /* * Support for path and index nodes. */ @@ -67,25 +72,16 @@ #endif /* - * Desired i-nodes cache size is MAX_INODES_MULTIPLIER times the number - * of slots in the names hash table. - */ -#define MAX_INODES_MULTIPLIER 3 - -/* * Active i-nodes in the system and the number of same. */ struct inodes_head _sysio_inodes; static size_t n_inodes = 0; -/* - * Desired number of active i-nodes. - */ -static size_t max_inodes = (MAX_INODES_MULTIPLIER * NAMES_TABLE_LEN); /* * System table for rapid access to component names. */ -static LIST_HEAD(, pnode_base) names[NAMES_TABLE_LEN]; +static struct tree_node *names[NAMES_TABLE_LEN]; + /* * Number of names tracked by the system. */ @@ -93,7 +89,8 @@ static size_t n_names = 0; /* * Desired number of base path nodes to maintain. */ -static size_t max_names = (2 * NAMES_TABLE_LEN); +static size_t desired_names = (3 * NAMES_TABLE_LEN); +static size_t max_names; /* * List of all path-nodes (aliases) referenced by any tree. @@ -105,6 +102,12 @@ struct pnodes_head _sysio_pnodes; */ struct pnode *_sysio_root = NULL; +#ifdef I_STATS +static unsigned long i_probes, i_hits; +static unsigned long pb_probes, pb_hits; +static unsigned long p_reclaims, p_examined, p_dismissed; +#endif + /* * Initialize path and i-node support. Must be called before any other * routine in this module. @@ -117,16 +120,23 @@ _sysio_i_init() TAILQ_INIT(&_sysio_inodes); for (i = 0; i < NAMES_TABLE_LEN; i++) - LIST_INIT(&names[i]); + names[i] = NULL; TAILQ_INIT(&_sysio_pnodes); + max_names = desired_names; + +#ifdef I_STATS + i_probes = i_hits = 0; + pb_probes = pb_hits = 0; + p_reclaims = p_examined = p_dismissed = 0; +#endif + return 0; } /* - * Garbage-collect idle i-nodes. We try to keep resource use limited to - * MAX_INODES_MULTIPLIER * max_names. + * Garbage-collect idle i-nodes. */ static void i_reclaim() @@ -134,35 +144,17 @@ i_reclaim() struct inode *next, *ino; size_t t; - /* - * I just can't figure out a good way to reclaim these well without - * getting really fancy and using complex algorithms. The - * base nodes hold references on them for a long time and then - * release them. Those will age to the front of the queue and - * we have to skip over them. Oh well... - */ - t = MAX_INODES_MULTIPLIER * max_names; - if (max_inodes < t) { - /* - * Oops. Nope. We want more inodes than names entries. - */ - max_inodes = t; - return; - } + t = n_inodes / 2; next = _sysio_inodes.tqh_first; - if (!next) - return; - t = max_inodes / 2; - do { + while (next) { ino = next; next = ino->i_nodes.tqe_next; if (ino->i_ref || ino->i_immune) continue; _sysio_i_gone(ino); - } while (next && n_inodes > t); - - if (n_inodes > t) - max_inodes += t; + if (n_inodes < t) + break; + } } static unsigned @@ -200,9 +192,11 @@ _sysio_i_new(struct filesys *fs, struct itable_entry *head; struct inode_ops operations; - if (n_inodes > max_inodes) { + if (n_inodes > n_names) { /* - * Try to limit growth. + * This has become pretty badly skewed relative to + * the number of active nodes in the system. Try to + * correct that, now. */ i_reclaim(); } @@ -264,9 +258,15 @@ _sysio_i_find(struct filesys *fs, struct fid->fid_data, fid->fid_len) == 0) { I_REF(ino); +#ifdef I_STATS + i_hits++; +#endif break; } +#ifdef I_STATS + i_probes++; +#endif return ino; } @@ -303,31 +303,111 @@ _sysio_i_undead(struct inode *ino) } /* + * Destroy path node and, if path base node is no longer referenced that + * node as well. + */ +static void +_sysio_p_kill(struct pnode *pno) +{ + struct pnode_base *pb; + + pb = pno->p_base; + _sysio_p_gone(pno); + if (!(pb->pb_aliases.lh_first || pb->pb_children.lh_first)) + _sysio_pb_gone(pb); +} + +/* * Garbage collect idle path (and base path) nodes tracked by the system. */ static void -p_reclaim() +p_reclaim(unsigned count) { + int adjust; struct pnode *next, *pno; size_t t; + struct pnode_base *nxtpb, *pb; + + adjust = 0; + if (count) + adjust = 1; +#ifdef I_STATS + p_reclaims++; +#endif next = _sysio_pnodes.tqh_first; if (!next) return; - t = max_names / 2; + t = n_names / 2; do { +#ifdef I_STATS + p_examined++; +#endif pno = next; next = pno->p_nodes.tqe_next; if (pno->p_ref) continue; - next->p_ref++; - assert(next->p_ref); - (void )_sysio_p_prune(pno); - next->p_ref--; - } while (n_names > t && next); + if (pno->p_mount->mnt_root == pno) { + /* + * We never reclaim mount points, here. + */ + continue; + } + nxtpb = pno->p_base; +#ifdef I_STATS + p_dismissed++; +#endif + _sysio_p_gone(pno); + /* + * Have to run up the tree, too. We might + * have removed the last child from the parent + * as well. + */ + while ((pb = nxtpb)) { + nxtpb = NULL; + if (!(pb->pb_aliases.lh_first || + pb->pb_children.lh_first)) { + nxtpb = pb->pb_key.pbk_parent; + _sysio_pb_gone(pb); + } + } + } while ((!count || --count) && n_names > t && next); + + if (!adjust) + return; if (n_names > t) max_names += t; + else { + max_names = t; + if (max_names < desired_names) + max_names = desired_names; + } +} + +static int +compar_pb_key(const struct pnode_base_key *pbk1, + const struct pnode_base_key *pbk2) +{ + + if (pbk1->pbk_parent < pbk2->pbk_parent) + return -1; + if (pbk1->pbk_parent > pbk2->pbk_parent) + return 1; + + if (pbk1->pbk_name.len < pbk2->pbk_name.len) + return -1; + if (pbk1->pbk_name.len > pbk2->pbk_name.len) + return 1; + + if (pbk1->pbk_name.hashval < pbk2->pbk_name.hashval) + return -1; + if (pbk1->pbk_name.hashval > pbk2->pbk_name.hashval) + return 1; + + return strncmp(pbk1->pbk_name.name, + pbk2->pbk_name.name, + pbk1->pbk_name.len); } /* @@ -342,18 +422,20 @@ _sysio_pb_new(struct qstr *name, struct /* * Try to limit growth. */ - p_reclaim(); + p_reclaim(0); } pb = malloc(sizeof(struct pnode_base) + name->len); if (!pb) return NULL; - pb->pb_name.name = NULL; - pb->pb_name.len = name->len; - if (pb->pb_name.len) { + pb->pb_key.pbk_name = *name; + pb->pb_key.pbk_parent = parent; + if (pb->pb_key.pbk_name.len) { char *cp; + pb->pb_tentry.tn_key = &pb->pb_key; + pb->pb_tentry.tn_left = pb->pb_tentry.tn_right = NULL; /* * Copy the passed name. * @@ -362,11 +444,15 @@ _sysio_pb_new(struct qstr *name, struct */ cp = (char *)pb + sizeof(struct pnode_base); (void )strncpy(cp, name->name, name->len); - pb->pb_name.name = cp; - pb->pb_name.hashval = name->hashval; - LIST_INSERT_HEAD(&names[name->hashval % NAMES_TABLE_LEN], - pb, - pb_names); + pb->pb_key.pbk_name.name = cp; + pb->pb_key.pbk_name.hashval = name->hashval; + if (_sysio_tree_search(&pb->pb_tentry, + &names[pb->pb_key.pbk_name.hashval % + NAMES_TABLE_LEN], + (int (*)(const void *, + const void *))compar_pb_key) != + &pb->pb_tentry) + abort(); } pb->pb_ino = ino; @@ -374,7 +460,6 @@ _sysio_pb_new(struct qstr *name, struct LIST_INIT(&pb->pb_aliases); if (parent) LIST_INSERT_HEAD(&parent->pb_children, pb, pb_sibs); - pb->pb_parent = parent; n_names++; assert(n_names); @@ -390,6 +475,7 @@ _sysio_pb_new(struct qstr *name, struct static void pb_destroy(struct pnode_base *pb) { + struct tree_node *tn; assert(n_names); n_names--; @@ -397,9 +483,17 @@ pb_destroy(struct pnode_base *pb) assert(!pb->pb_aliases.lh_first); assert(!pb->pb_children.lh_first); assert(!pb->pb_ino); - if (pb->pb_name.len) - LIST_REMOVE(pb, pb_names); - if (pb->pb_parent) + if (pb->pb_key.pbk_name.len) { + tn = + _sysio_tree_delete(&pb->pb_key, + &names[pb->pb_key.pbk_name.hashval % + NAMES_TABLE_LEN], + (int (*)(const void *, + const void *))compar_pb_key); + if (TREE_ENTRY(tn, pnode_base, pb_tentry) != pb) + abort(); + } + if (pb->pb_key.pbk_parent) LIST_REMOVE(pb, pb_sibs); free(pb); @@ -412,8 +506,11 @@ void _sysio_pb_gone(struct pnode_base *pb) { - if (pb->pb_ino) + if (pb->pb_ino) { I_RELE(pb->pb_ino); + if (!pb->pb_ino->i_ref) + _sysio_i_gone(pb->pb_ino); + } pb->pb_ino = NULL; pb_destroy(pb); @@ -426,6 +523,7 @@ static void _sysio_pb_disconnect(struct pnode_base *pb) { struct pnode *pno; + struct tree_node *tn; /* * Disconnect all aliases associated with the referenced base node. @@ -438,9 +536,17 @@ _sysio_pb_disconnect(struct pnode_base * * Remove name from the names cache so that it can't * be found anymore. */ - if (pb->pb_name.len) - LIST_REMOVE(pb, pb_names); - pb->pb_name.len = 0; + if (pb->pb_key.pbk_name.len) { + tn = + _sysio_tree_delete(&pb->pb_tentry, + &names[pb->pb_key.pbk_name.hashval % + NAMES_TABLE_LEN], + (int (*)(const void *, + const void *))compar_pb_key); + if (TREE_ENTRY(tn, pnode_base, pb_tentry) != pb) + abort(); + } + pb->pb_key.pbk_name.len = 0; } #ifdef ZERO_SUM_MEMORY @@ -451,6 +557,8 @@ void _sysio_i_shutdown() { + max_names = desired_names; + return; } #endif @@ -541,6 +649,8 @@ _sysio_p_find_alias(struct pnode *parent struct pnode **pnop) { struct pnode_base *pb; + struct pnode_base_key key; + struct tree_node *tn; int err; struct pnode *pno; @@ -555,15 +665,22 @@ _sysio_p_find_alias(struct pnode *parent /* * Try the names table. */ - pb = names[name->hashval % NAMES_TABLE_LEN].lh_first; - while (pb) { - if (pb->pb_parent == parent->p_base && - pb->pb_name.len == name->len && - strncmp(pb->pb_name.name, - name->name, - name->len) == 0) - break; - pb = pb->pb_names.le_next; +#ifdef I_STATS + pb_probes++; +#endif + key.pbk_name = *name; + key.pbk_parent = parent->p_base; + tn = + _sysio_tree_find(&key, + &names[key.pbk_name.hashval % + NAMES_TABLE_LEN], + (int (*)(const void *, + const void *))compar_pb_key); + if (tn) { + pb = TREE_ENTRY(tn, pnode_base, pb_tentry); +#ifdef I_STATS + pb_hits++; +#endif } } if (!pb) { @@ -683,7 +800,7 @@ _sysio_p_prune(struct pnode *root) #else /* * This is an automount-point. Must - * unmount before relcaim. + * unmount before reclaim. */ P_REF(pno); if (_sysio_do_unmount(pno->p_mount) != 0) { @@ -693,10 +810,7 @@ _sysio_p_prune(struct pnode *root) continue; #endif } - _sysio_p_gone(pno); - if (!(pb->pb_aliases.lh_first || - pb->pb_children.lh_first)) - _sysio_pb_gone(pb); + _sysio_p_kill(pno); } } @@ -728,13 +842,8 @@ _sysio_p_prune(struct pnode *root) count++; } #endif - } else { - pb = root->p_base; - _sysio_p_gone(root); - if (!(pb->pb_aliases.lh_first || - pb->pb_children.lh_first)) - _sysio_pb_gone(pb); - } + } else + _sysio_p_kill(root); return count; } @@ -761,13 +870,13 @@ _sysio_pb_pathof(struct pnode_base *pb, len = 0; tmp = pb; do { - n = tmp->pb_name.len; - len += tmp->pb_name.len; + n = tmp->pb_key.pbk_name.len; + len += tmp->pb_key.pbk_name.len; if (n) len++; - tmp = tmp->pb_parent; + tmp = tmp->pb_key.pbk_parent; } while (tmp); - if (tmp && !tmp->pb_name.len) + if (tmp && !tmp->pb_key.pbk_name.len) return -ENOENT; if (!len) len++; @@ -787,13 +896,13 @@ _sysio_pb_pathof(struct pnode_base *pb, *cp = '\0'; /* NUL term */ tmp = pb; do { - cp -= tmp->pb_name.len; - n = tmp->pb_name.len; + cp -= tmp->pb_key.pbk_name.len; + n = tmp->pb_key.pbk_name.len; if (n) { - (void )strncpy(cp, tmp->pb_name.name, n); + (void )strncpy(cp, tmp->pb_key.pbk_name.name, n); *--cp = separator; } - tmp = tmp->pb_parent; + tmp = tmp->pb_key.pbk_parent; } while (tmp); *pathp = buf; @@ -931,7 +1040,7 @@ _sysio_p_rename(struct pnode *old, struc nxtpb = new->p_base; do { pb = nxtpb; - nxtpb = pb->pb_parent; + nxtpb = pb->pb_key.pbk_parent; if (pb == old->p_base) return -EINVAL; } while (nxtpb); Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -b -B -p -r1.24 -r1.25 --- mount.c 2 Jul 2007 18:58:17 -0000 1.24 +++ mount.c 21 Sep 2007 19:41:37 -0000 1.25 @@ -131,7 +131,7 @@ _sysio_do_mount(struct filesys *fs, for (pb = rootpb; pb && pb != tocover->p_base; - pb = pb->pb_parent) + pb = pb->pb_key.pbk_parent) ; if (pb == tocover->p_base) return -EBUSY; |
From: Lee W. <lw...@us...> - 2007-09-21 19:41:40
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv759/drivers/incore Modified Files: fs_incore.c Log Message: The pnode base name cache is now maintained as a hashed table of trees, instead of lists. The pnode base record was re-organized. The qstr name record and parent were grouped under a pnodE_base_key sub-record and the new field named pb_key. As well, the LIST_ENTRY for pb_names was removed and a struct tree record added, reflecting the conversion to trees from lists in the hash table slots. + Fixed an issue in inode.c where the pnode base nodes were being reclaimed wholesale, instead of partially, on every call to the garbage collector. Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -w -b -B -p -r1.33 -r1.34 --- fs_incore.c 2 Jul 2007 18:58:15 -0000 1.33 +++ fs_incore.c 21 Sep 2007 19:41:37 -0000 1.34 @@ -835,7 +835,7 @@ _sysio_incore_dirop_lookup(struct pnode icino = I2IC(ino); INCORE_LD_INIT(&lookup_data, ULONG_MAX, - &pno->p_base->pb_name); + &pno->p_base->pb_key.pbk_name); de = incore_directory_probe(icino->ici_data, icino->ici_st.st_size, @@ -1228,7 +1228,7 @@ _sysio_incore_dirop_mkdir(struct pnode * */ err = incore_directory_insert(parent, - &pno->p_base->pb_name, + &pno->p_base->pb_key.pbk_name, stat.st_ino, INCORE_D_TYPEOF(S_IFDIR)); @@ -1299,11 +1299,11 @@ _sysio_incore_dirop_rmdir(struct pnode * struct incore_inode *icino = I2IC(ino); int err; - if (!pno->p_base->pb_name.len || - (pno->p_base->pb_name.name[0] == '.' && - (pno->p_base->pb_name.len == 1 || - (pno->p_base->pb_name.len == 2 && - pno->p_base->pb_name.name[1] == '.')))) + if (!pno->p_base->pb_key.pbk_name.len || + (pno->p_base->pb_key.pbk_name.name[0] == '.' && + (pno->p_base->pb_key.pbk_name.len == 1 || + (pno->p_base->pb_key.pbk_name.len == 2 && + pno->p_base->pb_key.pbk_name.name[1] == '.')))) return -EINVAL; if (!S_ISDIR(icino->ici_st.st_mode)) @@ -1315,7 +1315,7 @@ _sysio_incore_dirop_rmdir(struct pnode * pno->p_base->pb_ino = NULL; err = incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), - &pno->p_base->pb_name); + &pno->p_base->pb_key.pbk_name); return err; } @@ -1355,7 +1355,7 @@ incore_create(struct pnode *pno, struct */ err = incore_directory_insert(I2IC(dino), - &pno->p_base->pb_name, + &pno->p_base->pb_key.pbk_name, stat->st_ino, INCORE_D_TYPEOF(icino->ici_st.st_mode)); if (err) { @@ -1429,7 +1429,7 @@ _sysio_incore_dirop_link(struct pnode *o */ err = incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name, + &new->p_base->pb_key.pbk_name, icino->ici_st.st_ino, INCORE_D_TYPEOF(icino->ici_st.st_mode)); if (err) @@ -1457,7 +1457,7 @@ _sysio_incore_dirop_rename(struct pnode return -ENOTEMPTY; err = incore_unlink_entry(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name); + &new->p_base->pb_key.pbk_name); if (err) return err; } @@ -1467,7 +1467,7 @@ _sysio_incore_dirop_rename(struct pnode */ err = incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), - &new->p_base->pb_name, + &new->p_base->pb_key.pbk_name, icino->ici_st.st_ino, INCORE_D_TYPEOF(icino->ici_st.st_mode)); if (err) @@ -1477,7 +1477,7 @@ _sysio_incore_dirop_rename(struct pnode */ err = incore_unlink_entry(I2IC(old->p_parent->p_base->pb_ino), - &old->p_base->pb_name); + &old->p_base->pb_key.pbk_name); if (err) abort(); @@ -1507,7 +1507,7 @@ _sysio_incore_dirop_unlink(struct pnode err = incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), - &pno->p_base->pb_name); + &pno->p_base->pb_key.pbk_name); return err; } |
From: Lee W. <lw...@us...> - 2007-09-21 19:41:40
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv759/include Modified Files: inode.h Log Message: The pnode base name cache is now maintained as a hashed table of trees, instead of lists. The pnode base record was re-organized. The qstr name record and parent were grouped under a pnodE_base_key sub-record and the new field named pb_key. As well, the LIST_ENTRY for pb_names was removed and a struct tree record added, reflecting the conversion to trees from lists in the hash table slots. + Fixed an issue in inode.c where the pnode base nodes were being reclaimed wholesale, instead of partially, on every call to the garbage collector. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -w -b -B -p -r1.32 -r1.33 --- inode.h 14 May 2007 15:47:30 -0000 1.32 +++ inode.h 21 Sep 2007 19:41:37 -0000 1.33 @@ -41,6 +41,8 @@ * le...@sa... */ +#include "tree.h" + #if defined(AUTOMOUNT_FILE_NAME) && !defined(MAX_MOUNT_DEPTH) /* * Maximum number of automounts to attempt in path traversal. @@ -205,13 +207,15 @@ struct qstr { * common information. */ struct pnode_base { - struct qstr pb_name; /* entry name */ + struct tree_node pb_tentry; /* cache node entry */ + struct pnode_base_key { + struct qstr pbk_name; /* entry name */ + struct pnode_base *pbk_parent; /* parent */ + } pb_key; struct inode *pb_ino; /* inode */ LIST_HEAD(, pnode_base) pb_children; /* children if a dir */ LIST_ENTRY(pnode_base) pb_sibs; /* links to siblings */ - LIST_ENTRY(pnode_base) pb_names; /* near names links */ LIST_HEAD(, pnode) pb_aliases; /* aliases */ - struct pnode_base *pb_parent; /* parent */ }; /* |
From: Lee W. <lw...@us...> - 2007-09-21 19:37:03
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv355/include Modified Files: sysio-cmn.h Log Message: Oops. Need to add changes supporting CONTAINER macro for the new tree abstraction support. Index: sysio-cmn.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio-cmn.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -b -B -p -r1.18 -r1.19 --- sysio-cmn.h 20 Aug 2007 19:12:08 -0000 1.18 +++ sysio-cmn.h 21 Sep 2007 19:36:59 -0000 1.19 @@ -83,6 +83,18 @@ struct intnl_xtvec; struct iovec; /* + * Return offset to given member of given structure or union. + */ +#define OFFSETOF(type, _mbr) \ + ((size_t )&((struct type *)0)->_mbr) + +/* + * Return ptr to record containing the passed member. + */ +#define CONTAINER(type, _mbr, ptr) \ + (struct type *)((ptrdiff_t )(ptr) - OFFSETOF(type, _mbr)) + +/* * Symbol composition. */ #define _PREPEND_HELPER(p, x) \ |
From: Lee W. <lw...@us...> - 2007-09-21 19:36:02
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv32383/include Modified Files: module.mk Added Files: tree.h Log Message: Add support for in-memory binary tree abstraction, supporting the core. --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2007 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #ifndef _TREE_H #define _TREE_H struct tree_node { void *tn_key; struct tree_node *tn_left; struct tree_node *tn_right; }; /* * Return containing record given ptr to tree node. */ #define TREE_ENTRY(tn, type, mbr) \ CONTAINER(type, mbr, tn) extern struct tree_node *_sysio_tree_search(struct tree_node *tn, struct tree_node **rootp, int (*compar)(const void *, const void *)); extern struct tree_node *_sysio_tree_find(const void *key, struct tree_node **rootp, int (*compar)(const void *, const void *)); extern struct tree_node *_sysio_tree_delete(const void *key, struct tree_node **rootp, int (*compar)(const void *, const void *)); #endif /* !defined(_TREE_H) */ Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/module.mk,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- module.mk 1 May 2007 17:28:42 -0000 1.7 +++ module.mk 21 Sep 2007 19:35:53 -0000 1.8 @@ -2,4 +2,4 @@ INCLUDE_EXTRA = include/dev.h include/fi include/inode.h include/mount.h include/sysio.h \ include/sysio-cmn.h include/sysio-symbols.h include/cplant-yod.h \ include/module.mk include/xtio.h include/stddir.h \ - include/native.h + include/native.h include/tree.h |
From: Lee W. <lw...@us...> - 2007-09-21 19:36:00
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv32383/src Modified Files: module.mk Added Files: tree.c Log Message: Add support for in-memory binary tree abstraction, supporting the core. --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2007 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdlib.h> #include "tree.h" /* * Splay to node with given key. * * Returns the value from the last compare; The one that brought, or left, * the root node at return. */ static int splay(const void *key, struct tree_node **rootp, int (*compar)(const void *, const void *)) { struct tree_node spare, *l, *r, *tmp, *root; int i; spare.tn_left = spare.tn_right = NULL; l = r = &spare; root = *rootp; for (;;) { i = (*compar)(key, root->tn_key); if (i < 0) { if (root->tn_left && (*compar)(key, root->tn_left->tn_key) < 0) { tmp = root->tn_left; root->tn_left = tmp->tn_right; tmp->tn_right = root; root = tmp; } if (!root->tn_left) break; r->tn_left = root; r = root; root = root->tn_left; } else if (i > 0) { if (root->tn_right && (*compar)(key, root->tn_right->tn_key) > 0) { tmp = root->tn_right; root->tn_right = tmp->tn_left; tmp->tn_left = root; root = tmp; } if (!root->tn_right) break; l->tn_right = root; l = root; root = root->tn_right; } else break; } /* * Re-link. */ l->tn_right = root->tn_left; r->tn_left = root->tn_right; root->tn_left = spare.tn_right; root->tn_right = spare.tn_left; *rootp = root; return i; } /* * Return tree node with matching key or replace with passed node. */ struct tree_node * _sysio_tree_search(struct tree_node *tn, struct tree_node **rootp, int (*compar)(const void *, const void *)) { int i; if (!*rootp) { tn->tn_left = tn->tn_right = NULL; } else { i = splay(tn->tn_key, rootp, compar); if (i < 0) { tn->tn_left = (*rootp)->tn_left; tn->tn_right = *rootp; (*rootp)->tn_left = NULL; } else if (i > 0) { tn->tn_right = (*rootp)->tn_right; tn->tn_left = *rootp; (*rootp)->tn_right = NULL; } else return *rootp; } *rootp = tn; return *rootp; } /* * Find node with given key. Return NULL if not found. */ struct tree_node * _sysio_tree_find(const void *key, struct tree_node **rootp, int (*compar)(const void *, const void *)) { if (!*rootp) return NULL; return splay(key, rootp, compar) == 0 ? *rootp : NULL; } /* * Remove node with given key. Returns the node removed or NULL if not found. */ struct tree_node * _sysio_tree_delete(const void *key, struct tree_node **rootp, int (*compar)(const void *, const void *)) { struct tree_node *tn; tn = _sysio_tree_find(key, rootp, compar); if (!tn) return NULL; /* * Invariant; The desired node is at the root. */ if (!(*rootp)->tn_left) *rootp = (*rootp)->tn_right; else { splay((*rootp)->tn_key, &(*rootp)->tn_left, compar); (*rootp)->tn_left->tn_right = (*rootp)->tn_right; *rootp = (*rootp)->tn_left; } return tn; } Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -b -B -p -r1.15 -r1.16 --- module.mk 20 Aug 2007 19:12:08 -0000 1.15 +++ module.mk 21 Sep 2007 19:35:53 -0000 1.16 @@ -35,6 +35,6 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/symlink.c src/readlink.c \ src/truncate.c src/unlink.c src/utime.c \ $(FILE_SUPPORT) $(LUSTRE_SRCDIR_SRCS) \ - $(TRACING_SRCS) src/cprintf.c + $(TRACING_SRCS) src/cprintf.c src/tree.c SRCDIR_EXTRA = src/module.mk |
From: Ruth K. <rk...@us...> - 2007-09-19 16:01:39
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3762/src Modified Files: chmod.c chown.c lseek.c open.c rw.c stat.c statvfs.c Log Message: fix some formats for tracing, add stat buf to return macro Index: chmod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- chmod.c 2 Jul 2007 18:58:16 -0000 1.16 +++ chmod.c 19 Sep 2007 16:01:33 -0000 1.17 @@ -75,7 +75,7 @@ SYSIO_INTERFACE_NAME(chmod)(const char * struct pnode *pno; SYSIO_INTERFACE_DISPLAY_BLOCK; - SYSIO_INTERFACE_ENTER(chmod, "%s%mY", path, mode); + SYSIO_INTERFACE_ENTER(chmod, "%s%mZ", path, mode); err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) goto out; Index: chown.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -b -B -p -r1.15 -r1.16 --- chown.c 2 Jul 2007 18:58:16 -0000 1.15 +++ chown.c 19 Sep 2007 16:01:33 -0000 1.16 @@ -82,7 +82,7 @@ SYSIO_INTERFACE_NAME(chown)(const char * struct pnode *pno; SYSIO_INTERFACE_DISPLAY_BLOCK; - SYSIO_INTERFACE_ENTER(chown, "%s%uY%gY", path, owner, group); + SYSIO_INTERFACE_ENTER(chown, "%s%u%u", path, owner, group); err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) goto out; @@ -106,7 +106,7 @@ SYSIO_INTERFACE_NAME(fchown)(int fd, uid struct file *fil; SYSIO_INTERFACE_DISPLAY_BLOCK; - SYSIO_INTERFACE_ENTER(fchown, "%d%uY%gY", fd, owner, group); + SYSIO_INTERFACE_ENTER(fchown, "%d%u%u", fd, owner, group); err = 0; fil = _sysio_fd_find(fd); if (!fil) { Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- lseek.c 2 Jul 2007 18:58:16 -0000 1.30 +++ lseek.c 19 Sep 2007 16:01:33 -0000 1.31 @@ -128,16 +128,16 @@ SYSIO_INTERFACE_NAME(lseek64)(int fd, of off64_t off; SYSIO_INTERFACE_DISPLAY_BLOCK; - SYSIO_INTERFACE_ENTER(lseek64, "%d%loY%d", fd, offset, whence); + SYSIO_INTERFACE_ENTER(lseek64, "%d%loZ%d", fd, offset, whence); fil = _sysio_fd_find(fd); if (!fil) SYSIO_INTERFACE_RETURN((off64_t )-1, -EBADF, - lseek64, "%loY", 0); + lseek64, "%loZ", 0); off = _sysio_lseek(fil, offset, whence, _SEEK_MAX(fil)); SYSIO_INTERFACE_RETURN(off < 0 ? (off64_t )-1 : off, off < 0 ? (int )off : 0, - lseek64, "%loY", 0); + lseek64, "%loZ", 0); } #ifdef __GLIBC__ @@ -162,16 +162,16 @@ SYSIO_INTERFACE_NAME(lseek)(int fd, off_ off_t rtn; SYSIO_INTERFACE_DISPLAY_BLOCK; - SYSIO_INTERFACE_ENTER(lseek, "%d%oY%d", fd, offset, whence); + SYSIO_INTERFACE_ENTER(lseek, "%d%oZ%d", fd, offset, whence); fil = _sysio_fd_find(fd); if (!fil) - SYSIO_INTERFACE_RETURN((off_t )-1, -EBADF, lseek, "%oY", 0); + SYSIO_INTERFACE_RETURN((off_t )-1, -EBADF, lseek, "%oZ", 0); off = _sysio_lseek(fil, offset, whence, LONG_MAX); if (off < 0) - SYSIO_INTERFACE_RETURN((off_t )-1, (int )off, lseek, "%oY", 0); + SYSIO_INTERFACE_RETURN((off_t )-1, (int )off, lseek, "%oZ", 0); rtn = (off_t )off; assert(rtn == off); - SYSIO_INTERFACE_RETURN(rtn, 0, lseek, "%oY", 0); + SYSIO_INTERFACE_RETURN(rtn, 0, lseek, "%oZ", 0); } #ifdef __GLIBC__ Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- open.c 2 Jul 2007 18:58:17 -0000 1.30 +++ open.c 19 Sep 2007 16:01:33 -0000 1.31 @@ -161,7 +161,7 @@ SYSIO_INTERFACE_NAME(open)(const char *p if (flags & O_NOFOLLOW) ndflags |= ND_NOFOLLOW; #endif - SYSIO_INTERFACE_ENTER(open, "%s%d%mY", path, flags, mode); + SYSIO_INTERFACE_ENTER(open, "%s%d%mZ", path, flags, mode); /* * Find the file. Index: rw.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rw.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -w -b -B -p -r1.22 -r1.23 --- rw.c 2 Jul 2007 18:58:17 -0000 1.22 +++ rw.c 19 Sep 2007 16:01:33 -0000 1.23 @@ -307,7 +307,7 @@ _do_ireadx(int fd, SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER(ireadx, - "%d%*iY%*xZ", + "%d%*iZ%*xY", fd, iov_count, iov, xtv_count, xtv); @@ -357,7 +357,7 @@ _do_iwritex(int fd, SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER(iwritex, - "%d%*iY%*xZ", + "%d%*iZ%*xY", fd, iov_count, iov, xtv_count, xtv); @@ -877,9 +877,9 @@ _do_iiov(direction dir, SYSIO_INTERFACE_DISPLAY_BLOCK; if (dir == READ) - SYSIO_INTERFACE_ENTER(ireadv, "%d%*iY", fd, count, iov); + SYSIO_INTERFACE_ENTER(ireadv, "%d%*iZ", fd, count, iov); else - SYSIO_INTERFACE_ENTER(iwritev, "%d%*iY", fd, count, iov); + SYSIO_INTERFACE_ENTER(iwritev, "%d%*iZ", fd, count, iov); xtv = NULL; err = 0; do { Index: stat.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -b -B -p -r1.20 -r1.21 --- stat.c 2 Jul 2007 18:58:17 -0000 1.20 +++ stat.c 19 Sep 2007 16:01:33 -0000 1.21 @@ -84,10 +84,7 @@ _sysio_fxstat(int ver, int fildes, struc */ err = PNOP_GETATTR(fil->f_pno, stat_buf); out: - /* - * Note: Pass the stat buffer to the tracing routines some day. - */ - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fxstat, "%d", 0); + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fxstat, "%d%sY", stat_buf); } static int @@ -121,10 +118,7 @@ _sysio_xstatnd(int ver, sizeof(struct intnl_stat)); P_RELE(pno); out: - /* - * Note: Pass the stat buffer to the tracing routines some day. - */ - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, xstatnd, "%d", 0); + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, xstatnd, "%d%sY", stat_buf); } #ifdef _LARGEFILE64_SOURCE Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -w -b -B -p -r1.17 -r1.18 --- statvfs.c 2 Jul 2007 18:58:17 -0000 1.17 +++ statvfs.c 19 Sep 2007 16:01:33 -0000 1.18 @@ -96,10 +96,7 @@ SYSIO_INTERFACE_NAME(statvfs64)(const ch SYSIO_INTERFACE_ENTER(statvfs64, "%s", path); err = _sysio_statvfs(path, buf); - /* - * Note: Pass the statvfs buffer to the tracing routines some day. - */ - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, statvfs64, "%d", 0); + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, statvfs64, "%d%sY", buf); } #ifdef REDSTORM @@ -116,10 +113,7 @@ SYSIO_INTERFACE_NAME(fstatvfs64)(int fd, SYSIO_INTERFACE_ENTER(fstatvfs64, "%d", fd); err = _sysio_fstatvfs(fd, buf); - /* - * Note: Pass the statvfs buffer to the tracing routines some day. - */ - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fstatvfs64, "%d", 0); + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fstatvfs64, "%d%sY", buf); } #ifdef REDSTORM @@ -169,10 +163,7 @@ SYSIO_INTERFACE_NAME(statvfs)(const char convstatvfs(buf, _call_buf); #undef _call_buf #endif /* defined(_LARGEFILE64_SOURCE) */ - /* - * Note: Pass the statvfs buffer to the tracing routines some day. - */ - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, statvfs, "%d", 0); + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, statvfs, "%d%sY", buf); } #ifdef REDSTORM @@ -200,10 +191,7 @@ SYSIO_INTERFACE_NAME(fstatvfs)(int fd, s convstatvfs(buf, _call_buf); #undef _call_buf #endif - /* - * Note: Pass the statvfs buffer to the tracing routines some day. - */ - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fstatvfs, "%d", 0); + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fstatvfs, "%d%sY", buf); } #ifdef REDSTORM |
From: Lee W. <lw...@us...> - 2007-08-28 17:42:00
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25553/src Modified Files: inode.c Log Message: Removed the free inodes and pnodes cache and allocators. Replaced with simple malloc/free. Performance tests showed that malloc/free was very nearly as fast; Less than 1% slower. Might as well keep it simple, then. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -w -b -B -p -r1.27 -r1.28 --- inode.c 1 May 2007 16:33:53 -0000 1.27 +++ inode.c 28 Aug 2007 17:41:56 -0000 1.28 @@ -96,34 +96,11 @@ static size_t n_names = 0; static size_t max_names = (2 * NAMES_TABLE_LEN); /* - * Number of pnodes to grab per memory allocation when filling the - * free list. - */ -#define PNODES_PER_CHUNK ((8 * 1024) / sizeof(struct pnode) - 2) - -#ifdef ZERO_SUM_MEMORY -/* - * Allocation information for pnodes bulk allocation. - */ -struct pnodes_block { - LIST_ENTRY(pnodes_block) pnblk_links; - struct pnode pnblk_nodes[PNODES_PER_CHUNK]; -}; - -static LIST_HEAD( ,pnodes_block) pnblocks; -#endif - -/* * List of all path-nodes (aliases) referenced by any tree. */ struct pnodes_head _sysio_pnodes; /* - * Free path-nodes -- Not referenced by any tree for fas reuse. - */ -static LIST_HEAD( ,pnode) free_pnodes; - -/* * The system root -- Aka `/'. */ struct pnode *_sysio_root = NULL; @@ -142,11 +119,7 @@ _sysio_i_init() for (i = 0; i < NAMES_TABLE_LEN; i++) LIST_INIT(&names[i]); -#ifdef ZERO_SUM_MEMORY - LIST_INIT(&pnblocks); -#endif TAILQ_INIT(&_sysio_pnodes); - LIST_INIT(&free_pnodes); return 0; } @@ -470,37 +443,6 @@ _sysio_pb_disconnect(struct pnode_base * pb->pb_name.len = 0; } -/* - * Generate more path (alias) nodes for the fast allocator. - */ -static void -more_pnodes() -{ - size_t n; -#ifdef ZERO_SUM_MEMORY - struct pnodes_block *pnblk; -#endif - struct pnode *pno; - -#ifdef ZERO_SUM_MEMORY - pnblk = malloc(sizeof(struct pnodes_block)); - pno = NULL; - if (pnblk) { - LIST_INSERT_HEAD(&pnblocks, pnblk, pnblk_links); - pno = pnblk->pnblk_nodes; - } -#else - pno = malloc(PNODES_PER_CHUNK * sizeof(struct pnode)); -#endif - if (!pno) - return; - n = PNODES_PER_CHUNK; - do { - LIST_INSERT_HEAD(&free_pnodes, pno, p_links); - pno++; - } while (--n); -} - #ifdef ZERO_SUM_MEMORY /* * Shutdown @@ -508,12 +450,8 @@ more_pnodes() void _sysio_i_shutdown() { - struct pnodes_block *pnblk; - while ((pnblk = pnblocks.lh_first)) { - LIST_REMOVE(pnblk, pnblk_links); - free(pnblk); - } + return; } #endif @@ -528,14 +466,9 @@ _sysio_p_new_alias(struct pnode *parent, { struct pnode *pno; - pno = free_pnodes.lh_first; - if (!pno) { - more_pnodes(); - pno = free_pnodes.lh_first; - } + pno = malloc(sizeof(struct pnode)); if (!pno) return NULL; - LIST_REMOVE(pno, p_links); pno->p_ref = 1; pno->p_parent = parent; @@ -562,7 +495,7 @@ _sysio_p_gone(struct pnode *pno) TAILQ_REMOVE(&_sysio_pnodes, pno, p_nodes); LIST_REMOVE(pno, p_links); - LIST_INSERT_HEAD(&free_pnodes, pno, p_links); + free(pno); } /* |
From: Lee W. <lw...@us...> - 2007-08-28 17:37:13
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23409 Modified Files: test_stats.c Log Message: Modified to allow a list of path names to be passed via stdin. Preserves the old behavior of taking them from the ocmmand line as well. If any are present on the ocmmand line it ignores stdin. Index: test_stats.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- test_stats.c 28 Mar 2007 21:27:12 -0000 1.10 +++ test_stats.c 28 Aug 2007 17:37:08 -0000 1.11 @@ -43,6 +43,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> @@ -95,8 +96,27 @@ main(int argc, char * const argv[]) (void )SYSIO_INTERFACE_NAME(umask)(022); + if (optind < argc) { while (optind < argc) do_stats(argv[optind++]); + } else { + int doflush; + static char buf[4096]; + size_t len; + char *cp; + char c; + + doflush = 0; + while (fgets(buf, sizeof(buf), stdin) != NULL) { + len = strlen(buf); + cp = buf + len - 1; + c = *cp; + *cp = '\0'; + if (!doflush) + do_stats(buf); + doflush = c == '\n' ? 0 : 1; + } + } /* * Clean up. |
From: Ruth K. <rk...@us...> - 2007-08-24 16:50:31
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17270 Modified Files: configure.in Log Message: typo in readlink configure Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.37 retrieving revision 1.38 diff -u -w -b -B -p -r1.37 -r1.38 --- configure.in 20 Aug 2007 19:30:54 -0000 1.37 +++ configure.in 24 Aug 2007 16:50:20 -0000 1.38 @@ -283,7 +283,7 @@ if test x$symlink_support = xyes; then readlink_returns_int="no" ) AC_MSG_RESULT($readlink_returns_int) - if test x$readlink_returns_int = no; then + if test x$readlink_returns_int = xno; then AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t]) |
From: Lee W. <lw...@us...> - 2007-08-20 19:37:09
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25496 Modified Files: fs_native.c Log Message: Bugfix, from Cray, for CFS bug 11512 (getdirentries can prematurely signal EOF from native driver). Initialized the waste variable when using getdirentries. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -w -b -B -p -r1.63 -r1.64 --- fs_native.c 9 May 2007 23:16:20 -0000 1.63 +++ fs_native.c 20 Aug 2007 19:37:05 -0000 1.64 @@ -983,6 +983,9 @@ native_ifilldirentries(struct native_ino nino->ni_resetfpos = 0; } +#if defined(SYSIO_SYS_getdirentries) + waste = *posp; +#endif cc = #if defined(SYSIO_SYS_getdirentries) syscall(SYSIO_SYS_getdirentries, |
From: Lee W. <lw...@us...> - 2007-08-20 19:30:58
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23924 Modified Files: configure.in Log Message: Bump the minor version number. Version is now 1.3 Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.36 retrieving revision 1.37 diff -u -w -b -B -p -r1.36 -r1.37 --- configure.in 20 Aug 2007 19:28:12 -0000 1.36 +++ configure.in 20 Aug 2007 19:30:54 -0000 1.37 @@ -1,4 +1,4 @@ -AC_INIT(libsysio, 1.2) +AC_INIT(libsysio, 1.3) AC_CANONICAL_HOST |
From: Lee W. <lw...@us...> - 2007-08-20 19:30:21
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23442 Added Files: tracing.c Log Message: Tracing support was split out from the init code and moved here. The init code has become some sort of a catch-all. Shouldn't be :( --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2007 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <stdarg.h> #include <sys/queue.h> #include "sysio.h" #ifdef SYSIO_TRACING /* * Tracing callback record. */ struct trace_callback { TAILQ_ENTRY(trace_callback) links; /* trace list links */ void (*f)(const char *file, /* callback function */ const char *func, int line, void *data, int tag, const char *fmt, va_list ap); void *data; /* callback data */ void (*destructor)(void *data); /* data destructor */ }; /* * Initialize a tracing callback record. */ #define TCB_INIT(__tcb, __f, __d, __destroy) \ do { \ (__tcb)->f = (__f); \ (__tcb)->data = (__d); \ (__tcb)->destructor = (__destroy); \ } while (0); /* * Trace queue head record. */ TAILQ_HEAD(trace_q, trace_callback); /* * The entry and exit queue heads, and queue pointers. */ static struct trace_q _sysio_entry_trace_head; void *_sysio_entry_trace_q = &_sysio_entry_trace_head; static struct trace_q _sysio_exit_trace_head; void *_sysio_exit_trace_q = &_sysio_exit_trace_head; /* * Initializer pseudo-event queue head and pointer. */ static struct trace_q _sysio_initializer_trace_head; void *_sysio_initializer_trace_q = &_sysio_initializer_trace_head; /* * Register a trace callback. * * The pointer to the trace record is returned. */ void * _sysio_register_trace(void *q, void (*f)(const char *file, const char *func, int line, void *data, int tag, const char *fmt, va_list ap), void *data, void (*destructor)(void *data)) { struct trace_callback *tcb; tcb = malloc(sizeof(struct trace_callback)); if (!tcb) return NULL; TCB_INIT(tcb, f, data, destructor); TAILQ_INSERT_TAIL((struct trace_q *)q, tcb, links); return tcb; } /* * Remove a registered trace callback. */ void _sysio_remove_trace(void *q, void *p) { struct trace_callback *tcb; tcb = (struct trace_callback *)p; if (tcb->destructor) (*tcb->destructor)(tcb->data); TAILQ_REMOVE((struct trace_q *)q, tcb, links); free(tcb); } void /* * Run a trace queue, making all the callbacks. */ _sysio_run_trace_q(void *q, const char *file, const char *func, int line, int tag, const char *fmt, ...) { va_list ap, aq; struct trace_callback *tcb; va_start(ap, fmt); tcb = ((struct trace_q *)q)->tqh_first; while (tcb) { va_copy(aq, ap); (*tcb->f)(file, func, line, tcb->data, tag, fmt, ap); va_end(aq); tcb = tcb->links.tqe_next; } va_end(ap); } int _sysio_trace_init() { /* * Initialize initializer callback queue. */ TAILQ_INIT(&_sysio_initializer_trace_head); /* * Initialize tracing callback queues. */ TAILQ_INIT(&_sysio_entry_trace_head); TAILQ_INIT(&_sysio_exit_trace_head); return 0; } /* * Sysio library shutdown. */ void _sysio_trace_shutdown() { struct trace_callback *tcb; /* * Empty the initializer queue and free the entries. */ while ((tcb = _sysio_initializer_trace_head.tqh_first) != NULL) _sysio_remove_trace(&_sysio_initializer_trace_head, tcb); /* * Empty the trace queues and free the entries. */ while ((tcb = _sysio_entry_trace_head.tqh_first) != NULL) _sysio_remove_trace(&_sysio_entry_trace_head, tcb); while ((tcb = _sysio_exit_trace_head.tqh_first) != NULL) _sysio_remove_trace(&_sysio_exit_trace_head, tcb); } #endif /* defined(SYSIO_TRACING) */ |
From: Lee W. <lw...@us...> - 2007-08-20 19:28:15
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22661 Modified Files: Rules.make configure.in Log Message: Add/Alter build rules to get statvfs support. Index: Rules.make =================================================================== RCS file: /cvsroot/libsysio/libsysio/Rules.make,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- Rules.make 28 Mar 2007 21:28:59 -0000 1.12 +++ Rules.make 20 Aug 2007 19:28:12 -0000 1.13 @@ -15,4 +15,5 @@ DEV_CPPFLAGS = $(STDFD_DEV_CPPFLAGS) AM_CPPFLAGS = \ $(TRACING) \ $(AUTOMOUNT) $(ZERO_SUM_MEMORY) $(DEV_CPPFLAGS) $(SOCKETS_CPPFLAGS) \ - $(DEFER_INIT_CWD) $(SYSIO_LABEL_NAMES) -I$(top_srcdir)/include + $(DEFER_INIT_CWD) $(SYSIO_LABEL_NAMES) $(_HAVE_STATVFS) \ + -I$(top_srcdir)/include Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.35 retrieving revision 1.36 diff -u -w -b -B -p -r1.35 -r1.36 --- configure.in 20 Aug 2007 19:12:07 -0000 1.35 +++ configure.in 20 Aug 2007 19:28:12 -0000 1.36 @@ -114,7 +114,7 @@ AC_ARG_WITH(defer-init-cwd, [with_defer_init_cwd=no]) AC_SUBST(DEFER_INIT_CWD) -AC_ARG_WITH(with-statvfs, +AC_ARG_WITH(statvfs, AC_HELP_STRING([--with-statvfs], [enable support for statvfs]), [ case "${withval}" in |
From: Lee W. <lw...@us...> - 2007-08-20 19:12:12
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15038/src Modified Files: init.c module.mk Log Message: Split tracing support out. Added an initializer queue so that trace functionality may be added external to this library. to use it, register your initializer function with _sysio_register_trace using the _sysio_initializer_trace_q. Only the "func" argument is valid when the pseudo-event is called from _sysio_boot_trace. You might want to remove your initializer event from the initializer queue once called, unless it's ok to call it more than once. Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -w -b -B -p -r1.37 -r1.38 --- init.c 20 Aug 2007 16:02:56 -0000 1.37 +++ init.c 20 Aug 2007 19:12:08 -0000 1.38 @@ -41,23 +41,9 @@ * le...@sa... */ -#ifdef __linux__ -#define _BSD_SOURCE -#endif - -#ifdef SYSIO_TRACING -#include <stdio.h> -#endif #include <stdlib.h> -#ifdef _BSD_SOURCE -#include <sys/syscall.h> -#endif -#include <unistd.h> #include <string.h> #include <errno.h> -#ifdef SYSIO_TRACING -#include <stdarg.h> -#endif #include <limits.h> #include <assert.h> #include <sys/types.h> @@ -67,10 +53,6 @@ #include <sys/queue.h> #include "sysio.h" -#include "xtio.h" -#ifdef SYSIO_TRACING -#include "native.h" -#endif #include "inode.h" #include "fs.h" #include "mount.h" @@ -81,48 +63,6 @@ #include "stdfd.h" #endif -#ifdef SYSIO_TRACING - -/* - * Tracing callback record. - */ -struct trace_callback { - TAILQ_ENTRY(trace_callback) links; /* trace list links */ - void (*f)(const char *file, /* callback function */ - const char *func, - int line, - void *data, - int tag, - const char *fmt, - va_list ap); - void *data; /* callback data */ - void (*destructor)(void *data); /* data destructor */ -}; - -/* - * Initialize a tracing callback record. - */ -#define TCB_INIT(__tcb, __f, __d, __destroy) \ - do { \ - (__tcb)->f = (__f); \ - (__tcb)->data = (__d); \ - (__tcb)->destructor = (__destroy); \ - } while (0); - -/* - * Trace queue head record. - */ -TAILQ_HEAD(trace_q, trace_callback); - -/* - * The entry and exit queue heads, and queue pointers. - */ -static struct trace_q _sysio_entry_trace_head; -void *_sysio_entry_trace_q = &_sysio_entry_trace_head; -static struct trace_q _sysio_exit_trace_head; -void *_sysio_exit_trace_q = &_sysio_exit_trace_head; -#endif - /* * White space characters. */ @@ -145,6 +85,100 @@ void *_sysio_exit_trace_q = &_sysio_exit */ #define COMMENT_INTRO '#' +#ifdef SYSIO_TRACING +static void *entry_tcb = NULL; /* entry callback */ +static void *exit_tcb = NULL; /* exit callback */ +#endif /* defined(SYSIO_TRACING) */ + +#ifdef SYSIO_TRACING +static void +trace_entry(const char *file __IS_UNUSED, + const char *func, + int line __IS_UNUSED, + void *data __IS_UNUSED, + tracing_tag tag, + const char *fmt __IS_UNUSED, + va_list ap __IS_UNUSED) +{ + + _sysio_cprintf("+ENTER+ %s (%d)\n", func, tag); +} + +static void +trace_exit(const char *file __IS_UNUSED, + const char *func, + int line __IS_UNUSED, + void *data __IS_UNUSED, + tracing_tag tag, + const char *fmt __IS_UNUSED, + va_list ap __IS_UNUSED) +{ + + _sysio_cprintf("+EXIT+ %s (%d)\n", func, tag); +} + +/* + * Start/Stop our simple tracer. + * + * Normally, these things would remove themselves from the trace + * initializers queue when called. For backward compatibility, this one + * must stick around so it can be turned on and off. Ugh! It all does get + * cleaned up at exit, though. + */ +static void +trace_initializer(const char *file __IS_UNUSED, + const char *func, + int line __IS_UNUSED, + void *data __IS_UNUSED, + tracing_tag tag __IS_UNUSED, + const char *fmt __IS_UNUSED, + va_list ap __IS_UNUSED) +{ + long l; + char *cp; + + /* + * Func is overloaded, for initializers. It contains the initializer + * argument string. + * + * We are looking for an integer value. If non-zero, turn our + * little tracer on. Otherwise, off. + */ + l = strtol(func, (char **)&cp, 0); + if (*func != '\0' && *cp != '\0') { + /* + * Not for us. Must be some other. + */ + return; + } + if (l) { + if (!entry_tcb) + entry_tcb = + _sysio_register_trace(_sysio_entry_trace_q, + &trace_entry, + NULL, + NULL); + if (!exit_tcb) + exit_tcb = + _sysio_register_trace(_sysio_exit_trace_q, + &trace_exit, + NULL, + NULL); + } else { + if (entry_tcb) { + _sysio_remove_trace(_sysio_entry_trace_q, + entry_tcb); + entry_tcb = NULL; + } + if (exit_tcb) { + _sysio_remove_trace(_sysio_exit_trace_q, + exit_tcb); + exit_tcb = NULL; + } + } +} +#endif /* defined(SYSIO_TRACING) */ + /* * Sysio library initialization. Must be called before anything else in the * library. @@ -158,13 +192,19 @@ _sysio_init() #endif #ifdef SYSIO_TRACING - /* - * Initialize tracing callback queues. - */ - TAILQ_INIT(&_sysio_entry_trace_head); - TAILQ_INIT(&_sysio_exit_trace_head); + err = _sysio_trace_init(); + if (err) + goto error; + err = + _sysio_register_trace(_sysio_initializer_trace_q, + &trace_initializer, + NULL, + NULL) + ? 0 + : -ENOMEM; + if (err) + goto error; #endif - err = _sysio_ioctx_init(); if (err) goto error; @@ -208,18 +247,7 @@ _sysio_shutdown() { #ifdef SYSIO_TRACING - _sysio_trace_dump_stop(); - { - struct trace_callback *tcb; - - /* - * Empty the trace queues and free the entries. - */ - while ((tcb = _sysio_entry_trace_head.tqh_first) != NULL) - _sysio_remove_trace(&_sysio_entry_trace_head, tcb); - while ((tcb = _sysio_exit_trace_head.tqh_first) != NULL) - _sysio_remove_trace(&_sysio_exit_trace_head, tcb); - } + _sysio_trace_shutdown(); #endif if (!(_sysio_fd_close_all() == 0 && _sysio_unmount_all() == 0)) @@ -233,103 +260,6 @@ _sysio_shutdown() #endif } -#ifdef SYSIO_TRACING -/* - * Register a trace callback. - * - * The pointer to the trace record is returned. - */ -void * -_sysio_register_trace(void *q, - void (*f)(const char *file, - const char *func, - int line, - void *data, - int tag, - const char *fmt, - va_list ap), - void *data, - void (*destructor)(void *data)) -{ - struct trace_callback *tcb; - - tcb = malloc(sizeof(struct trace_callback)); - if (!tcb) - return NULL; - TCB_INIT(tcb, f, data, destructor); - TAILQ_INSERT_TAIL((struct trace_q *)q, tcb, links); - return tcb; -} - -/* - * Remove a registered trace callback. - */ -void -_sysio_remove_trace(void *q, void *p) -{ - struct trace_callback *tcb; - - tcb = (struct trace_callback *)p; - - if (tcb->destructor) - (*tcb->destructor)(tcb->data); - TAILQ_REMOVE((struct trace_q *)q, tcb, links); - free(tcb); -} - -void -/* - * Run a trace queue, making all the callbacks. - */ -_sysio_run_trace_q(void *q, - const char *file, - const char *func, - int line, - int tag, - const char *fmt, - ...) -{ - va_list ap, aq; - struct trace_callback *tcb; - - va_start(ap, fmt); - tcb = ((struct trace_q *)q)->tqh_first; - while (tcb) { - va_copy(aq, ap); - (*tcb->f)(file, func, line, tcb->data, tag, fmt, ap); - va_end(aq); - tcb = tcb->links.tqe_next; - } - va_end(ap); -} - -static void -_sysio_trace_entry(const char *file __IS_UNUSED, - const char *func, - int line __IS_UNUSED, - void *data __IS_UNUSED, - tracing_tag tag, - const char *fmt __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - _sysio_cprintf("+ENTER+ %s (%d)\n", func, tag); -} - -static void -_sysio_trace_exit(const char *file __IS_UNUSED, - const char *func, - int line __IS_UNUSED, - void *data __IS_UNUSED, - tracing_tag tag, - const char *fmt __IS_UNUSED, - va_list ap __IS_UNUSED) -{ - - _sysio_cprintf("+EXIT+ %s (%d)\n", func, tag); -} -#endif /* defined(SYSIO_TRACING) */ - /* * (kind of)Duplicates strtok function. * @@ -857,102 +787,23 @@ do_command(char *buf) static int _sysio_boot_tracing(const char *arg) { - int err; - const char *dirpath; - long l; - char *cp; - int stop; - struct hook { - struct trace_q *q; - void (*f)(const char *file, - const char *func, - int line, - void *data, - int tag, - const char *fmt, - va_list ap); - void *data; - void (*destructor)(void *data); - struct trace_callback *cb; - }; - static struct hook hooks[] = { - { - &_sysio_entry_trace_head, - _sysio_trace_entry, - NULL, - NULL, - NULL - }, - { - &_sysio_exit_trace_head, - _sysio_trace_exit, - NULL, - NULL, - NULL - }, - { - NULL, - NULL, - NULL, - NULL, - NULL - } - }; - struct hook *h; - err = 0; - dirpath = NULL; - l = strtol(arg, (char **)&cp, 0); - if (*arg != '\0' && *cp != '\0') - dirpath = arg; - stop = 0; - if (dirpath) - err = _sysio_trace_dump_start(dirpath); - else if (l) { - /* - * Start console tracing. - */ - do { - if (l != 1) { - err = -EINVAL; - break; - } - for (h = hooks; h->f != NULL; h++) { - if (h->cb) - continue; - h->cb = - _sysio_register_trace(h->q, - h->f, - h->data, - h->destructor); - if (!h->cb) { - err = -ENOMEM; - break; - } - } - } while (0); - } else { - /* - * Trace dump stop. - */ - stop = 1; - } - if (!(dirpath || l) || err) { - /* - * Trace dump stop. - */ - _sysio_trace_dump_stop(); + if (!arg) { /* - * Stop console tracing. + * NULL arg means not set at all. We really shouldn't + * have even been called. However, sometimes we are. + * It's not an error, then. Just a no-op. */ - for (h = hooks; h->f != NULL; h++) { - if (!h->cb) - continue; - _sysio_remove_trace(h->q, h->cb); - h->cb = NULL; - } + return 0; } - return err; + + _sysio_run_trace_q(_sysio_initializer_trace_q, + NULL, + arg, + -1, + -1, + NULL); + return 0; } #endif Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- module.mk 20 Aug 2007 16:02:56 -0000 1.14 +++ module.mk 20 Aug 2007 19:12:08 -0000 1.15 @@ -1,3 +1,9 @@ +if WITH_TRACING +TRACING_SRCS = src/tracing.c +else +TRACING_SRCS = +endif + if WITH_LUSTRE_HACK FILE_SUPPORT = src/file_hack.c else @@ -29,6 +35,6 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/symlink.c src/readlink.c \ src/truncate.c src/unlink.c src/utime.c \ $(FILE_SUPPORT) $(LUSTRE_SRCDIR_SRCS) \ - src/tracing.c src/cprintf.c + $(TRACING_SRCS) src/cprintf.c SRCDIR_EXTRA = src/module.mk |
From: Lee W. <lw...@us...> - 2007-08-20 19:12:12
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15038 Modified Files: configure.in Log Message: Split tracing support out. Added an initializer queue so that trace functionality may be added external to this library. to use it, register your initializer function with _sysio_register_trace using the _sysio_initializer_trace_q. Only the "func" argument is valid when the pseudo-event is called from _sysio_boot_trace. You might want to remove your initializer event from the initializer queue once called, unless it's ok to call it more than once. Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.34 retrieving revision 1.35 diff -u -w -b -B -p -r1.34 -r1.35 --- configure.in 2 Jul 2007 18:58:15 -0000 1.34 +++ configure.in 20 Aug 2007 19:12:07 -0000 1.35 @@ -127,14 +127,14 @@ AM_CONDITIONAL(WITH_STATVFS, test x$with AC_SUBST(_HAVE_STATVFS) AC_ARG_WITH(tracing, - AC_HELP_STRING([--with-tracing], - [enable tracing support]), + AC_HELP_STRING([--with-tracing], [enable tracing support]), [ case "${withval}" in yes) TRACING=-DSYSIO_TRACING=1 ;; no) ;; *) AC_MSG_ERROR(bad value ${withval} for --with-tracing) ;; esac], - [TRACING=-DSYSIO_TRACING=1]) + [with_tracing=no]) +AM_CONDITIONAL(WITH_TRACING, test x$with_tracing = xyes) AC_SUBST(TRACING) AC_ARG_WITH(cplant_yod, |
From: Lee W. <lw...@us...> - 2007-08-20 19:12:12
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15038/include Modified Files: sysio-cmn.h Log Message: Split tracing support out. Added an initializer queue so that trace functionality may be added external to this library. to use it, register your initializer function with _sysio_register_trace using the _sysio_initializer_trace_q. Only the "func" argument is valid when the pseudo-event is called from _sysio_boot_trace. You might want to remove your initializer event from the initializer queue once called, unless it's ok to call it more than once. Index: sysio-cmn.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio-cmn.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -w -b -B -p -r1.17 -r1.18 --- sysio-cmn.h 2 Jul 2007 18:58:15 -0000 1.17 +++ sysio-cmn.h 20 Aug 2007 19:12:08 -0000 1.18 @@ -210,9 +210,13 @@ typedef enum { SYSIO_TTAG(utime), } tracing_tag; +extern void *_sysio_initializer_trace_q; extern void *_sysio_entry_trace_q; extern void *_sysio_exit_trace_q; +extern int _sysio_trace_init(void); +extern void _sysio_trace_shutdown(void); + extern void *_sysio_register_trace(void *q, void (*)(const char *file, const char *func, @@ -251,8 +255,6 @@ extern void _sysio_run_trace_q(void *q, __VA_ARGS__); \ } while (0) -extern int _sysio_trace_dump_start(const char *dirpath); -extern void _sysio_trace_dump_stop(void); #else /* !defined(SYSIO_TRACING) */ #define SYSIO_ENTER(tag, fmt, ...) \ do { } while (0) |
From: Lee W. <lw...@us...> - 2007-08-20 16:03:02
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30003/src Modified Files: module.mk init.c Added Files: cprintf.c Log Message: Break cprintf, and friends, out of init.c and put them in their own file. Also, removed the dependency on _SYSIO_TRACING. --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2007 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #if defined(__linux__) && !defined(_BSD_SOURCE) #define _BSD_SOURCE #endif #include <stdio.h> #include <stdlib.h> #include <sys/syscall.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <stdarg.h> #include "sysio.h" #include "native.h" #if !(defined(_HAVE_ASPRINTF) && _HAVE_ASPRINTF) /* * Print a string to allocated memory. */ static int vasprintf(char **strp, const char *fmt, va_list ap) { size_t siz; int oerrno; char *s; va_list aq; int n; siz = 50; oerrno = errno; if (!(s = malloc(siz))) { errno = oerrno; return -1; } for (;;) { va_copy(aq, ap); n = vsnprintf (s, siz, fmt, aq); va_end(aq); if (n > -1 && (size_t )n < siz) break; if (n > -1) /* glibc 2.1 */ siz = n+1; /* precise */ else /* glibc 2.0 */ siz *= 2; /* twice the old */ if (!(s = realloc (s, siz))) break; } *strp = s; errno = oerrno; return n; } #if 0 static int asprintf(char **strp, const char *fmt, ...) { va_list ap; int n; va_start(ap, fmt); n = vasprintf(strp, fmt, ap); va_end(ap); return n; } #endif #endif /* !(defined(_HAVE_ASPRINTF) && _HAVE_ASPRINTF) */ static void _sysio_cwrite(const char *buf, size_t len) { int oerrno; oerrno = errno; (void )syscall(SYSIO_SYS_write, STDERR_FILENO, buf, len); errno = oerrno; } /* * Console printf. */ void _sysio_cprintf(const char *fmt, ...) { va_list ap; int len; char *buf; va_start(ap, fmt); buf = NULL; len = vasprintf(&buf, fmt, ap); va_end(ap); if (len < 0) return; _sysio_cwrite(buf, len); free(buf); } Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -b -B -p -r1.13 -r1.14 --- module.mk 2 Jul 2007 18:58:16 -0000 1.13 +++ module.mk 20 Aug 2007 16:02:56 -0000 1.14 @@ -29,6 +29,6 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/symlink.c src/readlink.c \ src/truncate.c src/unlink.c src/utime.c \ $(FILE_SUPPORT) $(LUSTRE_SRCDIR_SRCS) \ - src/tracing.c + src/tracing.c src/cprintf.c SRCDIR_EXTRA = src/module.mk Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -w -b -B -p -r1.36 -r1.37 --- init.c 2 Jul 2007 18:58:16 -0000 1.36 +++ init.c 20 Aug 2007 16:02:56 -0000 1.37 @@ -234,89 +234,6 @@ _sysio_shutdown() } #ifdef SYSIO_TRACING - -#if !(defined(_HAVE_ASPRINTF) && _HAVE_ASPRINTF) -/* - * Print a string to allocated memory. - */ -static int -vasprintf(char **strp, const char *fmt, va_list ap) -{ - size_t siz; - int oerrno; - char *s; - va_list aq; - int n; - - siz = 50; - oerrno = errno; - if (!(s = malloc(siz))) { - errno = oerrno; - return -1; - } - for (;;) { - va_copy(aq, ap); - n = vsnprintf (s, siz, fmt, aq); - va_end(aq); - if (n > -1 && (size_t )n < siz) - break; - if (n > -1) /* glibc 2.1 */ - siz = n+1; /* precise */ - else /* glibc 2.0 */ - siz *= 2; /* twice the old */ - if (!(s = realloc (s, siz))) - break; - } - *strp = s; - errno = oerrno; - return n; -} - -#if 0 -static int -asprintf(char **strp, const char *fmt, ...) -{ - va_list ap; - int n; - - va_start(ap, fmt); - n = vasprintf(strp, fmt, ap); - va_end(ap); - return n; -} -#endif -#endif /* !(defined(_HAVE_ASPRINTF) && _HAVE_ASPRINTF) */ - -static void -_sysio_cwrite(const char *buf, size_t len) -{ - int oerrno; - - oerrno = errno; - (void )syscall(SYSIO_SYS_write, STDERR_FILENO, buf, len); - errno = oerrno; -} - -/* - * Console printf. - */ -void -_sysio_cprintf(const char *fmt, ...) -{ - va_list ap; - int len; - char *buf; - - va_start(ap, fmt); - buf = NULL; - len = vasprintf(&buf, fmt, ap); - va_end(ap); - if (len < 0) - return; - _sysio_cwrite(buf, len); - free(buf); -} - /* * Register a trace callback. * |
From: Lee W. <lw...@us...> - 2007-08-20 16:03:02
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30003/include Modified Files: sysio.h Log Message: Break cprintf, and friends, out of init.c and put them in their own file. Also, removed the dependency on _SYSIO_TRACING. Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.42 retrieving revision 1.43 diff -u -w -b -B -p -r1.42 -r1.43 --- sysio.h 9 May 2007 23:16:20 -0000 1.42 +++ sysio.h 20 Aug 2007 16:02:56 -0000 1.43 @@ -152,9 +152,7 @@ extern char * _sysio_get_args(char *buf, extern time_t _sysio_local_time(void); -#ifdef SYSIO_TRACING extern void _sysio_cprintf(const char *fmt, ...); -#endif /* * The following should be defined by the system includes, and probably are, |
From: Lee W. <lw...@us...> - 2007-07-02 18:58:48
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18012/include Modified Files: sysio-cmn.h Log Message: Altered tracing support to include a format now. Re-introducing _HAVE_STATVFS6 for binary compatibility. Index: sysio-cmn.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio-cmn.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- sysio-cmn.h 9 May 2007 23:16:20 -0000 1.16 +++ sysio-cmn.h 2 Jul 2007 18:58:15 -0000 1.17 @@ -133,78 +133,81 @@ struct iovec; */ #define SYSIO_INTERFACE_DISPLAY_BLOCK \ int _saved_errno; -#define SYSIO_INTERFACE_ENTER(tag, ...) \ +#define SYSIO_INTERFACE_ENTER(tag, fmt, ...) \ do { \ _saved_errno = errno; \ - SYSIO_ENTER(tag, __VA_ARGS__); \ + SYSIO_ENTER(tag, (fmt), __VA_ARGS__); \ } while (0) -#define SYSIO_INTERFACE_RETURN(rtn, err, tag, ...) \ +#define SYSIO_INTERFACE_RETURN(rtn, err, tag, fmt, ...) \ do { \ - SYSIO_LEAVE(tag, (rtn), (err), __VA_ARGS__); \ + SYSIO_LEAVE(tag, (fmt), (err), (rtn), __VA_ARGS__); \ errno = (err) ? -(err) : _saved_errno; \ return (rtn); \ } while(0) -/* Interface enter/leave hook functions */ #ifdef SYSIO_TRACING -#define _SYSIO_TTAG(name) \ +#define SYSIO_TTAG(name) \ PREPEND(_SYSIO_TRACING_, name) /* * Supported tracing tags. */ typedef enum { - _SYSIO_TTAG(unsupported) = -1, - _SYSIO_TTAG(access), - _SYSIO_TTAG(chdir), - _SYSIO_TTAG(getcwd), - _SYSIO_TTAG(chmod), - _SYSIO_TTAG(fchmod), - _SYSIO_TTAG(chown), - _SYSIO_TTAG(fchown), - _SYSIO_TTAG(dup2), - _SYSIO_TTAG(dup), - _SYSIO_TTAG(vfcntl), - _SYSIO_TTAG(fsync), - _SYSIO_TTAG(fdatasync), - _SYSIO_TTAG(getdirentries64), - _SYSIO_TTAG(getdirentries), - _SYSIO_TTAG(ioctl), - _SYSIO_TTAG(iodone), - _SYSIO_TTAG(iowait), - _SYSIO_TTAG(link), - _SYSIO_TTAG(lseek64), - _SYSIO_TTAG(lseek), - _SYSIO_TTAG(llseek), - _SYSIO_TTAG(mkdir), - _SYSIO_TTAG(xmknod), - _SYSIO_TTAG(mount), - _SYSIO_TTAG(umount), - _SYSIO_TTAG(open), - _SYSIO_TTAG(close), - _SYSIO_TTAG(ireadx), - _SYSIO_TTAG(iwritex), - _SYSIO_TTAG(ireadv), - _SYSIO_TTAG(iwritev), - _SYSIO_TTAG(rename), - _SYSIO_TTAG(rmdir), - _SYSIO_TTAG(xstatnd), - _SYSIO_TTAG(fxstat), -#ifdef _HAVE_STATVFS - _SYSIO_TTAG(statvfs64), - _SYSIO_TTAG(fstatvfs64), - _SYSIO_TTAG(statvfs), - _SYSIO_TTAG(fstatvfs), + SYSIO_TTAG(unsupported) = -1, + SYSIO_TTAG(access), + SYSIO_TTAG(chdir), + SYSIO_TTAG(getcwd), + SYSIO_TTAG(chmod), + SYSIO_TTAG(fchmod), + SYSIO_TTAG(chown), + SYSIO_TTAG(fchown), + SYSIO_TTAG(dup2), + SYSIO_TTAG(dup), + SYSIO_TTAG(vfcntl), + SYSIO_TTAG(fsync), + SYSIO_TTAG(fdatasync), + SYSIO_TTAG(getdirentries), +#ifdef _LARGEFILE64_SOURCE + SYSIO_TTAG(getdirentries64), +#endif + SYSIO_TTAG(ioctl), + SYSIO_TTAG(iodone), + SYSIO_TTAG(iowait), + SYSIO_TTAG(link), + SYSIO_TTAG(lseek), +#ifdef _LARGEFILE64_SOURCE + SYSIO_TTAG(lseek64), #endif - _SYSIO_TTAG(opendir), - _SYSIO_TTAG(closedir), - _SYSIO_TTAG(symlink), - _SYSIO_TTAG(readlink), - _SYSIO_TTAG(truncate), - _SYSIO_TTAG(ftruncate), - _SYSIO_TTAG(unlink), - _SYSIO_TTAG(utime), + SYSIO_TTAG(llseek), + SYSIO_TTAG(mkdir), + SYSIO_TTAG(xmknod), + SYSIO_TTAG(mount), + SYSIO_TTAG(umount), + SYSIO_TTAG(open), + SYSIO_TTAG(close), + SYSIO_TTAG(ireadx), + SYSIO_TTAG(iwritex), + SYSIO_TTAG(ireadv), + SYSIO_TTAG(iwritev), + SYSIO_TTAG(rename), + SYSIO_TTAG(rmdir), + SYSIO_TTAG(xstatnd), + SYSIO_TTAG(fxstat), + SYSIO_TTAG(statvfs), + SYSIO_TTAG(fstatvfs), +#ifdef _LARGEFILE64_SOURCE + SYSIO_TTAG(statvfs64), + SYSIO_TTAG(fstatvfs64), +#endif + SYSIO_TTAG(opendir), + SYSIO_TTAG(closedir), + SYSIO_TTAG(symlink), + SYSIO_TTAG(readlink), + SYSIO_TTAG(truncate), + SYSIO_TTAG(ftruncate), + SYSIO_TTAG(unlink), + SYSIO_TTAG(utime), } tracing_tag; extern void *_sysio_entry_trace_q; @@ -216,6 +219,7 @@ extern void *_sysio_register_trace(void int line, void *data, tracing_tag tag, + const char *fmt, va_list ap), void *data, void (*destructor)(void *data)); @@ -225,30 +229,36 @@ extern void _sysio_run_trace_q(void *q, const char *func, int line, tracing_tag tag, + const char *fmt, ...); -#define SYSIO_ENTER(tag, ...) \ +/* Interface enter/leave hook functions */ +#define SYSIO_ENTER(tag, fmt, ...) \ do { \ _sysio_run_trace_q(_sysio_entry_trace_q, \ __FILE__, __func__, __LINE__, \ - _SYSIO_TTAG(tag), \ + SYSIO_TTAG(tag), \ + (fmt), \ __VA_ARGS__); \ } while (0) - -#define SYSIO_LEAVE(tag, ...) \ +#define SYSIO_LEAVE(tag, fmt, ...) \ do { \ _sysio_run_trace_q(_sysio_exit_trace_q, \ __FILE__, __func__, __LINE__, \ - _SYSIO_TTAG(tag), \ + SYSIO_TTAG(tag), \ + (fmt), \ __VA_ARGS__); \ } while (0) -#else -#define SYSIO_ENTER(tag, ...) \ + +extern int _sysio_trace_dump_start(const char *dirpath); +extern void _sysio_trace_dump_stop(void); +#else /* !defined(SYSIO_TRACING) */ +#define SYSIO_ENTER(tag, fmt, ...) \ do { } while (0) -#define SYSIO_LEAVE(tag, ...) \ +#define SYSIO_LEAVE(tag, fmt, ...) \ do { } while (0) -#endif +#endif /* !defined(SYSIO_TRACING) */ /* Accounting for IO stats; Read and write character count. */ #if defined(REDSTORM) |