qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 1/8] block: add bdrv_add_before_write_cb()


From: Wenchao Xia
Subject: Re: [Qemu-devel] [PATCH v3 1/8] block: add bdrv_add_before_write_cb()
Date: Thu, 16 May 2013 10:42:36 +0800
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5

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 <address@hidden>
---
  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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]