Files
android_kernel_xiaomi_sm8450/lib
Jens Axboe ee44bd07c4 UPSTREAM: iov_iter: add helper to save iov_iter state
[ Upstream commit 8fb0f47a9d7acf620d0fd97831b69da9bc5e22ed ]

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/
Bug: 268174392
Change-Id: Iab4de49932dea2823db03bcef673f726bcef4a9f
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e86db87191)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-02-07 13:38:07 +00:00
..
2022-05-18 10:23:44 +02:00
2020-05-24 20:48:11 +02:00
2018-08-16 12:14:42 -07:00
2021-05-15 09:28:55 +02:00
2022-07-12 16:32:23 +02:00
2022-07-28 15:53:46 +02:00
2018-10-16 13:45:44 +02:00
2022-06-22 14:13:18 +02:00
2022-11-15 19:14:08 +00:00
2021-05-22 15:34:48 +02:00
2020-09-26 10:33:57 -07:00
2020-06-29 10:02:23 +02:00
2018-10-15 16:31:29 -04:00
2021-05-20 15:35:25 +02:00