From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzPJX-0000Y6-04 for qemu-devel@nongnu.org; Wed, 26 Oct 2016 10:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzPJT-0000Bx-A6 for qemu-devel@nongnu.org; Wed, 26 Oct 2016 10:36:23 -0400 Date: Wed, 26 Oct 2016 16:36:12 +0200 From: Kevin Wolf Message-ID: <20161026143612.GP4758@noname.str.redhat.com> References: <6cf9c4b12d9d95692664efa731d1f56c01dc1581.1477476553.git.berto@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6cf9c4b12d9d95692664efa731d1f56c01dc1581.1477476553.git.berto@igalia.com> Subject: Re: [Qemu-devel] [PATCH v12 02/19] block: Pause all jobs during bdrv_reopen_multiple() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alberto Garcia Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz , Eric Blake , Markus Armbruster Am 26.10.2016 um 12:29 hat Alberto Garcia geschrieben: > When a BlockDriverState is about to be reopened it can trigger certain > operations that need to write to disk. During this process a different > block job can be woken up. If that block job completes and also needs > to call bdrv_reopen() it can happen that it needs to do it on the same > BlockDriverState that is still in the process of being reopened. > > This can have fatal consequences, like in this example: > > 1) Block job A starts and sleeps after a while. > 2) Block job B starts and tries to reopen node1 (a qcow2 file). > 3) Reopening node1 means flushing and replacing its qcow2 cache. > 4) While the qcow2 cache is being flushed, job A wakes up. > 5) Job A completes and reopens node1, replacing its cache. > 6) Job B resumes, but the cache that was being flushed no longer > exists. > > This patch splits the bdrv_drain_all() call to keep all block jobs > paused during bdrv_reopen_multiple(), so that step 4 can never happen > and the operation is safe. > > Note that this scenario can only happen if both bdrv_reopen() calls > are made by block jobs on the same backing chain. Otherwise there's no > chance that the same BlockDriverState appears in both reopen queues. > > Signed-off-by: Alberto Garcia > Reviewed-by: Paolo Bonzini Reviewed-by: Kevin Wolf