Commit 593cb59a authored by Pavel Emelyanov's avatar Pavel Emelyanov

pagemap: Use pread to read pagemap entries

When reading pagemaps, we read it from specific position. To
do it, we called lseek, then read. Fortunetely, there's a
syscall that does both things in one call -- pread. Since
we don't need to keep pagemap's position for further reads,
it perfectly suits our needs.

This removes 75% of lseek calls when dumping basic container.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 608db864
......@@ -105,17 +105,12 @@ static int generate_iovs(struct vma_area *vma, int pagemap, struct page_pipe *pp
{
unsigned long pfn, nr_to_scan;
unsigned long pages[2] = {};
u64 aux;
aux = vma->vma.start / PAGE_SIZE * sizeof(*map);
if (lseek(pagemap, aux, SEEK_SET) != aux) {
pr_perror("Can't rewind pagemap file");
return -1;
}
u64 from, len;
nr_to_scan = vma_area_len(vma) / PAGE_SIZE;
aux = nr_to_scan * sizeof(*map);
if (read(pagemap, map, aux) != aux) {
from = vma->vma.start / PAGE_SIZE * sizeof(*map);
len = nr_to_scan * sizeof(*map);
if (pread(pagemap, map, len, from) != len) {
pr_perror("Can't read pagemap file");
return -1;
}
......
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