libsysio-commit Mailing List for libsysio (Page 6)
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: Ruth K. <rk...@us...> - 2008-10-15 22:01:09
|
Update of /cvsroot/libsysio/libsysio/include In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25646/include Modified Files: module.mk native.h Removed Files: cplant-yod.h Log Message: Removing obsolete code related to cplant yod, lustre hack, and sockets driver. Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/module.mk,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- module.mk 26 Sep 2007 19:47:07 -0000 1.9 +++ module.mk 15 Oct 2008 22:01:01 -0000 1.10 @@ -1,5 +1,5 @@ INCLUDE_EXTRA = include/dev.h include/file.h include/fs.h \ include/inode.h include/mount.h include/sysio.h \ - include/sysio-cmn.h include/sysio-symbols.h include/cplant-yod.h \ + include/sysio-cmn.h include/sysio-symbols.h \ include/module.mk include/xtio.h include/stddir.h \ include/native.h include/tree.h include/creds.h Index: native.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/native.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- native.h 1 May 2007 16:33:52 -0000 1.4 +++ native.h 15 Oct 2008 22:01:01 -0000 1.5 @@ -227,12 +227,6 @@ do { #define SYSIO_SYS_statfs SYS_statfs #define SYSIO_SYS_fstatfs SYS_fstatfs #endif -#if defined(SYS_socketcall) -#define SYSIO_SYS_socketcall SYS_socketcall -#endif -#if defined(SYS_socket) -#define SYSIO_SYS_socket SYS_socket -#endif #if defined(SYS_accept) #define SYSIO_SYS_accept SYS_accept #endif --- cplant-yod.h DELETED --- |
From: Ruth K. <rk...@us...> - 2008-10-15 22:01:09
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25646/drivers/native Modified Files: fs_native.c Log Message: Removing obsolete code related to cplant yod, lustre hack, and sockets driver. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.67 retrieving revision 1.68 diff -u -w -b -B -p -r1.67 -r1.68 --- fs_native.c 11 Jul 2008 18:23:57 -0000 1.67 +++ fs_native.c 15 Oct 2008 22:01:01 -0000 1.68 @@ -1740,34 +1740,6 @@ native_inop_datasync(struct pnode *pno) return err; } -#ifdef HAVE_LUSTRE_HACK -static int -native_inop_ioctl(struct pnode *pno, - unsigned long int request, - va_list ap) -{ - struct inode *ino; - struct native_inode *nino; - long arg1, arg2, arg3, arg4; - int rtn; - - ino = pno->p_base->pb_ino; - assert(ino); - nino = I2NI(ino); - assert(nino->ni_fd >= 0); - arg1 = va_arg(ap, long); - arg2 = va_arg(ap, long); - arg3 = va_arg(ap, long); - arg4 = va_arg(ap, long); - - rtn = - syscall(SYSIO_SYS_ioctl, I2NI(ino)->ni_fd, request, - arg1, arg2, arg3, arg4); - if (rtn < 0) - rtn = -errno; - return rtn; -} -#else static int native_inop_ioctl(struct pnode *pno __IS_UNUSED, unsigned long int request __IS_UNUSED, @@ -1779,7 +1751,6 @@ native_inop_ioctl(struct pnode *pno __IS */ return -ENOTTY; } -#endif static void native_inop_gone(struct inode *ino) |
From: Ruth K. <rk...@us...> - 2008-10-15 22:01:09
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25646/drivers/yod Removed Files: fs_yod.c fs_yod.h module.mk Log Message: Removing obsolete code related to cplant yod, lustre hack, and sockets driver. --- fs_yod.c DELETED --- --- fs_yod.h DELETED --- --- module.mk DELETED --- |
From: Ruth K. <rk...@us...> - 2008-10-15 22:01:09
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25646/dev/stdfd Modified Files: stdfd.c Log Message: Removing obsolete code related to cplant yod, lustre hack, and sockets driver. Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- stdfd.c 11 Jul 2008 18:23:56 -0000 1.16 +++ stdfd.c 15 Oct 2008 22:01:01 -0000 1.17 @@ -62,15 +62,6 @@ #include "stdfd.h" -#ifdef CPLANT_YOD -#include <sys/statfs.h> -#include "cplant-yod.h" -#define dowrite(f, b, n) write_yod(f, b, n) -#define doread(f, b, n) read_yod(f, b, n) -#else -#define dowrite(f, b, n) syscall(SYSIO_SYS_write, f, b, n) -#define doread(f, b, n) syscall(SYSIO_SYS_read, f, b, n) -#endif /* * Pre-opened standard file descriptors driver. @@ -164,7 +155,7 @@ stdfd_read_simple(void *buf, int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); int cc; - cc = doread(fd, buf, nbytes); + cc = syscall(SYSIO_SYS_read, fd, buf, nbytes); if (cc < 0) cc = -errno; return cc; @@ -186,7 +177,7 @@ stdfd_write_simple(const void *buf, int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); int cc; - cc = dowrite(fd, buf, nbytes); + cc = syscall(SYSIO_SYS_write, fd, buf, nbytes); if (cc < 0) cc = -errno; return cc; |
From: Ruth K. <rk...@us...> - 2008-10-15 22:01:09
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25646/src Modified Files: fcntl.c init.c module.mk namei.c open.c Removed Files: file_hack.c stdlib.c Log Message: Removing obsolete code related to cplant yod, lustre hack, and sockets driver. Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -w -b -B -p -r1.31 -r1.32 --- fcntl.c 17 Jun 2008 17:18:57 -0000 1.31 +++ fcntl.c 15 Oct 2008 22:01:01 -0000 1.32 @@ -57,22 +57,6 @@ #include "sysio-symbols.h" -#ifdef HAVE_LUSTRE_HACK -#include <syscall.h> -#include <native.h> -#endif - -#ifdef HAVE_LUSTRE_HACK -static int -_sysio_lustre_fcntl(int fd, int cmd, va_list ap, int *rtn) -{ - long arg = va_arg(ap, long); - - *rtn = syscall(SYSIO_SYS_fcntl, fd, cmd, arg); - return *rtn == -1 ? -errno : 0; -} -#endif - static int _sysio_fcntl_raw_call(struct pnode *pno, int *r, int cmd, ...) { @@ -165,14 +149,9 @@ _sysio_vfcntl(int fd, int cmd, va_list a err = 0; fil = _sysio_fd_find(fd); if (!fil) { -#ifdef HAVE_LUSTRE_HACK - err = _sysio_lustre_fcntl(fd, cmd, ap, &rtn); - goto out; -#else rtn = -1; err = -EBADF; goto out; -#endif } switch (cmd) { Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -w -b -B -p -r1.41 -r1.42 --- init.c 17 Jun 2008 17:18:57 -0000 1.41 +++ init.c 15 Oct 2008 22:01:01 -0000 1.42 @@ -192,9 +192,6 @@ int _sysio_init() { int err; -#ifdef WITH_SOCKETS - extern int _sysio_sockets_init(void); -#endif mutex_init(&_sysio_biglock, MUTEX_RECURSIVE); @@ -234,11 +231,6 @@ _sysio_init() if (err) goto error; #endif -#ifdef WITH_SOCKETS - err = _sysio_sockets_init(); - if (err) - goto error; -#endif goto out; error: Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.17 retrieving revision 1.18 diff -u -w -b -B -p -r1.17 -r1.18 --- module.mk 17 Jun 2008 17:18:57 -0000 1.17 +++ module.mk 15 Oct 2008 22:01:01 -0000 1.18 @@ -10,17 +10,7 @@ else TRACING_SRCS = endif -if WITH_LUSTRE_HACK -FILE_SUPPORT = src/file_hack.c -else FILE_SUPPORT = src/file.c -endif - -if WITH_LUSTRE_HACK -LUSTRE_SRCDIR_SRCS = src/stdlib.c -else -LUSTRE_SRCDIR_SRCS = -endif if WITH_STATVFS STATVFS_SRCS = src/statvfs.c @@ -40,7 +30,6 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/stddir.c src/readdir.c src/readdir64.c \ 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 src/tree.c + $(FILE_SUPPORT) $(TRACING_SRCS) src/cprintf.c src/tree.c SRCDIR_EXTRA = src/module.mk Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- namei.c 17 Jun 2008 17:18:57 -0000 1.30 +++ namei.c 15 Oct 2008 22:01:01 -0000 1.31 @@ -531,17 +531,6 @@ _sysio_path_walk(struct pnode *parent, s return err; } -#ifdef CPLANT_YOD -/* - * for backward compatibility w/protocol switch - * remove everything up to the first ':' - * fortran libs prepend cwd to path, so not much choice - */ -#define STRIP_PREFIX(p) strchr(p,':') ? strchr(p,':')+1 : p -#else -#define STRIP_PREFIX(p) p -#endif - /* * Expanded form of the path-walk routine, with the common arguments, builds * the nameidata bundle and calls path-walk. @@ -556,7 +545,7 @@ _sysio_namei(struct pnode *parent, struct nameidata nameidata; int err; - ND_INIT(&nameidata, flags, STRIP_PREFIX(path), _sysio_root, intnt); + ND_INIT(&nameidata, flags, path, _sysio_root, intnt); err = _sysio_path_walk(parent, &nameidata); if (!err) *pnop = nameidata.nd_pno; Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -w -b -B -p -r1.32 -r1.33 --- open.c 17 Jun 2008 17:18:57 -0000 1.32 +++ open.c 15 Oct 2008 22:01:01 -0000 1.33 @@ -260,13 +260,8 @@ SYSIO_INTERFACE_NAME(creat)(const char * sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), PREPEND(__, SYSIO_INTERFACE_NAME(creat))) #undef creat64 -#ifndef HAVE_LUSTRE_HACK sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), SYSIO_INTERFACE_NAME(creat64)) -#else -/* XXX workaround SuSE SLES 8, glibc-2.2.5 */ -sysio_sym_strong_alias(SYSIO_INTERFACE_NAME(creat), - SYSIO_INTERFACE_NAME(creat64)) -#endif + #undef __creat64 sysio_sym_weak_alias(SYSIO_INTERFACE_NAME(creat), PREPEND(__, SYSIO_INTERFACE_NAME(creat64))) --- file_hack.c DELETED --- --- stdlib.c DELETED --- |
From: Ruth K. <rk...@us...> - 2008-10-15 22:01:09
|
Update of /cvsroot/libsysio/libsysio/drivers/sockets In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25646/drivers/sockets Removed Files: module.mk sockets.c Log Message: Removing obsolete code related to cplant yod, lustre hack, and sockets driver. --- module.mk DELETED --- --- sockets.c DELETED --- |
From: Lee W. <lw...@us...> - 2008-07-26 01:34:20
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8837 Modified Files: fs.c Log Message: The file system record now maintains the list of associated i-nodes as a tree. This speeds up _sysio_i_find greatly when the names table cache is allowed to become large. Index: fs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fs.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- fs.c 17 Jun 2008 17:18:57 -0000 1.16 +++ fs.c 26 Jul 2008 01:34:17 -0000 1.17 @@ -41,6 +41,7 @@ * le...@sa... */ +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <errno.h> @@ -143,22 +144,18 @@ _sysio_fs_new(struct filesys_ops *ops, u void _sysio_fs_gone(struct filesys *fs) { - size_t n; - struct itable_entry *head; struct inode *ino; if (fs->fs_ref) abort(); - n = FS_ITBLSIZ; - do { - head = &fs->fs_itbl[--n]; - while ((ino = head->lh_first)) { + /* + * Destroy all remaining i-nodes in the per-FS cache. + */ + while (fs->fs_icache) { + ino = TREE_ENTRY(fs->fs_icache, inode, i_tnode); I_LOCK(ino); I_GONE(ino); } - } while (n); - if (n) - abort(); (*fs->fs_ops.fsop_gone)(fs); free(fs); |
From: Lee W. <lw...@us...> - 2008-07-26 01:33:17
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8449 Modified Files: inode.h fs.h Log Message: The file system record now maintains the list of associated i-nodes as a tree. This speeds up _sysio_i_find greatly when the names table cache is allowed to become large. In struct inode, moved the file ID pointer and tree-node pointer to the top of the record. Removed definitions relative to the old per-FS i-nodes hashes. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.42 retrieving revision 1.43 diff -u -w -b -B -p -r1.42 -r1.43 --- inode.h 14 Jul 2008 19:14:07 -0000 1.42 +++ inode.h 26 Jul 2008 01:33:14 -0000 1.43 @@ -128,7 +128,8 @@ struct inode_ops { * An i-node record is maintained for each file object in the system. */ struct inode { - LIST_ENTRY(inode) i_link; /* FS i-nodes link */ + struct file_identifier *i_fid; /* file ident */ + struct tree_node i_tnode; /* cache tnode record */ mutex_t i_mutex; /* record mutex */ unsigned i_lckcnt; /* # recursive locks */ unsigned @@ -138,7 +139,6 @@ struct inode { struct inode_ops i_ops; /* operations */ struct intnl_stat i_stbuf; /* attrs */ struct filesys *i_fs; /* file system ptr */ - struct file_identifier *i_fid; /* file ident */ void *i_private; /* driver data */ TAILQ_ENTRY(inode) i_nodes; /* all i-nodes link */ }; @@ -148,6 +148,9 @@ struct inode { */ #define I_INIT(ino, fs, stat, ops, fid, immunity, private) \ do { \ + (ino)->i_fid = (fid); \ + (ino)->i_tnode.tn_key = (fid); \ + (ino)->i_tnode.tn_left = (ino)->i_tnode.tn_right = NULL; \ mutex_init(&(ino)->i_mutex, MUTEX_RECURSIVE); \ (ino)->i_lckcnt = 0; \ (ino)->i_immune = (immunity) ? 1 : 0; \ @@ -156,7 +159,6 @@ struct inode { (ino)->i_ops = *(ops); \ (ino)->i_stbuf = *(stat); \ (ino)->i_fs = (fs); \ - (ino)->i_fid = (fid); \ (ino)->i_private = (private); \ } while (0) Index: fs.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/fs.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- fs.h 30 Nov 2007 18:12:52 -0000 1.8 +++ fs.h 26 Jul 2008 01:33:14 -0000 1.9 @@ -92,21 +92,6 @@ struct filesys_ops { }; /* - * Define the desired size of the file system record's inode table. This should - * probably be something fancy that tries to use up a system page, or the - * like. I'm not feeling adventurous right now though. It is prime though. - * That should help out the hash. - */ -#ifndef FS_ITBLSIZ -#define FS_ITBLSIZ 503 -#endif - -/* - * Inode list head record. - */ -LIST_HEAD(itable_entry, inode); - -/* * A filesys record is maintained for each active file system or volume. */ struct filesys { @@ -115,7 +100,7 @@ struct filesys { unsigned fs_flags; /* flags (see below) */ struct filesys_ops fs_ops; /* operations */ void *fs_private; /* driver data */ - struct itable_entry fs_itbl[FS_ITBLSIZ]; /* inodes hash */ + struct tree_node *fs_icache; /* inodes cache */ unsigned long fs_id; /* ID */ size_t fs_bsize; /* DEPRECATED */ }; @@ -130,19 +115,11 @@ struct filesys { */ #define FS_INIT(fs, flags, ops, private) \ do { \ - size_t __i; \ - struct itable_entry *__head; \ - \ (fs)->fs_ref = 1; \ (fs)->fs_flags = (flags); \ (fs)->fs_ops = *(ops); \ (fs)->fs_private = (private); \ - __i = FS_ITBLSIZ; \ - __head = (fs)->fs_itbl; \ - do { \ - LIST_INIT(__head); \ - __head++; \ - } while (--__i); \ + (fs)->fs_icache = NULL; \ (fs)->fs_id = 0; \ } while (0) |
From: Lee W. <lw...@us...> - 2008-07-26 01:31:44
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8078 Modified Files: inode.c Log Message: The file system record now maintains the list of associated i-nodes as a tree. This speeds up _sysio_i_find greatly when the names table cache is allowed to become large. Removed deprecated function named _sysio_prune Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -w -b -B -p -r1.45 -r1.46 --- inode.c 14 Jul 2008 19:15:00 -0000 1.45 +++ inode.c 26 Jul 2008 01:31:40 -0000 1.46 @@ -68,6 +67,10 @@ #ifndef NAMES_TABLE_LEN #define NAMES_TABLE_LEN 251 #endif +/* + * Desired high-water mark. + */ +#define P_RECLAIM_MIN 16 /* * Active i-nodes in the system and the number of same. @@ -79,11 +82,6 @@ static size_t n_inodes = 0; * Number of names tracked by the system. */ static size_t n_names = 0; -/* - * Desired number of base path nodes to maintain. - */ -static size_t desired_names = (3 * NAMES_TABLE_LEN); -static size_t max_names; /* * List of all path-nodes (aliases) that are not currently referenced. @@ -103,6 +101,9 @@ struct pnode *_sysio_root = NULL; static struct { unsigned long long cst_iprobes; unsigned long long cst_ihits; + unsigned long long cst_ireclaims; + unsigned long long cst_iexamined; + unsigned long long cst_idismissed; unsigned long long cst_pbprobes; unsigned long long cst_pbhits; unsigned long long cst_preclaims; @@ -115,6 +116,9 @@ ino_cstats_init() { cstats.cst_iprobes = cstats.cst_ihits = 0; + cstats.cst_ireclaims = + cstats.cst_iexamined = + cstats.cst_idismissed = 0; cstats.cst_pbprobes = cstats.cst_pbhits = 0; cstats.cst_preclaims = cstats.cst_pexamined = @@ -142,8 +146,6 @@ _sysio_i_init() TAILQ_INIT(&_sysio_idle_pnodes); - max_names = desired_names; - #ifdef INO_CACHE_STATS ino_cstats_init(); #endif @@ -160,34 +162,88 @@ i_reclaim() struct inode *next, *ino; size_t t; - t = n_inodes / 2; + 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) continue; + INO_CST_UPDCNT(idismissed); _sysio_i_gone(ino); if (n_inodes < t) break; } } -static unsigned -hash(struct file_identifier *fid) +/* + * 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 + * second, or the result of a memory compare if lengths are the same. + */ +static int +compar_fid(const struct file_identifier *fid1, + const struct file_identifier *fid2) { - size_t n; - unsigned char *ucp; - unsigned hkey; - n = fid->fid_len; - ucp = fid->fid_data; - hkey = 0; - do { - hkey <<= 1; - hkey += *ucp++; - } while (--n); - return hkey; + if (fid1->fid_len < fid2->fid_len) + return -1; + if (fid1->fid_len > fid2->fid_len) + return 1; + return memcmp(fid1->fid_data, fid2->fid_data, fid1->fid_len); +} + +/* + * Insert inode into per-fs inode cache. + * + * NB: The given inode must not already be in the cache. + */ +static void +icache_insert(struct inode *ino) +{ + + if (_sysio_tree_search(&ino->i_tnode, + &ino->i_fs->fs_icache, + (int (*)(const void *, + const void *))compar_fid) != + &ino->i_tnode) + abort(); +} + +/* + * Remove inode from inode cache. + * + * NB: The inode must be present in the cache. + */ +static void +icache_delete(struct inode *ino) +{ + + if (_sysio_tree_delete(ino->i_fid, + &ino->i_fs->fs_icache, + (int (*)(const void *, + const void *))compar_fid) != + &ino->i_tnode) + abort(); +} + +/* + * Find, and return, inode with given file identifier. If not found, NULL is + * returned instead. + */ +static struct inode * +icache_lookup(struct filesys *fs, struct file_identifier *fid) +{ + struct tree_node *tn; + + tn = + _sysio_tree_find(fid, + &fs->fs_icache, + (int (*)(const void *, + const void *))compar_fid); + return tn ? TREE_ENTRY(tn, inode, i_tnode) : NULL; } /* @@ -206,7 +262,6 @@ _sysio_i_new(struct filesys *fs, { struct inode *ino; struct inode_ops operations; - struct itable_entry *head; if (n_inodes > n_names) { /* @@ -244,10 +299,9 @@ _sysio_i_new(struct filesys *fs, I_INIT(ino, fs, stat, &operations, fid, immunity, private); ino->i_ref = 1; TAILQ_INSERT_TAIL(&_sysio_inodes, ino, i_nodes); - head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; - LIST_INSERT_HEAD(head, ino, i_link); I_GET(ino); + icache_insert(ino); I_RELE(ino); n_inodes++; @@ -264,23 +318,13 @@ struct inode * _sysio_i_find(struct filesys *fs, struct file_identifier *fid) { struct inode *ino; - struct itable_entry *head; - head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; - /* - * Look for existing. - */ - for (ino = head->lh_first; ino; ino = ino->i_link.le_next) - if (ino->i_fid->fid_len == fid->fid_len && - memcmp(ino->i_fid->fid_data, - fid->fid_data, - fid->fid_len) == 0) { + INO_CST_UPDCNT(iprobes); + ino = icache_lookup(fs, fid); + if (!ino) + return NULL; I_GET(ino); INO_CST_UPDCNT(ihits); - break; - } - - INO_CST_UPDCNT(iprobes); return ino; } @@ -294,7 +338,7 @@ _sysio_i_gone(struct inode *ino) if (ino->i_ref) abort(); if (!ino->i_zombie) - LIST_REMOVE(ino, i_link); + icache_delete(ino); TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes); (*ino->i_ops.inop_gone)(ino); I_UNLOCK(ino); @@ -314,8 +358,8 @@ _sysio_i_undead(struct inode *ino) if (ino->i_zombie) return; - LIST_REMOVE(ino, i_link); ino->i_zombie = 1; + icache_delete(ino); } #ifdef P_RECLAIM_DEBUG @@ -349,17 +393,11 @@ p_reclaim_debug() * Garbage collect idle path (and base path) nodes tracked by the system. */ static void -p_reclaim(unsigned count) +p_reclaim(unsigned limit) { - int adjust; struct pnode *next, *pno; - size_t t; struct pnode_base *pb; - adjust = 0; - if (count) - adjust = 1; - #ifdef P_RECLAIM_DEBUG p_reclaim_debug(); #endif @@ -368,7 +406,6 @@ p_reclaim(unsigned count) next = _sysio_idle_pnodes.tqh_first; if (!next) return; - t = n_names / 2; do { INO_CST_UPDCNT(pexamined); pno = next; @@ -400,18 +437,7 @@ p_reclaim(unsigned count) _sysio_pb_gone(pb); else PB_UNLOCK(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; - } + } while ((!limit || limit-- > 1) && next); } static int @@ -498,13 +524,6 @@ _sysio_pb_new(struct qstr *name, struct struct pnode_base *pb; static struct qstr noname = { NULL, 0, 0 }; - if (n_names > max_names) { - /* - * Try to limit growth. - */ - p_reclaim(0); - } - pb = malloc(sizeof(struct pnode_base) + name->len); if (!pb) return NULL; @@ -532,12 +551,23 @@ _sysio_pb_new(struct qstr *name, struct ncache_insert(pb); } + n_names++; + assert(n_names); + #ifdef P_RECLAIM_DEBUG LIST_INSERT_HEAD(&pbnodes, pb, pb_links); #endif - 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; } @@ -609,6 +639,10 @@ _sysio_i_shutdown() _sysio_cprintf("inode: probe %llu, hit %llu\n", cstats.cst_iprobes, cstats.cst_ihits); + _sysio_cprintf("inode: reclaims %llu, examined %llu dismissed %llu\n", + cstats.cst_ireclaims, + cstats.cst_iexamined, + cstats.cst_idismissed); _sysio_cprintf("pbnode: probe %llu, hit %llu\n", cstats.cst_pbprobes, cstats.cst_pbhits); @@ -617,7 +651,6 @@ _sysio_i_shutdown() cstats.cst_pexamined, cstats.cst_pdismissed); #endif - max_names = desired_names; return; } @@ -971,32 +1004,6 @@ _sysio_p_find_alias(struct pnode *parent return err; } -#if 0 -/* - * Prune idle path base nodes from the passed sub-tree, including the root. - */ -static void -_sysio_prune(struct pnode_base *rpb) -{ - struct pnode_base *nxtpb, *pb; - - nxtpb = rpb->pb_children.lh_first; - while ((pb = nxtpb)) { - nxtpb = pb->pb_sibs.le_next; - if (pb->pb_aliases.lh_first) - continue; - if (pb->pb_children.lh_first) { - _sysio_prune(pb); - continue; - } - _sysio_pb_gone(pb); - } - if (rpb->pb_children.lh_first) - return; - _sysio_pb_gone(rpb); -} -#endif - static size_t p_remove_aliases(struct mount *mnt, struct pnode_base *pb) { |
From: Lee W. <lw...@us...> - 2008-07-14 19:15:04
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13306/src Modified Files: inode.c Log Message: Directory name cache comparison routine no longer needs parent node as a key. Removed that test. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -w -b -B -p -r1.44 -r1.45 --- inode.c 11 Jul 2008 16:48:01 -0000 1.44 +++ inode.c 14 Jul 2008 19:15:00 -0000 1.45 @@ -419,19 +419,21 @@ compar_pb_key(const struct pnode_base_ke const struct pnode_base_key *pbk2) { +#ifdef notdef if (pbk1->pbk_parent < pbk2->pbk_parent) return -1; if (pbk1->pbk_parent > pbk2->pbk_parent) return 1; +#endif - if (pbk1->pbk_name.len < pbk2->pbk_name.len) + if (pbk1->pbk_name.hashval < pbk2->pbk_name.hashval) return -1; - if (pbk1->pbk_name.len > pbk2->pbk_name.len) + if (pbk1->pbk_name.hashval > pbk2->pbk_name.hashval) return 1; - if (pbk1->pbk_name.hashval < pbk2->pbk_name.hashval) + if (pbk1->pbk_name.len < pbk2->pbk_name.len) return -1; - if (pbk1->pbk_name.hashval > pbk2->pbk_name.hashval) + if (pbk1->pbk_name.len > pbk2->pbk_name.len) return 1; return strncmp(pbk1->pbk_name.name, |
From: Lee W. <lw...@us...> - 2008-07-14 19:14:10
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12946/include Modified Files: inode.h Log Message: Updated copyright date. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.41 retrieving revision 1.42 diff -u -w -b -B -p -r1.41 -r1.42 --- inode.h 11 Jul 2008 18:23:57 -0000 1.41 +++ inode.h 14 Jul 2008 19:14:07 -0000 1.42 @@ -9,7 +9,7 @@ * 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. + * Cplant(TM) Copyright 1998-2008 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 |
From: Lee W. <lw...@us...> - 2008-07-11 18:25:08
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15153 Modified Files: configure.in Log Message: Changed version to 2.0 to reflect the incompatibilites in the drivers API. Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.41 retrieving revision 1.42 diff -u -w -b -B -p -r1.41 -r1.42 --- configure.in 17 Jun 2008 17:18:56 -0000 1.41 +++ configure.in 11 Jul 2008 18:25:05 -0000 1.42 @@ -1,4 +1,4 @@ -AC_INIT(libsysio, 1.4) +AC_INIT(libsysio, 2.0) AC_CANONICAL_HOST |
From: Lee W. <lw...@us...> - 2008-07-11 18:24:02
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14678/src Modified Files: file.c ioctx.c rw.c Log Message: Complete, finally, the change to use pnodes everywhere. Not ported to the new scheme were; sockets, yod, and incore driver. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -w -b -B -p -r1.23 -r1.24 --- file.c 17 Jun 2008 17:18:57 -0000 1.23 +++ file.c 11 Jul 2008 18:23:57 -0000 1.24 @@ -141,7 +141,7 @@ _sysio_fcompletio(struct ioctx *ioctx, s if (ioctx->ioctx_cc <= 0) return; - assert(ioctx->ioctx_ino == fil->f_pno->p_base->pb_ino); + assert(ioctx->ioctx_pno == fil->f_pno); off = fil->f_pos + ioctx->ioctx_cc; if (fil->f_pos && off <= fil->f_pos) abort(); Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -w -b -B -p -r1.28 -r1.29 --- ioctx.c 17 Jun 2008 17:18:57 -0000 1.28 +++ ioctx.c 11 Jul 2008 18:23:57 -0000 1.29 @@ -116,11 +116,7 @@ _sysio_ioctx_new(struct pnode *pno, if (!ioctx) return NULL; -#ifdef not_yet P_REF(pno); -#else - I_REF(pno->p_base->pb_ino); -#endif IOCTX_INIT(ioctx, 0, @@ -190,17 +186,10 @@ _sysio_ioctx_done(struct ioctx *ioctx) if (ioctx->ioctx_done) return 1; -#ifdef not_yet P_GET(ioctx->ioctx_pno); - if (PNOP_IODONE(ioctx->ioctx_pno, ioctx)) + if (PNOP_IODONE(ioctx)) ioctx->ioctx_done = 1; P_PUT(ioctx->ioctx_pno); -#else - I_GET(ioctx->ioctx_ino); - if ((*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx)) - ioctx->ioctx_done = 1; - I_PUT(ioctx->ioctx_ino); -#endif return (int )ioctx->ioctx_done; } @@ -278,10 +267,6 @@ _sysio_ioctx_complete(struct ioctx *ioct if (ioctx->ioctx_fast) return; -#ifdef not_yet P_RELE(ioctx->ioctx_pno); -#else - I_RELE(ioctx->ioctx_ino); -#endif free(ioctx); } Index: rw.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rw.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -w -b -B -p -r1.29 -r1.30 --- rw.c 17 Jun 2008 17:18:57 -0000 1.29 +++ rw.c 11 Jul 2008 18:23:57 -0000 1.30 @@ -64,7 +64,7 @@ typedef enum { READ, WRITE } direction; * Post some IO operation. */ static int -_sysio_post_io(int (*f)(struct inode *ino, struct ioctx *ioctx), +_sysio_post_io(int (*f)(struct ioctx *ioctx), struct pnode *pno, const struct iovec *iov, size_t iov_count, void (*release_iov)(struct ioctx *, void *), @@ -106,7 +106,7 @@ _sysio_post_io(int (*f)(struct inode *in /* * Post the op. */ - err = INOP_CALL(f, pno->p_base->pb_ino, ioctx); + err = INOP_CALL(f, ioctx); } while (0); if (!err) { *ioctxp = ioctx; @@ -137,7 +137,7 @@ free_arg(struct ioctx *ioctx __IS_UNUSED * Post simple asynch, internal, IO operation. */ static int -_do_p_aio(int (*f)(struct inode *ino, struct ioctx *ioctx), +_do_p_aio(int (*f)(struct ioctx *ioctx), struct pnode *pno, _SYSIO_OFF_T off, void *buf, @@ -215,7 +215,7 @@ _sysio_iiox(int writing, { int err; ssize_t cc; - int (*f)(struct inode *, struct ioctx *); + int (*f)(struct ioctx *); err = 0; do { |
From: Lee W. <lw...@us...> - 2008-07-11 18:24:02
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14678/include Modified Files: dev.h inode.h Log Message: Complete, finally, the change to use pnodes everywhere. Not ported to the new scheme were; sockets, yod, and incore driver. Index: dev.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/dev.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- dev.h 9 May 2007 23:16:20 -0000 1.12 +++ dev.h 11 Jul 2008 18:23:57 -0000 1.13 @@ -73,15 +73,13 @@ extern const struct inode_ops _sysio_nod const char *))_sysio_do_illop #define _sysio_nodev_inop_getattr \ (int (*)(struct pnode *, \ - struct inode *, \ struct intnl_stat *))_sysio_do_ebadf #define _sysio_nodev_inop_setattr \ (int (*)(struct pnode *, \ - struct inode *, \ unsigned , \ struct intnl_stat *))_sysio_do_ebadf #define _sysio_nodev_filldirentries \ - (ssize_t (*)(struct inode *, \ + (ssize_t (*)(struct pnode *, \ _SYSIO_OFF_T *, \ char *, \ size_t))_sysio_do_illop @@ -102,7 +100,7 @@ extern const struct inode_ops _sysio_nod int, \ mode_t))_sysio_do_enodev #define _sysio_nodev_inop_close \ - (int (*)(struct inode *))_sysio_do_ebadf + (int (*)(struct pnode *))_sysio_do_ebadf #define _sysio_nodev_inop_link \ (int (*)(struct pnode *, struct pnode *))_sysio_do_illop #define _sysio_nodev_inop_unlink \ @@ -110,26 +108,24 @@ extern const struct inode_ops _sysio_nod #define _sysio_nodev_inop_rename \ (int (*)(struct pnode *, struct pnode *))_sysio_do_illop #define _sysio_nodev_inop_read \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_ebadf + (int (*)(struct ioctx *))_sysio_do_ebadf #define _sysio_nodev_inop_write \ - (int (*)(struct inode *, \ - struct ioctx *))_sysio_do_ebadf + (int (*)(struct ioctx *))_sysio_do_ebadf #define _sysio_nodev_inop_pos \ - (_SYSIO_OFF_T (*)(struct inode *, _SYSIO_OFF_T))_sysio_do_ebadf + (_SYSIO_OFF_T (*)(struct pnode *, _SYSIO_OFF_T))_sysio_do_ebadf #define _sysio_nodev_inop_iodone \ (int (*)(struct ioctx *))_sysio_do_einval #define _sysio_nodev_inop_fcntl \ - (int (*)(struct inode *, \ + (int (*)(struct pnode *, \ int, \ va_list, \ int *))_sysio_do_ebadf #define _sysio_nodev_inop_sync \ - (int (*)(struct inode *))_sysio_do_ebadf + (int (*)(struct pnode *))_sysio_do_ebadf #define _sysio_nodev_inop_datasync \ - (int (*)(struct inode *))_sysio_do_ebadf + (int (*)(struct pnode *))_sysio_do_ebadf #define _sysio_nodev_inop_ioctl \ - (int (*)(struct inode *, \ + (int (*)(struct pnode *, \ unsigned long int, \ va_list))_sysio_do_ebadf #define _sysio_nodev_inop_mknod \ @@ -139,11 +135,10 @@ extern const struct inode_ops _sysio_nod #ifdef _HAVE_STATVFS #define _sysio_nodev_inop_statvfs \ (int (*)(struct pnode *, \ - struct inode *, \ struct intnl_statvfs *))_sysio_do_illop #endif #define _sysio_nodev_inop_gone \ - (void (*)(struct inode *ino))_sysio_do_noop + (void (*)(struct inode *))_sysio_do_noop extern int _sysio_dev_init(void); extern dev_t _sysio_dev_alloc(void); Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.40 retrieving revision 1.41 diff -u -w -b -B -p -r1.40 -r1.41 --- inode.h 11 Jul 2008 16:48:01 -0000 1.40 +++ inode.h 11 Jul 2008 18:23:57 -0000 1.41 @@ -79,17 +79,14 @@ struct ioctx; */ struct inode_ops { int (*inop_lookup)(struct pnode *pno, - struct inode **inop, + struct inode **ino, struct intent *intnt, const char *path); - int (*inop_getattr)(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stbuf); + int (*inop_getattr)(struct pnode *pno, struct intnl_stat *stbuf); int (*inop_setattr)(struct pnode *pno, - struct inode *ino, unsigned mask, struct intnl_stat *stbuf); - ssize_t (*inop_filldirentries)(struct inode *ino, + ssize_t (*inop_filldirentries)(struct pnode *pno, _SYSIO_OFF_T *posp, char *buf, size_t nbytes); @@ -98,23 +95,21 @@ struct inode_ops { int (*inop_symlink)(struct pnode *pno, const char *data); int (*inop_readlink)(struct pnode *pno, char *buf, size_t bufsiz); int (*inop_open)(struct pnode *pno, int flags, mode_t mode); - int (*inop_close)(struct inode *ino); + int (*inop_close)(struct pnode *pno); int (*inop_link)(struct pnode *old, struct pnode *new); int (*inop_unlink)(struct pnode *pno); int (*inop_rename)(struct pnode *old, struct pnode *new); - int (*inop_read)(struct inode *ino, struct ioctx *ioctx); - int (*inop_write)(struct inode *ino, struct ioctx *ioctx); - _SYSIO_OFF_T (*inop_pos)(struct inode *ino, _SYSIO_OFF_T off); - int (*inop_iodone)(struct ioctx *iocp); - int (*inop_fcntl)(struct inode *ino, int cmd, va_list ap, int *rtn); - int (*inop_sync)(struct inode *ino); - int (*inop_datasync)(struct inode *ino); - int (*inop_ioctl)(struct inode *ino, unsigned long int request, va_list ap); + int (*inop_read)(struct ioctx *ioctx); + int (*inop_write)(struct ioctx *ioctx); + _SYSIO_OFF_T (*inop_pos)(struct pnode *pno, _SYSIO_OFF_T off); + int (*inop_iodone)(struct ioctx *ioctx); + int (*inop_fcntl)(struct pnode *pno, int cmd, va_list ap, int *rtn); + int (*inop_sync)(struct pnode *pno); + int (*inop_datasync)(struct pnode *pno); + int (*inop_ioctl)(struct pnode *pno, unsigned long int request, va_list ap); int (*inop_mknod)(struct pnode *pno, mode_t mode, dev_t dev); #ifdef _HAVE_STATVFS - int (*inop_statvfs)(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); + int (*inop_statvfs)(struct pnode *pno, struct intnl_statvfs *buf); #endif void (*inop_gone)(struct inode *ino); }; @@ -509,13 +504,12 @@ struct pnode { #define PNOP_LOOKUP(_pno, _inop, _intnt, _path) \ _PNOP_MKCALL((_pno), lookup, (_pno), (_inop), (_intnt), (_path)) #define PNOP_GETATTR(_pno, _stbuf) \ - _PNOP_CALL((_pno), getattr, (_pno), (_pno)->p_base->pb_ino, (_stbuf)) + _PNOP_CALL((_pno), getattr, (_pno), (_stbuf)) #define PNOP_SETATTR(_pno, _mask, _stbuf) \ _PNOP_CALL((_pno), setattr, \ - (_pno), (_pno)->p_base->pb_ino, (_mask), (_stbuf)) + (_pno), (_mask), (_stbuf)) #define PNOP_FILLDIRENTRIES(_pno, _posp, _buf, _nbytes) \ - _PNOP_CALL((_pno), filldirentries, \ - (_pno)->p_base->pb_ino, (_posp), (_buf), (_nbytes)) + _PNOP_CALL((_pno), filldirentries, (_pno), (_posp), (_buf), (_nbytes)) #define PNOP_MKDIR(_pno, _mode) \ _PNOP_MKCALL((_pno), mkdir, (_pno), (_mode)) #define PNOP_RMDIR(_pno) \ @@ -527,37 +521,35 @@ struct pnode { #define PNOP_OPEN(_pno, _flags, _mode) \ _PNOP_MKCALL((_pno), open, (_pno), (_flags), (_mode)) #define PNOP_CLOSE(_pno) \ - _PNOP_CALL((_pno), close, (_pno)->p_base->pb_ino) + _PNOP_CALL((_pno), close, (_pno)) #define PNOP_LINK(_old, _new) \ _PNOP_CALL((_old), link, (_old), (_new)) #define PNOP_UNLINK(_pno) \ _PNOP_CALL((_pno), unlink, (_pno)) #define PNOP_RENAME(_old, _new) \ _PNOP_CALL((_old), rename, (_old), (_new)) -#define PNOP_READ(_pno, _ioctx) \ - _PNOP_CALL((_pno), read, (_pno)->p_base->pb_ino, (_ioctx)) -#define PNOP_WRITE(_pno, _ioctx) \ - _PNOP_CALL((_pno), write, (_pno)->p_base->pb_ino, (_ioctx)) +#define PNOP_READ(_ioctx) \ + _PNOP_CALL((_ioctx)->ioctx_pno, read, (_ioctx)) +#define PNOP_WRITE(_ioctx) \ + _PNOP_CALL((_ioctx)->ioctx_pno, write, (_ioctx)) #define PNOP_POS(_pno, _off) \ - _PNOP_CALL((_pno), pos, (_pno)->p_base->pb_ino, (_off)) -#define PNOP_IODONE(_pno, _ioctx) \ - _PNOP_CALL((_pno), iodone, (_ioctx)) + _PNOP_CALL((_pno), pos, (_pno), (_off)) +#define PNOP_IODONE(_ioctx) \ + _PNOP_CALL((_ioctx)->ioctx_pno, iodone, (_ioctx)) #define PNOP_FCNTL(_pno, _cmd, _ap, _rtn) \ - _PNOP_CALL((_pno), fcntl, (_pno)->p_base->pb_ino, (_cmd), (_ap), (_rtn)) + _PNOP_CALL((_pno), fcntl, (_pno), (_cmd), (_ap), (_rtn)) #define PNOP_SYNC(_pno) \ - _PNOP_CALL((_pno), sync, (_pno)->p_base->pb_ino) + _PNOP_CALL((_pno), sync, (_pno)) #define PNOP_DATASYNC(_pno) \ - _PNOP_CALL((_pno), datasync, (_pno)->p_base->pb_ino) + _PNOP_CALL((_pno), datasync, (_pno)) #define PNOP_IOCTL(_pno, _request, _ap) \ - _PNOP_CALL((_pno), ioctl, (_pno)->p_base->pb_ino, (_request), (_ap)) + _PNOP_CALL((_pno), ioctl, (_pno), (_request), (_ap)) #define PNOP_MKNOD(_pno, _mode, _dev) \ _PNOP_MKCALL((_pno), mknod, (_pno), (_mode), (_dev)) #ifdef _HAVE_STATVFS #define PNOP_STATVFS(_pno, _buf) \ - _PNOP_CALL((_pno), statvfs, (_pno), (_pno)->p_base->pb_ino, (_buf)) + _PNOP_CALL((_pno), statvfs, (_pno), (_buf)) #endif -#define PNOP_GONE(_pno) \ - _PNOP_CALL((_pno), gone, (_pno)->p_base->pb_ino) /* * An intent record allows callers of namei and lookup to pass some information @@ -650,10 +642,7 @@ struct ioctx { ioctx_fast : 1, /* from stack space */ ioctx_done : 1, /* transfer complete */ ioctx_write : 1; /* op is a write */ -#ifdef not_yet struct pnode *ioctx_pno; /* p-node */ -#endif - struct inode *ioctx_ino; /* i-node (deprecate) */ const struct iovec *ioctx_iov; /* scatter/gather vec */ size_t ioctx_iovlen; /* iovec length */ const struct intnl_xtvec *ioctx_xtv; /* extents */ @@ -672,7 +661,7 @@ struct ioctx { (ioctx)->ioctx_fast = (fast); \ (ioctx)->ioctx_done = 0; \ (ioctx)->ioctx_write = (wr) ? 1 : 0; \ - (ioctx)->ioctx_ino = (pno)->p_base->pb_ino; \ + (ioctx)->ioctx_pno = (pno); \ (ioctx)->ioctx_iov = (iov); \ (ioctx)->ioctx_iovlen = (iovlen); \ (ioctx)->ioctx_xtv = (xtv); \ |
From: Lee W. <lw...@us...> - 2008-07-11 18:24:02
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14678/dev/stdfd Modified Files: stdfd.c Log Message: Complete, finally, the change to use pnodes everywhere. Not ported to the new scheme were; sockets, yod, and incore driver. Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -b -B -p -r1.15 -r1.16 --- stdfd.c 17 Jun 2008 15:10:39 -0000 1.15 +++ stdfd.c 11 Jul 2008 18:23:56 -0000 1.16 @@ -77,13 +77,13 @@ */ static int stdfd_open(struct pnode *pno, int flags, mode_t mode); -static int stdfd_close(struct inode *ino); -static int stdfd_read(struct inode *ino, struct ioctx *ioctx); -static int stdfd_write(struct inode *ino, struct ioctx *ioctx); +static int stdfd_close(struct pnode *pno); +static int stdfd_read(struct ioctx *ioctx); +static int stdfd_write(struct ioctx *ioctx); static int stdfd_iodone(struct ioctx *ioctx); -static int stdfd_datasync(struct inode *ino); -static int stdfd_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int stdfd_ioctl(struct inode *ino, +static int stdfd_datasync(struct pnode *pno); +static int stdfd_fcntl(struct pnode *pno, int cmd, va_list ap, int *rtn); +static int stdfd_ioctl(struct pnode *pno, unsigned long int request, va_list ap); @@ -122,7 +122,7 @@ stdfd_open(struct pnode *pno __IS_UNUSED } static int -stdfd_close(struct inode *ino __IS_UNUSED) +stdfd_close(struct pnode *pno __IS_UNUSED) { return 0; @@ -130,9 +130,9 @@ stdfd_close(struct inode *ino __IS_UNUSE static int doio(ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, struct inode *), - struct inode *ino, struct ioctx *ioctx) { + struct inode *ino; if (ioctx->ioctx_xtvlen != 1) { /* @@ -141,6 +141,8 @@ doio(ssize_t (*f)(void *, size_t, _SYSIO */ return -EINVAL; } + ino = ioctx->ioctx_pno->p_base->pb_ino; + assert(ino); ioctx->ioctx_cc = _sysio_doio(ioctx->ioctx_xtv, ioctx->ioctx_xtvlen, ioctx->ioctx_iov, ioctx->ioctx_iovlen, @@ -169,10 +171,10 @@ stdfd_read_simple(void *buf, } static int -stdfd_read(struct inode *ino, struct ioctx *ioctx) +stdfd_read(struct ioctx *ioctx) { - return doio(stdfd_read_simple, ino, ioctx); + return doio(stdfd_read_simple, ioctx); } static ssize_t @@ -191,19 +193,18 @@ stdfd_write_simple(const void *buf, } static int -stdfd_write(struct inode *ino, struct ioctx *ioctx) +stdfd_write(struct ioctx *ioctx) { return doio((ssize_t (*)(void *, size_t, _SYSIO_OFF_T, struct inode *))stdfd_write_simple, - ino, ioctx); } static int -stdfd_iodone(struct ioctx *iocp __IS_UNUSED) +stdfd_iodone(struct ioctx *ioctx __IS_UNUSED) { /* @@ -213,15 +214,19 @@ stdfd_iodone(struct ioctx *iocp __IS_UNU } static int -stdfd_fcntl(struct inode *ino, +stdfd_fcntl(struct pnode *pno, int cmd, va_list ap, int *rtn) { + struct inode *ino; + int fd; int err; - int fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); long arg; + ino = pno->p_base->pb_ino; + assert(ino); + fd = SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev); err = 0; switch (cmd) { case F_GETFL: @@ -244,7 +249,7 @@ stdfd_fcntl(struct inode *ino, } static int -stdfd_datasync(struct inode *ino __IS_UNUSED) +stdfd_datasync(struct pnode *pno __IS_UNUSED) { /* @@ -254,7 +259,7 @@ stdfd_datasync(struct inode *ino __IS_UN } static int -stdfd_ioctl(struct inode *ino __IS_UNUSED, +stdfd_ioctl(struct pnode *pno __IS_UNUSED, unsigned long int request __IS_UNUSED, va_list ap __IS_UNUSED) { |
From: Lee W. <lw...@us...> - 2008-07-11 18:24:02
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14678/drivers/native Modified Files: fs_native.c Log Message: Complete, finally, the change to use pnodes everywhere. Not ported to the new scheme were; sockets, yod, and incore driver. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -w -b -B -p -r1.66 -r1.67 --- fs_native.c 17 Jun 2008 17:18:57 -0000 1.66 +++ fs_native.c 11 Jul 2008 18:23:57 -0000 1.67 @@ -164,13 +164,11 @@ static int native_inop_lookup(struct pno struct intent *intnt, const char *path); static int native_inop_getattr(struct pnode *pno, - struct inode *ino, struct intnl_stat *stbuf); static int native_inop_setattr(struct pnode *pno, - struct inode *ino, unsigned mask, struct intnl_stat *stbuf); -static ssize_t native_filldirentries(struct inode *ino, +static ssize_t native_filldirentries(struct pnode *pno, _SYSIO_OFF_T *posp, char *buf, size_t nbytes); @@ -179,25 +177,23 @@ static int native_inop_rmdir(struct pnod static int native_inop_symlink(struct pnode *pno, const char *data); static int native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); static int native_inop_open(struct pnode *pno, int flags, mode_t mode); -static int native_inop_close(struct inode *ino); +static int native_inop_close(struct pnode *pno); static int native_inop_link(struct pnode *old, struct pnode *new); static int native_inop_unlink(struct pnode *pno); static int native_inop_rename(struct pnode *old, struct pnode *new); -static int native_inop_read(struct inode *ino, struct ioctx *ioctx); -static int native_inop_write(struct inode *ino, struct ioctx *ioctx); -static _SYSIO_OFF_T native_inop_pos(struct inode *ino, _SYSIO_OFF_T off); +static int native_inop_read(struct ioctx *ioctx); +static int native_inop_write(struct ioctx *ioctx); +static _SYSIO_OFF_T native_inop_pos(struct pnode *pno, _SYSIO_OFF_T off); static int native_inop_iodone(struct ioctx *ioctx); -static int native_inop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn); -static int native_inop_sync(struct inode *ino); -static int native_inop_datasync(struct inode *ino); -static int native_inop_ioctl(struct inode *ino, +static int native_inop_fcntl(struct pnode *pno, int cmd, va_list ap, int *rtn); +static int native_inop_sync(struct pnode *pno); +static int native_inop_datasync(struct pnode *pno); +static int native_inop_ioctl(struct pnode *pno, unsigned long int request, va_list ap); static int native_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev); #ifdef _HAVE_STATVFS -static int native_inop_statvfs(struct pnode *pno, - struct inode *ino, - struct intnl_statvfs *buf); +static int native_inop_statvfs(struct pnode *pno, struct intnl_statvfs *buf); #endif static void native_inop_gone(struct inode *ino); @@ -686,12 +682,13 @@ native_inop_lookup(struct pnode *pno, } static int -native_inop_getattr(struct pnode *pno, - struct inode *ino, - struct intnl_stat *stat) +native_inop_getattr(struct pnode *pno, struct intnl_stat *stat) { - struct native_inode *nino; int err; + char *path; + struct inode *ino; + struct filesys *fs; + time_t t; /* * We just cannot use the cached attributes when getattr is @@ -702,35 +699,16 @@ native_inop_getattr(struct pnode *pno, * pretty volatile anyway. */ err = 0; /* compiler cookie */ - if (pno) { - char *path; - struct filesys *fs; - time_t t; path = _sysio_pb_path(pno->p_base, '/'); if (!path) return -ENOMEM; + ino = pno->p_base->pb_ino; + assert(ino); fs = pno->p_mount->mnt_fs; t = _SYSIO_LOCAL_TIME(); err = native_stat(path, ino, t + FS2NFS(fs)->nfs_atimo, stat); free(path); - } else if ((nino = I2NI(ino))->ni_fd >= 0) - /* - * Don't have access to the fs record anymore. Just - * refresh but keep the current timeout. - */ - err = native_stat(NULL, ino, nino->ni_attrtim, stat); - else { - /* - * Dev inodes don't open in this driver. We won't have - * a file descriptor with which to do the deed then. Satisfy - * the request from the cached copy of the attributes. - */ - (void )memcpy(stat, - &ino->i_stbuf, - sizeof(struct intnl_stat)); - err = 0; - } return err; } @@ -761,23 +739,22 @@ _ut(const char *path, time_t actime, tim static int native_inop_setattr(struct pnode *pno, - struct inode *ino, unsigned mask, struct intnl_stat *stat) { char *path; + struct inode *ino; struct native_inode *nino; int fd; int err; path = NULL; + ino = pno->p_base->pb_ino; nino = ino ? I2NI(ino) : NULL; fd = -1; if (nino) fd = nino->ni_fd; if (fd < 0 || mask & (SETATTR_MTIME|SETATTR_ATIME)) { - if (!pno) - return -EEXIST; path = _sysio_pb_path(pno->p_base, '/'); if (!path) return -ENOMEM; @@ -1004,12 +981,13 @@ native_ifilldirentries(struct native_ino } static ssize_t -native_filldirentries(struct inode *ino, +native_filldirentries(struct pnode *pno, _SYSIO_OFF_T *posp, char *buf, size_t nbytes) { - struct native_inode *nino = I2NI(ino); + struct inode *ino; + struct native_inode *nino; #ifdef DIR_CVT_64 char *bp; size_t count; @@ -1023,6 +1001,9 @@ native_filldirentries(struct inode *ino, #endif ssize_t cc; + ino = pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); assert(nino->ni_fd >= 0); #ifdef DIR_CVT_64 @@ -1233,11 +1214,15 @@ native_inop_open(struct pnode *pno, int } static int -native_inop_close(struct inode *ino) +native_inop_close(struct pnode *pno) { - struct native_inode *nino = I2NI(ino); + struct inode *ino; + struct native_inode *nino; int err; + ino = pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); if (nino->ni_fd < 0) abort(); @@ -1489,6 +1474,7 @@ order_xtv(const struct intnl_xtvec *xtv1 static int doio(char op, struct ioctx *ioctx) { + struct inode *ino; struct native_inode *nino; #if 0 int dolocks; @@ -1501,7 +1487,9 @@ doio(char op, struct ioctx *ioctx) struct intnl_xtvec *front, *rear, tmp; #endif - nino = I2NI(ioctx->ioctx_ino); + ino = ioctx->ioctx_pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); #if 0 dolocks = ioctx->ioctx_xtvlen > 1 && nino->ni_seekok; if (dolocks) { @@ -1565,25 +1553,29 @@ doio(char op, struct ioctx *ioctx) } static int -native_inop_read(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) +native_inop_read(struct ioctx *ioctx) { return doio('r', ioctx); } static int -native_inop_write(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) +native_inop_write(struct ioctx *ioctx) { return doio('w', ioctx); } static _SYSIO_OFF_T -native_inop_pos(struct inode *ino, _SYSIO_OFF_T off) +native_inop_pos(struct pnode *pno, _SYSIO_OFF_T off) { - struct native_inode *nino = I2NI(ino); + struct inode *ino; + struct native_inode *nino; int err; + ino = pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); err = native_pos(nino->ni_fd, &off, SEEK_SET); return err < 0 ? err : off; } @@ -1599,15 +1591,19 @@ native_inop_iodone(struct ioctx *ioctxp } static int -native_inop_fcntl(struct inode *ino, +native_inop_fcntl(struct pnode *pno, int cmd, va_list ap, int *rtn) { - struct native_inode *nino = I2NI(ino); + struct inode *ino; + struct native_inode *nino; long arg; int err; + ino = pno->p_base->pb_ino; + assert(ino); + nino = I2NI(ino); if (nino->ni_fd < 0) abort(); @@ -1655,14 +1651,15 @@ native_inop_mknod(struct pnode *pno __IS #ifdef _HAVE_STATVFS static int native_inop_statvfs(struct pnode *pno, - struct inode *ino, struct intnl_statvfs *buf) { char *path; + struct inode *ino; int rc; struct statfs fs; path = NULL; + ino = pno->p_base->pb_ino; if (!ino || I2NI(ino)->ni_fd < 0) { path = _sysio_pb_path(pno->p_base, '/'); if (!path) @@ -1703,10 +1700,13 @@ native_inop_statvfs(struct pnode *pno, #endif static int -native_inop_sync(struct inode *ino) +native_inop_sync(struct pnode *pno) { + struct inode *ino; int err; + ino = pno->p_base->pb_ino; + assert(ino); assert(I2NI(ino)->ni_fd >= 0); err = syscall(SYSIO_SYS_fsync, I2NI(ino)->ni_fd); @@ -1716,11 +1716,14 @@ native_inop_sync(struct inode *ino) } static int -native_inop_datasync(struct inode *ino) +native_inop_datasync(struct pnode *pno) { + struct inode *ino; struct native_inode *nino; int err; + ino = pno->p_base->pb_ino; + assert(ino); nino = I2NI(ino); assert(nino->ni_fd >= 0); @@ -1739,14 +1742,17 @@ native_inop_datasync(struct inode *ino) #ifdef HAVE_LUSTRE_HACK static int -native_inop_ioctl(struct inode *ino, +native_inop_ioctl(struct pnode *pno, unsigned long int request, va_list ap) { + struct inode *ino; struct native_inode *nino; long arg1, arg2, arg3, arg4; int rtn; + ino = pno->p_base->pb_ino; + assert(ino); nino = I2NI(ino); assert(nino->ni_fd >= 0); arg1 = va_arg(ap, long); @@ -1763,7 +1769,7 @@ native_inop_ioctl(struct inode *ino, } #else static int -native_inop_ioctl(struct inode *ino __IS_UNUSED, +native_inop_ioctl(struct pnode *pno __IS_UNUSED, unsigned long int request __IS_UNUSED, va_list ap __IS_UNUSED) { |
From: Lee W. <lw...@us...> - 2008-07-11 18:24:02
|
Update of /cvsroot/libsysio/libsysio/dev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14678/dev Modified Files: stddev.c Log Message: Complete, finally, the change to use pnodes everywhere. Not ported to the new scheme were; sockets, yod, and incore driver. Index: stddev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stddev.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- stddev.c 17 Jun 2008 15:17:30 -0000 1.2 +++ stddev.c 11 Jul 2008 18:23:56 -0000 1.3 @@ -62,12 +62,12 @@ */ static int stddev_open(struct pnode *pno, int flags, mode_t mode); -static int stddev_close(struct inode *ino); -static int stddev_read(struct inode *ino, struct ioctx *ioctx); -static int stddev_write(struct inode *ino, struct ioctx *ioctx); +static int stddev_close(struct pnode *pno); +static int stddev_read(struct ioctx *ioctx); +static int stddev_write(struct ioctx *ioctx); static int stddev_iodone(struct ioctx *ioctx); -static int stddev_datasync(struct inode *ino); -static int stddev_ioctl(struct inode *ino, +static int stddev_datasync(struct pnode *pno); +static int stddev_ioctl(struct pnode *pno, unsigned long int request, va_list ap); @@ -122,7 +122,7 @@ stddev_open(struct pnode *pno, } static int -stddev_close(struct inode *ino __IS_UNUSED) +stddev_close(struct pnode *pno __IS_UNUSED) { return 0; @@ -131,9 +131,12 @@ stddev_close(struct inode *ino __IS_UNUS static ssize_t doread(void *cp, size_t n, _SYSIO_OFF_T off __IS_UNUSED, struct ioctx *ioctx) { + struct inode *ino;; ssize_t cc; - switch (SYSIO_MINOR_DEV(ioctx->ioctx_ino->i_stbuf.st_rdev)) { + ino = ioctx->ioctx_pno->p_base->pb_ino; + assert(ino); + switch (SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev)) { case SYSIO_STDDEV_NULL_MINOR: cc = 0; break; @@ -158,9 +161,12 @@ dowrite(void *cp __IS_UNUSED, _SYSIO_OFF_T off __IS_UNUSED, struct ioctx *ioctx) { + struct inode *ino; ssize_t cc; - switch (SYSIO_MINOR_DEV(ioctx->ioctx_ino->i_stbuf.st_rdev)) { + ino = ioctx->ioctx_pno->p_base->pb_ino; + assert(ino); + switch (SYSIO_MINOR_DEV(ino->i_stbuf.st_rdev)) { case SYSIO_STDDEV_NULL_MINOR: /* * Fall into... @@ -200,14 +206,14 @@ doio(struct ioctx *ioctx, } static int -stddev_read(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) +stddev_read(struct ioctx *ioctx) { return doio(ioctx, doread); } static int -stddev_write(struct inode *ino __IS_UNUSED, struct ioctx *ioctx) +stddev_write(struct ioctx *ioctx) { return doio(ioctx, dowrite); @@ -224,7 +230,7 @@ stddev_iodone(struct ioctx *ioctx __IS_U } static int -stddev_datasync(struct inode *ino __IS_UNUSED) +stddev_datasync(struct pnode *pno __IS_UNUSED) { /* @@ -234,7 +240,7 @@ stddev_datasync(struct inode *ino __IS_U } static int -stddev_ioctl(struct inode *ino __IS_UNUSED, +stddev_ioctl(struct pnode *pno __IS_UNUSED, unsigned long int request __IS_UNUSED, va_list ap __IS_UNUSED) { |
From: Lee W. <lw...@us...> - 2008-07-11 16:48:06
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8234/include Modified Files: inode.h Log Message: Added per-directory name cache, replacing the global names cache. This involved: 1) Adding a root node for the binary tree to the path_base record. 2) Removing the global names cache from inode.c 3) Altering the implementation of ncache_{insert,delete} to use the parent node's names root as root. 4) Altering ncache_lookup to take the parent node and use it's root to find the key. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.39 retrieving revision 1.40 diff -u -w -b -B -p -r1.39 -r1.40 --- inode.h 17 Jun 2008 17:18:57 -0000 1.39 +++ inode.h 11 Jul 2008 16:48:01 -0000 1.40 @@ -272,6 +272,7 @@ struct qstr { struct pnode_base { mutex_t pb_mutex; /* record mutex */ unsigned pb_lckcnt; /* # recursive locks */ + struct tree_node *pb_ncache; /* names cache */ struct tree_node pb_tentry; /* cache node entry */ struct pnode_base_key { struct qstr pbk_name; /* entry name */ @@ -293,6 +294,7 @@ struct pnode_base { do { \ mutex_init(&(_pb)->pb_mutex, MUTEX_RECURSIVE); \ (_pb)->pb_lckcnt = 0; \ + (_pb)->pb_ncache = NULL; \ (_pb)->pb_tentry.tn_key = &(_pb)->pb_key; \ (_pb)->pb_tentry.tn_left = (_pb)->pb_tentry.tn_right = NULL; \ (_pb)->pb_key.pbk_name = *(_name); \ |
From: Lee W. <lw...@us...> - 2008-07-11 16:48:05
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8234/src Modified Files: inode.c Log Message: Added per-directory name cache, replacing the global names cache. This involved: 1) Adding a root node for the binary tree to the path_base record. 2) Removing the global names cache from inode.c 3) Altering the implementation of ncache_{insert,delete} to use the parent node's names root as root. 4) Altering ncache_lookup to take the parent node and use it's root to find the key. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -w -b -B -p -r1.43 -r1.44 --- inode.c 17 Jun 2008 17:18:57 -0000 1.43 +++ inode.c 11 Jul 2008 16:48:01 -0000 1.44 @@ -76,23 +76,6 @@ struct inodes_head _sysio_inodes; static size_t n_inodes = 0; /* - * System table for rapid access to component names. - */ -static struct tree_node *names[NAMES_TABLE_LEN]; - -/* - * Return slot index in names table given pointer to path base key. - */ -#define ncache_key_index(pbk) \ - ((pbk)->pbk_name.hashval % NAMES_TABLE_LEN) - -/* - * Return ptr to slot in names table given hash value. - */ -#define ncache_slot(h) \ - (names[(h)] % NAMES_TABLE_LEN) - -/* * Number of names tracked by the system. */ static size_t n_names = 0; @@ -154,13 +137,9 @@ ino_cstats_init() int _sysio_i_init() { - unsigned i; TAILQ_INIT(&_sysio_inodes); - for (i = 0; i < NAMES_TABLE_LEN; i++) - names[i] = NULL; - TAILQ_INIT(&_sysio_idle_pnodes); max_names = desired_names; @@ -467,8 +446,9 @@ static void ncache_insert(struct pnode_base *pb) { + assert(pb->pb_key.pbk_parent); if (_sysio_tree_search(&pb->pb_tentry, - &names[ncache_key_index(&pb->pb_key)], + &pb->pb_key.pbk_parent->pb_ncache, (int (*)(const void *, const void *))compar_pb_key) != &pb->pb_tentry) @@ -482,8 +462,9 @@ static void ncache_delete(struct pnode_base *pb) { + assert(pb->pb_key.pbk_parent); if (_sysio_tree_delete(&pb->pb_key, - &names[ncache_key_index(&pb->pb_key)], + &pb->pb_key.pbk_parent->pb_ncache, (int (*)(const void *, const void *))compar_pb_key) != &pb->pb_tentry) @@ -494,13 +475,13 @@ ncache_delete(struct pnode_base *pb) * Lookup path base node in the system name cache given key info. */ static struct pnode_base * -ncache_lookup(struct pnode_base_key *pbk) +ncache_lookup(struct pnode_base *pb, struct pnode_base_key *pbk) { struct tree_node *tn; tn = _sysio_tree_find(pbk, - &names[ncache_key_index(pbk)], + &pb->pb_ncache, (int (*)(const void *, const void *))compar_pb_key); return tn ? TREE_ENTRY(tn, pnode_base, pb_tentry) : NULL; @@ -936,7 +917,7 @@ _sysio_p_find_alias(struct pnode *parent INO_CST_UPDCNT(pbprobes); key.pbk_name = *name; key.pbk_parent = parent->p_base; - pb = ncache_lookup(&key); + pb = ncache_lookup(key.pbk_parent, &key); if (pb) { PB_GET(pb); INO_CST_UPDCNT(pbhits); |
From: Lee W. <lw...@us...> - 2008-06-18 15:58:14
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1603 Modified Files: mount.c Log Message: Fixed a bug in _sysio_do_mount. It wasn't properly checking that the object to cover was a directory. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- mount.c 17 Jun 2008 17:18:57 -0000 1.30 +++ mount.c 18 Jun 2008 15:50:39 -0000 1.31 @@ -127,9 +127,10 @@ _sysio_do_mount(struct filesys *fs, * Directories only, please. */ if ((tocover && - (tocover->p_base->pb_ino && + !(tocover->p_base->pb_ino && S_ISDIR(tocover->p_base->pb_ino->i_stbuf.st_mode))) || - !rootpb->pb_ino || !S_ISDIR(rootpb->pb_ino->i_stbuf.st_mode)) + !(rootpb->pb_ino && + S_ISDIR(rootpb->pb_ino->i_stbuf.st_mode))) return -ENOTDIR; /* |
From: Lee W. <lw...@us...> - 2008-06-17 17:26:56
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17927 Modified Files: module.mk Log Message: Modifed to enumerate the extras directly instead of with an ls on any ...[ch] files found. Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/module.mk,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- module.mk 4 Feb 2005 00:18:52 -0000 1.2 +++ module.mk 17 Jun 2008 17:26:53 -0000 1.3 @@ -1,2 +1,22 @@ -TESTS_EXTRA = $(shell ls tests/*.[ch]) \ +TESTS_EXTRA = \ + tests/test.h \ + tests/drv_init_all.c \ + tests/startup.c \ + tests/sysio-run-start.c \ + tests/test_chown.c \ + tests/test_copy.c \ + tests/test_fcntl_lock.c \ + tests/test_getcwd.c \ + tests/test_link.c \ + tests/test_list.c \ + tests/test_mkdir.c \ + tests/test_mknod.c \ + tests/test_path.c \ + tests/test_regions.c \ + tests/test_rename.c \ + tests/test_stats.c \ + tests/test_statvfs.c \ + tests/test_stddir.c \ + tests/test_symlink.c \ + tests/test_unlink.c \ tests/Makefile.am tests/Makefile.in tests/module.mk |
From: Lee W. <lw...@us...> - 2008-06-17 17:19:10
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12543/drivers/native Modified Files: fs_native.c Log Message: Begin adding support for thread-safe operation. In detail: 1) Add smp.h and smp_posix.c 2) Add a big lock, wrapping the user API with appropriate mutex_lock and mutex_unlock calls. NB; initialization is *not* thread safe. 3) Add support for P_{GET,LOCK}, PB_LOCK, I_{GET,LOCK}, FIL_{GET,LOCK} and alter all related ref/de-ref usage to use get/put or lock/unlock as appropriate. 4) Remedial (no-op) support for MNT_GET. By default, POSIX threads supoprt is not enabled. To enable, use --with-threads, or --with-threads=yes, or --with-threads=posix. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.65 retrieving revision 1.66 diff -u -w -b -B -p -r1.65 -r1.66 --- fs_native.c 24 Sep 2007 19:00:03 -0000 1.65 +++ fs_native.c 17 Jun 2008 17:18:57 -0000 1.66 @@ -466,17 +466,19 @@ create_internal_namespace(const void *da err = _sysio_mounti(fs, rootino, 0, NULL, &mnt); if (err) goto error; - + I_PUT(rootino); /* drop ours */ native_internal_mount = mnt; return 0; error: if (mnt) { if (_sysio_do_unmount(mnt) != 0) abort(); - nfs = NULL; - fs = NULL; rootino = NULL; + fs = NULL; + nfs = NULL; } + if (rootino) + I_RELE(rootino); if (fs) { FS_RELE(fs); nfs = NULL; @@ -537,7 +539,7 @@ native_fsswop_mount(const char *source, * aliases we might have generated. We really don't need to cache them * as they are only used at mount time.. */ - P_RELE(nameidata.nd_pno); + P_PUT(nameidata.nd_pno); (void )_sysio_p_prune(native_internal_mount->mnt_root); if (!err) { |
From: Lee W. <lw...@us...> - 2008-06-17 17:19:06
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12543/include Modified Files: file.h inode.h mount.h sysio-cmn.h Added Files: smp.h Log Message: Begin adding support for thread-safe operation. In detail: 1) Add smp.h and smp_posix.c 2) Add a big lock, wrapping the user API with appropriate mutex_lock and mutex_unlock calls. NB; initialization is *not* thread safe. 3) Add support for P_{GET,LOCK}, PB_LOCK, I_{GET,LOCK}, FIL_{GET,LOCK} and alter all related ref/de-ref usage to use get/put or lock/unlock as appropriate. 4) Remedial (no-op) support for MNT_GET. By default, POSIX threads supoprt is not enabled. To enable, use --with-threads, or --with-threads=yes, or --with-threads=posix. --- NEW FILE --- #ifndef __SMP_H__ #define __SMP_H__ /* * Symmetric multi-processing abstraction. * * Allows compilation and execution to take place in two modes, single or * multi threaded. * * In single thread mode (define SINGLE_THREAD) most locking calls are * emulated. Others cause panics. For instance, it is very hard to * wait on a conditional variable with only a single thread -- no thread * to awaken things later. * * Structure: * * The structure of this file is blocks of implementation for a * mode or thread architecture surrounded by ifdef's. In the first part, * "real" thread packages are abstracted to the POSIX interface. In the * second (unsurrounded) part, common usage with asserts to catch errors, * that should never happen, is defined. * * More often than not, the unsurrounded interface should be used. You * can't though if the common usage doesn't match yours. For example, * if you want to take a mutex but are interested in the return code or * can't have the program abort on failure, use the under-score prepended * version of the routine. * * $Id: smp.h,v 1.1 2008/06/17 17:18:57 lward Exp $ */ #include <assert.h> #ifdef THREAD_MODEL_POSIX #include <pthread.h> #include <semaphore.h> #define THREAD_T_FMT "%lu" typedef pthread_t thread_t; #define thread_self() pthread_self() typedef pthread_mutex_t mutex_t; #define MUTEX_NORMAL PTHREAD_MUTEX_FAST_NP #define MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP extern int _posix_mutex_init_helper(mutex_t *mp, int typ); #define _mutex_init(mp, _typ) _posix_mutex_init_helper((mp), (_typ)) #define _mutex_destroy(mp) pthread_mutex_destroy(mp) #define _mutex_lock(mp) pthread_mutex_lock(mp) #define _mutex_trylock(mp) pthread_mutex_trylock(mp) #define _mutex_unlock(mp) pthread_mutex_unlock(mp) typedef pthread_cond_t cond_t; #define COND_INITIALIZER PTHREAD_COND_INITIALIZER #define _cond_init(condp) pthread_cond_init((condp), NULL) #define _cond_destroy(condp) pthread_cond_destroy(condp) #define _cond_wait(condp, mp) pthread_cond_wait((condp), (mp)) #define _cond_timedwait(condp, mp, tsp) \ pthread_cond_timedwait((condp), (mp), (tsp)) #define _cond_signal(condp) pthread_cond_signal(condp) #define _cond_broadcast(condp) pthread_cond_broadcast(condp) typedef pthread_once_t once_t; #define ONCE_INIT PTHREAD_ONCE_INIT #define _thread_once(oncp, f) pthread_once((oncp), (f)) typedef pthread_key_t thread_key_t; #define _thread_key_create(keyp, f) pthread_key_create((keyp), (f)) #define _thread_key_delete(key) pthread_key_delete(key) #define _thread_setspecific(key, p) pthread_setspecific((key), (p)) #define _thread_getspecific(key) pthread_getspecific(key) #define _thread_yield() sched_yield() #else typedef unsigned thread_t; #define thread_self() ((thread_t )(0)) typedef struct { unsigned initialized : 1, typ : 2; unsigned lckcnt; } mutex_t; #define MUTEX_NORMAL (1) #define MUTEX_RECURSIVE (2) #define __MUTEX_IF_INIT(mp, action) \ ((mp)->initialized ? (action) : EINVAL) #define __MUTEX_ON_TYPE(mp, normal, recursive) \ ((mp)->typ == MUTEX_NORMAL \ ? (normal) \ : ((mp)->typ == MUTEX_RECURSIVE \ ? (recursive) \ : EINVAL)) #define _mutex_init(mp, _typ) \ ((mp)->initialized = 1, \ (mp)->typ = (_typ), \ (mp)->lckcnt = 0, \ 0) #define _mutex_destroy(mp) \ __MUTEX_IF_INIT((mp), \ (!(mp)->lckcnt \ ? ((mp)->initialized = 0, 0) \ : EBUSY)) #define _mutex_lock(mp) \ __MUTEX_IF_INIT((mp), \ __MUTEX_ON_TYPE((mp), \ ((mp)->lckcnt \ ? EDEADLK \ : (mp)->lckcnt++), \ (++(mp)->lckcnt \ ? 0 \ : ERANGE))) #define _mutex_trylock(mp) \ __MUTEX_IF_INIT((mp), \ __MUTEX_ON_TYPE((mp), \ ((mp)->lckcnt \ ? EBUSY \ : (mp)->lckcnt++), \ (++(mp)->lckcnt \ ? 0 \ : ERANGE))) #define _mutex_unlock(mp) \ __MUTEX_IF_INIT((mp), ((mp)->lckcnt ? (--(mp)->lckcnt, 0) : ERANGE)) typedef unsigned cond_t; #define COND_INITIALIZER (1) #define __COND_IF_INIT(cond, action) \ (*(cond) == COND_INTIALIZER ? (action) : EINVAL) #define _cond_init(condp) ((int )(*(condp) = COND_INITIALIZER)) #define _cond_destroy(condp) ((int )(*(condp) = 0)) #define _cond_wait(condp, mp) \ (__COND_IF_INIT((condp), \ (__MUTEX_IF_INIT((mp), ENOSUP)))) #define _cond_timedwait(condp, mp, tsp) \ (__COND_IF_INIT((condp), \ (__MUTEX_IF_INIT((mp), ENOSUP)))) #define _cond_signal(condp) (0) #define _cond_broadcast(condp) (0) typedef int once_t; #define ONCE_INIT (0) #define _thread_once(oncp, f) (*(oncp) ? 0 : (*(f))(), *(oncp) = 1, 0) typedef struct _thread_key *thread_key_t; #define _thread_key_create(keyp, f) _single_thread_key_create((keyp), (f)) #define _thread_key_delete(key) _single_thread_key_delete(key) #define _thread_setspecific(key, p) _single_thread_setspecific((key), (p)) #define _thread_getspecific(key) _single_thread_getspecific(key) #define _thread_yield() ((int )0) extern int _single_thread_key_create(thread_key_t *, void (*)(void *)); extern int _single_thread_key_delete(thread_key_t); extern int _single_thread_setspecific(thread_key_t, void *); extern void *_single_thread_getspecific(thread_key_t); #endif /* thread model */ #define mutex_init(mp, _typ) assert(_mutex_init((mp), (_typ)) == 0) #define mutex_destroy(mp) assert(_mutex_destroy(mp) == 0) #define mutex_lock(mp) assert(_mutex_lock(mp) == 0) #define mutex_trylock(mp) _mutex_trylock(mp) #define mutex_unlock(mp) assert(_mutex_unlock(mp) == 0) #define cond_init(condp) assert(_cond_init(condp) == 0) #define cond_destroy(condp) assert(_cond_destroy(condp) == 0) #define cond_wait(condp, mp) assert(_cond_wait((condp), (mp)) == 0) #define cond_timedwait(condp, mp, tsp) \ _cond_timedwait((condp), (mp), (tsp)) #define cond_signal(condp) assert(_cond_signal(condp) == 0) #define cond_broadcast(condp) assert(_cond_broadcast(condp) == 0) #define sema_init(semp, val) assert(_sema_init((semp), (val)) == 0) #define sema_destroy(semp) assert(_sema_destroy(semp) == 0) #define sema_wait(semp) assert(_sema_wait(semp) == 0) #define sema_trywait(semp) _sema_trywait(semp) #define sema_post(semp) assert(_sema_post(semp) == 0) #define sema_getvalue(semp, valp) \ assert(_sema_getvalue((semp), (valp)) == 0) #define thread_once(oncp, f) assert(_thread_once((oncp), (f)) == 0) #define thread_key_create(keyp, f) \ assert(_thread_key_create((keyp), (f)) == 0) #define thread_key_delete(key) assert(_thread_key_delete(key) == 0) #define thread_setspecific(key, p) \ assert(_thread_setspecific((key), (p)) == 0) #define thread_getspecific(key) _thread_getspecific(key) #define thread_yield() assert(_thread_yield() == 0) #endif /* !defined(__SMP_H__) */ Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -b -B -p -r1.20 -r1.21 --- file.h 20 Nov 2007 17:34:38 -0000 1.20 +++ file.h 17 Jun 2008 17:18:57 -0000 1.21 @@ -41,6 +41,8 @@ * le...@sa... */ +#include "smp.h" + /* * Open file support. */ @@ -49,17 +51,17 @@ * Test whether large file support on this file. */ #ifdef O_LARGEFILE -#define _F_LARGEFILE(fil) \ +#define _FIL_LARGEFILE(fil) \ ((fil)->f_flags & O_LARGEFILE) #else -#define _F_LARGEFILE(fil) \ +#define _FIL_LARGEFILE(fil) \ (1) #endif /* * Return max seek value for this file. */ #define _SEEK_MAX(fil) \ - (_F_LARGEFILE(fil) ? _SYSIO_OFF_T_MAX : LONG_MAX) + (_FIL_LARGEFILE(fil) ? _SYSIO_OFF_T_MAX : LONG_MAX) #ifdef _LARGEFILE64_SOURCE #define _SYSIO_FLOCK flock64 @@ -73,30 +75,97 @@ * operations that may be performed. */ struct file { + mutex_t f_mutex; /* record mutex */ + unsigned f_lckcnt; /* # recursive locks */ struct pnode *f_pno; /* path node */ _SYSIO_OFF_T f_pos; /* current stream pos */ unsigned f_ref; /* ref count */ int f_flags; /* open/fcntl flags */ }; +#ifdef LOCK_DEBUG +#define _FIL_CHECK_LOCK(_fil, _test) \ + (assert(((_test) && (_fil)->f_lckcnt) || \ + !((_test) || (_fil)->f_lckcnt))) +#else +#define _FIL_CHECK_LOCK(_fil, _test) +#endif + +#define FIL_LOCK(_fil) \ + do { \ + mutex_lock(&(_fil)->f_mutex); \ + (_fil)->f_lckcnt++; \ + _FIL_CHECK_LOCK((_fil), 1); \ + } while (0) + +#define FIL_UNLOCK(_fil) \ + do { \ + _FIL_CHECK_LOCK((_fil), 1); \ + (_fil)->f_lckcnt--; \ + if ((_fil)->f_ref) \ + mutex_unlock(&(_fil)->f_mutex); \ + else \ + _sysio_fgone(_fil); \ + } while (0) + +/* + * Reference a file record. + */ +#define _FIL_REF_NO_LOCK(_fil) \ + do { \ + _FIL_CHECK_LOCK((_fil), 1); \ + (_fil)->f_ref++; \ + assert((_fil)->f_ref); \ + } while (0) + /* * Reference a file record. */ -#define F_REF(fil) \ +#define FIL_REF(_fil) \ do { \ - (fil)->f_ref++; \ - assert((fil)->f_ref); \ + FIL_LOCK(_fil); \ + _FIL_REF_NO_LOCK(_fil); \ + FIL_UNLOCK(_fil); \ } while (0) /* * Release reference to a file record. */ -#define F_RELE(fil) \ +#define _FIL_RELE_NO_LOCK(_fil) \ + do { \ + _FIL_CHECK_LOCK((_fil), 1); \ + (_fil)->f_ref--; \ + } while (0) + +/* + * Release reference to a file record. + */ +#define FIL_RELE(_fil) \ + do { \ + FIL_LOCK(_fil); \ + _FIL_RELE_NO_LOCK(_fil); \ + FIL_UNLOCK(_fil); \ + } while (0) + +/* + * Lock and reference file node; Lock associated path node. + */ +#define FIL_GET(_fil) \ + do { \ + FIL_LOCK(_fil); \ + _FIL_REF_NO_LOCK(_fil); \ + P_GET((_fil)->f_pno); \ + } while (0) + +/* + * Unlock and drop reference to file node; Unlock associated path node. + */ +#define FIL_PUT(_fil) \ do { \ - assert((fil)->f_ref); \ - (fil)->f_ref--; \ - if (!(fil)->f_ref) \ - _sysio_fgone(fil); \ + _FIL_CHECK_LOCK((_fil), 1); \ + P_PUT((_fil)->f_pno); \ + _FIL_RELE_NO_LOCK(_fil); \ + FIL_UNLOCK(_fil); \ } while (0) /* @@ -106,6 +175,8 @@ struct file { */ #define _SYSIO_FINIT(fil, pno, flags) \ do { \ + mutex_init(&(fil)->f_mutex, MUTEX_RECURSIVE); \ + (fil)->f_lckcnt = 0; \ (fil)->f_pno = (pno); \ (fil)->f_pos = 0; \ (fil)->f_ref = 0; \ @@ -115,7 +186,7 @@ struct file { /* * Valid file object? */ -#define F_FILEOK(_fil) \ +#define FIL_FILEOK(_fil) \ ((_fil) && (_fil)->f_pno) /* @@ -129,7 +200,7 @@ struct file { * 'w' for write access check */ -#define F_CHKRW(_fil, _c) \ +#define FIL_CHKRW(_fil, _c) \ (((_c) == 'r' && !((_fil)->f_flags & O_WRONLY)) || \ ((_c) == 'w' && ((_fil)->f_flags & (O_WRONLY | O_RDWR)))) @@ -137,8 +208,8 @@ struct file { * Is file object writable? Return 0, if so. Otherwise, the appropriate * (negated) error number. */ -#define F_WRITEOK(_fil) \ - (!(F_FILEOK(_fil) && F_CHKRW((_fil), 'w')) \ +#define FIL_WRITEOK(_fil) \ + (!(FIL_FILEOK(_fil) && FIL_CHKRW((_fil), 'w')) \ ? -EBADF \ : (IS_RDONLY((_fil)->f_pno) ? -EROFS : 0)) Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.38 retrieving revision 1.39 diff -u -w -b -B -p -r1.38 -r1.39 --- inode.h 23 Apr 2008 16:46:40 -0000 1.38 +++ inode.h 17 Jun 2008 17:18:57 -0000 1.39 @@ -41,6 +41,7 @@ * le...@sa... */ +#include "smp.h" #include "tree.h" #if defined(AUTOMOUNT_FILE_NAME) && !defined(MAX_MOUNT_DEPTH) @@ -133,6 +134,8 @@ struct inode_ops { */ struct inode { LIST_ENTRY(inode) i_link; /* FS i-nodes link */ + mutex_t i_mutex; /* record mutex */ + unsigned i_lckcnt; /* # recursive locks */ unsigned i_immune : 1, /* immune from GC */ i_zombie : 1; /* stale inode */ @@ -150,6 +153,8 @@ struct inode { */ #define I_INIT(ino, fs, stat, ops, fid, immunity, private) \ do { \ + mutex_init(&(ino)->i_mutex, MUTEX_RECURSIVE); \ + (ino)->i_lckcnt = 0; \ (ino)->i_immune = (immunity) ? 1 : 0; \ (ino)->i_zombie = 0; \ (ino)->i_ref = 0; \ @@ -160,34 +165,92 @@ struct inode { (ino)->i_private = (private); \ } while (0) +#ifdef LOCK_DEBUG +#define _I_CHECK_LOCK(_ino, _test) \ + (assert(((_test) && (_ino)->i_lckcnt) || \ + !((_test) || (_ino)->i_lckcnt))) +#else +#define _I_CHECK_LOCK(_ino, _test) +#endif + +#define I_LOCK(_ino) \ + do { \ + mutex_lock(&(_ino)->i_mutex); \ + (_ino)->i_lckcnt++; \ + _I_CHECK_LOCK(_ino, 1); \ + } while (0) + +#define I_UNLOCK(_ino) \ + do { \ + _I_CHECK_LOCK(_ino, 1); \ + --(_ino)->i_lckcnt; \ + mutex_unlock(&(_ino)->i_mutex); \ + } while (0) + /* * Take soft reference to i-node. */ -#define I_REF(ino) \ +#define _I_REF_NO_LOCK(_ino) \ + do { \ + _I_CHECK_LOCK((_ino), 1); \ + TAILQ_REMOVE(&_sysio_inodes, (_ino), i_nodes); \ + TAILQ_INSERT_TAIL(&_sysio_inodes, (_ino), i_nodes); \ + (_ino)->i_ref++; \ + assert((_ino)->i_ref); \ + } while (0) + +#define I_REF(_ino) \ + do { \ + I_LOCK(_ino); \ + _I_REF_NO_LOCK(_ino); \ + I_UNLOCK(_ino); \ + } while (0) + +/* + * Release soft reference to i-node, destroying it if last reference is + * removed. + */ +#define _I_RELE_NO_LOCK(_ino) \ + do { \ + _I_CHECK_LOCK((_ino), 1); \ + assert((_ino)->i_ref); \ + if (!--(_ino)->i_ref && (_ino)->i_zombie) \ + _sysio_i_gone((_ino)); \ + } while (0) + +#define I_RELE(_ino) \ + do { \ + I_LOCK(_ino); \ + _I_RELE_NO_LOCK(_ino); \ + I_UNLOCK(_ino); \ + } while (0) + +/* + * Lock and reference i-node. + */ +#define I_GET(_ino) \ do { \ - TAILQ_REMOVE(&_sysio_inodes, (ino), i_nodes); \ - TAILQ_INSERT_TAIL(&_sysio_inodes, (ino), i_nodes); \ - (ino)->i_ref++; \ - assert((ino)->i_ref); \ + I_LOCK(_ino); \ + _I_REF_NO_LOCK(_ino); \ } while (0) /* - * Release soft reference to i-node. + * Unlock and drop reference to i-node. */ -#define I_RELE(ino) \ +#define I_PUT(_ino) \ do { \ - assert((ino)->i_ref); \ - if (!--(ino)->i_ref && (ino)->i_zombie) \ - _sysio_i_gone(ino); \ + _I_RELE_NO_LOCK(_ino); \ + I_UNLOCK(_ino); \ } while (0) /* * Attempt to kill an inode. */ -#define I_GONE(ino) \ +#define I_GONE(_ino) \ do { \ - _sysio_i_undead(ino); \ - I_RELE(ino); \ + _I_CHECK_LOCK((_ino), 1); \ + _sysio_i_undead(_ino); \ + I_PUT(_ino); \ } while (0) /* @@ -202,11 +265,13 @@ struct qstr { }; /* - * A path node is an entry in a directory. It may have many aliases, one + * A path-base node is an entry in a directory. It may have many aliases, one * for each name space in which it occurs. This record holds the * common information. */ struct pnode_base { + mutex_t pb_mutex; /* record mutex */ + unsigned pb_lckcnt; /* # recursive locks */ struct tree_node pb_tentry; /* cache node entry */ struct pnode_base_key { struct qstr pbk_name; /* entry name */ @@ -222,6 +287,65 @@ struct pnode_base { }; /* + * Init a path-base record. + */ +#define PB_INIT(_pb, _name, _parent, _ino) \ + do { \ + mutex_init(&(_pb)->pb_mutex, MUTEX_RECURSIVE); \ + (_pb)->pb_lckcnt = 0; \ + (_pb)->pb_tentry.tn_key = &(_pb)->pb_key; \ + (_pb)->pb_tentry.tn_left = (_pb)->pb_tentry.tn_right = NULL; \ + (_pb)->pb_key.pbk_name = *(_name); \ + (_pb)->pb_key.pbk_parent = (_parent); \ + (_pb)->pb_ino = (_ino); \ + LIST_INIT(&(_pb)->pb_children); \ + LIST_INIT(&(_pb)->pb_aliases); \ + } while (0) + +#ifdef LOCK_DEBUG +#define _PB_CHECK_LOCK(_pb, _test) \ + (assert(((_test) && (_pb)->pb_lckcnt) || \ + !((_test) || (_pb)->pb_lckcnt))) +#else +#define _PB_CHECK_LOCK(_pb, _test) +#endif + +#define PB_LOCK(_pb) \ + do { \ + mutex_lock(&(_pb)->pb_mutex); \ + (_pb)->pb_lckcnt++; \ + _PB_CHECK_LOCK((_pb), 1); \ + } while (0) + +#define PB_UNLOCK(_pb) \ + do { \ + _PB_CHECK_LOCK((_pb), 1); \ + (_pb)->pb_lckcnt--; \ + mutex_unlock(&(_pb)->pb_mutex); \ + } while (0) + +/* + * Lock path-base node and get associated i-node if present. + */ +#define PB_GET(_pb) \ + do { \ + PB_LOCK(_pb); \ + if ((_pb)->pb_ino) \ + I_GET((_pb)->pb_ino); \ + } while (0) + +/* + * Unlock path-base node and put associated i-node if present. + */ +#define PB_PUT(_pb) \ + do { \ + _PB_CHECK_LOCK((_pb), 1); \ + if ((_pb)->pb_ino) \ + I_PUT((_pb)->pb_ino); \ + PB_UNLOCK(_pb); \ + } while (0) + +/* * Since a file system may be multiply mounted, in different parts of the local * tree, a file system object may appear in different places. We handle that * with aliases. There is one pnode for every alias the system is tracking. @@ -256,6 +380,8 @@ struct pnode_base { * The nodes link is bookkeeping. */ struct pnode { + mutex_t p_mutex; /* record mutex */ + unsigned p_lckcnt; /* # recursive locks */ unsigned p_ref; /* soft ref count */ struct pnode *p_parent; /* parent */ struct pnode_base *p_base; /* base part */ @@ -266,23 +392,97 @@ struct pnode { }; /* + * Init path node record. + */ +#define P_INIT(_pno, _parent, _pb, _mnt, _cover) \ + do { \ + mutex_init(&(_pno)->p_mutex, MUTEX_RECURSIVE); \ + (_pno)->p_lckcnt = 0; \ + (_pno)->p_ref = 0; \ + (_pno)->p_parent = (_parent); \ + (_pno)->p_base = (_pb); \ + (_pno)->p_mount = (_mnt); \ + (_pno)->p_cover = (_cover); \ + } while (0) + +#ifdef LOCK_DEBUG +#define _P_CHECK_LOCK(_pno, _test) \ + (assert(((_test) && (_pno)->p_lckcnt) || \ + !((_test) || (_pno)->p_lckcnt))) +#else +#define _P_CHECK_LOCK(_pno, _test) +#endif + +#define P_LOCK(_pno) \ + do { \ + mutex_lock(&(_pno)->p_mutex); \ + (_pno)->p_lckcnt++; \ + _P_CHECK_LOCK((_pno), 1); \ + } while (0) + +#define P_UNLOCK(_pno) \ + do { \ + _P_CHECK_LOCK((_pno), 1); \ + (_pno)->p_lckcnt--; \ + mutex_unlock(&(_pno)->p_mutex); \ + } while (0) + +/* * Reference path-tree node. */ -#define P_REF(pno) \ +#define _P_REF_NO_LOCK(_pno) \ + do { \ + _P_CHECK_LOCK((_pno), 1); \ + if (!(_pno)->p_ref++) \ + TAILQ_REMOVE(&_sysio_idle_pnodes, (_pno), p_idle); \ + assert((_pno)->p_ref); \ + } while (0) + +#define P_REF(_pno) \ do { \ - if (!(pno)->p_ref++) \ - TAILQ_REMOVE(&_sysio_idle_pnodes, (pno), p_idle); \ - assert((pno)->p_ref); \ + P_LOCK(_pno); \ + _P_REF_NO_LOCK(_pno); \ + P_UNLOCK(_pno); \ } while (0) /* * Release reference to path-tree node. */ -#define P_RELE(pno) \ +#define _P_RELE_NO_LOCK(_pno) \ + do { \ + _P_CHECK_LOCK((_pno), 1); \ + assert((_pno)->p_ref); \ + if (!--(_pno)->p_ref) \ + TAILQ_INSERT_TAIL(&_sysio_idle_pnodes, (_pno), p_idle); \ + } while (0) + +#define P_RELE(_pno) \ + do { \ + P_LOCK(_pno); \ + _P_RELE_NO_LOCK(_pno); \ + P_UNLOCK(_pno); \ + } while (0) + +/* + * Lock and reference pnode and get associated path-base node. + */ +#define P_GET(_pno) \ + do { \ + P_LOCK(_pno); \ + _P_REF_NO_LOCK(_pno); \ + PB_GET((_pno)->p_base); \ + } while (0) + +/* + * Unlock and drop reference to pnode and put associated path-base node. + * i-node. + */ +#define P_PUT(_pno) \ do { \ - assert((pno)->p_ref); \ - if (!--(pno)->p_ref) \ - TAILQ_INSERT_TAIL(&_sysio_idle_pnodes, (pno), p_idle); \ + _P_CHECK_LOCK((_pno), 1); \ + PB_PUT((_pno)->p_base); \ + _P_RELE_NO_LOCK(_pno); \ + P_UNLOCK(_pno); \ } while (0) /* @@ -525,7 +725,7 @@ extern struct pnode *_sysio_p_new_alias( struct mount *mnt); extern void _sysio_p_gone(struct pnode *pno); extern size_t _sysio_p_prune(struct pnode *root); -extern int _sysio_p_kill_all(struct pnode *root); +extern void _sysio_p_get2(struct pnode *pno1, struct pnode *pno2); extern int _sysio_pb_pathof(struct pnode_base *pb, char separator, char **pathp); Index: mount.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/mount.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- mount.h 24 Sep 2007 19:00:03 -0000 1.5 +++ mount.h 17 Jun 2008 17:18:57 -0000 1.6 @@ -69,7 +69,38 @@ struct mount { #define MOUNT_F_AUTO 0x02 /* automount enabled */ #endif +/* + * Mount status (internal state) flags. + */ +#define MOUNT_ST_IFST 0xf000 /* st flags bitmask */ #ifdef AUTOMOUNT_FILE_NAME +#define MOUNT_ST_IFAUTO 0x1000 /* automount */ +#endif + +/* + * Test macros for mount status. + */ +#define _MOUNT_ST_ISST(st, mask) \ + (((st) & MOUNT_ST_IFST) == (mask)) + +#ifdef MOUNT_ST_IFAUTO +#define MOUNT_ST_ISAUTO(st) _MOUNT_ST_ISST((st), MOUNT_ST_IFAUTO) +#endif + +/* + * Lock mount record. + */ +#define MNT_GET(_mnt) + +/* + * Unlock mount record. + */ +#define MNT_PUT(_mnt) + +#ifdef AUTOMOUNT_FILE_NAME +/* + * Relative name of file containing automount description. + */ extern struct qstr _sysio_mount_file_name; #endif Index: sysio-cmn.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio-cmn.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -b -B -p -r1.19 -r1.20 --- sysio-cmn.h 21 Sep 2007 19:36:59 -0000 1.19 +++ sysio-cmn.h 17 Jun 2008 17:18:57 -0000 1.20 @@ -41,6 +41,8 @@ * le...@sa... */ +#include "smp.h" + /* * System IO common information. */ @@ -248,9 +250,12 @@ extern void _sysio_run_trace_q(void *q, const char *fmt, ...); +extern mutex_t _sysio_biglock; + /* Interface enter/leave hook functions */ #define SYSIO_ENTER(tag, fmt, ...) \ do { \ + mutex_lock(&_sysio_biglock); \ _sysio_run_trace_q(_sysio_entry_trace_q, \ __FILE__, __func__, __LINE__, \ SYSIO_TTAG(tag), \ @@ -265,6 +270,7 @@ extern void _sysio_run_trace_q(void *q, SYSIO_TTAG(tag), \ (fmt), \ __VA_ARGS__); \ + mutex_unlock(&_sysio_biglock); \ } while (0) #else /* !defined(SYSIO_TRACING) */ |
From: Lee W. <lw...@us...> - 2008-06-17 17:19:04
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12543 Modified Files: Makefile.am Rules.make configure.in Log Message: Begin adding support for thread-safe operation. In detail: 1) Add smp.h and smp_posix.c 2) Add a big lock, wrapping the user API with appropriate mutex_lock and mutex_unlock calls. NB; initialization is *not* thread safe. 3) Add support for P_{GET,LOCK}, PB_LOCK, I_{GET,LOCK}, FIL_{GET,LOCK} and alter all related ref/de-ref usage to use get/put or lock/unlock as appropriate. 4) Remedial (no-op) support for MNT_GET. By default, POSIX threads supoprt is not enabled. To enable, use --with-threads, or --with-threads=yes, or --with-threads=posix. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- Makefile.am 17 Jun 2008 15:17:30 -0000 1.16 +++ Makefile.am 17 Jun 2008 17:18:56 -0000 1.17 @@ -63,6 +63,7 @@ AM_CFLAGS = $(OPTIONAL_LUSTRE_CFLAGS) __LIBBUILD_DIR__libsysio_a_SOURCES = \ $(SRCDIR_SRCS) \ + $(THREAD_MODEL_POSIX_SRCS) \ $(OPTIONAL_STDDEV_SRCS) \ $(OPTIONAL_STDFD_SRCS) \ $(OPTIONAL_INCORE_SRCS) \ Index: Rules.make =================================================================== RCS file: /cvsroot/libsysio/libsysio/Rules.make,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- Rules.make 17 Jun 2008 15:17:30 -0000 1.14 +++ Rules.make 17 Jun 2008 17:18:56 -0000 1.15 @@ -17,7 +17,14 @@ endif DEV_CPPFLAGS = $(STDFD_DEV_CPPFLAGS) $(STDDEV_DEV_CPPFLAGS) +if WITH_THREAD_MODEL_POSIX +THREAD_MODEL_POSIX_COMPILER_FLAGS=-pthread +else +THREAD_MODEL_POSIX_COMPILER_FLAGS= +endif + AM_CPPFLAGS = \ + $(THREAD_MODEL_POSIX_COMPILER_FLAGS) \ $(TRACING) \ $(AUTOMOUNT) $(ZERO_SUM_MEMORY) $(DEV_CPPFLAGS) $(SOCKETS_CPPFLAGS) \ $(DEFER_INIT_CWD) $(SYSIO_LABEL_NAMES) $(_HAVE_STATVFS) \ Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.40 retrieving revision 1.41 diff -u -w -b -B -p -r1.40 -r1.41 --- configure.in 17 Jun 2008 15:17:30 -0000 1.40 +++ configure.in 17 Jun 2008 17:18:56 -0000 1.41 @@ -215,6 +215,23 @@ AC_ARG_WITH(alternate-symbols, esac]) AC_SUBST(SYSIO_LABEL_NAMES) +AC_ARG_WITH(threads, + AC_HELP_STRING([--with-threads@<:@=<model>@:>@], + [Enable thread-safe operation via named model]), + [ case "${withval}" in + yes|posix) AC_DEFINE(THREAD_MODEL_POSIX);; + no) ;; + *) AC_MSG_ERROR(bad value ${withval} for --with-threads) ;; + esac], + [with_threads=no]) +if test x$with_threads = xyes; then + with_threads=posix +fi +if test x$with_threads = xposix; then + AC_DEFINE(THREAD_MODEL_POSIX) +fi +AM_CONDITIONAL(WITH_THREAD_MODEL_POSIX, test x$with_threads = xposix) + # We keep the original values in `$config_*' and never modify them, so we # can write them unchanged into config.make. Everything else uses # $machine, $vendor, and $os, and changes them whenever convenient. |
From: Lee W. <lw...@us...> - 2008-06-17 17:19:01
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12543/src Modified Files: access.c chdir.c chmod.c chown.c dup.c fcntl.c file.c file_hack.c fs.c fsync.c getdirentries.c init.c inode.c ioctl.c ioctx.c link.c lseek.c mkdir.c mknod.c module.mk mount.c namei.c open.c readlink.c rename.c rmdir.c rw.c stat.c statvfs.c symlink.c truncate.c unlink.c utime.c Added Files: smp_posix.c Log Message: Begin adding support for thread-safe operation. In detail: 1) Add smp.h and smp_posix.c 2) Add a big lock, wrapping the user API with appropriate mutex_lock and mutex_unlock calls. NB; initialization is *not* thread safe. 3) Add support for P_{GET,LOCK}, PB_LOCK, I_{GET,LOCK}, FIL_{GET,LOCK} and alter all related ref/de-ref usage to use get/put or lock/unlock as appropriate. 4) Remedial (no-op) support for MNT_GET. By default, POSIX threads supoprt is not enabled. To enable, use --with-threads, or --with-threads=yes, or --with-threads=posix. --- 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-2008 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 "smp.h" int _posix_mutex_init_helper(mutex_t *mp, int typ) { pthread_mutexattr_t mattr; int err; if ((err = pthread_mutexattr_init(&mattr))) return err; if ((err = pthread_mutexattr_settype(&mattr, typ))) return err; err = pthread_mutex_init(mp, &mattr); return err; } Index: access.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/access.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -b -B -p -r1.18 -r1.19 --- access.c 15 Apr 2008 19:29:06 -0000 1.18 +++ access.c 17 Jun 2008 17:18:57 -0000 1.19 @@ -43,6 +43,7 @@ #include <stdlib.h> #include <errno.h> +#include <assert.h> #include <unistd.h> #include <assert.h> #include <sys/types.h> @@ -286,7 +287,7 @@ SYSIO_INTERFACE_NAME(access)(const char err = _sysio_check_permission(pno, &cr, amode); out: - P_RELE(pno); + P_PUT(pno); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, access, "%d", 0); } Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -w -b -B -p -r1.32 -r1.33 --- chdir.c 14 Apr 2008 23:22:47 -0000 1.32 +++ chdir.c 17 Jun 2008 17:18:57 -0000 1.33 @@ -114,6 +114,7 @@ _sysio_p_chdir(struct pnode *pno) /* * Finally, change to the new. */ + P_REF(pno); _sysio_cwd = pno; return 0; @@ -132,8 +133,7 @@ SYSIO_INTERFACE_NAME(chdir)(const char * SYSIO_INTERFACE_RETURN(-1, err, chdir, "%d", 0); err = _sysio_p_chdir(pno); - if (err) - P_RELE(pno); + P_PUT(pno); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, chdir, "%d", 0); } @@ -160,10 +160,11 @@ SYSIO_INTERFACE_NAME(getcwd)(char *buf, */ if (_sysio_namei(NULL, ".", 0, NULL, &pno) != 0) abort(); - P_RELE(pno); - } + } else #endif + P_GET(_sysio_cwd); err = _sysio_p_path(_sysio_cwd, &buf, buf ? size : 0); + P_PUT(_sysio_cwd); SYSIO_INTERFACE_RETURN(err ? NULL : buf, err, getcwd, "%s", 0); } Index: chmod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -b -B -p -r1.20 -r1.21 --- chmod.c 29 Feb 2008 23:14:34 -0000 1.20 +++ chmod.c 17 Jun 2008 17:18:57 -0000 1.21 @@ -83,7 +83,7 @@ SYSIO_INTERFACE_NAME(chmod)(const char * if (err) goto out; err = do_chmod(pno, mode); - P_RELE(pno); + P_PUT(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, chmod, "%d", 0); } @@ -110,6 +110,7 @@ SYSIO_INTERFACE_NAME(fchmod)(int fd, mod } err = do_chmod(fil->f_pno, mode); + FIL_PUT(fil); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fchmod, "%d", 0); } Index: chown.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- chown.c 19 Sep 2007 16:01:33 -0000 1.16 +++ chown.c 17 Jun 2008 17:18:57 -0000 1.17 @@ -88,7 +88,7 @@ SYSIO_INTERFACE_NAME(chown)(const char * goto out; err = _do_chown(pno, owner, group); - P_RELE(pno); + P_PUT(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, chown, "%d", 0); } @@ -115,6 +115,7 @@ SYSIO_INTERFACE_NAME(fchown)(int fd, uid } err = _do_chown(fil->f_pno, owner, group); + FIL_PUT(fil); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fchown, "%d", 0); } Index: dup.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dup.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- dup.c 2 Jul 2007 18:58:16 -0000 1.14 +++ dup.c 17 Jun 2008 17:18:57 -0000 1.15 @@ -44,9 +44,11 @@ #include <unistd.h> #include <errno.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #include "sysio.h" +#include "inode.h" #include "file.h" #include "sysio-symbols.h" Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- fcntl.c 2 Jul 2007 18:58:16 -0000 1.30 +++ fcntl.c 17 Jun 2008 17:18:57 -0000 1.31 @@ -269,6 +269,7 @@ _sysio_vfcntl(int fd, int cmd, va_list a } out: + FIL_PUT(fil); SYSIO_INTERFACE_RETURN(rtn, err, vfcntl, "%d", 0); } Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -w -b -B -p -r1.22 -r1.23 --- file.c 1 May 2007 16:33:53 -0000 1.22 +++ file.c 17 Jun 2008 17:18:57 -0000 1.23 @@ -49,8 +49,10 @@ #include <sys/queue.h> #include "sysio.h" -#include "file.h" +#include "fs.h" +#include "mount.h" #include "inode.h" +#include "file.h" /* * Support for file IO. @@ -74,9 +76,10 @@ _sysio_fnew(struct pnode *pno, int flags if (!fil) return NULL; + P_REF(pno); _SYSIO_FINIT(fil, pno, flags); - F_REF(fil); - P_REF(fil->f_pno); + FIL_LOCK(fil); + FIL_REF(fil); return fil; } @@ -87,13 +90,43 @@ _sysio_fnew(struct pnode *pno, int flags void _sysio_fgone(struct file *fil) { - int err; + int oerr, err; assert(!fil->f_ref); assert(fil->f_pno); - err = PNOP_CLOSE(fil->f_pno); - assert(!err); + oerr = 0; + P_GET(fil->f_pno); + while ((err = PNOP_CLOSE(fil->f_pno))) { + if (err == EBADF) { + if (!oerr) + oerr = err; + break; + } else if (oerr) { + char *path; + static char *error_path = "<noname>"; + + /* + * If this happens we are bleeding file descriptors + * from somewhere. + */ + path = NULL; + if (_sysio_pb_pathof(fil->f_pno->p_base, + PATH_SEPARATOR, + &path) != 0) + path = error_path; + _sysio_cprintf("[lu]\"%s\" pnode won't close (%d)\n", + fil->f_pno->p_mount->mnt_fs->fs_id, + path); + if (path != error_path) + free(path); + break; + } + oerr = err; + } + P_PUT(fil->f_pno); P_RELE(fil->f_pno); + mutex_unlock(&fil->f_mutex); + mutex_destroy(&fil->f_mutex); free(fil); } @@ -193,10 +226,15 @@ find_free_fildes(int low) struct file * _sysio_fd_find(int fd) { + struct file *fil; + if (fd < 0 || (unsigned )fd >= _sysio_oftab_size) return NULL; - return _sysio_oftab[fd]; + fil = _sysio_oftab[fd]; + if (fil) + FIL_GET(fil); + return fil; } /* @@ -212,8 +250,8 @@ _sysio_fd_close(int fd) return -EBADF; _sysio_oftab[fd] = NULL; - - F_RELE(fil); + FIL_RELE(fil); + FIL_PUT(fil); return 0; } @@ -254,8 +292,11 @@ _sysio_fd_set(struct file *fil, int fd, * Take the entry. */ _sysio_oftab[fd] = fil; - if (ofil) - F_RELE(ofil); + FIL_REF(fil); + if (ofil) { + FIL_RELE(ofil); + FIL_PUT(ofil); + } return fd; } @@ -282,8 +323,7 @@ _sysio_fd_dup(int oldfd, int newfd, int return -EBADF; fd = _sysio_fd_set(fil, newfd, force); - if (fd >= 0) - F_REF(fil); + FIL_PUT(fil); return fd; } @@ -301,7 +341,10 @@ _sysio_fd_close_all() fd++, filp++) { if (!*filp) continue; - F_RELE(*filp); + FIL_LOCK(*filp); + P_RELE((*filp)->f_pno); + FIL_RELE(*filp); + FIL_UNLOCK(*filp); *filp = NULL; } Index: file_hack.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file_hack.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- file_hack.c 1 May 2007 16:33:53 -0000 1.12 +++ file_hack.c 17 Jun 2008 17:18:57 -0000 1.13 @@ -105,9 +105,10 @@ _sysio_fnew(struct pnode *pno, int flags if (!fil) return NULL; - _SYSIO_FINIT(fil, pno, flags); - F_REF(fil); P_REF(pno); + _SYSIO_FINIT(fil, pno, flags); + FIL_LOCK(fil); + FIL_REF(fil); return fil; } @@ -118,16 +119,45 @@ _sysio_fnew(struct pnode *pno, int flags void _sysio_fgone(struct file *fil) { - int err; + int oerr, err; assert(!fil->f_ref); assert(fil->f_pno); - err = PNOP_CLOSE(fil->f_pno); + oerr = 0; + P_GET(fil->f_pno); + while ((err = PNOP_CLOSE(fil->f_pno))) { + if (err == EBADF) { + if (!oerr) + oerr = err; + break; + } else if (oerr) { + char *path; + static char *error_path = "<noname>"; + + /* + * If this happens we are bleeding file descriptors + * from somewhere. + */ + path = NULL; + if (_sysio_pb_pathof(fil->f_pno->p_base, + PATH_SEPARATOR, + &path) != 0) + path = error_path; + _sysio_cprintf("[lu]\"%s\" pnode won't close (%d)\n", + fil->f_pno->p_mount->mnt_fs->fs_id, + path); + if (path != error_path) + free(path); + break; + } + oerr = err; + } + P_PUT(fil->f_pno); P_RELE(fil->f_pno); - assert(!err); + mutex_unlock(&fil->f_mutex); + mutex_destroy(&fil->f_mutex); free(fil); } - /* * IO operation completion handler. */ @@ -244,7 +274,7 @@ find_free_fildes(oftab_t *oftab, int low * clear this entry if 'clear' is non-zero */ static struct file * -__sysio_fd_get(int fd, int clear) +_sysio_fd_get(int fd, int clear) { oftab_t *oftab; struct file *file; @@ -259,6 +289,8 @@ __sysio_fd_get(int fd, int clear) return NULL; file = oftab->table[fd - oftab->offset]; + if (file) + FIL_GET(file); if (clear) oftab->table[fd - oftab->offset] = NULL; @@ -271,7 +303,8 @@ __sysio_fd_get(int fd, int clear) struct file * _sysio_fd_find(int fd) { - return __sysio_fd_get(fd, 0); + + return _sysio_fd_get(fd, 0); } /* @@ -282,11 +315,11 @@ _sysio_fd_close(int fd) { struct file *fil; - fil = fil = __sysio_fd_get(fd, 1); + fil = _sysio_fd_get(fd, 1); if (!fil) return -EBADF; - - F_RELE(fil); + FIL_RELE(fil); + FIL_PUT(fil); return 0; } @@ -328,22 +361,17 @@ _sysio_fd_set(struct file *fil, int fd, /* * Remember old. */ - ofil = __sysio_fd_get(fd, 1); + ofil = _sysio_fd_get(fd, 1); + /* + * Take the entry. + */ + oftab->table[fd - oftab->offset] = fil; + FIL_REF(fil); if (ofil) { - /* FIXME sometimes we could intercept open/socket to create - * a fd, but missing close()? currently we have this problem - * with resolv lib. as a workaround simply destroy the file - * struct here. And this hack will break the behavior of - * DUPFD. - */ - if (fd >= 0 && oftab == &_sysio_oftab[0]) - free(ofil); - else - F_RELE(ofil); + FIL_RELE(ofil); + FIL_PUT(ofil); } - oftab->table[fd - oftab->offset] = fil; - return fd; } @@ -371,12 +399,12 @@ _sysio_fd_dup(int oldfd, int newfd, int return -EBADF; /* old & new must belong to the same oftab */ - if (select_oftab(oldfd) != select_oftab(newfd)) + if (select_oftab(oldfd) != select_oftab(newfd)) { + FIL_PUT(fil); return -EINVAL; + } fd = _sysio_fd_set(fil, newfd, force); - if (fd >= 0) - F_REF(fil); return fd; } @@ -391,7 +419,10 @@ _sysio_oftable_close_all(oftab_t *oftab) fd++, filp++) { if (!*filp) continue; - F_RELE(*filp); + FIL_LOCK(*filp); + P_RELE((*filp)->f_pno); + FIL_RELE(*filp); + FIL_UNLOCK(*filp); *filp = NULL; } } Index: fs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fs.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -b -B -p -r1.15 -r1.16 --- fs.c 1 May 2007 16:33:53 -0000 1.15 +++ fs.c 17 Jun 2008 17:18:57 -0000 1.16 @@ -145,14 +145,17 @@ _sysio_fs_gone(struct filesys *fs) { size_t n; struct itable_entry *head; + struct inode *ino; if (fs->fs_ref) abort(); n = FS_ITBLSIZ; do { head = &fs->fs_itbl[--n]; - while (head->lh_first) - _sysio_i_gone(head->lh_first); + while ((ino = head->lh_first)) { + I_LOCK(ino); + I_GONE(ino); + } } while (n); if (n) abort(); Index: fsync.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fsync.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -b -B -p -r1.11 -r1.12 --- fsync.c 20 Nov 2007 17:46:28 -0000 1.11 +++ fsync.c 17 Jun 2008 17:18:57 -0000 1.12 @@ -43,6 +43,7 @@ #include <unistd.h> #include <errno.h> +#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -63,11 +64,12 @@ SYSIO_INTERFACE_NAME(fsync)(int fd) err = 0; do { fil = _sysio_fd_find(fd); - if (!F_FILEOK(fil)) + if (!FIL_FILEOK(fil)) err = -EBADF; if (err) break; err = PNOP_SYNC(fil->f_pno); + FIL_PUT(fil); } while (0); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fsync, "%d", 0); } @@ -83,11 +85,12 @@ SYSIO_INTERFACE_NAME(fdatasync)(int fd) err = 0; do { fil = _sysio_fd_find(fd); - if (!F_FILEOK(fil)) + if (!FIL_FILEOK(fil)) err = -EBADF; if (err) break; err = PNOP_DATASYNC(fil->f_pno); + FIL_PUT(fil); } while (0); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fdatasync, "%d", 0); } Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -w -b -B -p -r1.26 -r1.27 --- getdirentries.c 15 Nov 2007 15:05:34 -0000 1.26 +++ getdirentries.c 17 Jun 2008 17:18:57 -0000 1.27 @@ -48,6 +48,7 @@ #endif #include <string.h> #include <errno.h> +#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> @@ -99,8 +100,13 @@ PREPEND(_, SYSIO_INTERFACE_NAME(getdiren SYSIO_INTERFACE_ENTER(getdirentries64, "%d%zu%oZ", fd, nbytes, basep); + cc = -EBADF; /* assume failure */ fil = _sysio_fd_find(fd); + if (FIL_FILEOK(fil)) { cc = filldirents(fil, buf, nbytes, basep); + FIL_PUT(fil); + } + SYSIO_INTERFACE_RETURN(cc < 0 ? -1 : cc, cc < 0 ? (int )cc : 0, getdirentries64, "%zd%oZ", basep); @@ -167,8 +173,13 @@ SYSIO_INTERFACE_NAME(getdirentries)(int SYSIO_INTERFACE_ENTER(getdirentries, "%d%zu%d", fd, nbytes, *basep); + cc = -EBADF; /* assume failure */ fil = _sysio_fd_find(fd); - count = cc = filldirents(fil, buf, nbytes, &b); + if (FIL_FILEOK(fil)) { + cc = filldirents(fil, buf, nbytes, &b); + FIL_PUT(fil); + } + count = cc; d64p = (void *)buf; dp = (void *)buf; reclen = 0; @@ -224,24 +235,18 @@ SYSIO_INTERFACE_NAME(getdirentries)(int d64p = (struct dirent64 *)((char *)d64p + d64.d_reclen); } - if (cc < 0) { #ifndef BSD #define _basefmt "%oY" #else #define _basefmt "%ld" #endif + if (cc < 0) { SYSIO_INTERFACE_RETURN(-1, cc, getdirentries, "%zd" _basefmt, *basep); -#undef _basefmt } cc = (char *)dp - buf; *basep = b; -#ifndef BSD -#define _basefmt "%oY" -#else -#define _basefmt "%ld" -#endif SYSIO_INTERFACE_RETURN(cc, 0, getdirentries, "%zd" _basefmt, *basep); #undef _basefmt } Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -w -b -B -p -r1.40 -r1.41 --- init.c 17 Jun 2008 15:11:40 -0000 1.40 +++ init.c 17 Jun 2008 17:18:57 -0000 1.41 @@ -66,6 +66,8 @@ #include "stddev.h" #endif +mutex_t _sysio_biglock; /* API big lock */ + /* * White space characters. */ @@ -194,6 +196,8 @@ _sysio_init() extern int _sysio_sockets_init(void); #endif + mutex_init(&_sysio_biglock, MUTEX_RECURSIVE); + #ifdef SYSIO_TRACING err = _sysio_trace_init(); if (err) @@ -266,6 +270,8 @@ _sysio_shutdown() _sysio_fssw_shutdown(); _sysio_access_shutdown(); #endif + + mutex_destroy(&_sysio_biglock); } /* @@ -552,7 +558,7 @@ do_creat(char *args) abort(); } - P_RELE(pno); + P_PUT(pno); return err; } @@ -607,12 +613,14 @@ do_mnt(char *args) if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) return -ENOENT; + P_GET(dir); return _sysio_mount(dir, ty, v[1].ovi_value, name, flags, v[3].ovi_value); + P_PUT(dir); } @@ -648,8 +656,7 @@ do_cd(char *args) if (err) return err; err = _sysio_p_chdir(pno); - if (err) - P_RELE(pno); + P_PUT(pno); return err; } #endif @@ -693,7 +700,7 @@ do_chmd(char *args) if (err) return err; err = _sysio_p_setattr(pno, SETATTR_MODE, &stbuf); - P_RELE(pno); + P_PUT(pno); return err; } @@ -756,9 +763,9 @@ do_open(char *args) return 0; } while (0); if (fil) - F_RELE(fil); + FIL_PUT(fil); if (pno) - P_RELE(pno); + P_PUT(pno); return err; } Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.42 retrieving revision 1.43 diff -u -w -b -B -p -r1.42 -r1.43 --- inode.c 23 Apr 2008 16:46:40 -0000 1.42 +++ inode.c 17 Jun 2008 17:18:57 -0000 1.43 @@ -226,8 +226,8 @@ _sysio_i_new(struct filesys *fs, void *private) { struct inode *ino; - struct itable_entry *head; struct inode_ops operations; + struct itable_entry *head; if (n_inodes > n_names) { /* @@ -241,7 +241,6 @@ _sysio_i_new(struct filesys *fs, ino = malloc(sizeof(struct inode)); if (!ino) return NULL; - ino->i_ops = *ops; operations = *ops; if (S_ISBLK(stat->st_mode) || S_ISCHR(stat->st_mode) || @@ -269,6 +268,9 @@ _sysio_i_new(struct filesys *fs, head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; LIST_INSERT_HEAD(head, ino, i_link); + I_GET(ino); + I_RELE(ino); + n_inodes++; assert(n_inodes); @@ -294,7 +296,7 @@ _sysio_i_find(struct filesys *fs, struct memcmp(ino->i_fid->fid_data, fid->fid_data, fid->fid_len) == 0) { - I_REF(ino); + I_GET(ino); INO_CST_UPDCNT(ihits); break; } @@ -316,6 +318,8 @@ _sysio_i_gone(struct inode *ino) LIST_REMOVE(ino, i_link); TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes); (*ino->i_ops.inop_gone)(ino); + I_UNLOCK(ino); + mutex_destroy(&ino->i_mutex); free(ino); assert(n_inodes); @@ -389,6 +393,7 @@ p_reclaim(unsigned count) do { INO_CST_UPDCNT(pexamined); pno = next; + P_LOCK(pno); next = pno->p_idle.tqe_next; if (pno->p_ref) abort(); @@ -396,6 +401,7 @@ p_reclaim(unsigned count) /* * We never reclaim mount points, here. */ + P_UNLOCK(pno); continue; } if (pno->p_base->pb_children.lh_first) { @@ -404,13 +410,17 @@ p_reclaim(unsigned count) * might be aliases on the child pointing * at this one. */ + P_UNLOCK(pno); continue; } INO_CST_UPDCNT(pdismissed); + PB_LOCK(pno->p_base); pb = pno->p_base; _sysio_p_gone(pno); if (!(pb->pb_children.lh_first || pb->pb_aliases.lh_first)) _sysio_pb_gone(pb); + else + PB_UNLOCK(pb); } while ((!count || --count) && n_names > t && next); if (!adjust) @@ -503,6 +513,7 @@ struct pnode_base * _sysio_pb_new(struct qstr *name, struct pnode_base *parent, struct inode *ino) { struct pnode_base *pb; + static struct qstr noname = { NULL, 0, 0 }; if (n_names > max_names) { /* @@ -515,13 +526,17 @@ _sysio_pb_new(struct qstr *name, struct if (!pb) return NULL; - pb->pb_key.pbk_name = *name; - pb->pb_key.pbk_parent = parent; + if (!name) + name = &noname; + PB_INIT(pb, name, parent, ino); + if (ino) + I_REF(ino); + PB_GET(pb); + if (parent) + LIST_INSERT_HEAD(&parent->pb_children, pb, pb_sibs); 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. * @@ -531,15 +546,9 @@ _sysio_pb_new(struct qstr *name, struct cp = (char *)pb + sizeof(struct pnode_base); (void )strncpy(cp, name->name, name->len); pb->pb_key.pbk_name.name = cp; - pb->pb_key.pbk_name.hashval = name->hashval; ncache_insert(pb); } - pb->pb_ino = ino; - LIST_INIT(&pb->pb_children); - LIST_INIT(&pb->pb_aliases); - if (parent) - LIST_INSERT_HEAD(&parent->pb_children, pb, pb_sibs); #ifdef P_RECLAIM_DEBUG LIST_INSERT_HEAD(&pbnodes, pb, pb_links); #endif @@ -551,20 +560,19 @@ _sysio_pb_new(struct qstr *name, struct } /* - * Destroy base path node, releasing resources back to the system. - * - * NB: Caller must release the inode referenced by the record. + * Force reclaim of idle base path node. */ -static void -pb_destroy(struct pnode_base *pb) +void +_sysio_pb_gone(struct pnode_base *pb) { + struct inode *ino; assert(n_names); n_names--; assert(!pb->pb_aliases.lh_first); assert(!pb->pb_children.lh_first); - assert(!pb->pb_ino); + if (pb->pb_key.pbk_name.len) ncache_delete(pb); if (pb->pb_key.pbk_parent) @@ -572,25 +580,21 @@ pb_destroy(struct pnode_base *pb) #ifdef P_RECLAIM_DEBUG LIST_REMOVE(pb, pb_links); #endif - + ino = pb->pb_ino; + if (ino) + I_LOCK(ino); + pb->pb_ino = NULL; + PB_UNLOCK(pb); + mutex_destroy(&pb->pb_mutex); free(pb); -} - -/* - * Force reclaim of idle base path node. - */ -void -_sysio_pb_gone(struct pnode_base *pb) -{ - if (pb->pb_ino) { - I_RELE(pb->pb_ino); - if (!pb->pb_ino->i_ref) - _sysio_i_gone(pb->pb_ino); + if (ino) { + I_RELE(ino); + if (!ino->i_ref) + _sysio_i_gone(ino); + else + I_UNLOCK(ino); } - pb->pb_ino = NULL; - - pb_destroy(pb); } /* @@ -751,13 +755,12 @@ _sysio_p_new_alias(struct pnode *parent, if (!pno) return NULL; + if (!parent) + parent = pno; + P_INIT(pno, parent, pb, mnt, NULL); pno->p_ref = 1; - pno->p_parent = parent; - if (!pno->p_parent) - pno->p_parent = pno; - pno->p_base = pb; - pno->p_mount = mnt; - pno->p_cover = NULL; + P_GET(pno); + P_RELE(pno); LIST_INSERT_HEAD(&pb->pb_aliases, pno, p_links); #ifdef P_DEBUG _sysio_p_show("P_CREATE_ALIAS", pno); @@ -863,6 +866,8 @@ _sysio_p_gone(struct pnode *pno) #ifdef P_DEBUG _sysio_p_show("P_GONE", pno); #endif + P_UNLOCK(pno); + mutex_destroy(&pno->p_mutex); free(pno); } @@ -886,13 +891,14 @@ _sysio_p_validate(struct pnode *pno, str * Make valid. */ pno->p_base->pb_ino = ino; + I_REF(pno->p_base->pb_ino); } else if (pno->p_base->pb_ino != ino) { /* * Path resolves to a different inode, now. The * currently attached inode, then, is stale. */ err = -ESTALE; - I_RELE(ino); + I_PUT(ino); } } else if (pno->p_base->pb_ino) _sysio_pb_disconnect(pno->p_base); @@ -931,9 +937,11 @@ _sysio_p_find_alias(struct pnode *parent key.pbk_name = *name; key.pbk_parent = parent->p_base; pb = ncache_lookup(&key); - if (pb) + if (pb) { + PB_GET(pb); INO_CST_UPDCNT(pbhits); } + } if (!pb) { /* * None found, create new child. @@ -950,7 +958,7 @@ _sysio_p_find_alias(struct pnode *parent pno = pb->pb_aliases.lh_first; while (pno) { if (pno->p_parent == parent) { - P_REF(pno); + P_GET(pno); break; } pno = pno->p_links.le_next; @@ -969,6 +977,7 @@ _sysio_p_find_alias(struct pnode *parent if (!pno) err = -ENOMEM; } + PB_PUT(pb); if (!err) { #ifdef P_DEBUG if (!isnew) @@ -1012,8 +1021,15 @@ p_remove_aliases(struct mount *mnt, stru struct pnode *nxtpno, *pno; count = 0; + pno = NULL; nxtpno = pb->pb_aliases.lh_first; - while ((pno = nxtpno)) { + for (;;) { + if (pno) + P_UNLOCK(pno); + pno = nxtpno; + if (!pno) + break; + P_LOCK(pno); nxtpno = pno->p_links.le_next; if (pno->p_mount != mnt) { /* @@ -1042,6 +1058,7 @@ p_remove_aliases(struct mount *mnt, stru } #endif _sysio_p_gone(pno); + pno = NULL; } return count; @@ -1053,6 +1070,7 @@ pb_prune(struct mount *mnt, struct pnode size_t count; struct pnode_base *nxt, *child; + PB_LOCK(pb); count = 0; nxt = pb->pb_children.lh_first; while ((child = nxt)) { @@ -1061,9 +1079,13 @@ pb_prune(struct mount *mnt, struct pnode } if (!count) { count += p_remove_aliases(mnt, pb); - if (!(pb->pb_aliases.lh_first || pb->pb_children.lh_first)) + if (!(pb->pb_aliases.lh_first || pb->pb_children.lh_first)) { _sysio_pb_gone(pb); + pb = NULL; + } } + if (pb) + PB_UNLOCK(pb); return count; } @@ -1080,6 +1102,78 @@ _sysio_p_prune(struct pnode *pno) } /* + * Simultaneous get of two path nodes. + */ +void +_sysio_p_get2(struct pnode *pno1, struct pnode *pno2) +{ + struct inode *ino1, *ino2; + char *cp1, *cp2; + size_t count1, count2; + int order; + + if (pno1 < pno2) { + P_LOCK(pno1); + P_LOCK(pno2); + } else { + P_LOCK(pno2); + P_LOCK(pno1); + } + if (pno1->p_base < pno2->p_base) { + PB_LOCK(pno1->p_base); + PB_LOCK(pno2->p_base); + } else { + PB_LOCK(pno2->p_base); + PB_LOCK(pno1->p_base); + } + /* + * File identifiers are never allowed to change and we've prevented + * the inode pointer from changing in the path-base records. So... + * It's safe to examine the file identifiers without a lock now. + */ + ino1 = pno1->p_base->pb_ino; + ino2 = pno2->p_base->pb_ino; + cp1 = NULL; + count1 = 0; + if (ino1) { + cp1 = ino1->i_fid->fid_data; + count1 = ino1->i_fid->fid_len; + } + cp2 = NULL; + count2 = 0; + if (ino2) { + cp2 = ino2->i_fid->fid_data; + count2 = ino2->i_fid->fid_len; + } + order = 0; + while (count1 && count2 && *cp1 == *cp2) { + cp1++; cp2++; + count1--; count2--; + } + if (count1 && count2) + order = *cp2 - *cp1; + else if (count1 > count2) + order = 1; + else if (count1 > count2) + order = -1; + if (order <= 0) { + P_GET(pno1); + P_GET(pno2); + } else { + P_GET(pno2); + P_GET(pno1); + } + /* + * We did get operations, finally, above. Have to release our + * redundant locks. The order in which we unlock is unimportant. + */ + PB_UNLOCK(pno1->p_base); + PB_UNLOCK(pno2->p_base); + P_UNLOCK(pno1); + P_UNLOCK(pno2); +} + +/* * Return path tracked by the base path node ancestor chain. * * Remember, base path nodes track the path relative to the file system and Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- ioctl.c 2 Jul 2007 18:58:16 -0000 1.14 +++ ioctl.c 17 Jun 2008 17:18:57 -0000 1.15 @@ -42,6 +42,7 @@ */ #include <errno.h> +#include <assert.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> @@ -72,6 +73,7 @@ SYSIO_INTERFACE_NAME(ioctl)(int fd, unsi va_start(ap, request); err = PNOP_IOCTL(fil->f_pno, request, ap); va_end(ap); + FIL_PUT(fil); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, ioctl, "%d%lu", request); Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -w -b -B -p -r1.27 -r1.28 --- ioctx.c 14 May 2007 20:43:28 -0000 1.27 +++ ioctx.c 17 Jun 2008 17:18:57 -0000 1.28 @@ -110,6 +110,8 @@ _sysio_ioctx_new(struct pnode *pno, { struct ioctx *ioctx; + assert(pno->p_base->pb_ino); + ioctx = malloc(sizeof(struct ioctx)); if (!ioctx) return NULL; @@ -189,14 +191,17 @@ _sysio_ioctx_done(struct ioctx *ioctx) if (ioctx->ioctx_done) return 1; #ifdef not_yet - if (!PNOP_IODONE(ioctx->ioctx_pno, ioctx)) - return 0; + P_GET(ioctx->ioctx_pno); + if (PNOP_IODONE(ioctx->ioctx_pno, ioctx)) + ioctx->ioctx_done = 1; + P_PUT(ioctx->ioctx_pno); #else - if (!(*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx)) - return 0; -#endif + I_GET(ioctx->ioctx_ino); + if ((*ioctx->ioctx_ino->i_ops.inop_iodone)(ioctx)) ioctx->ioctx_done = 1; - return 1; + I_PUT(ioctx->ioctx_ino); +#endif + return (int )ioctx->ioctx_done; } /* Index: link.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/link.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -b -B -p -r1.15 -r1.16 --- link.c 20 Nov 2007 17:49:26 -0000 1.15 +++ link.c 17 Jun 2008 17:18:57 -0000 1.16 @@ -71,12 +71,23 @@ SYSIO_INTERFACE_NAME(link)(const char *o _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); if (err) break; + P_REF(old); + P_PUT(old); INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); if (err) break; + P_REF(new); + P_PUT(new); + if (new->p_base->pb_ino) { + err = -EEXIST; + break; + } + _sysio_p_get2(old, new->p_parent); err = _sysio_p_link(old, new); + P_PUT(new->p_parent); + P_PUT(old); } while (0); if (new) P_RELE(new); Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -w -b -B -p -r1.31 -r1.32 --- lseek.c 19 Sep 2007 16:01:33 -0000 1.31 +++ lseek.c 17 Jun 2008 17:18:57 -0000 1.32 @@ -135,6 +135,7 @@ SYSIO_INTERFACE_NAME(lseek64)(int fd, of -EBADF, lseek64, "%loZ", 0); off = _sysio_lseek(fil, offset, whence, _SEEK_MAX(fil)); + FIL_PUT(fil); SYSIO_INTERFACE_RETURN(off < 0 ? (off64_t )-1 : off, off < 0 ? (int )off : 0, lseek64, "%loZ", 0); @@ -167,6 +168,7 @@ SYSIO_INTERFACE_NAME(lseek)(int fd, off_ if (!fil) SYSIO_INTERFACE_RETURN((off_t )-1, -EBADF, lseek, "%oZ", 0); off = _sysio_lseek(fil, offset, whence, LONG_MAX); + FIL_PUT(fil); if (off < 0) SYSIO_INTERFACE_RETURN((off_t )-1, (int )off, lseek, "%oZ", 0); rtn = (off_t )off; @@ -218,6 +220,7 @@ SYSIO_INTERFACE_NAME(llseek)(unsigned in off |= offset_low; #endif off = _sysio_lseek(fil, off, whence, _SEEK_MAX(fil)); + FIL_PUT(fil); if (off < 0) SYSIO_INTERFACE_RETURN(-1, (int )off, llseek, "%d", NULL); *result = off; Index: mkdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mkdir.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -w -b -B -p -r1.23 -r1.24 --- mkdir.c 27 Sep 2007 17:22:36 -0000 1.23 +++ mkdir.c 17 Jun 2008 17:18:57 -0000 1.24 @@ -86,7 +86,7 @@ SYSIO_INTERFACE_NAME(mkdir)(const char * mode &= ~(_sysio_umask & 0777); /* apply umask */ err = _sysio_mkdir(pno, mode); - P_RELE(pno); + P_PUT(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, mkdir, "%d", 0); } Index: mknod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mknod.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -w -b -B -p -r1.22 -r1.23 --- mknod.c 26 Oct 2007 19:48:23 -0000 1.22 +++ mknod.c 17 Jun 2008 17:18:57 -0000 1.23 @@ -109,7 +109,7 @@ PREPEND(__, SYSIO_INTERFACE_NAME(xmknod) goto error; err = _sysio_mknod(pno, mode, *dev); error: - P_RELE(pno); + P_PUT(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, xmknod, "%d", 0); } Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- module.mk 21 Sep 2007 19:35:53 -0000 1.16 +++ module.mk 17 Jun 2008 17:18:57 -0000 1.17 @@ -1,3 +1,9 @@ +if WITH_THREAD_MODEL_POSIX +THREAD_MODEL_POSIX_SRCS = src/smp_posix.c +else +THREAD_MODEL_POSIX_SRCS = +endif + if WITH_TRACING TRACING_SRCS = src/tracing.c else @@ -30,7 +36,7 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/link.c src/lseek.c src/mkdir.c \ src/mknod.c src/mount.c src/namei.c \ src/open.c src/rw.c src/reconcile.c src/rename.c \ - src/rmdir.c src/stat.c $(STATVFS_SRCS) \ + src/rmdir.c $(THREAD_MODEL_POSIX_SRCS) src/stat.c $(STATVFS_SRCS) \ src/stddir.c src/readdir.c src/readdir64.c \ src/symlink.c src/readlink.c \ src/truncate.c src/unlink.c src/utime.c \ Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -w -b -B -p -r1.29 -r1.30 --- mount.c 23 Apr 2008 00:23:21 -0000 1.29 +++ mount.c 17 Jun 2008 17:18:57 -0000 1.30 @@ -1,4 +1,5 @@ /* +P_REF(mnt->mnt_covers); * This Cplant(TM) source code is the property of Sandia National * Laboratories. * @@ -126,7 +127,7 @@ _sysio_do_mount(struct filesys *fs, * Directories only, please. */ if ((tocover && - !(tocover->p_base->pb_ino && + (tocover->p_base->pb_ino && S_ISDIR(tocover->p_base->pb_ino->i_stbuf.st_mode))) || !rootpb->pb_ino || !S_ISDIR(rootpb->pb_ino->i_stbuf.st_mode)) return -ENOTDIR; @@ -176,6 +177,12 @@ _sysio_do_mount(struct filesys *fs, goto error; } /* + * Need ref for the mount record but drop the locks now. + */ + P_REF(mnt->mnt_root); + P_PUT(mnt->mnt_root); + + /* * Cover up the mount point. */ mnt->mnt_covers = tocover; @@ -185,6 +192,7 @@ _sysio_do_mount(struct filesys *fs, */ mnt->mnt_covers = tocover = mnt->mnt_root; } + P_REF(mnt->mnt_covers); assert(!tocover->p_cover); tocover->p_cover = mnt->mnt_root; @@ -221,6 +229,8 @@ _sysio_mounti(struct filesys *fs, err = _sysio_do_mount(fs, rootpb, flags, tocover, mntp); if (err) _sysio_pb_gone(rootpb); + else + PB_PUT(rootpb); return err; } @@ -235,11 +245,13 @@ _sysio_do_unmount(struct mount *mnt) struct filesys *fs; root = mnt->mnt_root; + P_LOCK(root); assert(root->p_ref); if (root->p_cover && root->p_cover != root) { /* * Active mount. */ + P_UNLOCK(root); return -EBUSY; } #ifdef P_DEBUG @@ -250,6 +262,7 @@ _sysio_do_unmount(struct mount *mnt) /* * Active aliases. */ + P_UNLOCK(root); return -EBUSY; } /* @@ -257,7 +270,6 @@ _sysio_do_unmount(struct mount *mnt) * * Drop ref of covered pnode and break linkage in name space. */ - if (root->p_cover != root) P_RELE(mnt->mnt_covers); mnt->mnt_covers->p_cover = NULL; LIST_REMOVE(mnt, mnt_link); @@ -267,9 +279,12 @@ _sysio_do_unmount(struct mount *mnt) P_RELE(root); root->p_cover = NULL; rootpb = root->p_base; + PB_LOCK(rootpb); _sysio_p_gone(root); if (!(rootpb->pb_aliases.lh_first || rootpb->pb_children.lh_first)) _sysio_pb_gone(rootpb); + else + PB_UNLOCK(rootpb); /* * Release mount record resource. */ @@ -281,6 +296,33 @@ _sysio_do_unmount(struct mount *mnt) } /* + * Helper function to find FS type and call FS-specific mount routine. + */ +static int +_sysio_fs_mount(const char *source, + const char *fstype, + unsigned status, + unsigned flags, + const void *data, + struct pnode *tocover, + struct mount **mntp) +{ + struct fsswent *fssw; + int err; + + assert(((status & MOUNT_ST_IFST) == status) && + !(flags & MOUNT_ST_IFST)); + flags |= status & MOUNT_ST_IFST; + fssw = _sysio_fssw_lookup(fstype); + if (!fssw) + return -ENODEV; + assert(fssw->fssw_ops.fsswop_mount); + err = + (*fssw->fssw_ops.fsswop_mount)(source, flags, data, tocover, mntp); + return err; +} + +/* * Establish the system name space. */ int @@ -289,22 +331,19 @@ _sysio_mount_root(const char *source, unsigned flags, const void *data) { - struct fsswent *fssw; int err; struct mount *mnt; if (_sysio_root) return -EBUSY; - fssw = _sysio_fssw_lookup(fstype); - if (!fssw) - return -ENODEV; - - err = (*fssw->fssw_ops.fsswop_mount)(source, flags, data, NULL, &mnt); + mnt = NULL; + err = _sysio_fs_mount(source, fstype, 0, flags, data, NULL, &mnt); if (err) return err; _sysio_root = mnt->mnt_root; + P_REF(_sysio_root); #ifndef DEFER_INIT_CWD /* * It is very annoying to have to set the current working directory. @@ -328,27 +367,19 @@ _sysio_mount(struct pnode *cwd, const void *data) { int err; - struct fsswent *fssw; struct intent intent; - struct pnode *tgt; + struct pnode *tocover; struct mount *mnt; /* - * Find the file system switch entry specified. - */ - fssw = _sysio_fssw_lookup(filesystemtype); - if (!fssw) - return -ENODEV; - - /* * Look up the target path node. */ INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(cwd, target, 0, &intent, &tgt); + err = _sysio_namei(cwd, target, 0, &intent, &tocover); if (err) return err; - if (tgt == _sysio_root) { + if (tocover == _sysio_root) { /* * Attempting to mount over root. */ @@ -358,14 +389,16 @@ _sysio_mount(struct pnode *cwd, * Do the deed. */ err = - (*fssw->fssw_ops.fsswop_mount)(source, + _sysio_fs_mount(source, + filesystemtype, + 0, mountflags, data, - tgt, + tocover, &mnt); } if (err) - P_RELE(tgt); + P_PUT(tocover); return err; } @@ -412,7 +445,7 @@ SYSIO_INTERFACE_NAME(umount)(const char mnt = pno->p_mount; if (!err && mnt->mnt_root != pno) err = -EINVAL; - P_RELE(pno); /* was ref'd */ + P_PUT(pno); /* was ref'd */ if (err) goto out; @@ -444,6 +477,10 @@ _sysio_unmount_all() err = 0; while ((mnt = mounts.lh_first)) { pno = mnt->mnt_root; + if (pno == _sysio_root) { + P_RELE(_sysio_root); + _sysio_root = NULL; + } /* * If this is an automount generated mount, the root * has no reference. We can accomplish the dismount with a @@ -454,8 +491,6 @@ _sysio_unmount_all() err = _sysio_do_unmount(mnt); if (err) break; - if (pno == _sysio_root) - _sysio_root = NULL; } return err; @@ -668,7 +703,6 @@ _sysio_automount(struct pnode *mntpno) ssize_t cc; char *fstype, *source, *opts; unsigned flags; - struct fsswent *fssw; struct mount *mnt; /* @@ -711,25 +745,17 @@ _sysio_automount(struct pnode *mntpno) err = parse_automount_spec(buf, &fstype, &source, &opts); if (err) goto out; - flags = 0; if (opts) opts = parse_opts(opts, &flags); /* - * Find the file system switch entry specified. - */ - fssw = _sysio_fssw_lookup(fstype); - if (!fssw) { - err = -ENODEV; - goto out; - } - - /* * Do the deed. */ assert(mntpno->p_parent->p_ref); err = - (*fssw->fssw_ops.fsswop_mount)(source, + _sysio_fs_mount(source, + fstype, + MOUNT_ST_IFAUTO, flags, opts, mntpno->p_parent, Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -w -b -B -p -r1.29 -r1.30 --- namei.c 22 Apr 2008 21:56:03 -0000 1.29 +++ namei.c 17 Jun 2008 17:18:57 -0000 1.30 @@ -90,14 +90,9 @@ lookup(struct pnode *parent, int err; struct pnode *pno; - assert(parent != NULL); - /* - * The parent must be valid and a directory. - */ - if (!parent->p_parent) - return -ENOENT; - if (!S_ISDIR(parent->p_base->pb_ino->i_stbuf.st_mode)) - return -ENOTDIR; + assert(parent != NULL && + parent->p_parent && + S_ISDIR(parent->p_base->pb_ino->i_stbuf.st_mode)); /* * Sometimes we don't want to check permissions. At initialization @@ -113,20 +108,60 @@ lookup(struct pnode *parent, * Short-circuit `.' and `..'; We don't cache those. */ pno = NULL; - if (name->len == 1 && name->name[0] == '.') + if (name->len == 1 && name->name[0] == '.') { pno = parent; - else if (name->len == 2 && + P_GET(pno); + } else if (name->len == 2 && name->name[0] == '.' && name->name[1] == '.') { - while (parent->p_mount->mnt_root == parent && - parent != parent->p_mount->mnt_covers) - parent = parent->p_mount->mnt_covers; - pno = parent->p_parent; - assert(pno); - } - if (pno) - P_REF(pno); - else { + int parent_is_locked; + struct pnode *child; + + parent_is_locked = 1; + /* + * Careful not to enter deadly embrace. Only + * one node in any given type locked while we're doing this. + */ + pno = parent; + if (pno == pno->p_parent && pno->p_cover != pno) { + + /* + * This node loops on itself and is not the root + * of some name-space. It's an interior mount-point. + */ + P_REF(pno); /* ref passed parent */ + do { + struct mount *mnt; + + /* + * Only the mount record has the pointer + * to the covered path node. + */ + mnt = pno->p_mount; + MNT_GET(mnt); + assert(pno == mnt->mnt_root && + pno != mnt->mnt_covers); + P_PUT(pno); + parent_is_locked = 0; + pno = mnt->mnt_covers; + P_GET(pno); + MNT_PUT(mnt); + } while (pno == pno->p_parent && pno->p_cover != pno); + } + /* + * Now, move to parent of this node. + */ + child = pno; + if (parent_is_locked) + P_REF(child); + pno = pno->p_parent; + P_PUT(child); + P_GET(pno); + if (!parent_is_locked) + child = parent; + P_GET(child); + P_RELE(child); + } else { /* * Get cache entry then. */ @@ -140,8 +175,8 @@ lookup(struct pnode *parent, struct pnode *cover; cover = pno->p_cover; - P_REF(cover); - P_RELE(pno); + P_GET(cover); + P_PUT(pno); pno = cover; } } @@ -215,22 +250,25 @@ _sysio_path_walk(struct pnode *parent, s (void )_sysio_namei(nd->nd_root, icwd, 0, NULL, &parent); if (_sysio_p_chdir(parent) != 0) abort(); + P_PUT(parent); } #endif /* * (Re)Validate the parent. */ + P_GET(parent); err = _sysio_p_validate(parent, NULL, NULL); - if (err) + if (err) { + P_PUT(parent); return err; + } /* * Prime everything for the loop. Will need another reference to the * initial directory. It'll be dropped later. */ nd->nd_pno = parent; - P_REF(nd->nd_pno); _sysio_next_component(nd->nd_path, &next); path = next.name; parent = NULL; @@ -270,6 +308,8 @@ _sysio_path_walk(struct pnode *parent, s /* * Handle symbolic links with recursion. Yuck! */ + P_REF(nd->nd_pno); + P_PUT(nd->nd_pno); ND_INIT(&nameidata, (nd->nd_flags | ND_NEGOK), lpath, @@ -278,28 +318,36 @@ _sysio_path_walk(struct pnode *parent, s nameidata.nd_slicnt = nd->nd_slicnt + 1; err = _sysio_path_walk(nd->nd_pno->p_parent, &nameidata); + P_GET(nd->nd_pno); + P_RELE(nd->nd_pno); free(lpath); if (err) break; - P_RELE(nd->nd_pno); + P_PUT(nd->nd_pno); nd->nd_pno = nameidata.nd_pno; ino = nd->nd_pno->p_base->pb_ino; } #ifdef AUTOMOUNT_FILE_NAME else if (ino && - S_ISDIR(ino->i_stbuf.st_mode) && - (nd->nd_pno->p_mount->mnt_flags & MOUNT_F_AUTO) && nd->nd_amcnt < MAX_MOUNT_DEPTH && - ino->i_stbuf.st_mode & S_ISUID) { + S_ISDIR(ino->i_stbuf.st_mode) && + ino->i_stbuf.st_mode & S_ISUID && + (nd->nd_pno->p_mount->mnt_flags & MOUNT_F_AUTO)) { + struct mount *mnt; struct pnode *pno; /* - * We're committed to a lookup. It's time to see if - * we're going to do it in an automount-point and - * arrange the mount if so. + * Handle directories that hint they might + * be automount-points. */ - assert(!nd->nd_pno->p_cover); + mnt = nd->nd_pno->p_mount; + MNT_GET(mnt); + err = + nd->nd_pno->p_mount->mnt_flags & MOUNT_F_AUTO + ? 0 + : -EACCES; pno = NULL; + if (!err) { err = lookup(nd->nd_pno, &_sysio_mount_file_name, @@ -307,6 +355,8 @@ _sysio_path_walk(struct pnode *parent, s NULL, NULL, 1); + assert(!err || (err && !pno)); + } if (!err && (err = _sysio_automount(pno)) == 0) { /* * All went well. Need to switch @@ -322,7 +372,7 @@ _sysio_path_walk(struct pnode *parent, s * infinite loop. */ nd->nd_pno = nd->nd_pno->p_cover; - P_REF(nd->nd_pno); + P_GET(nd->nd_pno); ino = nd->nd_pno->p_base->pb_ino; assert(ino); @@ -334,7 +384,8 @@ _sysio_path_walk(struct pnode *parent, s } if (pno) - P_RELE(pno); + P_PUT(pno); + MNT_PUT(mnt); if (!err) { /* * Must go back top and retry with this @@ -424,8 +475,13 @@ _sysio_path_walk(struct pnode *parent, s break; } path = NULL; /* Stop that! */ - if ((parent->p_mount->mnt_fs != - nd->nd_pno->p_mount->mnt_fs)) { + /* + * Next check requires no further locks. We are preventing + * the destruction of the mount records by holding locks + * on the two path nodes and the FS field is immutable. + */ + if (!(parent->p_mount == nd->nd_pno->p_mount || + parent->p_mount->mnt_fs == nd->nd_pno->p_mount->mnt_fs)) { /* * Crossed into a new fs. We'll want the next lookup * to include the path again. @@ -434,9 +490,9 @@ _sysio_path_walk(struct pnode *parent, s } /* - * Release the parent. + * Finished with the current parent. */ - P_RELE(parent); + P_PUT(parent); parent = NULL; } @@ -457,18 +513,18 @@ _sysio_path_walk(struct pnode *parent, s } /* - * Drop reference to parent if set. Either we have a dup of the original + * Put the parent if present. Either we have a dup of the original * parent or an intermediate reference. */ if (parent) - P_RELE(parent); + P_PUT(parent); /* - * On error, we will want to drop our reference to the current + * On error, we will want to drop the current * path node if at end. */ if (err && nd->nd_pno) { - P_RELE(nd->nd_pno); + P_PUT(nd->nd_pno); nd->nd_pno = NULL; } Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -w -b -B -p -r1.31 -r1.32 --- open.c 19 Sep 2007 16:01:33 -0000 1.31 +++ open.c 17 Jun 2008 17:18:57 -0000 1.32 @@ -95,8 +95,8 @@ _sysio_open(struct pnode *pno, int flags if (ro) return -EROFS; err = _sysio_p_validate(pno->p_parent, NULL, NULL); - if (!err) - err = PNOP_OPEN(pno, flags, mode); + if (!err && (err = PNOP_OPEN(pno, flags, mode)) == 0) + I_REF(pno->p_base->pb_ino); } else if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) err = -EEXIST; else if (!pno->p_base->pb_ino) @@ -190,15 +190,15 @@ SYSIO_INTERFACE_NAME(open)(const char *p if (rtn < 0) goto error; - P_RELE(pno); + FIL_PUT(fil); SYSIO_INTERFACE_RETURN(rtn, 0, open, "%d", 0); error: if (fil) - F_RELE(fil); + FIL_PUT(fil); if (pno) - P_RELE(pno); + P_PUT(pno); SYSIO_INTERFACE_RETURN(-1, rtn, open, "%d", 0); } Index: readlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/readlink.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- readlink.c 2 Jul 2007 18:58:17 -0000 1.10 +++ readlink.c 17 Jun 2008 17:18:57 -0000 1.11 @@ -75,7 +75,7 @@ SYSIO_INTERFACE_NAME(readlink)(const cha } err = PNOP_READLINK(pno, buf, bufsiz); error: - P_RELE(pno); + P_PUT(pno); out: #ifdef HAVE_POSIX_1003_READLINK #define _rtnfmt "%zd" Index: rename.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rename.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- rename.c 2 Jul 2007 18:58:17 -0000 1.14 +++ rename.c 17 Jun 2008 17:18:57 -0000 1.15 @@ -86,6 +86,8 @@ SYSIO_INTERFACE_NAME(rename)(const char old = NULL; break; } + P_REF(old); + P_PUT(old); /* * Resolve newpath to a path node. */ @@ -100,8 +102,13 @@ SYSIO_INTERFACE_NAME(rename)(const char new = NULL; break; } + P_REF(new); + P_PUT(new); + _sysio_p_get2(old, new); err = _sysio_p_rename(old, new); + P_PUT(old); + P_PUT(new); } while (0); if (new) Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -w -b -B -p -r1.22 -r1.23 --- rmdir.c 2 Jul 2007 18:58:17 -0000 1.22 +++ rmdir.c 17 Jun 2008 17:18:57 -0000 1.23 @@ -78,7 +78,7 @@ SYSIO_INTERFACE_NAME(rmdir)(const char * break; } while (0); if (pno) - P_RELE(pno); + P_PUT(pno); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, rmdir, "%d", 0); } Index: rw.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rw.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -w -b -B -p -r1.28 -r1.29 --- rw.c 30 Nov 2007 18:10:33 -0000 1.28 +++ rw.c 17 Jun 2008 17:18:57 -0000 1.29 @@ -222,7 +222,7 @@ _sysio_iiox(int writing, /* * Opened for proper access? */ - if (!F_CHKRW(fil, writing ? 'w' : 'r')) { + if (!FIL_CHKRW(fil, writing ? 'w' : 'r')) { err = -EBADF; break; } @@ -311,11 +311,16 @@ _do_ireadx(int fd, fd, iov_count, iov, xtv_count, xtv); + do { fil = _sysio_fd_find(fd); - if (fil == NULL) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF, ireadx, "%p", 0); - if (fil->f_pno->p_base->pb_ino == NULL) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ESTALE, ireadx, "%p", 0); + if (fil == NULL) { + err = -EBADF; + break; + } + if (fil->f_pno->p_base->pb_ino == NULL) { + err = -ESTALE; + break; + } err = _sysio_iiox(READ, fil, @@ -323,6 +328,9 @@ _do_ireadx(int fd, xtv, xtv_count, release_xtvec, completio, &ioctx); + } while (0); + if (fil) + FIL_PUT(fil); SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err, ireadx, "%p", 0); } @@ -361,11 +369,16 @@ _do_iwritex(int fd, fd, iov_count, iov, xtv_count, xtv); + do { fil = _sysio_fd_find(fd); - if (fil == NULL) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -EBADF, iwritex, "%p", 0); - if (fil->f_pno->p_base->pb_ino == NULL) - SYSIO_INTERFACE_RETURN(IOID_FAIL, -ESTALE, iwritex, "%p", 0); + if (fil == NULL) { + err = -EBADF; + break; + } + if (fil->f_pno->p_base->pb_ino == NULL) { + err = -ESTALE; + break; + } err = _sysio_iiox(WRITE, fil, @@ -373,6 +386,9 @@ _do_iwritex(int fd, xtv, xtv_count, release_xtvec, completio, &ioctx); + } while (0); + if (fil) + FIL_PUT(fil); SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err, iwritex, "%p", 0); } @@ -913,6 +929,8 @@ _do_iiov(direction dir, void *))_sysio_fcompletio, &ioctx); } while (0); + if (fil) + FIL_PUT(fil); if (err && xtv) free(xtv); if (dir == READ) Index: stat.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -b -B -p -r1.21 -r1.22 --- stat.c 19 Sep 2007 16:01:33 -0000 1.21 +++ stat.c 17 Jun 2008 17:18:57 -0000 1.22 @@ -83,6 +83,7 @@ _sysio_fxstat(int ver, int fildes, struc * want fresh ones. */ err = PNOP_GETATTR(fil->f_pno, stat_buf); + FIL_PUT(fil); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fxstat, "%d%sY", stat_buf); } @@ -116,7 +117,7 @@ _sysio_xstatnd(int ver, (void )memcpy(stat_buf, &pno->p_base->pb_ino->i_stbuf, sizeof(struct intnl_stat)); - P_RELE(pno); + P_PUT(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, xstatnd, "%d%sY", stat_buf); } Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -b -B -p -r1.19 -r1.20 --- statvfs.c 26 Oct 2007 19:48:23 -0000 1.19 +++ statvfs.c 17 Jun 2008 17:18:57 -0000 1.20 @@ -68,7 +68,7 @@ _sysio_statvfs(const char *path, struct return err; err = PNOP_STATVFS(pno, buf); - P_RELE(pno); + P_PUT(pno); return err; } @@ -84,6 +84,7 @@ _sysio_fstatvfs(int fd, struct intnl_sta return -EBADF; err = PNOP_STATVFS(filp->f_pno, buf); + FIL_PUT(filp); return err; } Index: symlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/symlink.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -b -B -p -r1.19 -r1.20 --- symlink.c 20 Nov 2007 18:01:42 -0000 1.19 +++ symlink.c 17 Jun 2008 17:18:57 -0000 1.20 @@ -79,7 +79,7 @@ SYSIO_INTERFACE_NAME(symlink)(const char err = _sysio_p_symlink(oldpath, pno); } while (0); if (pno) - P_RELE(pno); + P_PUT(pno); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, symlink, "%d", 0); } Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -b -B -p -r1.18 -r1.19 --- truncate.c 2 Jul 2007 18:58:17 -0000 1.18 +++ truncate.c 17 Jun 2008 17:18:57 -0000 1.19 @@ -96,7 +96,7 @@ PREPEND(_, SYSIO_INTERFACE_NAME(truncate if (err) goto out; err = do_truncate(pno, length); - P_RELE(pno); + P_PUT(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, truncate, "%d", 0); @@ -130,12 +130,14 @@ PREPEND(_, SYSIO_INTERFACE_NAME(ftruncat SYSIO_INTERFACE_ENTER(ftruncate, "%d%oZ", fd, length); err = 0; fil = _sysio_fd_find(fd); - if (!(fil && F_CHKRW(fil, 'w'))) { + if (!(fil && FIL_CHKRW(fil, 'w'))) { err = -EBADF; goto out; } err = do_truncate(fil->f_pno, length); out: + if (fil) + FIL_PUT(fil); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, ftruncate, "%d", 0); } Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -b -B -p -r1.20 -r1.21 --- unlink.c 2 Jul 2007 18:58:17 -0000 1.20 +++ unlink.c 17 Jun 2008 17:18:57 -0000 1.21 @@ -79,7 +79,7 @@ SYSIO_INTERFACE_NAME(unlink)(const char break; } while (0); if (pno) - P_RELE(pno); + P_PUT(pno); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, unlink, "%d", 0); } Index: utime.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/utime.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- utime.c 2 Jul 2007 18:58:18 -0000 1.9 +++ utime.c 17 Jun 2008 17:18:57 -0000 1.10 @@ -89,7 +89,7 @@ SYSIO_INTERFACE_NAME(utime)(const char * stbuf.st_mtime = buf->modtime; err = _sysio_p_setattr(pno, SETATTR_ATIME | SETATTR_MTIME, &stbuf); - P_RELE(pno); + P_PUT(pno); out: /* * Note: Pass the utimbuf buffer to the tracing routines some day. |