2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

iov: Add iov_init() helper

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2014-06-19 15:38:02 +04:00
parent bb7ac03a5b
commit cd34724092

View File

@ -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
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)
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)
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;
} }