[Libsysio-commit] HEAD: libsysio/include file.h inode.h sysio-cmn.h
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-04-30 16:52:28
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv2000/include Modified Files: file.h inode.h sysio-cmn.h Log Message: Merged "unification" branch. First, the changes alter the core to perform pnode-ops by pnode. However, it maintains the pre-existing interface in order to minimize driver changes. Second, more detailed tracing information is available now in the form of a tag, indicating which function the data is from, as well as arguments and return data. Note1: The S_IFDIR bit is no longer set when the pnode-op mkdir function is called. If you need that, set it in your driver. Note2: It is possible to encounter a disconnected tree in _sysio_pb_path. If so, it returns an empty string. This *might* be good enough for your driver. If not, you'll need a change for this as well -- In fact, you should go ahead and change it anyway. Instead of _sysio_pb_path, use _sysio_pb_pathof. This new function takes the base pnode and a pointer to a string. It returns an integer. The usual zero on success or a negated errno on failure. Note3: Sockets support is horribly broken and won't build. As far as I know, this was never used. Unless somebody tells me differently, sockets support will be deprecated in the next release. Otherwise, let me know and I'll fix it. Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -w -b -B -p -r1.17 -r1.18 --- file.h 12 Apr 2007 18:00:42 -0000 1.17 +++ file.h 30 Apr 2007 16:52:20 -0000 1.18 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States @@ -73,7 +73,7 @@ * operations that may be performed. */ struct file { - struct inode *f_ino; /* path node */ + 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 */ @@ -102,11 +102,11 @@ struct file { /* * Init file record. * - * NB: Don't forget to take a reference to the inode too! + * NB: Don't forget to take a reference to the pnode too! */ -#define _SYSIO_FINIT(fil, ino, flags) \ +#define _SYSIO_FINIT(fil, pno, flags) \ do { \ - (fil)->f_ino = (ino); \ + (fil)->f_pno = (pno); \ (fil)->f_pos = 0; \ (fil)->f_ref = 0; \ (fil)->f_flags = (flags); \ @@ -129,7 +129,7 @@ struct file { struct ioctx; -extern struct file *_sysio_fnew(struct inode *ino, int flags); +extern struct file *_sysio_fnew(struct pnode *pno, int flags); extern void _sysio_fgone(struct file *fil); extern void _sysio_fcompletio(struct ioctx *ioctx, struct file *fil); extern int _sysio_fd_close(int fd); Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.27 retrieving revision 1.28 diff -u -w -b -B -p -r1.27 -r1.28 --- inode.h 3 May 2006 22:34:46 -0000 1.27 +++ inode.h 30 Apr 2007 16:52:20 -0000 1.28 @@ -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-2006 Sandia Corporation. + * Cplant(TM) Copyright 1998-2007 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -279,6 +279,78 @@ struct pnode { } while (0) /* + * Path node meta-call. + */ +#define INOP_CALL(_f, ...) \ + ((*_f)(__VA_ARGS__)) +#define _INOP_FUNC(_ino, _fbase) \ + ((_ino)->i_ops.inop_##_fbase) +#define PNOP_FUNC(_pno, _fbase) \ + _INOP_FUNC((_pno)->p_base->pb_ino, _fbase) +#define _PNOP_CALL(_pno, _fbase, ...) \ + INOP_CALL(PNOP_FUNC((_pno), _fbase), __VA_ARGS__) +#define _PNOP_MKCALL(_pno, _fbase, ...) \ + ((_pno)->p_base->pb_ino \ + ? _PNOP_CALL((_pno), _fbase, __VA_ARGS__) \ + : _PNOP_CALL((_pno)->p_mount->mnt_root, _fbase, __VA_ARGS__)) + +/* + * Operations + */ +#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)) +#define PNOP_SETATTR(_pno, _mask, _stbuf) \ + _PNOP_CALL((_pno), setattr, \ + (_pno), (_pno)->p_base->pb_ino, (_mask), (_stbuf)) +#define PNOP_FILLDIRENTRIES(_pno, _posp, _buf, _nbytes) \ + _PNOP_CALL((_pno), filldirentries, \ + (_pno)->p_base->pb_ino, (_posp), (_buf), (_nbytes)) +#define PNOP_MKDIR(_pno, _mode) \ + _PNOP_MKCALL((_pno), mkdir, (_pno), (_mode)) +#define PNOP_RMDIR(_pno) \ + _PNOP_MKCALL((_pno), rmdir, (_pno)) +#define PNOP_SYMLINK(_pno, _data) \ + _PNOP_MKCALL((_pno), symlink, (_pno), (_data)) +#define PNOP_READLINK(_pno, _buf, _bufsiz) \ + _PNOP_CALL((_pno), readlink, (_pno), (_buf), (_bufsiz)) +#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) +#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_POS(_pno, _off) \ + _PNOP_CALL((_pno), pos, (_pno)->p_base->pb_ino, (_off)) +#define PNOP_IODONE(_pno, _ioctx) \ + _PNOP_CALL((_pno), iodone, (_ioctx)) +#define PNOP_FCNTL(_pno, _cmd, _ap, _rtn) \ + _PNOP_CALL((_pno), fcntl, (_pno)->p_base->pb_ino, (_cmd), (_ap), (_rtn)) +#define PNOP_SYNC(_pno) \ + _PNOP_CALL((_pno), sync, (_pno)->p_base->pb_ino) +#define PNOP_DATASYNC(_pno) \ + _PNOP_CALL((_pno), datasync, (_pno)->p_base->pb_ino) +#define PNOP_IOCTL(_pno, _request, _ap) \ + _PNOP_CALL((_pno), ioctl, (_pno)->p_base->pb_ino, (_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)) +#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 * about what they want to accomplish in the end. */ @@ -369,7 +441,8 @@ struct ioctx { ioctx_fast : 1, /* from stack space */ ioctx_done : 1, /* transfer complete */ ioctx_write : 1; /* op is a write */ - struct inode *ioctx_ino; /* i-node */ + struct pnode *ioctx_pno; /* p-node */ + 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 */ @@ -383,12 +456,13 @@ struct ioctx { /* * Init IO context record. */ -#define IOCTX_INIT(ioctx, fast, wr, ino, iov, iovlen, xtv, xtvlen) \ +#define IOCTX_INIT(ioctx, fast, wr, pno, iov, iovlen, xtv, xtvlen) \ do { \ (ioctx)->ioctx_fast = (fast); \ (ioctx)->ioctx_done = 0; \ (ioctx)->ioctx_write = (wr) ? 1 : 0; \ - (ioctx)->ioctx_ino = (ino); \ + (ioctx)->ioctx_pno = (pno); \ + (ioctx)->ioctx_ino = (pno)->p_base->pb_ino; \ (ioctx)->ioctx_iov = (iov); \ (ioctx)->ioctx_iovlen = (iovlen); \ (ioctx)->ioctx_xtv = (xtv); \ @@ -424,27 +498,32 @@ extern struct inode *_sysio_i_find(struc struct file_identifier *fid); extern void _sysio_i_gone(struct inode *ino); extern void _sysio_i_undead(struct inode *ino); +extern struct pnode_base *_sysio_pb_new(struct qstr *name, + struct pnode_base *parent, + struct inode *ino); +extern void _sysio_pb_gone(struct pnode_base *pb); extern int _sysio_p_find_alias(struct pnode *parent, struct qstr *name, struct pnode **pnop); extern int _sysio_p_validate(struct pnode *pno, struct intent *intnt, const char *path); -extern struct pnode_base *_sysio_pb_new(struct qstr *name, - struct pnode_base *parent, - struct inode *ino); -extern void _sysio_pb_gone(struct pnode_base *pb); extern struct pnode *_sysio_p_new_alias(struct pnode *parent, struct pnode_base *pb, 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 int _sysio_pb_pathof(struct pnode_base *pb, + char separator, + char **pathp); extern char *_sysio_pb_path(struct pnode_base *pb, char separator); -extern int _sysio_setattr(struct pnode *pno, - struct inode *ino, +extern int _sysio_p_setattr(struct pnode *pno, unsigned mask, struct intnl_stat *stbuf); +extern int _sysio_p_unlink(struct pnode *pno); +extern int _sysio_p_rmdir(struct pnode *pno); +extern int _sysio_p_rename(struct pnode *old, struct pnode *new); extern void _sysio_do_noop(void); extern void _sysio_do_illop(void); extern int _sysio_do_ebadf(void); @@ -467,7 +546,7 @@ extern int _sysio_namei(struct pnode *pn extern int _sysio_p_chdir(struct pnode *pno); extern int _sysio_ioctx_init(void); extern void _sysio_ioctx_enter(struct ioctx *ioctx); -extern struct ioctx *_sysio_ioctx_new(struct inode *ino, +extern struct ioctx *_sysio_ioctx_new(struct pnode *pno, int wr, const struct iovec *iov, size_t iovlen, @@ -482,5 +561,15 @@ extern int _sysio_ioctx_done(struct ioct extern ssize_t _sysio_ioctx_wait(struct ioctx *ioctx); extern void _sysio_ioctx_complete(struct ioctx *ioctx); extern int _sysio_open(struct pnode *pno, int flags, mode_t mode); +extern int _sysio_p_aread(struct pnode *pno, + _SYSIO_OFF_T off, + void *buf, + size_t count, + struct ioctx **ioctxp); +extern int _sysio_p_awrite(struct pnode *pno, + _SYSIO_OFF_T off, + void *buf, + size_t count, + struct ioctx **ioctxp); extern int _sysio_mkdir(struct pnode *where, mode_t mode); extern int _sysio_mknod(struct pnode *where, mode_t mode, dev_t dev); Index: sysio-cmn.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio-cmn.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- sysio-cmn.h 14 Feb 2007 18:50:17 -0000 1.12 +++ sysio-cmn.h 30 Apr 2007 16:52:20 -0000 1.13 @@ -140,20 +140,74 @@ struct iovec; */ #define SYSIO_INTERFACE_DISPLAY_BLOCK \ int _saved_errno; -#define SYSIO_INTERFACE_ENTER \ +#define SYSIO_INTERFACE_ENTER(tag, ...) \ do { \ _saved_errno = errno; \ - SYSIO_ENTER; \ + SYSIO_ENTER(tag, __VA_ARGS__); \ } while (0) -#define SYSIO_INTERFACE_RETURN(rtn, err) \ +#define SYSIO_INTERFACE_RETURN(rtn, err, tag, ...) \ do { \ - SYSIO_LEAVE; \ + SYSIO_LEAVE(tag, (rtn), (err), __VA_ARGS__); \ errno = (err) ? -(err) : _saved_errno; \ return (rtn); \ } while(0) /* Interface enter/leave hook functions */ #if SYSIO_TRACING + +#define _SYSIO_TTAG(name) \ + PREPEND(_SYSIO_TRACING_, name) + +/* + * Supported tracing tags. + */ +typedef enum { + _SYSIO_TTAG(unsupported) = -1, + _SYSIO_TTAG(access), + _SYSIO_TTAG(chdir), + _SYSIO_TTAG(getcwd), + _SYSIO_TTAG(chmod), + _SYSIO_TTAG(fchmod), + _SYSIO_TTAG(chown), + _SYSIO_TTAG(fchown), + _SYSIO_TTAG(dup2), + _SYSIO_TTAG(dup), + _SYSIO_TTAG(vfcntl), + _SYSIO_TTAG(fsync), + _SYSIO_TTAG(fdatasync), + _SYSIO_TTAG(getdirentries64), + _SYSIO_TTAG(getdirentries), + _SYSIO_TTAG(ioctl), + _SYSIO_TTAG(iodone), + _SYSIO_TTAG(iowait), + _SYSIO_TTAG(link), + _SYSIO_TTAG(lseek64), + _SYSIO_TTAG(lseek), + _SYSIO_TTAG(llseek), + _SYSIO_TTAG(mkdir), + _SYSIO_TTAG(xmknod), + _SYSIO_TTAG(mount), + _SYSIO_TTAG(umount), + _SYSIO_TTAG(open), + _SYSIO_TTAG(close), + _SYSIO_TTAG(ireadx), + _SYSIO_TTAG(iwritex), + _SYSIO_TTAG(ireadv), + _SYSIO_TTAG(iwritev), + _SYSIO_TTAG(rename), + _SYSIO_TTAG(rmdir), + _SYSIO_TTAG(xstatnd), + _SYSIO_TTAG(fxstat), + _SYSIO_TTAG(opendir), + _SYSIO_TTAG(closedir), + _SYSIO_TTAG(symlink), + _SYSIO_TTAG(readlink), + _SYSIO_TTAG(truncate), + _SYSIO_TTAG(ftruncate), + _SYSIO_TTAG(unlink), + _SYSIO_TTAG(utime), +} tracing_tag; + extern void *_sysio_entry_trace_q; extern void *_sysio_exit_trace_q; @@ -161,30 +215,39 @@ extern void *_sysio_register_trace(void void (*)(const char *file, const char *func, int line, - void *data), + void *data, + tracing_tag tag, + va_list ap), void *data, void (*destructor)(void *data)); extern void _sysio_remove_trace(void *q, void *p); extern void _sysio_run_trace_q(void *q, const char *file, const char *func, - int line); -#define SYSIO_ENTER \ + int line, + tracing_tag tag, + ...); + +#define SYSIO_ENTER(tag, ...) \ do { \ _sysio_run_trace_q(_sysio_entry_trace_q, \ - __FILE__, __func__, __LINE__); \ + __FILE__, __func__, __LINE__, \ + _SYSIO_TTAG(tag), \ + __VA_ARGS__); \ } while (0) -#define SYSIO_LEAVE \ +#define SYSIO_LEAVE(tag, ...) \ do { \ _sysio_run_trace_q(_sysio_exit_trace_q, \ - __FILE__, __func__, __LINE__); \ + __FILE__, __func__, __LINE__, \ + _SYSIO_TTAG(tag), \ + __VA_ARGS__); \ } while (0) #else -#define SYSIO_ENTER \ +#define SYSIO_ENTER(tag, ...) \ do { } while (0) -#define SYSIO_LEAVE \ +#define SYSIO_LEAVE(tag, ...) \ do { } while (0) #endif |