From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9LZX-0006vo-Vd for qemu-devel@nongnu.org; Thu, 08 Jan 2015 17:28:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9LZV-0006dm-99 for qemu-devel@nongnu.org; Thu, 08 Jan 2015 17:28:55 -0500 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:49080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9LZV-0006dh-0D for qemu-devel@nongnu.org; Thu, 08 Jan 2015 17:28:53 -0500 Received: by mail-wi0-f180.google.com with SMTP id n3so6300063wiv.1 for ; Thu, 08 Jan 2015 14:28:52 -0800 (PST) Sender: Paolo Bonzini Message-ID: <54AF049F.6020207@redhat.com> Date: Thu, 08 Jan 2015 23:28:47 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1418307457-25996-1-git-send-email-vsementsov@parallels.com> <1418307457-25996-8-git-send-email-vsementsov@parallels.com> In-Reply-To: <1418307457-25996-8-git-send-email-vsementsov@parallels.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 7/9] block-migration: remove not needed iothread lock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org Cc: kwolf@redhat.com, den@openvz.org, jsnow@redhat.com, stefanha@redhat.com On 11/12/2014 15:17, Vladimir Sementsov-Ogievskiy wrote: > - qemu_mutex_lock_iothread(); > + bdrv_reset_dirty_bitmap(bs, bmds->dirty_bitmap, cur_sector, nr_sectors); > + > blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov, > nr_sectors, blk_mig_read_cb, blk); > > - bdrv_reset_dirty_bitmap(bs, bmds->dirty_bitmap, cur_sector, nr_sectors); > - qemu_mutex_unlock_iothread(); > - bdrv_aio_readv is not thread safe, so it needs the iothread lock. bdrv_reset_dirty_bitmap is also not thread safe, because bmds->dirty_bitmap is accessed concurrently by bdrv_reset_dirty (discard) and bdrv_set_dirty (write). So it needs the iothread lock too. Moving bdrv_reset_dirty_bitmap before the read is a good idea. Paolo