From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSvtg-0004Za-KZ for qemu-devel@nongnu.org; Mon, 08 Feb 2016 19:11:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSvtf-0008At-Jh for qemu-devel@nongnu.org; Mon, 08 Feb 2016 19:11:12 -0500 References: <1453804705-7205-1-git-send-email-famz@redhat.com> <1453804705-7205-3-git-send-email-famz@redhat.com> From: John Snow Message-ID: <56B92E98.8050901@redhat.com> Date: Mon, 8 Feb 2016 19:11:04 -0500 MIME-Version: 1.0 In-Reply-To: <1453804705-7205-3-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 02/16] block: Set dirty before doing write List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Markus Armbruster , mreitz@redhat.com, vsementsov@parallels.com, Stefan Hajnoczi On 01/26/2016 05:38 AM, Fam Zheng wrote: > So that driver can write the dirty bits into persistent dirty bitmaps in > the write callback. > > Signed-off-by: Fam Zheng > --- > block/io.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/block/io.c b/block/io.c > index 343ff1f..b964e7e 100644 > --- a/block/io.c > +++ b/block/io.c > @@ -1164,6 +1164,8 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, > } > } > > + bdrv_set_dirty(bs, sector_num, nb_sectors); > + > if (ret < 0) { > /* Do nothing, write notifier decided to fail this request */ > } else if (flags & BDRV_REQ_ZERO_WRITE) { > @@ -1179,8 +1181,6 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs, > ret = bdrv_co_flush(bs); > } > > - bdrv_set_dirty(bs, sector_num, nb_sectors); > - > if (bs->wr_highest_offset < offset + bytes) { > bs->wr_highest_offset = offset + bytes; > } > Might want a comment here acknowledging the write gets errantly set on write failure, but that for $reasons it needs to be above anyway -- so someone doesn't helpfully try to move it back below. Reviewed-by: John Snow