Commit 9061d14a authored by Al Viro's avatar Al Viro

aio: all callers of aio_{read,write,fsync,poll} treat 0 and -EIOCBQUEUED the same way

... so just make them return 0 when caller does not need to destroy iocb
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 3c96c7f4
...@@ -1461,11 +1461,11 @@ static int aio_setup_rw(int rw, struct iocb *iocb, struct iovec **iovec, ...@@ -1461,11 +1461,11 @@ static int aio_setup_rw(int rw, struct iocb *iocb, struct iovec **iovec,
return import_iovec(rw, buf, len, UIO_FASTIOV, iovec, iter); return import_iovec(rw, buf, len, UIO_FASTIOV, iovec, iter);
} }
static inline ssize_t aio_rw_ret(struct kiocb *req, ssize_t ret) static inline void aio_rw_done(struct kiocb *req, ssize_t ret)
{ {
switch (ret) { switch (ret) {
case -EIOCBQUEUED: case -EIOCBQUEUED:
return ret; break;
case -ERESTARTSYS: case -ERESTARTSYS:
case -ERESTARTNOINTR: case -ERESTARTNOINTR:
case -ERESTARTNOHAND: case -ERESTARTNOHAND:
...@@ -1478,7 +1478,6 @@ static inline ssize_t aio_rw_ret(struct kiocb *req, ssize_t ret) ...@@ -1478,7 +1478,6 @@ static inline ssize_t aio_rw_ret(struct kiocb *req, ssize_t ret)
/*FALLTHRU*/ /*FALLTHRU*/
default: default:
aio_complete_rw(req, ret, 0); aio_complete_rw(req, ret, 0);
return 0;
} }
} }
...@@ -1507,10 +1506,10 @@ static ssize_t aio_read(struct kiocb *req, struct iocb *iocb, bool vectored, ...@@ -1507,10 +1506,10 @@ static ssize_t aio_read(struct kiocb *req, struct iocb *iocb, bool vectored,
goto out_fput; goto out_fput;
ret = rw_verify_area(READ, file, &req->ki_pos, iov_iter_count(&iter)); ret = rw_verify_area(READ, file, &req->ki_pos, iov_iter_count(&iter));
if (!ret) if (!ret)
ret = aio_rw_ret(req, call_read_iter(file, req, &iter)); aio_rw_done(req, call_read_iter(file, req, &iter));
kfree(iovec); kfree(iovec);
out_fput: out_fput:
if (unlikely(ret && ret != -EIOCBQUEUED)) if (unlikely(ret))
fput(file); fput(file);
return ret; return ret;
} }
...@@ -1552,11 +1551,11 @@ static ssize_t aio_write(struct kiocb *req, struct iocb *iocb, bool vectored, ...@@ -1552,11 +1551,11 @@ static ssize_t aio_write(struct kiocb *req, struct iocb *iocb, bool vectored,
__sb_writers_release(file_inode(file)->i_sb, SB_FREEZE_WRITE); __sb_writers_release(file_inode(file)->i_sb, SB_FREEZE_WRITE);
} }
req->ki_flags |= IOCB_WRITE; req->ki_flags |= IOCB_WRITE;
ret = aio_rw_ret(req, call_write_iter(file, req, &iter)); aio_rw_done(req, call_write_iter(file, req, &iter));
} }
kfree(iovec); kfree(iovec);
out_fput: out_fput:
if (unlikely(ret && ret != -EIOCBQUEUED)) if (unlikely(ret))
fput(file); fput(file);
return ret; return ret;
} }
...@@ -1587,7 +1586,7 @@ static int aio_fsync(struct fsync_iocb *req, struct iocb *iocb, bool datasync) ...@@ -1587,7 +1586,7 @@ static int aio_fsync(struct fsync_iocb *req, struct iocb *iocb, bool datasync)
req->datasync = datasync; req->datasync = datasync;
INIT_WORK(&req->work, aio_fsync_work); INIT_WORK(&req->work, aio_fsync_work);
schedule_work(&req->work); schedule_work(&req->work);
return -EIOCBQUEUED; return 0;
} }
/* need to use list_del_init so we can check if item was present */ /* need to use list_del_init so we can check if item was present */
...@@ -1715,7 +1714,7 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, struct iocb *iocb) ...@@ -1715,7 +1714,7 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, struct iocb *iocb)
done: done:
if (mask) if (mask)
__aio_poll_complete(aiocb, mask); __aio_poll_complete(aiocb, mask);
return -EIOCBQUEUED; return 0;
out_fail: out_fail:
fput(req->file); fput(req->file);
return -EINVAL; /* same as no support for IOCB_CMD_POLL */ return -EINVAL; /* same as no support for IOCB_CMD_POLL */
...@@ -1800,12 +1799,11 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, ...@@ -1800,12 +1799,11 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
} }
/* /*
* If ret is -EIOCBQUEUED, ownership of the file reference acquired * If ret is 0, we'd either done aio_complete() ourselves or have
* above passed to the file system, which at this point might have * arranged for that to be done asynchronously. Anything non-zero
* dropped the reference, so we must be careful to not reference it * means that we need to destroy req ourselves.
* once we have called into the file system.
*/ */
if (ret && ret != -EIOCBQUEUED) if (ret)
goto out_put_req; goto out_put_req;
return 0; return 0;
out_put_req: out_put_req:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment