From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYARo-0002KL-PL for qemu-devel@nongnu.org; Tue, 23 Feb 2016 05:44:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYARo-0007sG-0R for qemu-devel@nongnu.org; Tue, 23 Feb 2016 05:44:04 -0500 Sender: Paolo Bonzini References: <1455638000-18051-1-git-send-email-pbonzini@redhat.com> <20160217025722.GC30207@ad.usersys.redhat.com> <56C4595D.1020206@redhat.com> <20160223055704.GC19080@ad.usersys.redhat.com> From: Paolo Bonzini Message-ID: <56CC37EB.7050901@redhat.com> Date: Tue, 23 Feb 2016 11:43:55 +0100 MIME-Version: 1.0 In-Reply-To: <20160223055704.GC19080@ad.usersys.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] qed: fix bdrv_qed_drain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: stefanha@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-stable@nongnu.org On 23/02/2016 06:57, Fam Zheng wrote: >>>> + qed_cancel_need_check_timer(s); >>>> + qed_need_check_timer_cb(s); >>>> + } >>> >>> What if an allocating write is queued (the else branch case)? Its completion >>> will be in bdrv_drain and it could arm the need_check_timer which is wrong. >>> >>> We need to drain the allocating_write_reqs queue before checking the timer. >> >> You're right, but how? That's what bdrv_drain(bs) does, it's a >> chicken-and-egg problem. > > Maybe use an aio_poll loop before the if? That would not change the fact that you're reimplementing bdrv_drain inside bdrv_qed_drain. Perhaps for now it's simplest to just remove the QED .bdrv_drain callback, if you think this patch is not a good stopgap measure to avoid the segmentation faults. Once the bdrv_drain rework is in, we can move the callback _after_ I/O is drained on bs and before it is drained on bs->file->bs. Paolo