From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uco9s-00017L-SU for qemu-devel@nongnu.org; Wed, 15 May 2013 22:43:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uco9n-0007f7-Mj for qemu-devel@nongnu.org; Wed, 15 May 2013 22:43:08 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:42165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uco9m-0007bU-57 for qemu-devel@nongnu.org; Wed, 15 May 2013 22:43:03 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2013 12:37:30 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id B6D1C3578051 for ; Thu, 16 May 2013 12:42:49 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4G2SmKc23003278 for ; Thu, 16 May 2013 12:28:48 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4G2gmI1012673 for ; Thu, 16 May 2013 12:42:48 +1000 Message-ID: <5194479C.3030309@linux.vnet.ibm.com> Date: Thu, 16 May 2013 10:42:36 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1368628476-19622-1-git-send-email-stefanha@redhat.com> <1368628476-19622-2-git-send-email-stefanha@redhat.com> <51939EF1.6050800@redhat.com> In-Reply-To: <51939EF1.6050800@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 1/8] block: add bdrv_add_before_write_cb() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , Fam Zheng , qemu-devel@nongnu.org, imain@redhat.com, Stefan Hajnoczi , dietmar@proxmox.com Reviewed the code, except Paolo's comments, function seems fine. > Il 15/05/2013 16:34, Stefan Hajnoczi ha scritto: >> The bdrv_add_before_write_cb() function installs a callback that is >> invoked before a write request is processed. This will be used to >> implement copy-on-write point-in-time snapshots where we need to copy >> out old data before overwriting it. > > Perhaps a notifier list that receives the BdrvTrackedRequest? (BTW we > should probably remove all the notifier_remove wrappers, they're useless). > > The BdrvTrackedRequest pointer would also act as a unique id of the request. > >> Signed-off-by: Stefan Hajnoczi >> --- >> block.c | 37 +++++++++++++++++++++++++++++++++++++ >> include/block/block_int.h | 32 ++++++++++++++++++++++++++++++++ >> 2 files changed, 69 insertions(+) >> >> diff --git a/block.c b/block.c >> index 3f87489..0fd7167 100644 >> --- a/block.c >> +++ b/block.c >> @@ -308,6 +308,7 @@ BlockDriverState *bdrv_new(const char *device_name) >> } >> bdrv_iostatus_disable(bs); >> notifier_list_init(&bs->close_notifiers); >> + QTAILQ_INIT(&bs->before_write_cbs); >> >> return bs; >> } >> @@ -1383,6 +1384,8 @@ void bdrv_close(BlockDriverState *bs) >> bs->growable = 0; >> QDECREF(bs->options); >> bs->options = NULL; >> + assert(QTAILQ_EMPTY(&bs->before_write_cbs)); >> + QTAILQ_INIT(&bs->before_write_cbs); > > INIT not needed if you assert before. > > Paolo > -- Best Regards Wenchao Xia