Skip to content

Commit 2112ff5

Browse files
isilenceAl Viro
authored andcommitted
iov_iter: track truncated size
Remember how many bytes were truncated and reverted back. Because not reexpanded iterators don't always work well with reverting, we may need to know that to reexpand ourselves when needed. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e73f0f0 commit 2112ff5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

include/linux/uio.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct iov_iter {
4747
};
4848
loff_t xarray_start;
4949
};
50+
size_t truncated;
5051
};
5152

5253
static inline enum iter_type iov_iter_type(const struct iov_iter *i)
@@ -254,8 +255,10 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
254255
* conversion in assignement is by definition greater than all
255256
* values of size_t, including old i->count.
256257
*/
257-
if (i->count > count)
258+
if (i->count > count) {
259+
i->truncated += i->count - count;
258260
i->count = count;
261+
}
259262
}
260263

261264
/*
@@ -264,6 +267,7 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
264267
*/
265268
static inline void iov_iter_reexpand(struct iov_iter *i, size_t count)
266269
{
270+
i->truncated -= count - i->count;
267271
i->count = count;
268272
}
269273

0 commit comments

Comments
 (0)