Skip to contentSkip to conversation

AIO!!

DISCUSSION Karthik Sarangan 3 participants 4 messages Oct 10, 2005 – Oct 11, 2005 SCSI

lore
Share & tools
lore
#0 lore raw

I wrote a small program to do Async IO from a raw disk open has no problems.
My program gets stuck up at aio_read(paio); !!WHY!!

-----------------------------------------------
#define _GNU_SOURCE
#include <aio.h>
#include <unistd.h>
#include <fcntl.h>

#define AIOLEN (256 * 1024)

int main(void)
{
/* Allocate resources /
struct aiocb *paio = (struct aiocb *) malloc(sizeof(struct aiocb)); paio->aio_buf = malloc(AIOLEN);
paio->aio_fildes = open("/dev/raw/raw1", O_DIRECT | O_RDWR);

  paio->aio_nbytes = AIOLEN;
  paio->aio_reqprio = 0; paio->aio_sigevent.sigev_notify = SIGEV_NONE;

  aio_read(paio);

  /* My program gets stuck here in this loop.  !!WHY!!  */
  while(aio_error(paio))
  {
    sched_yield();
  }

  aio_return(paio);

  /* Return all resources to Linux */
  close(paio->aio_fildes);
  free(paio->aio_buf);
  free(paio);

return 0;
}
-----------------------------------------------

I also have tried inserting an 'aio_fsync' between 'aio_read' and the 'while' loop ... to no avail.

#1 lore raw
Quoted 4 lines · Karthik Sarangan

I wrote a small program to do Async IO from a raw disk open has no problems.
My program gets stuck up at aio_read(paio); !!WHY!!

O_DIRECT buffers must be aligned on block sized boundaries (minimum 512 bytes). Check the actual return code from the aiocb and you'll find that it is likely -EINVAL, no -EINPROGRESS. See the man page for posix_memalign() to properly align the pointer.

-ben

#2 lore raw
Quoted 3 lines

Benjamin LaHaise wrote:
O_DIRECT buffers must be aligned on block sized boundaries (minimum 512 bytes). Check the actual return code from the aiocb and you'll find that it is likely -EINVAL, no -EINPROGRESS. See the man page for posix_memalign() to properly align the pointer.

EEP!! I forgot all about buffer alignment!! Thanks for pointing it out

:)

------------------

Two more questions.

1. Is aio_fsync of any use while 'aio_read'ing and 'aio_write'ing to a 'raw' device or a '/dev/sdb' with O_DIRECT?

2. I have an Ultra320 SCSI disk whose datasheet says it has a max. possible throughput of 78MBps

I did a 'aio_write' onto '/dev/sdb' with O_DIRECT. Following are some throughput values.

Buffer for IO | Avg Speed
(in KBytes) |
----------------O-----------

   Upto 512KB      |  69MBps
   1024KB          |  125MBps
   2048KB          |  250MBps
   4096KB          |  500MBps
   8192KB          |  1GBps		-- What the !! --

Buffer cache does not come into consideration.

Does this mean that the SCSI lower layer (aic79xx) can transfer data only upto 512 KB?

#3 lore raw
Quoted 7 lines · Karthik Sarangan
Quoted 5 lines

Benjamin LaHaise wrote:
O_DIRECT buffers must be aligned on block sized boundaries (minimum 512 bytes). Check the actual return code from the aiocb and you'll find that it is likely -EINVAL, no -EINPROGRESS. See the man page for posix_memalign() to properly align the pointer.

EEP!! I forgot all about buffer alignment!! Thanks for pointing it out

Why do you constantly shout?

Quoted 5 lines

------------------
Two more questions.

1. Is aio_fsync of any use while 'aio_read'ing and 'aio_write'ing to a 'raw' device or a '/dev/sdb' with O_DIRECT?

I suspect you did not do some research first.

Quoted 6 lines

2. I have an Ultra320 SCSI disk whose datasheet says it has a max. possible throughput of 78MBps

I did a 'aio_write' onto '/dev/sdb' with O_DIRECT. Following are some throughput values.

Quoted 8 lines

Buffer for IO | Avg Speed
(in KBytes) |
----------------O-----------
Upto 512KB | 69MBps
1024KB | 125MBps
2048KB | 250MBps
4096KB | 500MBps
8192KB | 1GBps -- What the !! --

Most probably bug in your program.

Quoted 4 lines

Buffer cache does not come into consideration.

Does this mean that the SCSI lower layer (aic79xx) can transfer data only upto 512 KB?

It means that you are in dire need of reading this:

http://www.catb.org/~esr/faqs/smart-questions.html

--
vda