From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-block@nongnu.org, famz@redhat.com, qemu-devel@nongnu.org,
mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after bdrv_reopen()
Date: Mon, 18 Sep 2017 11:35:57 +0200 [thread overview]
Message-ID: <20170918093557.GE31915@localhost.localdomain> (raw)
In-Reply-To: <726a7ef6-820b-2695-4ce5-ffa06da078d1@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2171 bytes --]
Am 15.09.2017 um 21:06 hat Eric Blake geschrieben:
> On 09/15/2017 05:10 AM, Kevin Wolf wrote:
> > If we switch between read-only and read-write, the permissions that
> > image format drivers need on bs->file change, too. Make sure to update
> > the permissions during bdrv_reopen().
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> > include/block/block.h | 1 +
> > block.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 65 insertions(+)
> >
>
> > +static BlockReopenQueueEntry *find_parent_in_reopen_queue(BlockReopenQueue *q,
> > + BdrvChild *c)
> > +{
> > + BlockReopenQueueEntry *entry;
> > +
> > + QSIMPLEQ_FOREACH(entry, q, entry) {
> > + BlockDriverState *bs = entry->state.bs;
> > + BdrvChild *child;
> > +
> > + QLIST_FOREACH(child, &bs->children, next) {
> > + if (child == c) {
> > + return entry;
>
> An O(n^2) loop. Is it going to bite us at any point in the future, or
> are we generally dealing with a small enough queue size and BDS graph to
> not worry about it?
The loops you're quoting aren't O(n^2), they don't loop over the same
thing. This part is O(n) in terms of BdrvChild elements looked at.
The thing that worried me a bit more is the caller:
+ QLIST_FOREACH(c, &bs->parents, next_parent) {
+ parent = find_parent_in_reopen_queue(q, c);
This is indeed O(n^2) (again with n = number of BdrvChild elements) in
the pathological worst case of a quorum node where all children point to
the same node.
As soon as all parents of the node are distinct - and I don't see any
reason why they wouldn't in practice - we're back to O(n) because each
BdrvChild belongs to only one parent. Even if we ever introduce a driver
where having the same node as a child in a constant number of different
roles makes sense for a parent (i.e. anything that doesn't involve an
(unbounded) array of children), we would still be O(n) with an additional
small constant factor.
So I think in practice we should be okay.
Kevin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2017-09-18 9:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 10:10 [Qemu-devel] [PATCH 0/6] block: Fix permissions after ro/rw reopen Kevin Wolf
2017-09-15 10:10 ` [Qemu-devel] [PATCH 1/6] qemu-io: Reset qemuio_blk permissions before each command Kevin Wolf
2017-09-15 17:44 ` Eric Blake
2017-09-18 7:16 ` Fam Zheng
2017-09-21 13:53 ` Kevin Wolf
2017-09-22 10:46 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2017-09-22 12:55 ` [Qemu-devel] [PATCH v2 1/6] qemu-io: Drop write permissions before read-only reopen Kevin Wolf
2017-09-22 13:22 ` Fam Zheng
2017-09-15 10:10 ` [Qemu-devel] [PATCH 2/6] block: Add reopen_queue to bdrv_child_perm() Kevin Wolf
2017-09-15 17:51 ` Eric Blake
2017-09-15 10:10 ` [Qemu-devel] [PATCH 3/6] block: Add reopen queue to bdrv_check_perm() Kevin Wolf
2017-09-15 18:39 ` Eric Blake
2017-09-15 10:10 ` [Qemu-devel] [PATCH 4/6] block: Base permissions on rw state after reopen Kevin Wolf
2017-09-15 18:58 ` Eric Blake
2017-09-15 10:10 ` [Qemu-devel] [PATCH 5/6] block: reopen: Queue children after their parents Kevin Wolf
2017-09-15 19:01 ` Eric Blake
2017-09-15 10:10 ` [Qemu-devel] [PATCH 6/6] block: Fix permissions after bdrv_reopen() Kevin Wolf
2017-09-15 19:06 ` Eric Blake
2017-09-18 9:35 ` Kevin Wolf [this message]
2017-09-18 7:37 ` Fam Zheng
2017-09-18 7:43 ` Kevin Wolf
2017-09-15 17:02 ` [Qemu-devel] [PATCH 7/6] qemu-iotests: Test change-backing-file command Kevin Wolf
2017-09-15 19:14 ` Eric Blake
2017-09-18 7:51 ` [Qemu-devel] [PATCH 0/6] block: Fix permissions after ro/rw reopen Fam Zheng
2017-09-18 8:11 ` Kevin Wolf
2017-09-18 11:53 ` Fam Zheng
2017-09-18 12:11 ` Kevin Wolf
2017-09-18 12:32 ` Fam Zheng
2017-09-20 10:33 ` 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=20170918093557.GE31915@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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).