[Lustre-discuss] Does Lustre support asynchronous I/O calls

Johnlya johnlya at gmail.com
Wed Jul 30 19:51:23 PDT 2008


Hi, Brian,
Please help me, thank you!

I test aio on Linux 2.6.42 and find it ok.
Is right test on below:

[root at CLIENT lustretest]# uname -an
Linux CLIENT 2.6.9-67.0.7.EL_lustre.1.6.5smp #1 SMP Mon May 12
22:02:50 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux


#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include "aio.h"
#include <errno.h>

#define BUFSIZE 1*1024*1024
#define FILESIZE 2*1024

int g_count = 0;
struct timeval  tstart, tend;
char *szbuffer;

void aio_completion_handler(sigval_t sigval)
{
  struct aiocb *req;
  int ret = 0;

  req = (struct aiocb *) sigval.sival_ptr;
  /*Dis the request complete?*/
  if (aio_error( req ) == 0)
  {
        /*Request completed successfully, get the return status*/
        ret = aio_return( req );
        if (ret != BUFSIZE)
                printf("Request completed %d\n", ret);
        else
                g_count++;
        if (g_count == FILESIZE-1)
        {
                 ret = gettimeofday(&tend, NULL);
                 if (ret != 0)
                        printf("gettimeofday error %d\n", ret);
                 else
                 {
                        printf("start time is %d %ld\n",
tstart.tv_sec, tstart.tv_usec);
                        printf("end time is %d %ld\n", tend.tv_sec,
tend.tv_usec);
                        printf("sec:%d usec:%ld\n", tend.tv_sec-
tstart.tv_sec, tend.tv_usec-tstart.tv_usec);


                 }

        }
        free(req);
  }
  return;
}

void testwrite_aio()
{
  int retval;
  int i = 0;
  size_t nbytes = 0;
  size_t ulen = BUFSIZE;
  szbuffer = (char*)malloc(BUFSIZE*sizeof(char));
  int fdw =  open( "/mnt/webfile/test.rm", O_RDWR|O_CREAT);
  memset(szbuffer, 'A', BUFSIZE);
  if (fdw == -1)
  {
        printf("fopen file error!\n");
        return ;
  }
  retval = gettimeofday(&tstart, NULL);
  if (retval != 0)
        printf("gettimeofday error %d\n", retval);

  for (i=0; i<FILESIZE; i++)
  {
        struct aiocb *myaiocb = malloc(sizeof(struct aiocb));
        bzero( myaiocb, sizeof (struct aiocb));
        myaiocb->aio_fildes = fdw;
        myaiocb->aio_offset = nbytes;
        myaiocb->aio_buf = (void *) szbuffer;
        myaiocb->aio_nbytes = ulen;
        /* Link the AIO request with a thread callback */
        myaiocb->aio_sigevent.sigev_notify = SIGEV_THREAD;
        myaiocb->aio_sigevent._sigev_un._sigev_thread._function=
aio_completion_handler;
        myaiocb->aio_sigevent._sigev_un._sigev_thread._attribute=
NULL;
        myaiocb->aio_sigevent.sigev_value.sival_ptr = myaiocb;
         if( (retval = aio_write( myaiocb )) != 0)
        {
                printf("write file error\n");
                break;
        }
        else
        {
                nbytes += ulen;
        }
  }
  return;
}
int main()
{
	testwrite_aio();
	getchar();
	if (szbuffer != NULL)
		free(szbuffer);
	return 0;
}



On Thu, 2008-07-24, at 12:49 AM, "Brian J. Murrell"
<Brian.Murr... at Sun.COM> wrote:
> On Wed, 2008-07-23 at 17:01 +0530, Tanya Raj wrote:
> > I'm running on Linux kernel 2.6.16 Does lustre support POSIX
> > asynchronous disk i/o strategy (Posix AIO) ?
>
> No.  I think there have been previous questions here about this.  A
> search of the archives would probably provide fruitful.  A search of our
> bugzilla might also yield some interesting information.
>
> b.
>
>  signature.asc
> 1Kdownload
>
> _______________________________________________
> Lustre-discuss mailing list
> Lustre-disc... at lists.lustre.orghttp://lists.lustre.org/mailman/listinfo/lustre-discuss



More information about the lustre-discuss mailing list