Commit cd347240 authored by Pavel Emelyanov's avatar Pavel Emelyanov

iov: Add iov_init() helper

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent bb7ac03a
...@@ -19,6 +19,12 @@ static inline bool iov_grow_page(struct iovec *iov, unsigned long addr) ...@@ -19,6 +19,12 @@ static inline bool iov_grow_page(struct iovec *iov, unsigned long addr)
return false; return false;
} }
static inline void iov_init(struct iovec *iov, unsigned long addr)
{
iov->iov_base = (void *)addr;
iov->iov_len = PAGE_SIZE;
}
static int page_pipe_grow(struct page_pipe *pp) static int page_pipe_grow(struct page_pipe *pp)
{ {
struct page_pipe_buf *ppb; struct page_pipe_buf *ppb;
...@@ -150,9 +156,7 @@ static inline int try_add_page_to(struct page_pipe *pp, struct page_pipe_buf *pp ...@@ -150,9 +156,7 @@ static inline int try_add_page_to(struct page_pipe *pp, struct page_pipe_buf *pp
pr_debug("Add iov to page pipe (%u iovs, %u/%u total)\n", pr_debug("Add iov to page pipe (%u iovs, %u/%u total)\n",
ppb->nr_segs, pp->free_iov, pp->nr_iovs); ppb->nr_segs, pp->free_iov, pp->nr_iovs);
ppb->iov[ppb->nr_segs].iov_base = (void *)addr; iov_init(&ppb->iov[ppb->nr_segs++], addr);
ppb->iov[ppb->nr_segs].iov_len = PAGE_SIZE;
ppb->nr_segs++;
pp->free_iov++; pp->free_iov++;
BUG_ON(pp->free_iov > pp->nr_iovs); BUG_ON(pp->free_iov > pp->nr_iovs);
out: out:
...@@ -187,8 +191,6 @@ int page_pipe_add_page(struct page_pipe *pp, unsigned long addr) ...@@ -187,8 +191,6 @@ int page_pipe_add_page(struct page_pipe *pp, unsigned long addr)
int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr) int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr)
{ {
struct iovec *iov;
if (pp->free_hole >= pp->nr_holes) { if (pp->free_hole >= pp->nr_holes) {
pp->holes = xrealloc(pp->holes, pp->holes = xrealloc(pp->holes,
(pp->nr_holes + PP_HOLES_BATCH) * sizeof(struct iovec)); (pp->nr_holes + PP_HOLES_BATCH) * sizeof(struct iovec));
...@@ -202,10 +204,7 @@ int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr) ...@@ -202,10 +204,7 @@ int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr)
iov_grow_page(&pp->holes[pp->free_hole - 1], addr)) iov_grow_page(&pp->holes[pp->free_hole - 1], addr))
goto out; goto out;
iov = &pp->holes[pp->free_hole]; iov_init(&pp->holes[pp->free_hole++], addr);
iov->iov_base = (void *)addr;
iov->iov_len = PAGE_SIZE;
pp->free_hole++;
out: out:
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment