Public bug reported:

My system:

$ uname -a
Linux blackhole 3.2.0-53-generic #81-Ubuntu SMP Thu Aug 22 21:01:03 UTC 2013 
x86_64 x86_64 x86_64 GNU/Linux

Problem: The following program which uses libaio doesn't work - No
errors but no data is read. Exactly same program works if I just remove
the O_DIRECT flag while opening the file.


#define _GNU_SOURCE             /* syscall() is not POSIX */

#include <stdio.h>              /* for perror() */
#include <unistd.h>             /* for syscall() */
#include <libaio.h>     /* for AIO types and constants */
#include <fcntl.h>              /* O_RDWR */
#include <string.h>             /* memset() */
#include <inttypes.h>   /* uint64_t */

int main()
{
        io_context_t ctx;
        struct iocb cb;
        struct iocb *cbs[1];
        struct io_event events[1];
        int fd;
        char *data;

        fd = open("/tmp/testfile", O_RDONLY | O_CREAT | O_DIRECT);

        ctx = 0;
        printf("Setup : %d\n", io_setup(128, &ctx));

        printf("Aligned : %d\n", posix_memalign(&data, 512, 40));
        io_prep_pread(&cb, fd, data, 40, 0);

        cbs[0] = &cb;

        printf("Submitted : %d\n", io_submit(ctx, 1, cbs));

        printf("Got Events : %d\n", io_getevents(ctx, 1, 1, events, NULL));
        printf("%ld\n", events[0].res);
        printf("%s\n", data);

        printf("Destroyed : %d\n", io_destroy(ctx));

        return 0;
}

Results:
$ ./a.out 
Setup : 0
Aligned : 0
Submitted : 1
Got Events : 1
-22

Destroyed : 0

** Affects: libaio (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1223400

Title:
  libaio with O_DIRECT doesn't seem to work

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libaio/+bug/1223400/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to