From: Manos Pitsidianakis <el13635@mail.ntua.gr>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Alberto Garcia <berto@igalia.com>,
qemu-block <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PATCH 2/3] block: skip implicit nodes in snapshots, blockjobs
Date: Tue, 1 Aug 2017 16:49:06 +0300 [thread overview]
Message-ID: <20170801134907.31253-3-el13635@mail.ntua.gr> (raw)
In-Reply-To: <20170801134907.31253-1-el13635@mail.ntua.gr>
Implicit filter nodes added at the top of nodes can interfere with block
jobs. This is not a problem when they are added by other jobs since
adding another job will issue a QERR_DEVICE_IN_USE, but it can happen in
the next commit which introduces an implicitly created throttle filter
node below BlockBackend, which we want to be skipped during automatic
operations on the graph since the user does not necessarily know about
their existence.
Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr>
---
block.c | 17 +++++++++++++++++
blockdev.c | 12 ++++++++++++
include/block/block_int.h | 2 ++
3 files changed, 31 insertions(+)
diff --git a/block.c b/block.c
index 886a457ab0..9ebdba28b0 100644
--- a/block.c
+++ b/block.c
@@ -4947,3 +4947,20 @@ bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
return drv->bdrv_can_store_new_dirty_bitmap(bs, name, granularity, errp);
}
+
+/* Get first non-implicit node down a bs chain. */
+BlockDriverState *bdrv_get_first_non_implicit(BlockDriverState *bs)
+{
+ if (!bs) {
+ return NULL;
+ }
+
+ if (!bs->implicit) {
+ return bs;
+ }
+
+ /* at this point bs is implicit and must have a child */
+ assert(bs->file);
+
+ return bdrv_get_first_non_implicit(bs->file->bs);
+}
diff --git a/blockdev.c b/blockdev.c
index 23475abb72..d903a23786 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1664,6 +1664,9 @@ static void external_snapshot_prepare(BlkActionState *common,
return;
}
+ /* Skip implicit filter nodes */
+ state->old_bs = bdrv_get_first_non_implicit(state->old_bs);
+
/* Acquire AioContext now so any threads operating on old_bs stop */
state->aio_context = bdrv_get_aio_context(state->old_bs);
aio_context_acquire(state->aio_context);
@@ -3095,6 +3098,9 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
return;
}
+ /* Skip implicit filter nodes */
+ bs = bdrv_get_first_non_implicit(bs);
+
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
@@ -3209,6 +3215,9 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,
return NULL;
}
+ /* Skip implicit filter nodes */
+ bs = bdrv_get_first_non_implicit(bs);
+
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
@@ -3484,6 +3493,9 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)
return;
}
+ /* Skip implicit filter nodes */
+ bs = bdrv_get_first_non_implicit(bs);
+
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index d4f4ea7584..9eeae490f0 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -981,4 +981,6 @@ void bdrv_dec_in_flight(BlockDriverState *bs);
void blockdev_close_all_bdrv_states(void);
+BlockDriverState *bdrv_get_first_non_implicit(BlockDriverState *bs);
+
#endif /* BLOCK_INT_H */
--
2.11.0
next prev parent reply other threads:[~2017-08-01 13:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-01 13:49 [Qemu-devel] [PATCH 0/3] block: remove legacy I/O throttling Manos Pitsidianakis
2017-08-01 13:49 ` [Qemu-devel] [PATCH 1/3] block: add options parameter to bdrv_new_open_driver() Manos Pitsidianakis
2017-08-02 9:33 ` Stefan Hajnoczi
2017-08-01 13:49 ` Manos Pitsidianakis [this message]
2017-08-02 9:52 ` [Qemu-devel] [PATCH 2/3] block: skip implicit nodes in snapshots, blockjobs Stefan Hajnoczi
2017-08-03 10:22 ` Kevin Wolf
2017-08-01 13:49 ` [Qemu-devel] [PATCH 3/3] block: remove legacy I/O throttling Manos Pitsidianakis
2017-08-02 10:07 ` Stefan Hajnoczi
2017-08-02 10:33 ` Kevin Wolf
2017-08-02 16:46 ` Manos Pitsidianakis
2017-08-02 10:34 ` Manos Pitsidianakis
2017-08-02 14:36 ` Stefan Hajnoczi
2017-08-03 11:10 ` Kevin Wolf
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=20170801134907.31253-3-el13635@mail.ntua.gr \
--to=el13635@mail.ntua.gr \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).