[CRIU] [PATCH 1/3] page-read: Do not lseek file to get its current position
Pavel Emelyanov
xemul at virtuozzo.com
Mon Nov 14 04:58:37 PST 2016
On 11/12/2016 04:35 PM, Mike Rapoport wrote:
> On Wed, Nov 09, 2016 at 08:39:17PM +0200, Mike Rapoport wrote:
>> On Mon, Nov 07, 2016 at 07:02:50PM +0300, Pavel Emelyanov wrote:
>>> It's already written into page_read->pi_off, so just use one.
>>>
>>> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
>>
>> Acked-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
>
> Actually, not...
> For cases when pages*img is randomly accessed, i.e. dedup and lazy-pages,
> we still have to maintain actual position on the pages*img file and that
> requires lseek. We can avoid lseek's for sequential reads if, say, we'll
> add another pi_off_something to track actual position in the pages*img.
Don't we ->reset the page-read in such cases? I thought we did...
>>> ---
>>> criu/pagemap.c | 11 +++++------
>>> 1 file changed, 5 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/criu/pagemap.c b/criu/pagemap.c
>>> index 105ad59..cfc9659 100644
>>> --- a/criu/pagemap.c
>>> +++ b/criu/pagemap.c
>>> @@ -260,23 +260,22 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, int nr,
>>> BUG();
>>> } else {
>>> int fd = img_raw_fd(pr->pi);
>>> - off_t current_vaddr = lseek(fd, pr->pi_off, SEEK_SET);
>>>
>>> - pr_debug("\tpr%u Read page from self %lx/%"PRIx64"\n", pr->id, pr->cvaddr, current_vaddr);
>>> - ret = read(fd, buf, len);
>>> + pr_debug("\tpr%u Read page from self %lx/%"PRIx64"\n", pr->id, pr->cvaddr, pr->pi_off);
>>> + ret = pread(fd, buf, len, pr->pi_off);
>>> if (ret != len) {
>>> pr_perror("Can't read mapping page %d", ret);
>>> return -1;
>>> }
>>>
>>> - pr->pi_off += len;
>>> -
>>> if (opts.auto_dedup) {
>>> - ret = punch_hole(pr, current_vaddr, len, false);
>>> + ret = punch_hole(pr, pr->pi_off, len, false);
>>> if (ret == -1) {
>>> return -1;
>>> }
>>> }
>>> +
>>> + pr->pi_off += len;
>>> }
>>>
>>> pr->cvaddr += len;
>>> --
>>> 2.1.4
>>>
>>> _______________________________________________
>>> CRIU mailing list
>>> CRIU at openvz.org
>>> https://lists.openvz.org/mailman/listinfo/criu
>>>
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU at openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>>
>
> .
>
More information about the CRIU
mailing list