qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] block: simplify write-threshold and drop write notifiers


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH] block: simplify write-threshold and drop write notifiers
Date: Wed, 5 May 2021 13:17:52 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0

05.05.2021 13:10, Stefan Hajnoczi wrote:
On Thu, Apr 22, 2021 at 01:09:50AM +0300, Vladimir Sementsov-Ogievskiy wrote:
@@ -1981,8 +1985,15 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t 
offset, int64_t bytes,
          } else {
              assert(child->perm & BLK_PERM_WRITE);
          }
-        return notifier_with_return_list_notify(&bs->before_write_notifiers,
-                                                req);
+        write_threshold = qatomic_read(&bs->write_threshold_offset);
+        if (write_threshold > 0 && offset + bytes > write_threshold) {
+            qapi_event_send_block_write_threshold(
+                bs->node_name,
+                offset + bytes - write_threshold,
+                write_threshold);
+            qatomic_set(&bs->write_threshold_offset, 0);

It's safer to reset the threshold before emitting the event. That way
there is no race with the QMP client setting a new threshold via
bdrv_write_threshold_is_set(). I guess the race is possible since
qatomic is used and there is no lock.

I like the idea of dropping write notifiers:
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>


Sorry, this is an outdated patch, I've sent a v2:

 [PATCH v2 0/9] block: refactor write threshold

--
Best regards,
Vladimir



reply via email to

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