]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
iov_iter: add helper to save iov_iter state
authorJens Axboe <axboe@kernel.dk>
Fri, 10 Sep 2021 17:18:36 +0000 (11:18 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 14 Sep 2021 14:12:18 +0000 (08:12 -0600)
commit8fb0f47a9d7acf620d0fd97831b69da9bc5e22ed
tree89e9ff5375b25a40b66986e284fdf7a7592ed3b1
parentd6c338a741295c04ed84679153448b2fffd2c9cf
iov_iter: add helper to save iov_iter state

In an ideal world, when someone is passed an iov_iter and returns X bytes,
then X bytes would have been consumed/advanced from the iov_iter. But we
have use cases that always consume the entire iterator, a few examples
of that are iomap and bdev O_DIRECT. This means we cannot rely on the
state of the iov_iter once we've called ->read_iter() or ->write_iter().

This would be easier if we didn't always have to deal with truncate of
the iov_iter, as rewinding would be trivial without that. We recently
added a commit to track the truncate state, but that grew the iov_iter
by 8 bytes and wasn't the best solution.

Implement a helper to save enough of the iov_iter state to sanely restore
it after we've called the read/write iterator helpers. This currently
only works for IOVEC/BVEC/KVEC as that's all we need, support for other
iterator types are left as an exercise for the reader.

Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wiacKV4Gh-MYjteU0LwNBSGpWrK-Ov25HdqB1ewinrFPg@mail.gmail.com/
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/uio.h
lib/iov_iter.c