X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Flibaio.c;h=0333509400ca7460781b975443cd1524cb339017;hb=1f90e9bb1ecd102400ba43c40d7237cae25e95eb;hp=d386d144fe84448d4541c2340e7cb670cb28847a;hpb=c36210b443a37c53978bbea88f1dabb0b61799d7;p=fio.git diff --git a/engines/libaio.c b/engines/libaio.c index d386d144..03335094 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "../fio.h" #include "../lib/pow2.h" @@ -125,16 +127,26 @@ static int fio_libaio_prep(struct thread_data fio_unused *td, struct io_u *io_u) else iocb = &io_u->iocb; - iocb->u.c.flags = 0; - if (io_u->ddir == DDIR_READ) { - io_prep_pread(iocb, f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset); - if (o->hipri) - iocb->u.c.flags |= IOCB_FLAG_HIPRI; + if (o->fixedbufs) { + iocb->aio_fildes = f->fd; + iocb->aio_lio_opcode = IO_CMD_PREAD; + iocb->u.c.offset = io_u->offset; + } else { + io_prep_pread(iocb, f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset); + if (o->hipri) + iocb->u.c.flags |= IOCB_FLAG_HIPRI; + } } else if (io_u->ddir == DDIR_WRITE) { - io_prep_pwrite(iocb, f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset); - if (o->hipri) - iocb->u.c.flags |= IOCB_FLAG_HIPRI; + if (o->fixedbufs) { + iocb->aio_fildes = f->fd; + iocb->aio_lio_opcode = IO_CMD_PWRITE; + iocb->u.c.offset = io_u->offset; + } else { + io_prep_pwrite(iocb, f->fd, io_u->xfer_buf, io_u->xfer_buflen, io_u->offset); + if (o->hipri) + iocb->u.c.flags |= IOCB_FLAG_HIPRI; + } } else if (ddir_sync(io_u->ddir)) io_prep_fsync(iocb, f->fd); @@ -440,11 +452,18 @@ static int fio_libaio_queue_init(struct libaio_data *ld, unsigned int depth, flags |= IOCTX_FLAG_IOPOLL; if (useriocb) flags |= IOCTX_FLAG_USERIOCB; - if (fixedbufs) + if (fixedbufs) { + struct rlimit rlim = { + .rlim_cur = RLIM_INFINITY, + .rlim_max = RLIM_INFINITY, + }; + + setrlimit(RLIMIT_MEMLOCK, &rlim); flags |= IOCTX_FLAG_FIXEDBUFS; + } ret = syscall(__NR_sys_io_setup2, depth, flags, ld->user_iocbs, - &ld->aio_ctx); + NULL, NULL, &ld->aio_ctx); if (!ret) return 0; /* fall through to old syscall */ @@ -468,6 +487,10 @@ static int fio_libaio_post_init(struct thread_data *td) iocb = &ld->user_iocbs[i]; iocb->u.c.buf = io_u->buf; iocb->u.c.nbytes = td_max_bs(td); + + iocb->u.c.flags = 0; + if (o->hipri) + iocb->u.c.flags |= IOCB_FLAG_HIPRI; } }