summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen LaHaise <bcrl@kvack.org>2002-09-05 05:02:03 +0000
committerBen LaHaise <bcrl@kvack.org>2002-09-05 05:02:03 +0000
commitca9fefa3e580e5df4640d87cdbb31bb4552c5a77 (patch)
tree532e3860ff9ef180bf1c51d8d04a1d82313a1a27
parent2372d3b050af6aefe7065ba2a98b00ffaf0bc09f (diff)
downloadlibaio-ca9fefa3e580e5df4640d87cdbb31bb4552c5a77.tar.gz
libaio-0.4.0 targetted changeslibaio.0-3-90.1
-rw-r--r--ChangeLog6
-rw-r--r--libaio.spec5
-rw-r--r--man/io_cancel.121
-rw-r--r--man/io_destroy.117
-rw-r--r--man/io_getevents.129
-rw-r--r--man/io_setup.115
-rw-r--r--man/io_submit.168
-rw-r--r--src/Makefile23
-rw-r--r--src/compat-0_1.c70
-rw-r--r--src/io_cancel.c6
-rw-r--r--src/io_getevents.c6
-rw-r--r--src/io_queue_init.c3
-rw-r--r--src/io_queue_release.c2
-rw-r--r--src/io_queue_run.c2
-rw-r--r--src/io_queue_wait.c2
-rw-r--r--src/io_submit.c6
-rw-r--r--src/libaio.h14
-rw-r--r--src/libaio.map12
-rw-r--r--src/syscall-i386.h36
-rw-r--r--src/syscall.h13
20 files changed, 320 insertions, 36 deletions
diff --git a/ChangeLog b/ChangeLog
index 1945d08..e9e250a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+0.4.0
+ - remove libredhat-kernel
+ - add rough outline for man pages
+ - make the compiled io_getevents() add the extra parameter and
+ pass the timeout for updating as per 2.5
+
0.3.15
- use real syscall interface, but don't break source compatibility
yet (that will happen with 0.4.0)
diff --git a/libaio.spec b/libaio.spec
index 735803e..29d73db 100644
--- a/libaio.spec
+++ b/libaio.spec
@@ -1,5 +1,5 @@
Name: libaio
-Version: 0.3.15
+Version: 0.3.90
Release: 1
Summary: Linux-native asynchronous I/O access library
Copyright: LGPL
@@ -63,6 +63,9 @@ make install prefix=$RPM_BUILD_ROOT/usr root=$RPM_BUILD_ROOT
%attr(0755,root,root) /usr/lib/libredhat-kernel.so
%changelog
+* Thu Sep 5 2002 Benjamin LaHaise <bcrl@redhat.com>
+- libaio 0.3.90 test release
+
* Mon Apr 29 2002 Benjamin LaHaise <bcrl@redhat.com>
- add requires initscripts >= 6.47-1 to get boot time libredhat-kernel
linkage correct.
diff --git a/man/io_cancel.1 b/man/io_cancel.1
new file mode 100644
index 0000000..16e898a
--- /dev/null
+++ b/man/io_cancel.1
@@ -0,0 +1,21 @@
+.\"/* sys_io_cancel:
+.\" * Attempts to cancel an iocb previously passed to io_submit. If
+.\" * the operation is successfully cancelled, the resulting event is
+.\" * copied into the memory pointed to by result without being placed
+.\" * into the completion queue and 0 is returned. May fail with
+.\" * -EFAULT if any of the data structures pointed to are invalid.
+.\" * May fail with -EINVAL if aio_context specified by ctx_id is
+.\" * invalid. May fail with -EAGAIN if the iocb specified was not
+.\" * cancelled. Will fail with -ENOSYS if not implemented.
+.\" */
+.\"
+.TH io_cancel 2 2002-09-03 "Linux 2.4" "Linux AIO"
+.SH NAME
+io_cancel \- cancel io requests
+.SH SYNOPSIS
+.B #include <errno.h>
+.br
+.B #include <libaio.h>
+.LP
+.BI "int io_submit(io_context_t " ctx ", struct iocb *" iocb ", struct io_event *" result ");"
+
diff --git a/man/io_destroy.1 b/man/io_destroy.1
new file mode 100644
index 0000000..177683b
--- /dev/null
+++ b/man/io_destroy.1
@@ -0,0 +1,17 @@
+.\"/* sys_io_destroy:
+.\" * Destroy the aio_context specified. May cancel any outstanding
+.\" * AIOs and block on completion. Will fail with -ENOSYS if not
+.\" * implemented. May fail with -EFAULT if the context pointed to
+.\" * is invalid.
+.\" */
+.\" libaio provides this as io_queue_release.
+.TH io_destroy 2 2002-09-03 "Linux 2.4" "Linux AIO"
+.SH NAME
+io_destroy \- destroy an io context
+.SH SYNOPSIS
+.B #include <errno.h>
+.br
+.B #include <libaio.h>
+.LP
+.BI "int io_destroy(io_context_t " ctx ");"
+
diff --git a/man/io_getevents.1 b/man/io_getevents.1
new file mode 100644
index 0000000..27730b9
--- /dev/null
+++ b/man/io_getevents.1
@@ -0,0 +1,29 @@
+./"/* io_getevents:
+./" * Attempts to read at least min_nr events and up to nr events from
+./" * the completion queue for the aio_context specified by ctx_id. May
+./" * fail with -EINVAL if ctx_id is invalid, if min_nr is out of range,
+./" * if nr is out of range, if when is out of range. May fail with
+./" * -EFAULT if any of the memory specified to is invalid. May return
+./" * 0 or < min_nr if no events are available and the timeout specified
+./" * by when has elapsed, where when == NULL specifies an infinite
+./" * timeout. Note that the timeout pointed to by when is relative and
+./" * will be updated if not NULL and the operation blocks. Will fail
+./" * with -ENOSYS if not implemented.
+./" */
+./"asmlinkage long sys_io_getevents(io_context_t ctx_id,
+./" long min_nr,
+./" long nr,
+./" struct io_event *events,
+./" struct timespec *timeout)
+./"
+.TH io_getevents 2 2002-09-03 "Linux 2.4" "Linux AIO"
+.SH NAME
+io_getevents \- read resulting events from io requests
+.SH SYNOPSIS
+.B #include <errno.h>
+.br
+.B #include <libaio.h>
+.sp
+.BI "int io_getevents(io_context_t " ctx ", long " min_nr ", long " nr ", struct io_events *" events "[], struct timespec *" timeout ");"
+
+
diff --git a/man/io_setup.1 b/man/io_setup.1
new file mode 100644
index 0000000..68690e1
--- /dev/null
+++ b/man/io_setup.1
@@ -0,0 +1,15 @@
+./"/* sys_io_setup:
+./" * Create an aio_context capable of receiving at least nr_events.
+./" * ctxp must not point to an aio_context that already exists, and
+./" * must be initialized to 0 prior to the call. On successful
+./" * creation of the aio_context, *ctxp is filled in with the resulting
+./" * handle. May fail with -EINVAL if *ctxp is not initialized,
+./" * if the specified nr_events exceeds internal limits. May fail
+./" * with -EAGAIN if the specified nr_events exceeds the user's limit
+./" * of available events. May fail with -ENOMEM if insufficient kernel
+./" * resources are available. May fail with -EFAULT if an invalid
+./" * pointer is passed for ctxp. Will fail with -ENOSYS if not
+./" * implemented.
+./" */
+./" -- note: libaio is actually providing io_queue_init and io_queue_grow
+./" as separate functions. For now io_setup is the same as io_queue_grow.
diff --git a/man/io_submit.1 b/man/io_submit.1
new file mode 100644
index 0000000..e28dc28
--- /dev/null
+++ b/man/io_submit.1
@@ -0,0 +1,68 @@
+#/* sys_io_submit:
+# * Queue the nr iocbs pointed to by iocbpp for processing. Returns
+# * the number of iocbs queued. May return -EINVAL if the aio_context
+# * specified by ctx_id is invalid, if nr is < 0, if the iocb at
+# * *iocbpp[0] is not properly initialized, if the operation specified
+# * is invalid for the file descriptor in the iocb. May fail with
+# * -EFAULT if any of the data structures point to invalid data. May
+# * fail with -EBADF if the file descriptor specified in the first
+# * iocb is invalid. May fail with -EAGAIN if insufficient resources
+# * are available to queue any iocbs. Will return 0 if nr is 0. Will
+# * fail with -ENOSYS if not implemented.
+# */
+.TH io_submit 2 2002-09-02 "Linux 2.4" "Linux AIO"
+.SH NAME
+io_submit \- submit io requests
+.SH SYNOPSIS
+.B #include <errno.h>
+.br
+.B #include <libaio.h>
+.LP
+.BI "int io_submit(io_context_t " ctx ", long " nr ", struct iocb *" iocbs "[]);"
+.nf
+struct iocb {
+ void *data;
+ unsigned key;
+ short aio_lio_opcode;
+ short aio_reqprio;
+ int aio_fildes;
+};
+.fi
+.SH DESCRIPTION
+.B io_submit
+submits
+.I nr
+iocbs for processing.
+.SH "RETURN VALUES"
+On success,
+.B io_submit
+returns the number of iocbs submitted successfully. Otherwise, -error is return, where
+error is one of the Exxx values defined in the Errors section.
+.SH ERRORS
+.TP
+.B EFAULT
+.I iocbs
+referenced data outside of the program's accessible address space.
+.TP
+.B EINVAL
+.I ctx
+refers to an unitialized aio context, the iocb pointed to by
+.I iocbs
+contains an improperly initialized iocb,
+.TP
+.B EBADF
+The iocb contains a file descriptor that does not exist.
+.TP
+.B EINVAL
+The file specified in the iocb does not support the given io operation.
+.SH "SEE ALSO"
+.BR io_setup(2),
+.BR io_destroy(2),
+.BR io_getevents(2),
+.BR io_wait(2),
+.BR io_prep_pread(2),
+.BR io_prep_pwrite(2),
+.BR io_prep_fsync(2),
+.BR io_prep_fdsync(2),
+.BR io_cancel(2),
+.BR errno(3)
diff --git a/src/Makefile b/src/Makefile
index 6c4cfff..f5cfc4b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,20 +3,22 @@ prefix=/usr
CFLAGS=-nostdlib -nostartfiles -Wall -I. -g -fomit-frame-pointer -O2
SO_CFLAGS=-shared $(CFLAGS)
L_CFLAGS=$(CFLAGS)
-LINK_FLAGS=-L. -lredhat-kernel
+LINK_FLAGS=
soname=libaio.so.1
all_targets += libaio.a $(soname)
all: $(all_targets)
-libredhat-kernel.so:
- @$(MAKE) -C lib/src
- @cp lib/src/libredhat-kernel.so.1 ./
- @ln -sf libredhat-kernel.so.1 libredhat-kernel.so
+# libaio provided functions
+libaio_srcs := io_queue_init.c io_queue_release.c
+libaio_srcs += io_queue_wait.c io_queue_run.c
-libaio_srcs := io_queue_init.c io_submit.c io_cancel.c io_queue_wait.c
-libaio_srcs += io_queue_run.c io_getevents.c io_queue_release.c
+# real syscalls
+libaio_srcs += io_getevents.c io_submit.c io_cancel.c
+
+# old symbols
+libaio_srcs += compat-0_1.c
libaio_objs := $(patsubst %.c,%.ol,$(libaio_srcs))
libaio_sobjs := $(patsubst %.c,%.os,$(libaio_srcs))
@@ -35,11 +37,10 @@ libaio.a: $(libaio_objs)
ar r libaio.a $^
ranlib libaio.a
-$(soname): $(libaio_sobjs) libredhat-kernel.so libaio.map
- $(CC) $(SO_CFLAGS) -Wl,--version-script=libaio.map -Wl,-soname=$(soname) -o $@ $(libaio_sobjs) libredhat-kernel.so $(LINK_FLAGS)
+$(soname): $(libaio_sobjs) libaio.map
+ $(CC) $(SO_CFLAGS) -Wl,--version-script=libaio.map -Wl,-soname=$(soname) -o $@ $(libaio_sobjs) $(LINK_FLAGS)
install: $(all_targets)
- @$(MAKE) -C lib/src install
install -D -m 644 libaio.h $(prefix)/include/libaio.h
install -D -m 644 libaio.a $(prefix)/lib/libaio.a
install -D -m 755 $(soname) $(prefix)/lib/$(soname)
@@ -50,5 +51,3 @@ $(libaio_objs): libaio.h
clean:
rm -f $(all_targets) $(libaio_objs) $(libaio_sobjs) $(soname).new
rm -f *.so* *.a *.o
- rm -f lib/*.so*
- @$(MAKE) -C lib/src clean
diff --git a/src/compat-0_1.c b/src/compat-0_1.c
new file mode 100644
index 0000000..d9576ec
--- /dev/null
+++ b/src/compat-0_1.c
@@ -0,0 +1,70 @@
+/* libaio Linux async I/O interface
+
+ compat-0_1.c : compatibility symbols for libaio 0.1.x-0.3.x
+
+ Copyright 2002 Red Hat, Inc.
+
+ 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 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
+ */
+#include <stdlib.h>
+#include <asm/errno.h>
+
+#include "libaio.h"
+#include "vsys_def.h"
+
+#include "syscall.h"
+
+
+static inline int real_sys_io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *event)
+{
+ return syscall3(__NR_io_cancel, ctx, iocb, event);
+}
+
+/* ABI change. Provide partial compatibility on this one for now. */
+SYMVER(compat0_1_io_cancel, io_cancel, 0.1);
+int compat0_1_io_cancel(io_context_t ctx, struct iocb *iocb)
+{
+ struct io_event event;
+
+ /* FIXME: the old ABI would return the event on the completion queue */
+ return real_sys_io_cancel(ctx, iocb, &event);
+}
+
+SYMVER(compat0_1_io_wait, io_wait, 0.1);
+int compat0_1_io_wait(io_context_t ctx, struct iocb *iocb, const struct timespec *when)
+{
+ return -ENOSYS;
+}
+
+
+/* ABI change. Provide backwards compatibility for this one. */
+static inline long real_sys_io_getevents(io_context_t ctx_id, long min_nr,
+ long nr, struct io_event *events, struct timespec *timeout)
+{
+ return syscall5(__NR_io_getevents, ctx_id, min_nr, nr, events, timeout);
+}
+
+SYMVER(compat0_1_io_getevents, io_getevents, 0.1);
+int compat0_1_io_getevents(io_context_t ctx_id, long nr,
+ struct io_event *events,
+ const struct timespec *const_timeout)
+{
+ struct timespec timeout;
+ if (const_timeout)
+ timeout = *const_timeout;
+ return real_sys_io_getevents(ctx_id, 1, nr, events,
+ const_timeout ? &timeout : NULL);
+}
+
diff --git a/src/io_cancel.c b/src/io_cancel.c
index ce9c564..ed5fb54 100644
--- a/src/io_cancel.c
+++ b/src/io_cancel.c
@@ -17,9 +17,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <libaio.h>
-#include "vsys_def.h"
+#include "syscall.h"
-int io_cancel(io_context_t ctx, struct iocb *iocb)
+int io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *event)
{
- return vsys_io_cancel(ctx, iocb);
+ return syscall3(__NR_io_cancel, ctx, iocb, event);
}
diff --git a/src/io_getevents.c b/src/io_getevents.c
index d485a0c..cc5de6d 100644
--- a/src/io_getevents.c
+++ b/src/io_getevents.c
@@ -20,9 +20,9 @@
#include <errno.h>
#include <stdlib.h>
#include <time.h>
-#include "vsys_def.h"
+#include "syscall.h"
-int io_getevents(io_context_t ctx, long nr, struct io_event *events, const struct timespec *timeout)
+int io_getevents(io_context_t ctx, long min_nr, long nr, struct io_event *events, struct timespec *timeout)
{
- return vsys_io_getevents(ctx, nr, events, timeout);
+ return syscall5(__NR_io_getevents, ctx, min_nr, nr, events, timeout);
}
diff --git a/src/io_queue_init.c b/src/io_queue_init.c
index 6988f5e..d187ee1 100644
--- a/src/io_queue_init.c
+++ b/src/io_queue_init.c
@@ -20,13 +20,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
-#include "vsys_def.h"
int io_queue_init(int maxevents, io_context_t *ctxp)
{
if (maxevents > 0) {
*ctxp = NULL;
- return vsys_io_setup(maxevents, ctxp);
+ return io_setup(maxevents, ctxp);
}
return -EINVAL;
}
diff --git a/src/io_queue_release.c b/src/io_queue_release.c
index b4cbd68..afa57fe 100644
--- a/src/io_queue_release.c
+++ b/src/io_queue_release.c
@@ -24,5 +24,5 @@
int io_queue_release(io_context_t ctx)
{
- return vsys_io_destroy(ctx);
+ return io_destroy(ctx);
}
diff --git a/src/io_queue_run.c b/src/io_queue_run.c
index c7fd992..255392f 100644
--- a/src/io_queue_run.c
+++ b/src/io_queue_run.c
@@ -28,7 +28,7 @@ int io_queue_run(io_context_t ctx)
struct io_event event;
int ret;
- /* FIXME: batch requests */
+ /* FIXME: batch requests? */
while (1 == (ret = vsys_io_getevents(ctx, 1, &event, &timeout))) {
io_callback_t cb = (io_callback_t)event.data;
struct iocb *iocb = (struct iocb *)event.obj;
diff --git a/src/io_queue_wait.c b/src/io_queue_wait.c
index 075f5ab..a39bc47 100644
--- a/src/io_queue_wait.c
+++ b/src/io_queue_wait.c
@@ -25,7 +25,7 @@
struct timespec;
-int io_queue_wait(io_context_t ctx, const struct timespec *timeout)
+int io_queue_wait(io_context_t ctx, struct timespec *timeout)
{
return vsys_io_getevents(ctx, 0, NULL, timeout);
}
diff --git a/src/io_submit.c b/src/io_submit.c
index 763d0b3..18efb0e 100644
--- a/src/io_submit.c
+++ b/src/io_submit.c
@@ -18,11 +18,9 @@
*/
#include <errno.h>
#include <libaio.h>
-#include "vsys_def.h"
+#include "syscall.h"
int io_submit(io_context_t ctx, long nr, struct iocb **iocbs)
{
- if (nr >= 0)
- return vsys_io_submit(ctx, nr, iocbs);
- return -EINVAL;
+ return syscall3(__NR_io_submit, ctx, nr, iocbs);
}
diff --git a/src/libaio.h b/src/libaio.h
index 20b581c..3f14b43 100644
--- a/src/libaio.h
+++ b/src/libaio.h
@@ -102,15 +102,19 @@ struct io_event {
typedef void (*io_callback_t)(io_context_t ctx, struct iocb *iocb, long res, long res2);
+/* library wrappers */
extern int io_queue_init(int maxevents, io_context_t *ctxp);
-extern int io_queue_grow(io_context_t ctx, int new_maxevents);
+/*extern int io_queue_grow(io_context_t ctx, int new_maxevents);*/
extern int io_queue_release(io_context_t ctx);
-extern int io_queue_wait(io_context_t ctx, const struct timespec *timeout);
+/*extern int io_queue_wait(io_context_t ctx, struct timespec *timeout);*/
extern int io_queue_run(io_context_t ctx);
-extern int io_submit(io_context_t ctx, long nr, struct iocb *ios[]);
-extern int io_cancel(io_context_t ctx, struct iocb *iocb);
-extern int io_getevents(io_context_t ctx_id, long nr, struct io_event *events, const struct timespec *timeout);
+/* Actual syscalls */
+extern int io_setup(int maxevents, io_context_t *ctxp);
+extern int io_destroy(io_context_t ctx);
+extern int io_submit(io_context_t ctx, long nr, struct iocb *ios[]);
+extern int io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *evt);
+extern int io_getevents(io_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout);
static inline void io_set_callback(struct iocb *iocb, io_callback_t cb)
diff --git a/src/libaio.map b/src/libaio.map
index 51199c0..480fbf8 100644
--- a/src/libaio.map
+++ b/src/libaio.map
@@ -1,5 +1,12 @@
-LIBAIO_0.1 {
+LIBAIO_0.4 {
global:
+ io_cancel;
+ io_getevents;
+ local:
+ *;
+};
+
+LIBAIO_0.1 {
io_queue_init;
io_queue_run;
io_queue_wait;
@@ -7,6 +14,5 @@ LIBAIO_0.1 {
io_cancel;
io_submit;
io_getevents;
- local:
- *;
};
+
diff --git a/src/syscall-i386.h b/src/syscall-i386.h
new file mode 100644
index 0000000..fc67ce8
--- /dev/null
+++ b/src/syscall-i386.h
@@ -0,0 +1,36 @@
+#define __NR_io_setup 245
+#define __NR_io_destroy 246
+#define __NR_io_getevents 247
+#define __NR_io_submit 248
+#define __NR_io_cancel 249
+
+#define syscall1(nr, a) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a)); \
+ __ret; })
+
+#define syscall2(nr, a, b) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a), "c" (b)); \
+ __ret; })
+
+#define syscall3(nr, a, b, c) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a), "c" (b), "d" (c)); \
+ __ret; })
+
+#define syscall4(nr, a, b, c, d) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a), "c" (b), "d" (c), "S" (d)); \
+ __ret; })
+
+#define syscall5(nr, a, b, c, d, e) ({ \
+ long __ret; \
+ __asm__ __volatile__("int $0x80" : "=a" (__ret) : \
+ "0" (nr), "b" (a), "c" (b), "d" (c), "S" (d), "D" (e)); \
+ __ret; })
+
diff --git a/src/syscall.h b/src/syscall.h
new file mode 100644
index 0000000..400314c
--- /dev/null
+++ b/src/syscall.h
@@ -0,0 +1,13 @@
+#if defined(__i386__)
+#include "syscall-i386.h"
+#else
+#error "add syscall-arch.h"
+#endif
+
+#define _SYMSTR(str) #str
+#define SYMSTR(str) _SYMSTR(str)
+
+#define SYMVER(compat_sym, orig_sym, ver_sym) \
+ __asm__(".symver " SYMSTR(compat_sym) "," SYMSTR(orig_sym) "@LIBAIO_" SYMSTR(ver_sym));
+
+