{"id":813554,"url":"http://patchwork.ozlabs.org/api/patches/813554/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913181910.29688-2-mreitz@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170913181910.29688-2-mreitz@redhat.com>","list_archive_url":null,"date":"2017-09-13T18:18:53","name":"[01/18] block: Add BdrvDeletedStatus","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"4223563c1bf35e4bccbe73424823b8097cc51aa9","submitter":{"id":36836,"url":"http://patchwork.ozlabs.org/api/people/36836/?format=json","name":"Max Reitz","email":"mreitz@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170913181910.29688-2-mreitz@redhat.com/mbox/","series":[{"id":2960,"url":"http://patchwork.ozlabs.org/api/series/2960/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2960","date":"2017-09-13T18:18:52","name":"block/mirror: Add active-sync mirroring","version":1,"mbox":"http://patchwork.ozlabs.org/series/2960/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/813554/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/813554/checks/","tags":{},"related":[],"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-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=mreitz@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 3xsqhp0H0rz9sNV\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 04:20:25 +1000 (AEST)","from localhost ([::1]:43982 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 1dsCGt-0007eH-B8\n\tfor incoming@patchwork.ozlabs.org; Wed, 13 Sep 2017 14:20:23 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:36390)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1dsCG3-0007ah-P7\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 14:19:36 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mreitz@redhat.com>) id 1dsCG2-0004bc-Ky\n\tfor qemu-devel@nongnu.org; Wed, 13 Sep 2017 14:19:31 -0400","from mx1.redhat.com ([209.132.183.28]:50038)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mreitz@redhat.com>)\n\tid 1dsCG0-0004a2-BN; Wed, 13 Sep 2017 14:19:28 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\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 78A5E81DE4;\n\tWed, 13 Sep 2017 18:19:27 +0000 (UTC)","from localhost (ovpn-204-23.brq.redhat.com [10.40.204.23])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 5FD0C5D724;\n\tWed, 13 Sep 2017 18:19:21 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 78A5E81DE4","From":"Max Reitz <mreitz@redhat.com>","To":"qemu-block@nongnu.org","Date":"Wed, 13 Sep 2017 20:18:53 +0200","Message-Id":"<20170913181910.29688-2-mreitz@redhat.com>","In-Reply-To":"<20170913181910.29688-1-mreitz@redhat.com>","References":"<20170913181910.29688-1-mreitz@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tWed, 13 Sep 2017 18:19:27 +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":"[Qemu-devel] [PATCH 01/18] block: Add BdrvDeletedStatus","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":"Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,\n\tqemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,\n\tStefan Hajnoczi <stefanha@redhat.com>, John Snow <jsnow@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>"},"content":"Sometimes an operation may delete a BDS.  It may then not be trivial to\ndetermine this because the BDS object itself cannot be accessed\nafterwards.  With this patch, one can attach a BdrvDeletedStatus object\nto a BDS which can be used to safely query whether the BDS still exists\neven after it has been deleted.\n\nSigned-off-by: Max Reitz <mreitz@redhat.com>\n---\n include/block/block_int.h | 12 ++++++++++++\n block.c                   |  6 ++++++\n 2 files changed, 18 insertions(+)","diff":"diff --git a/include/block/block_int.h b/include/block/block_int.h\nindex ba4c383393..eaeaad9428 100644\n--- a/include/block/block_int.h\n+++ b/include/block/block_int.h\n@@ -498,6 +498,13 @@ typedef struct BdrvAioNotifier {\n     QLIST_ENTRY(BdrvAioNotifier) list;\n } BdrvAioNotifier;\n \n+typedef struct BdrvDeletedStatus {\n+    /* Set to true by bdrv_delete() */\n+    bool deleted;\n+\n+    QLIST_ENTRY(BdrvDeletedStatus) next;\n+} BdrvDeletedStatus;\n+\n struct BdrvChildRole {\n     /* If true, bdrv_replace_node() doesn't change the node this BdrvChild\n      * points to. */\n@@ -706,6 +713,11 @@ struct BlockDriverState {\n \n     /* Only read/written by whoever has set active_flush_req to true.  */\n     unsigned int flushed_gen;             /* Flushed write generation */\n+\n+    /* When bdrv_delete() is invoked, it will walk through this list\n+     * and set every entry's @deleted field to true.  The entries will\n+     * not be freed automatically. */\n+    QLIST_HEAD(, BdrvDeletedStatus) deleted_status;\n };\n \n struct BlockBackendRootState {\ndiff --git a/block.c b/block.c\nindex 6dd47e414e..0b55c5a41c 100644\n--- a/block.c\n+++ b/block.c\n@@ -3246,10 +3246,16 @@ out:\n \n static void bdrv_delete(BlockDriverState *bs)\n {\n+    BdrvDeletedStatus *del_stat;\n+\n     assert(!bs->job);\n     assert(bdrv_op_blocker_is_empty(bs));\n     assert(!bs->refcnt);\n \n+    QLIST_FOREACH(del_stat, &bs->deleted_status, next) {\n+        del_stat->deleted = true;\n+    }\n+\n     bdrv_close(bs);\n \n     /* remove from list, if necessary */\n","prefixes":["01/18"]}