Wim ten Have, <wtenhave@sybase.com>
Sat Mar 18 12:26:29 CET 2000

Special words of thanks go to the SGI engineer Rajagopal Ananthanarayanan,
<mailto:ananth@sgi.com> allowing me to make small modifications to his
original efforts for a KAIO library setup.   This to suite ASE internally
for a DLL making most worlds work.


Asynchronous storage I/O DLL implementation.  If you need to you can
create further code towards KAIO or any Async I/O support via the ASE
internal registered DLL setup:

    dlopen(2)
        dlopen (driver, RTLD_NOW|RTLD_GLOBAL)));

        *driver         provides the pathname as collected via getenv(3)
                        over "SRV_KAIODRIVER" and if not set default loaded
                        from "$SYBASE/lib/kaioasync.so"

    dlsym(2)
        aio_init (int);
        aio_read (aiocb_t *);
        aio_write (aiocb_t *);
        aio_return (aiocb_t *);


    aio_error(aiocb_t *)       For performance reasons aio_error(2) was
                               implemented as a macro and will directly
                               collect the struct aiocb {}; passed
                               errno information from the KAIO subsystem.


Take note that Adaptive Server Enterprise is a highly optimized and
complex threading package.  You Async I/O driver subsystem should be
MT-safe and *not* duplicate any address space other then using clone(2)
with CLONE_VM defined. (share virtual address space).

To bring the Async driver (dynamic loadable shared object) in place
follow the below steps.  Linux Native platforms only!  A pre-built
version of kaioasync.so already exists.

    1) Visit the GPL directory which contains the kaiodriver.

    	$ cd $SYBASE/GPL/kaiodriver

    2) Build the driver.  You can only do this if the KAIO changes are
       applied and your system has /usr/include/linux/aio.h in place.

       	$ make install
	cc -shared -o kaioasync.so -O -O3 -D_REENTRANT -pipe -I. aiolib.c
	install -m 0755 kaioasync.so /opt/sybase/lib

    3) Reboot your Adaptive Server Enterprise and take note of the
       server boot messages before it mounts the master device.

	$ cd $SYBASE/install
	$ ./startserver -f ./RUN_YOURSERVER
		..
       	00:2000/03/18 11:42:34.14 server  Size of the 2K memory pool: 3674 Kb
	00:2000/03/18 11:42:34.14 kernel  Dynamic loadable KAIO support enabled with 1 kaiod-thrd / engine.
	00:2000/03/18 11:42:34.14 kernel  Initializing virtual device 0, '/work/sybase/master.dat'
	00:2000/03/18 11:42:34.14 kernel  Virtual device /work/sybase/master.dat allows for async i/o on regular
	 file.
	00:2000/03/18 11:42:34.14 kernel  Virtual device 0 started using asynchronous i/o.
	00:2000/03/18 11:42:34.15 server  No active traceflags
		..


The Async I/O support will by default enable when running on Raw devices,
if filesystem mapped devices are in place you need to setup for it with
help of the sticky bit added to the database devices.

Enjoy,
-- Wim ten Have.
