mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
new methods: ->read_iter() and ->write_iter()
Beginning to introduce those. Just the callers for now, and it's clumsier than it'll eventually become; once we finish converting aio_read and aio_write instances, the things will get nicer. For now, these guys are in parallel to ->aio_read() and ->aio_write(); they take iocb and iov_iter, with everything in iov_iter already validated. File offset is passed in iocb->ki_pos, iov/nr_segs - in iov_iter. Main concerns in that series are stack footprint and ability to split the damn thing cleanly. [fix from Peter Ujfalusi <[email protected]> folded] Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
7f7f25e82d
commit
293bc9822f
7 changed files with 121 additions and 13 deletions
14
fs/aio.c
14
fs/aio.c
|
|
@ -1241,6 +1241,7 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)
|
|||
|
||||
typedef ssize_t (aio_rw_op)(struct kiocb *, const struct iovec *,
|
||||
unsigned long, loff_t);
|
||||
typedef ssize_t (rw_iter_op)(struct kiocb *, struct iov_iter *);
|
||||
|
||||
static ssize_t aio_setup_vectored_rw(struct kiocb *kiocb,
|
||||
int rw, char __user *buf,
|
||||
|
|
@ -1298,7 +1299,9 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
|
|||
int rw;
|
||||
fmode_t mode;
|
||||
aio_rw_op *rw_op;
|
||||
rw_iter_op *iter_op;
|
||||
struct iovec inline_vec, *iovec = &inline_vec;
|
||||
struct iov_iter iter;
|
||||
|
||||
switch (opcode) {
|
||||
case IOCB_CMD_PREAD:
|
||||
|
|
@ -1306,6 +1309,7 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
|
|||
mode = FMODE_READ;
|
||||
rw = READ;
|
||||
rw_op = file->f_op->aio_read;
|
||||
iter_op = file->f_op->read_iter;
|
||||
goto rw_common;
|
||||
|
||||
case IOCB_CMD_PWRITE:
|
||||
|
|
@ -1313,12 +1317,13 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
|
|||
mode = FMODE_WRITE;
|
||||
rw = WRITE;
|
||||
rw_op = file->f_op->aio_write;
|
||||
iter_op = file->f_op->write_iter;
|
||||
goto rw_common;
|
||||
rw_common:
|
||||
if (unlikely(!(file->f_mode & mode)))
|
||||
return -EBADF;
|
||||
|
||||
if (!rw_op)
|
||||
if (!rw_op && !iter_op)
|
||||
return -EINVAL;
|
||||
|
||||
ret = (opcode == IOCB_CMD_PREADV ||
|
||||
|
|
@ -1347,7 +1352,12 @@ rw_common:
|
|||
if (rw == WRITE)
|
||||
file_start_write(file);
|
||||
|
||||
ret = rw_op(req, iovec, nr_segs, req->ki_pos);
|
||||
if (iter_op) {
|
||||
iov_iter_init(&iter, rw, iovec, nr_segs, req->ki_nbytes);
|
||||
ret = iter_op(req, &iter);
|
||||
} else {
|
||||
ret = rw_op(req, iovec, nr_segs, req->ki_pos);
|
||||
}
|
||||
|
||||
if (rw == WRITE)
|
||||
file_end_write(file);
|
||||
|
|
|
|||
Loading…
Reference in a new issue