[Libsysio-commit] HEAD: libsysio/src dev.c fsync.c inode.c ioctx.c rw.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2009-12-07 22:00:33
|
Update of /cvsroot/libsysio/libsysio/src In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv2260/src Modified Files: dev.c fsync.c inode.c ioctx.c rw.c Log Message: Added ifsync and ifdatasync. These are asynchronous versions of the standard calls. In fact, the core has been reworked so that the async versions are the core implementation. For backward compatibility, if your driver has old versions you may set the new inop_isync ad inop_idatasync fields to NULL and retain the old interface and, synchronous, semantics. The existing fields were renamed to inop_old_sync and inop_old_datasync and will be deprecated in the future. One important, related, change is that the ioctx record has a new field, called ioctx_args, which is a void * type. It's only used to pass the real function to call aby the code that is faking the async API but using the old fsync and fdatasync. Index: dev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -b -B -p -r1.15 -r1.16 --- dev.c 5 May 2009 16:35:29 -0000 1.15 +++ dev.c 7 Dec 2009 22:00:24 -0000 1.16 @@ -72,7 +72,9 @@ const struct inode_ops _sysio_nodev_ops _sysio_nodev_inop_pos, _sysio_nodev_inop_iodone, _sysio_nodev_inop_fcntl, + NULL, _sysio_nodev_inop_sync, + NULL, _sysio_nodev_inop_datasync, _sysio_nodev_inop_ioctl, _sysio_nodev_inop_mknod, Index: fsync.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fsync.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- fsync.c 17 Jun 2008 17:18:57 -0000 1.12 +++ fsync.c 7 Dec 2009 22:00:24 -0000 1.13 @@ -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-2009 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... */ @@ -50,17 +50,63 @@ #include <sys/queue.h> #include "sysio.h" +#include "xtio.h" #include "inode.h" #include "file.h" -int -SYSIO_INTERFACE_NAME(fsync)(int fd) +struct fake_args { + int (*f)(struct pnode *); +}; + +static int +fakeit(struct ioctx *ioctx) +{ + struct fake_args *f; + + f = ioctx->ioctx_args; + ioctx->ioctx_cc = (*(f->f))(ioctx->ioctx_pno); + ioctx->ioctx_done = 1; + + return 0; +} + +static int +_sysio_p_sync(struct pnode *pno, struct ioctx **ioctxp) +{ + void *args; + struct fake_args fake; + int (*f)(struct ioctx *); + int err; + + args = NULL; + if (pno->p_base->pb_ino->i_ops.inop_isync) + f = PNOP_FUNC(pno, isync); + else { + f = fakeit; + fake.f = PNOP_FUNC(pno, old_sync); + args = &fake; + } + err = + _sysio_p_iiox(f, + pno, + -1, + NULL, 0, NULL, + NULL, 0, NULL, + NULL, NULL, + args, + ioctxp); + return err; +} + +ioid_t +SYSIO_INTERFACE_NAME(ifsync)(int fd) { int err; struct file *fil; + struct ioctx *ioctx; SYSIO_INTERFACE_DISPLAY_BLOCK; - SYSIO_INTERFACE_ENTER(fsync, "%d", fd); + SYSIO_INTERFACE_ENTER(ifsync, "%d", fd); err = 0; do { fil = _sysio_fd_find(fd); @@ -68,20 +114,60 @@ SYSIO_INTERFACE_NAME(fsync)(int fd) err = -EBADF; if (err) break; - err = PNOP_SYNC(fil->f_pno); + err = _sysio_p_sync(fil->f_pno, &ioctx); FIL_PUT(fil); } while (0); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fsync, "%d", 0); + SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, err, ifsync, "%p", 0); } int -SYSIO_INTERFACE_NAME(fdatasync)(int fd) +SYSIO_INTERFACE_NAME(fsync)(int fd) +{ + ioid_t ioid; + + ioid = SYSIO_INTERFACE_NAME(ifsync)(fd); + if (ioid == IOID_FAIL) + return -1; + return SYSIO_INTERFACE_NAME(iowait(ioid)); +} + +static int +_sysio_p_datasync(struct pnode *pno, struct ioctx **ioctxp) +{ + void *args; + struct fake_args fake; + int (*f)(struct ioctx *); + int err; + + args = NULL; + if (pno->p_base->pb_ino->i_ops.inop_idatasync) + f = PNOP_FUNC(pno, idatasync); + else { + f = fakeit; + fake.f = PNOP_FUNC(pno, old_datasync); + args = &fake; + } + err = + _sysio_p_iiox(f, + pno, + -1, + NULL, 0, NULL, + NULL, 0, NULL, + NULL, NULL, + args, + ioctxp); + return err; +} + +ioid_t +SYSIO_INTERFACE_NAME(ifdatasync)(int fd) { int err; struct file *fil; + struct ioctx *ioctx; SYSIO_INTERFACE_DISPLAY_BLOCK; - SYSIO_INTERFACE_ENTER(fdatasync, "%d", fd); + SYSIO_INTERFACE_ENTER(ifdatasync, "%d", fd); err = 0; do { fil = _sysio_fd_find(fd); @@ -89,8 +175,22 @@ SYSIO_INTERFACE_NAME(fdatasync)(int fd) err = -EBADF; if (err) break; - err = PNOP_DATASYNC(fil->f_pno); + err = _sysio_p_datasync(fil->f_pno, &ioctx); FIL_PUT(fil); } while (0); - SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, fdatasync, "%d", 0); + SYSIO_INTERFACE_RETURN(err ? IOID_FAIL : ioctx, + err, + ifdatasync, + "%p", 0); +} + +int +SYSIO_INTERFACE_NAME(fdatasync)(int fd) +{ + ioid_t ioid; + + ioid = SYSIO_INTERFACE_NAME(ifdatasync)(fd); + if (ioid == IOID_FAIL) + return -1; + return SYSIO_INTERFACE_NAME(iowait(ioid)); } Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -w -b -B -p -r1.61 -r1.62 --- inode.c 22 Sep 2009 22:31:54 -0000 1.61 +++ inode.c 7 Dec 2009 22:00:24 -0000 1.62 @@ -260,7 +260,8 @@ _sysio_i_new(struct filesys *fs, operations.inop_pos = o->inop_pos; operations.inop_iodone = o->inop_iodone; operations.inop_fcntl = o->inop_fcntl; - operations.inop_datasync = o->inop_datasync; + operations.inop_old_datasync = o->inop_old_datasync; + operations.inop_idatasync = o->inop_idatasync; operations.inop_ioctl = o->inop_ioctl; } I_INIT(ino, fs, stat, &operations, fid, immunity, private); Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -w -b -B -p -r1.29 -r1.30 --- ioctx.c 11 Jul 2008 18:23:57 -0000 1.29 +++ ioctx.c 7 Dec 2009 22:00:24 -0000 1.30 @@ -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-2009 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... */ @@ -102,11 +102,11 @@ _sysio_ioctx_enter(struct ioctx *ioctx) */ struct ioctx * _sysio_ioctx_new(struct pnode *pno, - int wr, const struct iovec *iov, size_t iovlen, const struct intnl_xtvec *xtv, - size_t xtvlen) + size_t xtvlen, + void *args) { struct ioctx *ioctx; @@ -120,10 +120,10 @@ _sysio_ioctx_new(struct pnode *pno, IOCTX_INIT(ioctx, 0, - wr, pno, iov, iovlen, - xtv, xtvlen); + xtv, xtvlen, + args); /* * Link request onto the outstanding requests queue. Index: rw.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rw.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -w -b -B -p -r1.31 -r1.32 --- rw.c 28 Jan 2009 16:13:19 -0000 1.31 +++ rw.c 7 Dec 2009 22:00:24 -0000 1.32 @@ -72,6 +72,7 @@ _sysio_post_io(int (*f)(struct ioctx *io void (*release_xtv)(struct ioctx *, void *), void (*completio)(struct ioctx *, void *), struct file *fil, + void *args, struct ioctx **ioctxp) { struct ioctx *ioctx; @@ -85,9 +86,9 @@ _sysio_post_io(int (*f)(struct ioctx *io */ ioctx = _sysio_ioctx_new(pno, - 0, iov, iov_count, - xtv, xtv_count); + xtv, xtv_count, + args); if (ioctx == NULL) return -ENOMEM; do { @@ -161,6 +162,7 @@ _do_p_aio(int (*f)(struct ioctx *ioctx), iov, 1, free_arg, xtv, 1, free_arg, NULL, NULL, + NULL, ioctxp); } if (err) { @@ -213,10 +215,10 @@ _sysio_p_iiox(int (*f)(struct ioctx *), void (*release_xtv)(struct ioctx *, void *), void (*completio)(struct ioctx *, void *), void *data, + void *args, struct ioctx **ioctxp) { int err; - ssize_t cc; err = 0; do { @@ -233,15 +235,21 @@ _sysio_p_iiox(int (*f)(struct ioctx *), break; } + if (limit && xtv && iov) { + ssize_t cc; + /* * Valid maps? */ cc = - _sysio_validx(xtv, xtv_count, iov, iov_count, limit); + _sysio_validx(xtv, xtv_count, + iov, iov_count, + limit); if (cc < 0) { err = cc; break; } + } /* * Post the operation. */ @@ -250,7 +258,9 @@ _sysio_p_iiox(int (*f)(struct ioctx *), pno, iov, iov_count, release_iov, xtv, xtv_count, release_xtv, - completio, data, + completio, + data, + args, ioctxp); } while (0); return err; @@ -291,6 +301,7 @@ _sysio_iiox(direction writing, iov, iov_count, release_iov, xtv, xtv_count, release_xtv, completio, fil, + NULL, ioctxp); return err; } |