[Libsysio-commit] unification: libsysio/include file.h inode.h
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2007-02-05 15:54:37
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6564/include Modified Files: Tag: unification file.h inode.h Log Message: The open file table now maintains a link to the path-node, or `pnode', instead of the inode. This is done in order to enable support for per-mount options. The issue is that bound-mounts could not have independent options. We had lost the linkage between the mount that a particular alias came from and, so, could not act on per-mount flags. As part of this, all calls through the VFS have been wrapped by macros. They all begin with PNOP_. For instance, the inop_mkdir call is wrapped with PNOP_MKDIR now. These modifications, while intrusive, require no changes to the existing drivers. However, there are many calls that take both a path-node and an inode, and at some time in the future, the path-node, only, will be passed. You might be pro-active in altering the various entry-points so that the inode is ignored -- It's always available now. Of course, that can't be done for the IO routines, which take only an inode. Note, though, that the ioctx structure now carries the path-node, in addition. Perhaps use that? In short, I'm going to deprecate the passing of inodes through the VFS in favor of the path-node at some point. Index: file.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/file.h,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -w -b -B -p -r1.16 -r1.16.2.1 --- file.h 3 May 2006 22:34:46 -0000 1.16 +++ file.h 5 Feb 2007 15:54:27 -0000 1.16.2.1 @@ -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); \ @@ -127,7 +127,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.27.2.1 diff -u -w -b -B -p -r1.27 -r1.27.2.1 --- inode.h 3 May 2006 22:34:46 -0000 1.27 +++ inode.h 5 Feb 2007 15:54:27 -0000 1.27.2.1 @@ -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 @@ -279,6 +279,92 @@ struct pnode { } while (0) /* + * Pnode meta-call. + */ +#define _PNOP_MKCALL(_pno, _fbase, ...) \ + ((_pno)->p_base->pb_ino ? \ + (*(_pno)->p_base->pb_ino->i_ops.inop_##_fbase)(__VA_ARGS__) : \ + -ESTALE) + +/* + * Operations + */ +#define PNOP_LOOKUP(_pno, _inop, _intnt, _path) \ + _PNOP_MKCALL((_pno)->p_parent, lookup, \ + (_pno), (_inop), (_intnt), (_path)) +#define PNOP_GETATTR(_pno, _stbuf) \ + _PNOP_MKCALL((_pno), getattr, \ + (_pno), (_pno)->p_base->pb_ino, (_stbuf)) +#define PNOP_SETATTR(_pno, _mask, _stbuf) \ + _PNOP_MKCALL((_pno), setattr, \ + (_pno), (_pno)->p_base->pb_ino, (_mask), (_stbuf)) +#define PNOP_FILLDIRENTRIES(_pno, _posp, _buf, _nbytes) \ + _PNOP_MKCALL((_pno), filldirentries, \ + (_pno)->p_base->pb_ino, (_posp), (_buf), (_nbytes)) +#define PNOP_MKDIR(_pno, _mode) \ + _PNOP_MKCALL((_pno)->p_parent, mkdir, \ + (_pno), (_mode)) +#define PNOP_RMDIR(_pno) \ + _PNOP_MKCALL((_pno), rmdir, \ + (_pno)) +#define PNOP_SYMLINK(_pno, _data) \ + _PNOP_MKCALL((_pno)->p_parent, symlink, \ + (_pno), (_data)) +#define PNOP_READLINK(_pno, _buf, _bufsiz) \ + _PNOP_MKCALL((_pno), readlink, \ + (_pno), (_buf), (_bufsiz)) +#define PNOP_OPEN(_pno, _flags, _mode) \ + _PNOP_MKCALL((_pno)->p_parent, open, \ + (_pno), (_flags), (_mode)) +#define PNOP_CLOSE(_pno) \ + _PNOP_MKCALL((_pno), close, \ + (_pno)->p_base->pb_ino) +#define PNOP_LINK(_old, _new) \ + _PNOP_MKCALL((_old)->p_parent, link, \ + (_old), (_new)) +#define PNOP_UNLINK(_pno) \ + _PNOP_MKCALL((_pno), unlink, \ + (_pno)) +#define PNOP_RENAME(_old, _new) \ + _PNOP_MKCALL((_old)->p_parent, rename, \ + (_old), (_new)) +#define PNOP_READ(_pno, _ioctx) \ + _PNOP_MKCALL((_pno), read, \ + (_pno)->p_base->pb_ino, (_ioctx)) +#define PNOP_WRITE(_pno, _ioctx) \ + _PNOP_MKCALL((_pno), write, \ + (_pno)->p_base->pb_ino, (_ioctx)) +#define PNOP_POS(_pno, _off) \ + _PNOP_MKCALL((_pno), pos, \ + (_pno)->p_base->pb_ino, (_off)) +#define PNOP_IODONE(_pno, _ioctx) \ + _PNOP_MKCALL((_pno), iodone, \ + (_ioctx)) +#define PNOP_FCNTL(_pno, _cmd, _ap, _rtn) \ + _PNOP_MKCALL((_pno), fcntl, \ + (_pno)->p_base->pb_ino, (_cmd), (_ap), (_rtn)) +#define PNOP_SYNC(_pno) \ + _PNOP_MKCALL((_pno), sync, \ + (_pno)->p_base->pb_ino) +#define PNOP_DATASYNC(_pno) \ + _PNOP_MKCALL((_pno), datasync, \ + (_pno)->p_base->pb_ino) +#define PNOP_IOCTL(_pno, _request, _ap) \ + _PNOP_MKCALL((_pno), ioctl, \ + (_pno)->p_base->pb_ino, (_request), (_ap)) +#define PNOP_MKNOD(_pno, _mode, _dev) \ + _PNOP_MKCALL((_pno)->p_parent, mknod, \ + (_pno), (_mode), (_dev)) +#ifdef _HAVE_STATVFS +#define PNOP_STATVFS(_pno, _buf) \ + _PNOP_MKCALL((_pno), statvfs, \ + (_pno), (_pno)->p_base->pb_ino, (_buf)) +#endif +#define PNOP_GONE(_pno) \ + _PNOP_MKCALL((_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 +455,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 +470,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,25 +512,25 @@ 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 void _sysio_pb_disconnect(struct pnode_base *pb); extern size_t _sysio_p_prune(struct pnode *root); extern int _sysio_p_kill_all(struct pnode *root); extern char *_sysio_pb_path(struct pnode_base *pb, char separator); extern int _sysio_setattr(struct pnode *pno, - struct inode *ino, unsigned mask, struct intnl_stat *stbuf); extern void _sysio_do_noop(void); @@ -467,7 +555,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, |