Commit a96114fa authored by Al Viro's avatar Al Viro

aio: simplify arguments of aio_setup_..._rw()

We don't need req in either of those.  We don't need nr_segs in caller.
We don't really need len in caller either - iov_iter_count(&iter) will do.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4c185ce0
...@@ -1352,43 +1352,33 @@ typedef ssize_t (aio_rw_op)(struct kiocb *, const struct iovec *, ...@@ -1352,43 +1352,33 @@ typedef ssize_t (aio_rw_op)(struct kiocb *, const struct iovec *,
unsigned long, loff_t); unsigned long, loff_t);
typedef ssize_t (rw_iter_op)(struct kiocb *, struct iov_iter *); typedef ssize_t (rw_iter_op)(struct kiocb *, struct iov_iter *);
static ssize_t aio_setup_vectored_rw(struct kiocb *kiocb, static int aio_setup_vectored_rw(int rw, char __user *buf, size_t len,
int rw, char __user *buf, struct iovec **iovec,
unsigned long *nr_segs, bool compat,
size_t *len, struct iov_iter *iter)
struct iovec **iovec,
bool compat,
struct iov_iter *iter)
{ {
ssize_t ret; ssize_t ret;
*nr_segs = *len;
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
if (compat) if (compat)
ret = compat_rw_copy_check_uvector(rw, ret = compat_rw_copy_check_uvector(rw,
(struct compat_iovec __user *)buf, (struct compat_iovec __user *)buf,
*nr_segs, UIO_FASTIOV, *iovec, iovec); len, UIO_FASTIOV, *iovec, iovec);
else else
#endif #endif
ret = rw_copy_check_uvector(rw, ret = rw_copy_check_uvector(rw,
(struct iovec __user *)buf, (struct iovec __user *)buf,
*nr_segs, UIO_FASTIOV, *iovec, iovec); len, UIO_FASTIOV, *iovec, iovec);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* len now reflect bytes instead of segs */ iov_iter_init(iter, rw, *iovec, len, ret);
*len = ret;
iov_iter_init(iter, rw, *iovec, *nr_segs, *len);
return 0; return 0;
} }
static ssize_t aio_setup_single_vector(struct kiocb *kiocb, static int aio_setup_single_vector(int rw, char __user *buf, size_t len,
int rw, char __user *buf, struct iovec *iovec,
unsigned long *nr_segs, struct iov_iter *iter)
size_t len,
struct iovec *iovec,
struct iov_iter *iter)
{ {
if (len > MAX_RW_COUNT) if (len > MAX_RW_COUNT)
len = MAX_RW_COUNT; len = MAX_RW_COUNT;
...@@ -1397,8 +1387,7 @@ static ssize_t aio_setup_single_vector(struct kiocb *kiocb, ...@@ -1397,8 +1387,7 @@ static ssize_t aio_setup_single_vector(struct kiocb *kiocb,
iovec->iov_base = buf; iovec->iov_base = buf;
iovec->iov_len = len; iovec->iov_len = len;
*nr_segs = 1; iov_iter_init(iter, rw, iovec, 1, len);
iov_iter_init(iter, rw, iovec, *nr_segs, len);
return 0; return 0;
} }
...@@ -1411,7 +1400,6 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode, ...@@ -1411,7 +1400,6 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
{ {
struct file *file = req->ki_filp; struct file *file = req->ki_filp;
ssize_t ret; ssize_t ret;
unsigned long nr_segs;
int rw; int rw;
fmode_t mode; fmode_t mode;
aio_rw_op *rw_op; aio_rw_op *rw_op;
...@@ -1443,13 +1431,14 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode, ...@@ -1443,13 +1431,14 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
return -EINVAL; return -EINVAL;
if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV) if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV)
ret = aio_setup_vectored_rw(req, rw, buf, &nr_segs, ret = aio_setup_vectored_rw(rw, buf, len,
&len, &iovec, compat, &iter); &iovec, compat, &iter);
else else
ret = aio_setup_single_vector(req, rw, buf, &nr_segs, ret = aio_setup_single_vector(rw, buf, len,
len, iovec, &iter); iovec, &iter);
if (!ret) if (!ret)
ret = rw_verify_area(rw, file, &req->ki_pos, len); ret = rw_verify_area(rw, file, &req->ki_pos,
iov_iter_count(&iter));
if (ret < 0) { if (ret < 0) {
if (iovec != inline_vecs) if (iovec != inline_vecs)
kfree(iovec); kfree(iovec);
......
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