Lines Matching refs:iocb

584 void kiocb_set_cancel_fn(struct kiocb *iocb, kiocb_cancel_fn *cancel)  in kiocb_set_cancel_fn()  argument
594 if (!(iocb->ki_flags & IOCB_AIO_RW)) in kiocb_set_cancel_fn()
597 req = container_of(iocb, struct aio_kiocb, rw); in kiocb_set_cancel_fn()
1103 static inline void iocb_destroy(struct aio_kiocb *iocb) in iocb_destroy() argument
1105 if (iocb->ki_eventfd) in iocb_destroy()
1106 eventfd_ctx_put(iocb->ki_eventfd); in iocb_destroy()
1107 if (iocb->ki_filp) in iocb_destroy()
1108 fput(iocb->ki_filp); in iocb_destroy()
1109 percpu_ref_put(&iocb->ki_ctx->reqs); in iocb_destroy()
1110 kmem_cache_free(kiocb_cachep, iocb); in iocb_destroy()
1121 static void aio_complete(struct aio_kiocb *iocb) in aio_complete() argument
1123 struct kioctx *ctx = iocb->ki_ctx; in aio_complete()
1145 *event = iocb->ki_res; in aio_complete()
1149 pr_debug("%p[%u]: %p: %p %Lx %Lx %Lx\n", ctx, tail, iocb, in aio_complete()
1150 (void __user *)(unsigned long)iocb->ki_res.obj, in aio_complete()
1151 iocb->ki_res.data, iocb->ki_res.res, iocb->ki_res.res2); in aio_complete()
1174 pr_debug("added to ring %p at [%u]\n", iocb, tail); in aio_complete()
1181 if (iocb->ki_eventfd) in aio_complete()
1182 eventfd_signal(iocb->ki_eventfd); in aio_complete()
1206 static inline void iocb_put(struct aio_kiocb *iocb) in iocb_put() argument
1208 if (refcount_dec_and_test(&iocb->ki_refcnt)) { in iocb_put()
1209 aio_complete(iocb); in iocb_put()
1210 iocb_destroy(iocb); in iocb_put()
1481 static void aio_remove_iocb(struct aio_kiocb *iocb) in aio_remove_iocb() argument
1483 struct kioctx *ctx = iocb->ki_ctx; in aio_remove_iocb()
1487 list_del(&iocb->ki_list); in aio_remove_iocb()
1493 struct aio_kiocb *iocb = container_of(kiocb, struct aio_kiocb, rw); in aio_complete_rw() local
1495 if (!list_empty_careful(&iocb->ki_list)) in aio_complete_rw()
1496 aio_remove_iocb(iocb); in aio_complete_rw()
1505 iocb->ki_res.res = res; in aio_complete_rw()
1506 iocb->ki_res.res2 = 0; in aio_complete_rw()
1507 iocb_put(iocb); in aio_complete_rw()
1510 static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb, int rw_type) in aio_prep_rw() argument
1516 req->ki_pos = iocb->aio_offset; in aio_prep_rw()
1518 if (iocb->aio_flags & IOCB_FLAG_RESFD) in aio_prep_rw()
1520 if (iocb->aio_flags & IOCB_FLAG_IOPRIO) { in aio_prep_rw()
1526 ret = ioprio_check_cap(iocb->aio_reqprio); in aio_prep_rw()
1532 req->ki_ioprio = iocb->aio_reqprio; in aio_prep_rw()
1536 ret = kiocb_set_rw_flags(req, iocb->aio_rw_flags, rw_type); in aio_prep_rw()
1544 static ssize_t aio_setup_rw(int rw, const struct iocb *iocb, in aio_setup_rw() argument
1548 void __user *buf = (void __user *)(uintptr_t)iocb->aio_buf; in aio_setup_rw()
1549 size_t len = iocb->aio_nbytes; in aio_setup_rw()
1580 static int aio_read(struct kiocb *req, const struct iocb *iocb, in aio_read() argument
1588 ret = aio_prep_rw(req, iocb, READ); in aio_read()
1597 ret = aio_setup_rw(ITER_DEST, iocb, &iovec, vectored, compat, &iter); in aio_read()
1607 static int aio_write(struct kiocb *req, const struct iocb *iocb, in aio_write() argument
1615 ret = aio_prep_rw(req, iocb, WRITE); in aio_write()
1625 ret = aio_setup_rw(ITER_SOURCE, iocb, &iovec, vectored, compat, &iter); in aio_write()
1641 struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, fsync.work); in aio_fsync_work() local
1642 const struct cred *old_cred = override_creds(iocb->fsync.creds); in aio_fsync_work()
1644 iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync); in aio_fsync_work()
1646 put_cred(iocb->fsync.creds); in aio_fsync_work()
1647 iocb_put(iocb); in aio_fsync_work()
1650 static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb, in aio_fsync() argument
1653 if (unlikely(iocb->aio_buf || iocb->aio_offset || iocb->aio_nbytes || in aio_fsync()
1654 iocb->aio_rw_flags)) in aio_fsync()
1673 struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll); in aio_poll_put_work() local
1675 iocb_put(iocb); in aio_poll_put_work()
1726 struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll); in aio_poll_complete_work() local
1728 struct kioctx *ctx = iocb->ki_ctx; in aio_poll_complete_work()
1761 list_del_init(&iocb->ki_list); in aio_poll_complete_work()
1762 iocb->ki_res.res = mangle_poll(mask); in aio_poll_complete_work()
1765 iocb_put(iocb); in aio_poll_complete_work()
1769 static int aio_poll_cancel(struct kiocb *iocb) in aio_poll_cancel() argument
1771 struct aio_kiocb *aiocb = container_of(iocb, struct aio_kiocb, rw); in aio_poll_cancel()
1790 struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll); in aio_poll_wake() local
1812 spin_trylock_irqsave(&iocb->ki_ctx->ctx_lock, flags)) { in aio_poll_wake()
1813 struct kioctx *ctx = iocb->ki_ctx; in aio_poll_wake()
1816 list_del(&iocb->ki_list); in aio_poll_wake()
1817 iocb->ki_res.res = mangle_poll(mask); in aio_poll_wake()
1818 if (iocb->ki_eventfd && !eventfd_signal_allowed()) { in aio_poll_wake()
1819 iocb = NULL; in aio_poll_wake()
1824 if (iocb) in aio_poll_wake()
1825 iocb_put(iocb); in aio_poll_wake()
1870 struct aio_kiocb *iocb; member
1889 pt->iocb->poll.head = head; in aio_poll_queue_proc()
1890 add_wait_queue(head, &pt->iocb->poll.wait); in aio_poll_queue_proc()
1893 static int aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb) in aio_poll() argument
1902 if ((u16)iocb->aio_buf != iocb->aio_buf) in aio_poll()
1905 if (iocb->aio_offset || iocb->aio_nbytes || iocb->aio_rw_flags) in aio_poll()
1909 req->events = demangle_poll(iocb->aio_buf) | EPOLLERR | EPOLLHUP; in aio_poll()
1918 apt.iocb = aiocb; in aio_poll()
1968 static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, in __io_submit_one() argument
1969 struct iocb __user *user_iocb, struct aio_kiocb *req, in __io_submit_one()
1972 req->ki_filp = fget(iocb->aio_fildes); in __io_submit_one()
1976 if (iocb->aio_flags & IOCB_FLAG_RESFD) { in __io_submit_one()
1984 eventfd = eventfd_ctx_fdget(iocb->aio_resfd); in __io_submit_one()
1997 req->ki_res.data = iocb->aio_data; in __io_submit_one()
2001 switch (iocb->aio_lio_opcode) { in __io_submit_one()
2003 return aio_read(&req->rw, iocb, false, compat); in __io_submit_one()
2005 return aio_write(&req->rw, iocb, false, compat); in __io_submit_one()
2007 return aio_read(&req->rw, iocb, true, compat); in __io_submit_one()
2009 return aio_write(&req->rw, iocb, true, compat); in __io_submit_one()
2011 return aio_fsync(&req->fsync, iocb, false); in __io_submit_one()
2013 return aio_fsync(&req->fsync, iocb, true); in __io_submit_one()
2015 return aio_poll(req, iocb); in __io_submit_one()
2017 pr_debug("invalid aio operation %d\n", iocb->aio_lio_opcode); in __io_submit_one()
2022 static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, in io_submit_one()
2026 struct iocb iocb; in io_submit_one() local
2029 if (unlikely(copy_from_user(&iocb, user_iocb, sizeof(iocb)))) in io_submit_one()
2033 if (unlikely(iocb.aio_reserved2)) { in io_submit_one()
2040 (iocb.aio_buf != (unsigned long)iocb.aio_buf) || in io_submit_one()
2041 (iocb.aio_nbytes != (size_t)iocb.aio_nbytes) || in io_submit_one()
2042 ((ssize_t)iocb.aio_nbytes < 0) in io_submit_one()
2052 err = __io_submit_one(ctx, &iocb, user_iocb, req, compat); in io_submit_one()
2082 struct iocb __user * __user *, iocbpp) in SYSCALL_DEFINE3()
2104 struct iocb __user *user_iocb; in SYSCALL_DEFINE3()
2175 SYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb, in SYSCALL_DEFINE3() argument
2182 u64 obj = (u64)(unsigned long)iocb; in SYSCALL_DEFINE3()
2184 if (unlikely(get_user(key, &iocb->aio_key))) in SYSCALL_DEFINE3()