diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-03-20 20:40:18 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-11 22:26:45 -0400 |
commit | a96114fa1acaabca1091a27aacebd945a5733075 (patch) | |
tree | b445444e69891262bf236ec882752eecb6ebbd0c /fs/aio.c | |
parent | 4c185ce06dca14f5cea192f5a2c981ef50663f2b (diff) |
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: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/aio.c')
-rw-r--r-- | fs/aio.c | 45 |
1 files changed, 17 insertions, 28 deletions
@@ -1352,43 +1352,33 @@ typedef ssize_t (aio_rw_op)(struct kiocb *, const struct iovec *, | |||
1352 | unsigned long, loff_t); | 1352 | unsigned long, loff_t); |
1353 | typedef ssize_t (rw_iter_op)(struct kiocb *, struct iov_iter *); | 1353 | typedef ssize_t (rw_iter_op)(struct kiocb *, struct iov_iter *); |
1354 | 1354 | ||
1355 | static ssize_t aio_setup_vectored_rw(struct kiocb *kiocb, | 1355 | static int aio_setup_vectored_rw(int rw, char __user *buf, size_t len, |
1356 | int rw, char __user *buf, | 1356 | struct iovec **iovec, |
1357 | unsigned long *nr_segs, | 1357 | bool compat, |
1358 | size_t *len, | 1358 | struct iov_iter *iter) |
1359 | struct iovec **iovec, | ||
1360 | bool compat, | ||
1361 | struct iov_iter *iter) | ||
1362 | { | 1359 | { |
1363 | ssize_t ret; | 1360 | ssize_t ret; |
1364 | 1361 | ||
1365 | *nr_segs = *len; | ||
1366 | |||
1367 | #ifdef CONFIG_COMPAT | 1362 | #ifdef CONFIG_COMPAT |
1368 | if (compat) | 1363 | if (compat) |
1369 | ret = compat_rw_copy_check_uvector(rw, | 1364 | ret = compat_rw_copy_check_uvector(rw, |
1370 | (struct compat_iovec __user *)buf, | 1365 | (struct compat_iovec __user *)buf, |
1371 | *nr_segs, UIO_FASTIOV, *iovec, iovec); | 1366 | len, UIO_FASTIOV, *iovec, iovec); |
1372 | else | 1367 | else |
1373 | #endif | 1368 | #endif |
1374 | ret = rw_copy_check_uvector(rw, | 1369 | ret = rw_copy_check_uvector(rw, |
1375 | (struct iovec __user *)buf, | 1370 | (struct iovec __user *)buf, |
1376 | *nr_segs, UIO_FASTIOV, *iovec, iovec); | 1371 | len, UIO_FASTIOV, *iovec, iovec); |
1377 | if (ret < 0) | 1372 | if (ret < 0) |
1378 | return ret; | 1373 | return ret; |
1379 | 1374 | ||
1380 | /* len now reflect bytes instead of segs */ | 1375 | iov_iter_init(iter, rw, *iovec, len, ret); |
1381 | *len = ret; | ||
1382 | iov_iter_init(iter, rw, *iovec, *nr_segs, *len); | ||
1383 | return 0; | 1376 | return 0; |
1384 | } | 1377 | } |
1385 | 1378 | ||
1386 | static ssize_t aio_setup_single_vector(struct kiocb *kiocb, | 1379 | static int aio_setup_single_vector(int rw, char __user *buf, size_t len, |
1387 | int rw, char __user *buf, | 1380 | struct iovec *iovec, |
1388 | unsigned long *nr_segs, | 1381 | struct iov_iter *iter) |
1389 | size_t len, | ||
1390 | struct iovec *iovec, | ||
1391 | struct iov_iter *iter) | ||
1392 | { | 1382 | { |
1393 | if (len > MAX_RW_COUNT) | 1383 | if (len > MAX_RW_COUNT) |
1394 | len = MAX_RW_COUNT; | 1384 | len = MAX_RW_COUNT; |
@@ -1397,8 +1387,7 @@ static ssize_t aio_setup_single_vector(struct kiocb *kiocb, | |||
1397 | 1387 | ||
1398 | iovec->iov_base = buf; | 1388 | iovec->iov_base = buf; |
1399 | iovec->iov_len = len; | 1389 | iovec->iov_len = len; |
1400 | *nr_segs = 1; | 1390 | iov_iter_init(iter, rw, iovec, 1, len); |
1401 | iov_iter_init(iter, rw, iovec, *nr_segs, len); | ||
1402 | return 0; | 1391 | return 0; |
1403 | } | 1392 | } |
1404 | 1393 | ||
@@ -1411,7 +1400,6 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode, | |||
1411 | { | 1400 | { |
1412 | struct file *file = req->ki_filp; | 1401 | struct file *file = req->ki_filp; |
1413 | ssize_t ret; | 1402 | ssize_t ret; |
1414 | unsigned long nr_segs; | ||
1415 | int rw; | 1403 | int rw; |
1416 | fmode_t mode; | 1404 | fmode_t mode; |
1417 | aio_rw_op *rw_op; | 1405 | aio_rw_op *rw_op; |
@@ -1443,13 +1431,14 @@ rw_common: | |||
1443 | return -EINVAL; | 1431 | return -EINVAL; |
1444 | 1432 | ||
1445 | if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV) | 1433 | if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV) |
1446 | ret = aio_setup_vectored_rw(req, rw, buf, &nr_segs, | 1434 | ret = aio_setup_vectored_rw(rw, buf, len, |
1447 | &len, &iovec, compat, &iter); | 1435 | &iovec, compat, &iter); |
1448 | else | 1436 | else |
1449 | ret = aio_setup_single_vector(req, rw, buf, &nr_segs, | 1437 | ret = aio_setup_single_vector(rw, buf, len, |
1450 | len, iovec, &iter); | 1438 | iovec, &iter); |
1451 | if (!ret) | 1439 | if (!ret) |
1452 | ret = rw_verify_area(rw, file, &req->ki_pos, len); | 1440 | ret = rw_verify_area(rw, file, &req->ki_pos, |
1441 | iov_iter_count(&iter)); | ||
1453 | if (ret < 0) { | 1442 | if (ret < 0) { |
1454 | if (iovec != inline_vecs) | 1443 | if (iovec != inline_vecs) |
1455 | kfree(iovec); | 1444 | kfree(iovec); |