
Under this directory structure you will find source code of Open Source
projects finalizing support for Dynamic loadable shared object support
allowing Sybase Adaptive Server to enable Asynchronous disk I/O support via
the SGI Open Source KAIO kernel functionality.

In detail information and kernel patches for this feature are available
from the SGI Linux Open Source pages under:

	<http://oss.sgi.com/projects/kaio/>

To suite Adaptive Server Enterprise with future enhancements towards
new KAIO functionality our Virtual Machine disk I/O structure will
access the KAIO via a dlopen(2) API.

The Linux Native API for this driver is available in source under
	/opt/sybase/GPL/kaiodriver
		Makefile	(Makefile to build the shared object)
		aiolib.c	(DLL API source code towards KAIO)

Follow the instructions to build and complete installation from here.

We like to thank the SGI engineer permitting us to include a slight
enhanced DLL based on his source code allowing for an ASE independent
setup.

The API for the DLL is Copy left under the GNU Public license.

Please visit <http://www.gnu.org/copyleft/> for further information on
the GNU Public license and translations of it.


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

You need to equip your Linux kernel with support for KAIO before ASE
can enable run-time support for this.  During final product testing
the under kernel-kaio changes where applied (with Fuzz :-) towards
kernel-2.2.14.

How to build a kernel?  Many words can be written here.  Below small
steps may help you going.  These are typical steps I perform .. others
may do it their way.  Please do not complain ... use it or leave it.

   1) Collect the 2.2.14 kernel source GNU TAR-ball and setup a
      kernel source tree.  The kernel archives can be collected
      from various points on the Internet.  You can visit:

      	<http://www.linuxhq.com/>
	<ftp://ftp.nluug.nl/pub/os/Linux/system/kernel/v2.2/>


   	# cd /usr/src

   *) If a previous configuration exists reflecting your setup make
      sure to save it before you continue.

        # cp linux/.config /usr/src/MYCONFIG

   *) Unpack the source tree and setup correct access.

        # export VERSION="2.2.14"
	# export TAR="linux-$VERSION.tar.gz"
	# set -x
	# tar xvpzf $TAR
	# chown -R root.root linux
	# mv linux linux-2.2.14
	# ln -s linux-2.2.14 linux

   2) Visit your linux kernel source directory tree and configure. 
      If you had a previous configuration copy the MYCONFIG or otherwise
      run 'make config'

	# cd /usr/src/linux
	# cp /usr/src/MYCONFIG arch/i386/defconfig

	# cp /opt/sybase/GPL/kernel-kaio/kaio-kern-1.1-2.2.13 .
	# patch -p0 < kaio-kern-1.1-2.2.13

	# make mrproper
	# make oldconfig
	# make dep
	# make include/linux/version.h
	# make bzImage
	# make modules

    3) Install the kernel allowing you to reboot it and use KAIO

	# cp arch/i386/boot/bzImage /boot/vmlinuz-$VERSION
	# ln -snf vmlinuz-$VERSION /boot/vmlinuz
	# cp System.map /boot/System.map-$VERSION
	# ln -snf System.map-$VERSION /boot/System.map
	# make modules_install KERNELRELEASE=$VERSION
	# rm -f /boot/initrd-$VERSION.img
	# /sbin/mkinitrd /boot/initrd-$VERSION.img $VERSION

    4) Update the boot strap.  LILO users only!

    	# vi /etc/lilo.conf
		..
	  default=linux-kaio
		..
	  image=/boot/vmlinuz-2.2.14
		label=linux-kaio
		initrd=/boot/initrd-2.2.14.img
		read-only
		root=/dev/hda5
		..
	# /sbin/lilo
	Added linux
	Added linux-kaio *

    5) Reboot the system and carefully notice boot messages and
       correct module dependencies!

       	# /sbin/reboot.


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

FreeBSD and Asynchronous I/O.  To allow FreeBSD taking advantage of the
Async I/O model a FreeBSD 'kaiodriver' DLL needs to be implemented as
done for Linux.

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)));

        char *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!

    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 automatically 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.
