#define _GNU_SOURCE 1 #include #include #include #include #include #include #include char buf[1024*1024*100*4 + 4096]; int main (int argc, char *argv[]) { char *bufp = buf; struct iocb iocb; struct iocb *iocbs[] = { &iocb, NULL }; io_context_t ctx = 0; int ret; int fd; int i; if (argc != 2) { printf("usage: %s \n", argv[0]); return 1; } printf("opening\n"); fflush(stdout); fd = open(argv[1], O_RDWR | O_DIRECT); if (fd < 0) { perror("open"); return 1; } if (((unsigned long)bufp) & 4095) bufp += 4096 - ((unsigned long)bufp & 4095); printf("init\n"); fflush(stdout); for (i=0; i < (sizeof(buf) - 4096); i++) bufp[i] = (char)i; printf("post init\n"); fflush(stdout); ret = io_setup(100, &ctx); if (ret) { printf("io_setup = %d (%s)\n", ret, strerror(ret)); return 1; } io_prep_pwrite(&iocb, fd, bufp, sizeof(buf), 0); printf("about to submit!\n"); fflush(stdout); ret = io_submit(ctx, 1, iocbs); printf("submit!\n"); fflush(stdout); close(fd); printf("done close!\n"); fflush(stdout); ret = io_destroy(ctx); if (ret) { printf("io_destroy = %d (%s)\n", ret, strerror(ret)); return 1; } printf("okay!\n"); return 0; }