summaryrefslogtreecommitdiff
path: root/fs/aio.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-05-26 19:11:40 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-05-29 23:17:40 -0400
commit9061d14a8a97009085242b284b5b5f668af2bf97 (patch)
tree10a98679764221cdf87a9b067e60d13d1e72c110 /fs/aio.c
parent3c96c7f4caeb044da53a85092903f9192f4e2342 (diff)
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: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/aio.c')
-rw-r--r--fs/aio.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/aio.c b/fs/aio.c
index ae5977563b7e..6098b6ba8671 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -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);
}
-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) {
case -EIOCBQUEUED:
- return ret;
+ break;
case -ERESTARTSYS:
case -ERESTARTNOINTR:
case -ERESTARTNOHAND:
@@ -1478,7 +1478,6 @@ static inline ssize_t aio_rw_ret(struct kiocb *req, ssize_t ret)
/*FALLTHRU*/
default:
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,
goto out_fput;
ret = rw_verify_area(READ, file, &req->ki_pos, iov_iter_count(&iter));
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);
out_fput:
- if (unlikely(ret && ret != -EIOCBQUEUED))
+ if (unlikely(ret))
fput(file);
return ret;
}
@@ -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);
}
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);
out_fput:
- if (unlikely(ret && ret != -EIOCBQUEUED))
+ if (unlikely(ret))
fput(file);
return ret;
}
@@ -1587,7 +1586,7 @@ static int aio_fsync(struct fsync_iocb *req, struct iocb *iocb, bool datasync)
req->datasync = datasync;
INIT_WORK(&req->work, aio_fsync_work);
schedule_work(&req->work);
- return -EIOCBQUEUED;
+ return 0;
}
/* 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)
done:
if (mask)
__aio_poll_complete(aiocb, mask);
- return -EIOCBQUEUED;
+ return 0;
out_fail:
fput(req->file);
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,
}
/*
- * If ret is -EIOCBQUEUED, ownership of the file reference acquired
- * above passed to the file system, which at this point might have
- * dropped the reference, so we must be careful to not reference it
- * once we have called into the file system.
+ * If ret is 0, we'd either done aio_complete() ourselves or have
+ * arranged for that to be done asynchronously. Anything non-zero
+ * means that we need to destroy req ourselves.
*/
- if (ret && ret != -EIOCBQUEUED)
+ if (ret)
goto out_put_req;
return 0;
out_put_req: