qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: famz@redhat.com
Subject: [Qemu-devel] [PATCH 12/19] block: access write_gen with atomics
Date: Mon,  5 Jun 2017 14:39:01 +0200	[thread overview]
Message-ID: <20170605123908.18777-13-pbonzini@redhat.com> (raw)
In-Reply-To: <20170605123908.18777-1-pbonzini@redhat.com>

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.c                   | 2 +-
 block/io.c                | 6 +++---
 include/block/block_int.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/block.c b/block.c
index af6366bcef..361005cba9 100644
--- a/block.c
+++ b/block.c
@@ -3424,7 +3424,7 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, Error **errp)
         ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);
         bdrv_dirty_bitmap_truncate(bs);
         bdrv_parent_cb_resize(bs);
-        ++bs->write_gen;
+        atomic_inc(&bs->write_gen);
     }
     return ret;
 }
diff --git a/block/io.c b/block/io.c
index bc69b4cecd..036f5a4870 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1402,7 +1402,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
     }
     bdrv_debug_event(bs, BLKDBG_PWRITEV_DONE);
 
-    ++bs->write_gen;
+    atomic_inc(&bs->write_gen);
     bdrv_set_dirty(bs, start_sector, end_sector - start_sector);
 
     stat64_max(&bs->wr_highest_offset, offset + bytes);
@@ -2291,7 +2291,7 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
         goto early_exit;
     }
 
-    current_gen = bs->write_gen;
+    current_gen = atomic_read(&bs->write_gen);
 
     /* Wait until any previous flushes are completed */
     while (bs->active_flush_req) {
@@ -2516,7 +2516,7 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
     }
     ret = 0;
 out:
-    ++bs->write_gen;
+    atomic_inc(&bs->write_gen);
     bdrv_set_dirty(bs, req.offset >> BDRV_SECTOR_BITS,
                    req.bytes >> BDRV_SECTOR_BITS);
     tracked_request_end(&req);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 8f36d1fc1d..8a9bc0bebc 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -612,7 +612,6 @@ struct BlockDriverState {
     QLIST_HEAD(, BdrvTrackedRequest) tracked_requests;
     CoQueue flush_queue;                  /* Serializing flush queue */
     bool active_flush_req;                /* Flush request in flight? */
-    unsigned int write_gen;               /* Current data generation */
     unsigned int flushed_gen;             /* Flushed write generation */
 
     QLIST_HEAD(, BdrvDirtyBitmap) dirty_bitmaps;
@@ -647,6 +646,7 @@ struct BlockDriverState {
 
     /* Accessed with atomic ops.  */
     int quiesce_counter;
+    unsigned int write_gen;               /* Current data generation */
 };
 
 struct BlockBackendRootState {
-- 
2.13.0

  parent reply	other threads:[~2017-06-05 12:39 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-05 12:38 [Qemu-devel] [PATCH v4 00/19] Block layer thread safety, part 1 Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 01/19] block: access copy_on_read with atomic ops Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 02/19] block: access quiesce_counter " Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 03/19] block: access io_limits_disabled " Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 04/19] block: access serialising_in_flight " Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 05/19] block: access wakeup " Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 06/19] block: access io_plugged " Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 07/19] throttle-groups: only start one coroutine from drained_begin Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 08/19] throttle-groups: do not use qemu_co_enter_next Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 09/19] throttle-groups: protect throttled requests with a CoMutex Paolo Bonzini
2017-06-05 12:38 ` [Qemu-devel] [PATCH 10/19] util: add stats64 module Paolo Bonzini
2017-06-05 12:39 ` [Qemu-devel] [PATCH 11/19] block: use Stat64 for wr_highest_offset Paolo Bonzini
2017-06-05 12:39 ` Paolo Bonzini [this message]
2017-06-05 12:39 ` [Qemu-devel] [PATCH 13/19] block: protect tracked_requests and flush_queue with reqs_lock Paolo Bonzini
2017-06-05 12:39 ` [Qemu-devel] [PATCH 14/19] block: introduce dirty_bitmap_mutex Paolo Bonzini
2017-06-05 12:39 ` [Qemu-devel] [PATCH 15/19] migration/block: reset dirty bitmap before reading Paolo Bonzini
2017-06-05 12:39 ` [Qemu-devel] [PATCH 16/19] block: protect modification of dirty bitmaps with a mutex Paolo Bonzini
2017-06-26 16:07   ` Vladimir Sementsov-Ogievskiy
2017-06-26 16:54     ` Paolo Bonzini
2017-06-27  9:07       ` Vladimir Sementsov-Ogievskiy
2017-06-27  9:27         ` Paolo Bonzini
2017-06-27  9:47           ` Vladimir Sementsov-Ogievskiy
2017-06-27 12:52             ` Paolo Bonzini
2017-06-27 13:51               ` Vladimir Sementsov-Ogievskiy
2017-06-27 13:58                 ` Paolo Bonzini
2017-06-27 14:20                   ` Vladimir Sementsov-Ogievskiy
2017-06-27 14:26                     ` Paolo Bonzini
2017-06-27 14:43                       ` Vladimir Sementsov-Ogievskiy
2017-06-27 14:48                         ` Paolo Bonzini
2017-06-27 15:31                       ` Vladimir Sementsov-Ogievskiy
2017-06-27 15:32                         ` Vladimir Sementsov-Ogievskiy
2017-06-27 15:42                           ` Paolo Bonzini
2017-06-05 12:39 ` [Qemu-devel] [PATCH 17/19] block: introduce block_account_one_io Paolo Bonzini
2017-06-05 12:39 ` [Qemu-devel] [PATCH 18/19] block: split BlockAcctStats creation and setup Paolo Bonzini
2017-06-06 15:43   ` Alberto Garcia
2017-06-05 12:39 ` [Qemu-devel] [PATCH 19/19] block: make accounting thread-safe Paolo Bonzini
2017-06-06 15:45   ` Alberto Garcia
2018-05-24 13:35   ` Alberto Garcia
2018-05-24 13:49     ` Alberto Garcia
2018-05-24 13:49     ` Paolo Bonzini
2017-06-05 13:18 ` [Qemu-devel] [PATCH v4 00/19] Block layer thread safety, part 1 no-reply
2017-06-07  0:04 ` Fam Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170605123908.18777-13-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=famz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).