[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH] block/mirror: limit qiov to IOV_MAX elements
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-block] [PATCH] block/mirror: limit qiov to IOV_MAX elements |
Date: |
Wed, 1 Jul 2015 17:03:56 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 |
On 01/07/2015 16:59, Stefan Hajnoczi wrote:
> I found it annoying to write it backwards too, but it's for consistency:
>
> if (s->buf_free_count < nb_chunks + added_chunks) {
> trace_mirror_break_buf_busy(s, nb_chunks, s->in_flight);
> break;
> }
> if (IOV_MAX < nb_chunks + added_chunks) {
> trace_mirror_break_iov_max(s, nb_chunks, added_chunks);
> break;
> }
>
> It's the same type of check as s->buf_free_count (which isn't modified
> by this loop either so it's a yoda conditional).
Hmm, right. The problem goes back to:
while (nb_chunks == 0 && s->buf_free_count < added_chunks) {
trace_mirror_yield_buf_busy(s, nb_chunks, s->in_flight);
qemu_coroutine_yield();
}
where s->buf_free_count _is_ modified by the loop. The if below:
if (s->buf_free_count < nb_chunks + added_chunks) {
trace_mirror_break_buf_busy(s, nb_chunks, s->in_flight);
break;
}
is written as a < check for consistency, and the one you add exacerbates
the problem. If you want you can change the < to > in the "while" loop
as well; otherwise the patch is okay as is.
Paolo