<div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote">2017-04-24 12:55 GMT+01:00 Pavel Emelyanov <span dir="ltr">&lt;<a href="mailto:xemul@virtuozzo.com" target="_blank">xemul@virtuozzo.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 04/23/2017 04:29 AM, Rodrigo Bruno wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; the patch looks good. It avoids using &#39;pread&#39; which is not supported for remote images.<br>
&gt;<br>
&gt; However, the patch that I sent for the mailing list introducing remote images used &#39;read&#39; instead of &#39;pread&#39;.<br>
<br>
</span>Yes, sorry about that, it was me wrongly merging async reads with remotes :(<br>
<br>
I have a question regarding this place, while we&#39;re at it. Here&#39;s the code from<br>
maybe_read_page_local():<br>
<br>
        if ((flags &amp; (PR_ASYNC|PR_ASAP)) == PR_ASYNC &amp;&amp; !opts.remote)<br>
                ret = enqueue_async_page(pr, vaddr, len, buf);<br>
        else {<br>
                ret = read_local_page(pr, vaddr, len, buf);<br>
<br>
Why don&#39;t we enqueue the read request for opts.remote case?<br></blockquote><div><br></div><div>To be honest, I don&#39;t remember why I avoided async pages... I looked through the code and I don&#39;t see any</div><div>particular reason for it not to work with remote images.</div><div><br></div><div>Anyway, just to clarify, what is the motivation behind async pages? Are we avoiding any page read that might be unnecessary</div><div>in the future? </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
&gt; If more code locations were reverted to &#39;pread&#39;, it might be necessary to protect them as well.<br>
&gt;<br>
&gt; Is there any reason for using &#39;pread&#39; instead of &#39;read&#39;? It seems to me that the code always reads files forwards.<br>
&gt; Additionally, I also made some experiments (including zdtm tests) back in February using &#39;read&#39; instead of &#39;pread&#39; and it worked.<br>
&gt;<br>
&gt; Best,<br>
&gt; rodrigo<br>
&gt;<br>
&gt;<br>
</span>&gt; 2017-04-22 4:42 GMT+01:00 Andrei Vagin &lt;<a href="mailto:avagin@virtuozzo.com">avagin@virtuozzo.com</a> &lt;mailto:<a href="mailto:avagin@virtuozzo.com">avagin@virtuozzo.com</a>&gt;&gt;<wbr>:<br>
<span class="">&gt;<br>
&gt;     Rodrigo, could you review this patch?<br>
&gt;<br>
&gt;     On Fri, Apr 21, 2017 at 06:25:54PM +0300, Mike Rapoport wrote:<br>
&gt;     &gt; When --remote option is specified, read_local_page tries to pread from a<br>
&gt;     &gt; socket, and fails with &quot;Illegal seek&quot; error.<br>
&gt;     &gt; Restore single pread call for regular image files case and use read syscall<br>
&gt;     &gt; instead of pread for the --remote case.<br>
&gt;     &gt;<br>
</span>&gt;     &gt; Signed-off-by: Mike Rapoport &lt;<a href="mailto:rppt@linux.vnet.ibm.com">rppt@linux.vnet.ibm.com</a> &lt;mailto:<a href="mailto:rppt@linux.vnet.ibm.com">rppt@linux.vnet.ibm.<wbr>com</a>&gt;&gt;<br>
<div class="HOEnZb"><div class="h5">&gt;     &gt; ---<br>
&gt;     &gt;  criu/pagemap.c | 18 +++++++++++++-----<br>
&gt;     &gt;  1 file changed, 13 insertions(+), 5 deletions(-)<br>
&gt;     &gt;<br>
&gt;     &gt; diff --git a/criu/pagemap.c b/criu/pagemap.c<br>
&gt;     &gt; index 6c741b4..7d25c6f 100644<br>
&gt;     &gt; --- a/criu/pagemap.c<br>
&gt;     &gt; +++ b/criu/pagemap.c<br>
&gt;     &gt; @@ -265,15 +265,23 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,<br>
&gt;     &gt;               return -1;<br>
&gt;     &gt;<br>
&gt;     &gt;       pr_debug(&quot;\tpr%d-%u Read page from self %lx/%&quot;PRIx64&quot;\n&quot;, pr-&gt;pid, pr-&gt;id, pr-&gt;cvaddr, pr-&gt;pi_off);<br>
&gt;     &gt; -     while (1) {<br>
&gt;     &gt; +     if (!opts.remote) {<br>
&gt;     &gt;               ret = pread(fd, buf + curr, len - curr, pr-&gt;pi_off + curr);<br>
&gt;     &gt; -             if (ret &lt; 1) {<br>
&gt;     &gt; +             if (ret != len) {<br>
&gt;     &gt;                       pr_perror(&quot;Can&#39;t read mapping page %d&quot;, ret);<br>
&gt;     &gt;                       return -1;<br>
&gt;     &gt;               }<br>
&gt;     &gt; -             curr += ret;<br>
&gt;     &gt; -             if (curr == len)<br>
&gt;     &gt; -                     break;<br>
&gt;     &gt; +     } else {<br>
&gt;     &gt; +             while (1) {<br>
&gt;     &gt; +                     ret = read(fd, buf + curr, len - curr);<br>
&gt;     &gt; +                     if (ret &lt; 0) {<br>
&gt;     &gt; +                             pr_perror(&quot;Can&#39;t read mapping page %d&quot;, ret);<br>
&gt;     &gt; +                             return -1;<br>
&gt;     &gt; +                     }<br>
&gt;     &gt; +                     curr += ret;<br>
&gt;     &gt; +                     if (curr == len)<br>
&gt;     &gt; +                             break;<br>
&gt;     &gt; +             }<br>
&gt;     &gt;       }<br>
&gt;     &gt;<br>
&gt;     &gt;       if (opts.auto_dedup) {<br>
&gt;     &gt; --<br>
&gt;     &gt; 1.9.1<br>
&gt;     &gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div></div>