mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
ITER_PIPE: clean pipe_advance() up
instead of setting ->iov_offset for new position and calling pipe_truncate() to adjust ->len of the last buffer and discard everything after it, adjust ->len at the same time we set ->iov_offset and use pipe_discard_from() to deal with buffers past that. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
ca59196754
commit
2c855de933
1 changed files with 18 additions and 18 deletions
|
@ -845,27 +845,27 @@ static inline void pipe_truncate(struct iov_iter *i)
|
||||||
static void pipe_advance(struct iov_iter *i, size_t size)
|
static void pipe_advance(struct iov_iter *i, size_t size)
|
||||||
{
|
{
|
||||||
struct pipe_inode_info *pipe = i->pipe;
|
struct pipe_inode_info *pipe = i->pipe;
|
||||||
if (size) {
|
unsigned int off = i->iov_offset;
|
||||||
struct pipe_buffer *buf;
|
|
||||||
unsigned int p_mask = pipe->ring_size - 1;
|
|
||||||
unsigned int i_head = i->head;
|
|
||||||
size_t off = i->iov_offset, left = size;
|
|
||||||
|
|
||||||
if (off) /* make it relative to the beginning of buffer */
|
if (!off && !size) {
|
||||||
left += off - pipe->bufs[i_head & p_mask].offset;
|
pipe_discard_from(pipe, i->start_head); // discard everything
|
||||||
while (1) {
|
return;
|
||||||
buf = &pipe->bufs[i_head & p_mask];
|
|
||||||
if (left <= buf->len)
|
|
||||||
break;
|
|
||||||
left -= buf->len;
|
|
||||||
i_head++;
|
|
||||||
}
|
|
||||||
i->head = i_head;
|
|
||||||
i->iov_offset = buf->offset + left;
|
|
||||||
}
|
}
|
||||||
i->count -= size;
|
i->count -= size;
|
||||||
/* ... and discard everything past that point */
|
while (1) {
|
||||||
pipe_truncate(i);
|
struct pipe_buffer *buf = pipe_buf(pipe, i->head);
|
||||||
|
if (off) /* make it relative to the beginning of buffer */
|
||||||
|
size += off - buf->offset;
|
||||||
|
if (size <= buf->len) {
|
||||||
|
buf->len = size;
|
||||||
|
i->iov_offset = buf->offset + size;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
size -= buf->len;
|
||||||
|
i->head++;
|
||||||
|
off = 0;
|
||||||
|
}
|
||||||
|
pipe_discard_from(pipe, i->head + 1); // discard everything past this one
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iov_iter_bvec_advance(struct iov_iter *i, size_t size)
|
static void iov_iter_bvec_advance(struct iov_iter *i, size_t size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue