<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 19, 2019 at 7:07 PM Jan Stancek <<a href="mailto:jstancek@redhat.com">jstancek@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
----- Original Message -----<br>
> - while (len) {<br>
> + while (len >= fi.f_bsize) {<br>
<br>
Let's say f_bsize is 512, and len is 1023. We hit ENOSPC for 1023,<br>
len for next round is 511. Loop ends, but we never tried write with<br>
f_bsize or smaller value.<br>
<br>
I think we should try len < fi.f_bsize at least once.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Good point. At least for len = fi.f_bsize.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> ret = write(fd, buf, MIN(len, sizeof(buf)));<br>
> <br>
> if (ret < 0) {<br>
> + if (errno == ENOSPC) {<br>
> + len /= 2;<br>
> + continue;<br>
> + }<br>
<br>
The return below (in original code) doesn't appear to be reachable now.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Yes, but it doesn't make much sense there, maybe we could remove that part directly?</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>