[Libsysio-commit] RedStorm: libsysio/drivers/native fs_native.c
Brought to you by:
lward
|
From: Lee W. <lw...@us...> - 2003-10-10 18:06:41
|
Update of /cvsroot/libsysio/libsysio/drivers/native
In directory sc8-pr-cvs1:/tmp/cvs-serv5485/drivers/native
Modified Files:
Tag: RedStorm
fs_native.c
Log Message:
Integrate RedStorm_merge branch. This incorporates changes required
for the Red Storm cnos.
Some things didn't make it:
a) The mount call change. We *really* want the original libsysio
version. Special, libsysio only, flags are unavailable without it.
Semantic differences are possible without it.
b) The Red Storm specific startup and initial mounts source. These
should be moved into the Cray-specific C library -- With
startup.c?
One thing enhanced; The native driver doio routine from RedStorm_merge err'd
if an iovec was more than one entry long. This will break things
in the future. Added code, in doio, to loop over iovecs, calling
the low-level transfer function (pread) for each element.
Notes:
The typedef and defined failure value for ioid_t need to be placed
in a more accessible place for the Cray. User-level source should *not*
include sysio.h ever.
The async IO call prototypes (those that begin with an `i') should be
prototyped somewhere outside libsysio. Look at ASCI Red in order to
promote backward compatibility?
The mount prototype in the catamount `C' lib includes should be altered
to reflect ours.
Prototypes for _sysio_start() and _sysio_shutdown() should be available
externally for startup.c. It, too, shouldn't include sysio.h.
Index: fs_native.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v
retrieving revision 1.11.4.9
retrieving revision 1.11.4.10
diff -u -w -b -B -p -r1.11.4.9 -r1.11.4.10
--- fs_native.c 29 Sep 2003 14:57:01 -0000 1.11.4.9
+++ fs_native.c 10 Oct 2003 18:06:37 -0000 1.11.4.10
@@ -73,6 +73,21 @@
#include "fs_native.h"
+#ifdef REDSTORM
+#include <catamount/syscall.h> /* ! in sys include? */
+#endif
+
+#ifdef REDSTORM
+/*
+ * The cnos IO routines on Red Storm can't do scatter/gather IO. We
+ * must use a different interface, then. The doio() routine will loop
+ * over the vector entries.
+ */
+typedef ssize_t (*iof)(int, void *, size_t, _SYSIO_OFF_T);
+#else
+typedef ssize_t (*iof)(int, const struct iovec *, int);
+#endif
+
/*
* Local host file system driver.
*/
@@ -120,19 +135,11 @@ do {
(dest)->st_gen = (src)->st_gen; \
} while (0);
-/* SYS_lseek has a different interface on alpha
- */
-#define CALL_LSEEK(fd, off, rc, wh) \
- (rc = syscall(SYS_lseek, fd, off, wh))
-
#else
#define __native_stat intnl_stat
#define COPY_STAT(src, dest) *(dest) = *(src)
-#define CALL_LSEEK(fd, off, rc, wh) \
- (syscall(SYS_lseek, fd, off, &rc, wh))
-
#endif
#if defined(USE_NATIVE_STAT)
@@ -887,15 +894,18 @@ native_getdirentries(struct inode *ino,
{
struct native_inode *nino = I2NI(ino);
int err;
+#ifndef SYS_getdirentries
#if _LARGEFILE64_SOURCE
loff_t result;
#else
_SYSIO_OFF_T result;
#endif
+#endif
ssize_t cc;
assert(nino->ni_fd >= 0);
+#ifndef SYS_getdirentries
result = *basep;
if (*basep != nino->ni_fpos) {
err = native_pos(nino->ni_fd, &result);
@@ -908,9 +918,20 @@ native_getdirentries(struct inode *ino,
#else
cc = syscall(SYS_getdents, nino->ni_fd, buf, nbytes);
#endif
+#else /* defined(SYS_getdirentries) */
+ cc =
+ syscall(SYS_getdirentries,
+ nino->ni_fd,
+ buf,
+ nbytes,
+ basep,
+ &nino->ni_fpos);
+#endif /* !defined(SYS_getdirentries) */
if (cc < 0)
return -errno;
+#ifndef SYS_getdirentries
nino->ni_fpos += cc;
+#endif
return cc;
}
@@ -1134,18 +1155,20 @@ native_inop_unlink(struct pnode *pno)
* now.
*/
static int
-doio(ssize_t (*f)(int, const struct iovec *, int),
+doio(iof f,
struct inode *ino,
struct io_arguments *ioargs,
struct ioctx **ioctxp)
{
struct native_inode *nino = I2NI(ino);
struct ioctx *ioctx;
+#ifndef REDSTORM
#if _LARGEFILE64_SOURCE
loff_t result;
#else
_SYSIO_OFF_T result;
#endif
+#endif
assert(nino->ni_fd >= 0);
@@ -1166,6 +1189,7 @@ doio(ssize_t (*f)(int, const struct iove
S_ISFIFO(ino->i_mode)))
return -EINVAL;
+#ifndef REDSTORM
/*
* This implementation first positions the real system descriptor, then
* performs the operation. This is not atomic.
@@ -1188,15 +1212,43 @@ doio(ssize_t (*f)(int, const struct iove
ioctx->ioctx_errno = -err;
goto out;
}
+ nino->ni_fpos = result;
}
+#endif
/*
* Call the appropriate (read/write) IO function to
* transfer the data now.
*/
- nino->ni_fpos = result;
+#ifdef REDSTORM
+ {
+ size_t count = ioctx->ioctx_iovlen;
+ struct iovec *iov = ioctx->ioctx_iovec;
+ ssize_t cc;
+
+ while (count) {
+ cc =
+ (*f)(nino->ni_fd,
+ iov->base,
+ iov->len,
+ nino->ni_fpos);
+ if (cc < 0) {
+ if (ioctx->ioctx_cc) {
+ /*
+ * No data written at all. Return
+ * error.
+ */
+ ioctx->ioctx_cc = -1;
+ }
+ break;
+ }
+ count--, iov++;
+ }
+ }
+#else /* !defined(REDSTORM) */
ioctx->ioctx_cc =
(*f)(nino->ni_fd, ioctx->ioctx_iovec, ioctx->ioctx_iovlen);
+#endif /* defined(REDSTORM) */
if (ioctx->ioctx_cc < 0)
ioctx->ioctx_errno = errno;
if (ioctx->ioctx_cc > 0)
@@ -1210,12 +1262,21 @@ out:
/*
* Helper function passed to doio(), above, to accomplish a real readv.
*/
+#ifdef REDSTORM
static ssize_t
-_readv(int fd, const struct iovec *vector, int count)
+native_read(int fd, void *buf, size_t count, _SYSIO_OFF_T offset)
+{
+
+ return syscall(SYS_pread, fd, buf, count, offset);
+}
+#else
+static ssize_t
+native_read(int fd, const struct iovec *vector, int count)
{
return syscall(SYS_readv, fd, vector, count);
}
+#endif
static int
native_inop_rename(struct pnode *old, struct pnode *new)
@@ -1247,18 +1308,27 @@ native_inop_ipreadv(struct inode *ino,
struct ioctx **ioctxp)
{
- return doio(_readv, ino, ioargs, ioctxp);
+ return doio(native_read, ino, ioargs, ioctxp);
}
/*
* Helper function passed to doio(), above, to accomplish a real writev.
*/
+#ifdef REDSTORM
static ssize_t
-_writev(int fd, const struct iovec *vector, int count)
+native_write(int fd, void *buf, size_t count, _SYSIO_OFF_T offset)
+{
+
+ return syscall(SYS_pwrite, fd, buf, count, offset);
+}
+#else
+static ssize_t
+native_write(int fd, const struct iovec *vector, int count)
{
return syscall(SYS_writev, fd, vector, count);
}
+#endif
static int
native_inop_ipwritev(struct inode *ino,
@@ -1266,7 +1336,7 @@ native_inop_ipwritev(struct inode *ino,
struct ioctx **ioctxp)
{
- return doio(_writev, ino, ioargs, ioctxp);
+ return doio(native_write, ino, ioargs, ioctxp);
}
static int
|