if (req->work.flags & IO_WQ_WORK_CANCEL) {
req_set_fail_links(req);
io_cqring_add_event(req, -ECANCELED);
- io_put_req(req);
+ io_double_put_req(req);
return true;
}
if (io_req_cancelled(req))
return;
__io_fsync(req, &nxt);
+ io_put_req(req); /* drop submission reference */
if (nxt)
io_wq_assign_next(workptr, nxt);
}
{
/* fsync always requires a blocking context */
if (force_nonblock) {
- io_put_req(req);
req->work.func = io_fsync_finish;
return -EAGAIN;
}
{
int ret;
- if (io_req_cancelled(req))
- return;
-
ret = vfs_fallocate(req->file, req->sync.mode, req->sync.off,
req->sync.len);
if (ret < 0)
struct io_kiocb *req = container_of(*workptr, struct io_kiocb, work);
struct io_kiocb *nxt = NULL;
+ if (io_req_cancelled(req))
+ return;
__io_fallocate(req, &nxt);
+ io_put_req(req); /* drop submission reference */
if (nxt)
io_wq_assign_next(workptr, nxt);
}
{
/* fallocate always requiring blocking context */
if (force_nonblock) {
- io_put_req(req);
req->work.func = io_fallocate_finish;
return -EAGAIN;
}
/* not cancellable, don't do io_req_cancelled() */
__io_close_finish(req, &nxt);
+ io_put_req(req); /* drop submission reference */
if (nxt)
io_wq_assign_next(workptr, nxt);
}
/* if the file has a flush method, be safe and punt to async */
if (req->close.put_file->f_op->flush && force_nonblock) {
+ /* submission ref will be dropped, take it for async */
+ refcount_inc(&req->refs);
+
req->work.func = io_close_finish;
/*
* Do manual async queue here to avoid grabbing files - we don't
if (io_req_cancelled(req))
return;
__io_sync_file_range(req, &nxt);
+ io_put_req(req); /* put submission ref */
if (nxt)
io_wq_assign_next(workptr, nxt);
}
{
/* sync_file_range always requires a blocking context */
if (force_nonblock) {
- io_put_req(req);
req->work.func = io_sync_file_range_finish;
return -EAGAIN;
}
struct io_kiocb *req = container_of(*workptr, struct io_kiocb, work);
struct io_kiocb *nxt = NULL;
- io_put_req(req);
-
if (io_req_cancelled(req))
return;
__io_accept(req, &nxt, false);
+ io_put_req(req); /* drop submission reference */
if (nxt)
io_wq_assign_next(workptr, nxt);
}
} while (1);
}
- /* drop submission reference */
- io_put_req(req);
-
if (ret) {
req_set_fail_links(req);
io_cqring_add_event(req, ret);
io_put_req(req);
}
- /* if a dependent link is ready, pass it back */
- if (!ret && nxt)
+ io_put_req(req); /* drop submission reference */
+ if (nxt)
io_wq_assign_next(workptr, nxt);
}