* Queue a new AIO request. Choosing either the threaded or direct bio VCHR * technique is done in this code. */
| 1497 | * technique is done in this code. |
| 1498 | */ |
| 1499 | int |
| 1500 | aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj, |
| 1501 | int type, struct aiocb_ops *ops) |
| 1502 | { |
| 1503 | struct proc *p = td->td_proc; |
| 1504 | struct file *fp = NULL; |
| 1505 | struct kaiocb *job; |
| 1506 | struct kaioinfo *ki; |
| 1507 | struct kevent kev; |
| 1508 | int opcode; |
| 1509 | int error; |
| 1510 | int fd, kqfd; |
| 1511 | int jid; |
| 1512 | u_short evflags; |
| 1513 | |
| 1514 | if (p->p_aioinfo == NULL) |
| 1515 | aio_init_aioinfo(p); |
| 1516 | |
| 1517 | ki = p->p_aioinfo; |
| 1518 | |
| 1519 | ops->store_status(ujob, -1); |
| 1520 | ops->store_error(ujob, 0); |
| 1521 | ops->store_kernelinfo(ujob, -1); |
| 1522 | |
| 1523 | if (num_queue_count >= max_queue_count || |
| 1524 | ki->kaio_count >= max_aio_queue_per_proc) { |
| 1525 | error = EAGAIN; |
| 1526 | goto err1; |
| 1527 | } |
| 1528 | |
| 1529 | job = uma_zalloc(aiocb_zone, M_WAITOK | M_ZERO); |
| 1530 | knlist_init_mtx(&job->klist, AIO_MTX(ki)); |
| 1531 | |
| 1532 | error = ops->aio_copyin(ujob, job, type); |
| 1533 | if (error) |
| 1534 | goto err2; |
| 1535 | |
| 1536 | if (job->uaiocb.aio_nbytes > IOSIZE_MAX) { |
| 1537 | error = EINVAL; |
| 1538 | goto err2; |
| 1539 | } |
| 1540 | |
| 1541 | if (job->uaiocb.aio_sigevent.sigev_notify != SIGEV_KEVENT && |
| 1542 | job->uaiocb.aio_sigevent.sigev_notify != SIGEV_SIGNAL && |
| 1543 | job->uaiocb.aio_sigevent.sigev_notify != SIGEV_THREAD_ID && |
| 1544 | job->uaiocb.aio_sigevent.sigev_notify != SIGEV_NONE) { |
| 1545 | error = EINVAL; |
| 1546 | goto err2; |
| 1547 | } |
| 1548 | |
| 1549 | if ((job->uaiocb.aio_sigevent.sigev_notify == SIGEV_SIGNAL || |
| 1550 | job->uaiocb.aio_sigevent.sigev_notify == SIGEV_THREAD_ID) && |
| 1551 | !_SIG_VALID(job->uaiocb.aio_sigevent.sigev_signo)) { |
| 1552 | error = EINVAL; |
| 1553 | goto err2; |
| 1554 | } |
| 1555 | |
| 1556 | /* Get the opcode. */ |
no test coverage detected