[{"id":1769369,"web_url":"http://patchwork.ozlabs.org/comment/1769369/","msgid":"<726a7ef6-820b-2695-4ce5-ffa06da078d1@redhat.com>","list_archive_url":null,"date":"2017-09-15T19:06:34","subject":"Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after\n\tbdrv_reopen()","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 09/15/2017 05:10 AM, Kevin Wolf wrote:\n> If we switch between read-only and read-write, the permissions that\n> image format drivers need on bs->file change, too. Make sure to update\n> the permissions during bdrv_reopen().\n> \n> Signed-off-by: Kevin Wolf <kwolf@redhat.com>\n> ---\n>  include/block/block.h |  1 +\n>  block.c               | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 65 insertions(+)\n> \n\n> +static BlockReopenQueueEntry *find_parent_in_reopen_queue(BlockReopenQueue *q,\n> +                                                          BdrvChild *c)\n> +{\n> +    BlockReopenQueueEntry *entry;\n> +\n> +    QSIMPLEQ_FOREACH(entry, q, entry) {\n> +        BlockDriverState *bs = entry->state.bs;\n> +        BdrvChild *child;\n> +\n> +        QLIST_FOREACH(child, &bs->children, next) {\n> +            if (child == c) {\n> +                return entry;\n\nAn O(n^2) loop. Is it going to bite us at any point in the future, or\nare we generally dealing with a small enough queue size and BDS graph to\nnot worry about it?\n\nReviewed-by: Eric Blake <eblake@redhat.com>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xv4f00n1qz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 16 Sep 2017 05:07:17 +1000 (AEST)","from localhost ([::1]:54689 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dsvxJ-0007Qv-HD\n\tfor incoming@patchwork.ozlabs.org; Fri, 15 Sep 2017 15:07:13 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:53431)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dsvws-0007PK-So\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 15:06:47 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dsvwr-0006xL-N8\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 15:06:46 -0400","from mx1.redhat.com ([209.132.183.28]:53902)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>)\n\tid 1dsvwn-0006wH-51; Fri, 15 Sep 2017 15:06:41 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 97FC380F79;\n\tFri, 15 Sep 2017 19:06:39 +0000 (UTC)","from [10.10.124.97] (ovpn-124-97.rdu2.redhat.com [10.10.124.97])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 35A2153;\n\tFri, 15 Sep 2017 19:06:35 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 97FC380F79","To":"Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org","References":"<20170915101008.16646-1-kwolf@redhat.com>\n\t<20170915101008.16646-7-kwolf@redhat.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<726a7ef6-820b-2695-4ce5-ffa06da078d1@redhat.com>","Date":"Fri, 15 Sep 2017 14:06:34 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170915101008.16646-7-kwolf@redhat.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"bLiElVtbVOmtmSVVts722p4TDBuHMAQBj\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tFri, 15 Sep 2017 19:06:40 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after\n\tbdrv_reopen()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"famz@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1769919,"web_url":"http://patchwork.ozlabs.org/comment/1769919/","msgid":"<20170918073741.GJ15551@lemon.lan>","list_archive_url":null,"date":"2017-09-18T07:37:41","subject":"Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after\n\tbdrv_reopen()","submitter":{"id":24872,"url":"http://patchwork.ozlabs.org/api/people/24872/","name":"Fam Zheng","email":"famz@redhat.com"},"content":"On Fri, 09/15 12:10, Kevin Wolf wrote:\n> If we switch between read-only and read-write, the permissions that\n> image format drivers need on bs->file change, too. Make sure to update\n> the permissions during bdrv_reopen().\n> \n> Signed-off-by: Kevin Wolf <kwolf@redhat.com>\n> ---\n>  include/block/block.h |  1 +\n>  block.c               | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 65 insertions(+)\n> \n> diff --git a/include/block/block.h b/include/block/block.h\n> index 082eb2cd9c..3c3af462e4 100644\n> --- a/include/block/block.h\n> +++ b/include/block/block.h\n> @@ -166,6 +166,7 @@ typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue;\n>  typedef struct BDRVReopenState {\n>      BlockDriverState *bs;\n>      int flags;\n> +    uint64_t perm, shared_perm;\n>      QDict *options;\n>      QDict *explicit_options;\n>      void *opaque;\n> diff --git a/block.c b/block.c\n> index 204cbb46c7..5c65fac672 100644\n> --- a/block.c\n> +++ b/block.c\n> @@ -2781,6 +2781,10 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,\n>      bs_entry->state.explicit_options = explicit_options;\n>      bs_entry->state.flags = flags;\n>  \n> +    /* This needs to be overwritten in bdrv_reopen_prepare() */\n> +    bs_entry->state.perm = UINT64_MAX;\n\nProbably doesn't matter because as the comment says it will be overwritten soon,\nbut is BLK_PERM_ALL more appropriate?\n\n> +    bs_entry->state.shared_perm = 0;\n> +\n>      QLIST_FOREACH(child, &bs->children, next) {\n>          QDict *new_child_options;\n>          char *child_key_dot;\n> @@ -2887,6 +2891,52 @@ int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp)\n>      return ret;\n>  }\n>  \n> +static BlockReopenQueueEntry *find_parent_in_reopen_queue(BlockReopenQueue *q,\n> +                                                          BdrvChild *c)\n> +{\n> +    BlockReopenQueueEntry *entry;\n> +\n> +    QSIMPLEQ_FOREACH(entry, q, entry) {\n> +        BlockDriverState *bs = entry->state.bs;\n> +        BdrvChild *child;\n> +\n> +        QLIST_FOREACH(child, &bs->children, next) {\n> +            if (child == c) {\n> +                return entry;\n> +            }\n> +        }\n> +    }\n> +\n> +    return NULL;\n> +}\n> +\n> +static void bdrv_reopen_perm(BlockReopenQueue *q, BlockDriverState *bs,\n> +                             uint64_t *perm, uint64_t *shared)\n> +{\n> +    BdrvChild *c;\n> +    BlockReopenQueueEntry *parent;\n> +    uint64_t cumulative_perms = 0;\n> +    uint64_t cumulative_shared_perms = BLK_PERM_ALL;\n> +\n> +    QLIST_FOREACH(c, &bs->parents, next_parent) {\n> +        parent = find_parent_in_reopen_queue(q, c);\n> +        if (!parent) {\n> +            cumulative_perms |= c->perm;\n> +            cumulative_shared_perms &= c->shared_perm;\n> +        } else {\n> +            uint64_t nperm, nshared;\n> +\n> +            bdrv_child_perm(parent->state.bs, bs, c, c->role, q,\n> +                            parent->state.perm, parent->state.shared_perm,\n> +                            &nperm, &nshared);\n> +\n> +            cumulative_perms |= nperm;\n> +            cumulative_shared_perms &= nshared;\n> +        }\n> +    }\n> +    *perm = cumulative_perms;\n> +    *shared = cumulative_shared_perms;\n> +}\n>  \n>  /*\n>   * Prepares a BlockDriverState for reopen. All changes are staged in the\n> @@ -2952,6 +3002,9 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,\n>          goto error;\n>      }\n>  \n> +    /* Calculate required permissions after reopening */\n> +    bdrv_reopen_perm(queue, reopen_state->bs,\n> +                     &reopen_state->perm, &reopen_state->shared_perm);\n>  \n>      ret = bdrv_flush(reopen_state->bs);\n>      if (ret) {\n> @@ -3007,6 +3060,12 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,\n>          } while ((entry = qdict_next(reopen_state->options, entry)));\n>      }\n>  \n> +    ret = bdrv_check_perm(reopen_state->bs, queue, reopen_state->perm,\n> +                          reopen_state->shared_perm, NULL, errp);\n> +    if (ret < 0) {\n> +        goto error;\n> +    }\n> +\n>      ret = 0;\n>  \n>  error:\n> @@ -3047,6 +3106,9 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)\n>  \n>      bdrv_refresh_limits(bs, NULL);\n>  \n> +    bdrv_set_perm(reopen_state->bs, reopen_state->perm,\n> +                  reopen_state->shared_perm);\n> +\n>      new_can_write =\n>          !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE);\n>      if (!old_can_write && new_can_write && drv->bdrv_reopen_bitmaps_rw) {\n> @@ -3080,6 +3142,8 @@ void bdrv_reopen_abort(BDRVReopenState *reopen_state)\n>      }\n>  \n>      QDECREF(reopen_state->explicit_options);\n> +\n> +    bdrv_abort_perm_update(reopen_state->bs);\n>  }\n>  \n>  \n> -- \n> 2.13.5\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=famz@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwdCl5z69z9ryQ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 17:38:27 +1000 (AEST)","from localhost ([::1]:35062 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dtqdN-0006Fe-Vs\n\tfor incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 03:38:26 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56685)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <famz@redhat.com>) id 1dtqct-0006DW-CG\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 03:37:58 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <famz@redhat.com>) id 1dtqcn-0006dM-BB\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 03:37:55 -0400","from mx1.redhat.com ([209.132.183.28]:52196)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <famz@redhat.com>)\n\tid 1dtqci-0006aN-DS; Mon, 18 Sep 2017 03:37:44 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 2CD7B4E049;\n\tMon, 18 Sep 2017 07:37:43 +0000 (UTC)","from localhost (ovpn-12-141.pek2.redhat.com [10.72.12.141])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 838165C541;\n\tMon, 18 Sep 2017 07:37:42 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 2CD7B4E049","Date":"Mon, 18 Sep 2017 15:37:41 +0800","From":"Fam Zheng <famz@redhat.com>","To":"Kevin Wolf <kwolf@redhat.com>","Message-ID":"<20170918073741.GJ15551@lemon.lan>","References":"<20170915101008.16646-1-kwolf@redhat.com>\n\t<20170915101008.16646-7-kwolf@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170915101008.16646-7-kwolf@redhat.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tMon, 18 Sep 2017 07:37:43 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after\n\tbdrv_reopen()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"qemu-devel@nongnu.org, qemu-block@nongnu.org, mreitz@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1769923,"web_url":"http://patchwork.ozlabs.org/comment/1769923/","msgid":"<20170918074344.GC31915@localhost.localdomain>","list_archive_url":null,"date":"2017-09-18T07:43:44","subject":"Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after\n\tbdrv_reopen()","submitter":{"id":2714,"url":"http://patchwork.ozlabs.org/api/people/2714/","name":"Kevin Wolf","email":"kwolf@redhat.com"},"content":"Am 18.09.2017 um 09:37 hat Fam Zheng geschrieben:\n> On Fri, 09/15 12:10, Kevin Wolf wrote:\n> > If we switch between read-only and read-write, the permissions that\n> > image format drivers need on bs->file change, too. Make sure to update\n> > the permissions during bdrv_reopen().\n> > \n> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>\n> > ---\n> >  include/block/block.h |  1 +\n> >  block.c               | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++\n> >  2 files changed, 65 insertions(+)\n> > \n> > diff --git a/include/block/block.h b/include/block/block.h\n> > index 082eb2cd9c..3c3af462e4 100644\n> > --- a/include/block/block.h\n> > +++ b/include/block/block.h\n> > @@ -166,6 +166,7 @@ typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue;\n> >  typedef struct BDRVReopenState {\n> >      BlockDriverState *bs;\n> >      int flags;\n> > +    uint64_t perm, shared_perm;\n> >      QDict *options;\n> >      QDict *explicit_options;\n> >      void *opaque;\n> > diff --git a/block.c b/block.c\n> > index 204cbb46c7..5c65fac672 100644\n> > --- a/block.c\n> > +++ b/block.c\n> > @@ -2781,6 +2781,10 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,\n> >      bs_entry->state.explicit_options = explicit_options;\n> >      bs_entry->state.flags = flags;\n> >  \n> > +    /* This needs to be overwritten in bdrv_reopen_prepare() */\n> > +    bs_entry->state.perm = UINT64_MAX;\n> \n> Probably doesn't matter because as the comment says it will be overwritten soon,\n> but is BLK_PERM_ALL more appropriate?\n\nI had BLK_PERM_ALL at first, but after debugging some assertion failures\nin gdb, I came to the conclusion that UINT64_MAX is easier to identify as\nuninitialised than BLK_PERM_ALL, which could be a valid result of the\npermission calculation.\n\nKevin","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=kwolf@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwdLX6R8mz9s3w\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 17:44:19 +1000 (AEST)","from localhost ([::1]:35085 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dtqj3-0008Qh-MP\n\tfor incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 03:44:17 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:58298)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dtqig-0008O1-Uc\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 03:43:55 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dtqif-0000Cg-Rh\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 03:43:55 -0400","from mx1.redhat.com ([209.132.183.28]:60106)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <kwolf@redhat.com>)\n\tid 1dtqib-0000BY-F3; Mon, 18 Sep 2017 03:43:49 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 7AD744DD7C;\n\tMon, 18 Sep 2017 07:43:48 +0000 (UTC)","from localhost.localdomain (ovpn-116-105.ams2.redhat.com\n\t[10.36.116.105])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 6F20960468;\n\tMon, 18 Sep 2017 07:43:45 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 7AD744DD7C","Date":"Mon, 18 Sep 2017 09:43:44 +0200","From":"Kevin Wolf <kwolf@redhat.com>","To":"Fam Zheng <famz@redhat.com>","Message-ID":"<20170918074344.GC31915@localhost.localdomain>","References":"<20170915101008.16646-1-kwolf@redhat.com>\n\t<20170915101008.16646-7-kwolf@redhat.com>\n\t<20170918073741.GJ15551@lemon.lan>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170918073741.GJ15551@lemon.lan>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tMon, 18 Sep 2017 07:43:48 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after\n\tbdrv_reopen()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"qemu-devel@nongnu.org, qemu-block@nongnu.org, mreitz@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1770017,"web_url":"http://patchwork.ozlabs.org/comment/1770017/","msgid":"<20170918093557.GE31915@localhost.localdomain>","list_archive_url":null,"date":"2017-09-18T09:35:57","subject":"Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after\n\tbdrv_reopen()","submitter":{"id":2714,"url":"http://patchwork.ozlabs.org/api/people/2714/","name":"Kevin Wolf","email":"kwolf@redhat.com"},"content":"Am 15.09.2017 um 21:06 hat Eric Blake geschrieben:\n> On 09/15/2017 05:10 AM, Kevin Wolf wrote:\n> > If we switch between read-only and read-write, the permissions that\n> > image format drivers need on bs->file change, too. Make sure to update\n> > the permissions during bdrv_reopen().\n> > \n> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>\n> > ---\n> >  include/block/block.h |  1 +\n> >  block.c               | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++\n> >  2 files changed, 65 insertions(+)\n> > \n> \n> > +static BlockReopenQueueEntry *find_parent_in_reopen_queue(BlockReopenQueue *q,\n> > +                                                          BdrvChild *c)\n> > +{\n> > +    BlockReopenQueueEntry *entry;\n> > +\n> > +    QSIMPLEQ_FOREACH(entry, q, entry) {\n> > +        BlockDriverState *bs = entry->state.bs;\n> > +        BdrvChild *child;\n> > +\n> > +        QLIST_FOREACH(child, &bs->children, next) {\n> > +            if (child == c) {\n> > +                return entry;\n> \n> An O(n^2) loop. Is it going to bite us at any point in the future, or\n> are we generally dealing with a small enough queue size and BDS graph to\n> not worry about it?\n\nThe loops you're quoting aren't O(n^2), they don't loop over the same\nthing. This part is O(n) in terms of BdrvChild elements looked at.\n\nThe thing that worried me a bit more is the caller:\n\n+    QLIST_FOREACH(c, &bs->parents, next_parent) {\n+        parent = find_parent_in_reopen_queue(q, c);\n\nThis is indeed O(n^2) (again with n = number of BdrvChild elements) in\nthe pathological worst case of a quorum node where all children point to\nthe same node.\n\nAs soon as all parents of the node are distinct - and I don't see any\nreason why they wouldn't in practice - we're back to O(n) because each\nBdrvChild belongs to only one parent. Even if we ever introduce a driver\nwhere having the same node as a child in a constant number of different\nroles makes sense for a parent (i.e. anything that doesn't involve an\n(unbounded) array of children), we would still be O(n) with an additional\nsmall constant factor.\n\nSo I think in practice we should be okay.\n\nKevin","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=kwolf@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwgr55w9fz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 19:36:35 +1000 (AEST)","from localhost ([::1]:35431 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dtsTg-0002ge-PQ\n\tfor incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 05:36:32 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:57316)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dtsTL-0002gU-PC\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 05:36:12 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <kwolf@redhat.com>) id 1dtsTH-00024N-R8\n\tfor qemu-devel@nongnu.org; Mon, 18 Sep 2017 05:36:11 -0400","from mx1.redhat.com ([209.132.183.28]:56112)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <kwolf@redhat.com>)\n\tid 1dtsTD-00023N-Bx; Mon, 18 Sep 2017 05:36:03 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 6DC9413A9D;\n\tMon, 18 Sep 2017 09:36:02 +0000 (UTC)","from localhost.localdomain (ovpn-116-105.ams2.redhat.com\n\t[10.36.116.105])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 262BF18A53;\n\tMon, 18 Sep 2017 09:35:58 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 6DC9413A9D","Date":"Mon, 18 Sep 2017 11:35:57 +0200","From":"Kevin Wolf <kwolf@redhat.com>","To":"Eric Blake <eblake@redhat.com>","Message-ID":"<20170918093557.GE31915@localhost.localdomain>","References":"<20170915101008.16646-1-kwolf@redhat.com>\n\t<20170915101008.16646-7-kwolf@redhat.com>\n\t<726a7ef6-820b-2695-4ce5-ffa06da078d1@redhat.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha1;\n\tprotocol=\"application/pgp-signature\"; boundary=\"VbJkn9YxBvnuCH5J\"","Content-Disposition":"inline","In-Reply-To":"<726a7ef6-820b-2695-4ce5-ffa06da078d1@redhat.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.29]);\n\tMon, 18 Sep 2017 09:36:02 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH 6/6] block: Fix permissions after\n\tbdrv_reopen()","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"famz@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org,\n\tmreitz@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]