Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 755B3C433E6 for ; Mon, 8 Mar 2021 17:30:12 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 355DF6523B for ; Mon, 8 Mar 2021 17:30:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 355DF6523B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.95039.179250 (Exim 4.92) (envelope-from ) id 1lJJhX-000349-3u; Mon, 08 Mar 2021 17:29:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 95039.179250; Mon, 08 Mar 2021 17:29:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJJhX-000342-0N; Mon, 08 Mar 2021 17:29:51 +0000 Received: by outflank-mailman (input) for mailman id 95039; Mon, 08 Mar 2021 17:29:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lJJhW-00033w-8x for xen-devel@lists.xenproject.org; Mon, 08 Mar 2021 17:29:50 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 63bd0c7d-db59-4ed4-885b-2095bf1a5a0b; Mon, 08 Mar 2021 17:29:48 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 63bd0c7d-db59-4ed4-885b-2095bf1a5a0b DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1615224588; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Qx692fbHiRL4L6T+MZfu9C8g3d1iJXU8ETMMmyC4JAk=; b=Y9h7/qd+AvVqFdw0VoO9yzYdgz88qVe7wICX8Z1nPNFv86/OItWH8td3 tBWdTqUxxEk1k9thX1TP0XtVUGxyoixv+ZvR4MUK/3374+q3QfImfUPNd cs/1xRkiVWyHyQaHAtjOtm3G1sw9Zzg9HROPEI2SqUNzyEc4ndJgdVFBx 4=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: j20KibSo3L8aG0dbglfkza8MpIL91Sk0L4AOpy/JSV8rb0P6eO/qFqdpeft2WyX7Gm8rqtfH0w +E16GcrD3X9FLrloQJJvApoXQXmmSvVZvW6uHtVTHlYFX0SiICk/06GkLDyR1hJQRRUYppN+zw WE3dm19Wv6Q4dOtqQ/gIdOp/rhZbPb49nJNTtKKeKSBkf/ur68+YrBTDr+T2eY4f3OcXKBAlbN XUjo5LlEcTmDelLt1tIYGcyxGSt7m4CyWjcnINYLXBlAkcXVGPD+o0zFYesd3WFAsSu3Z9U3jA 5Uo= X-SBRS: 4.0 X-MesageID: 38785020 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.81,232,1610427600"; d="scan'208";a="38785020" Date: Mon, 8 Mar 2021 17:29:40 +0000 From: Anthony PERARD To: Paolo Bonzini CC: , Stefan Hajnoczi , Maxim Levitsky , Stefano Stabellini , Paul Durrant , Kevin Wolf , Max Reitz , , Subject: Re: [PATCH] xen-block: Fix removal of backend instance via xenstore Message-ID: References: <20210308143232.83388-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: On Mon, Mar 08, 2021 at 03:38:49PM +0100, Paolo Bonzini wrote: > On 08/03/21 15:32, Anthony PERARD wrote: > > From: Anthony PERARD > > > > Whenever a Xen block device is detach via xenstore, the image > > associated with it remained open by the backend QEMU and an error is > > logged: > > qemu-system-i386: failed to destroy drive: Node xvdz-qcow2 is in use > > > > This happened since object_unparent() doesn't immediately frees the > > object and thus keep a reference to the node we are trying to free. > > The reference is hold by the "drive" property and the call > > xen_block_drive_destroy() fails. > > > > In order to fix that, we call drain_call_rcu() to run the callback > > setup by bus_remove_child() via object_unparent(). > > > > Fixes: 2d24a6466154 ("device-core: use RCU for list of children of a bus") > > > > Signed-off-by: Anthony PERARD > > --- > > CCing people whom introduced/reviewed the change to use RCU to give > > them a chance to say if the change is fine. > > If nothing else works then I guess it's okay, but why can't you do the > xen_block_drive_destroy from e.g. an unrealize callback? I'm not sure if that's possible. xen_block_device_create/xen_block_device_destroy() is supposed to be equivalent to do those qmp commands: blockdev-add node-name=xvdz-qcow2 driver=qcow2 file={"driver":"file","filename":"disk.qcow2","locking":"off"} device_add id=xvdz driver=xen-disk vdev=xvdz drive=xvdz-qcow2 But I tried to add a call xen_block_drive_destroy from xen_block_unrealize, but that still is called too early, it's called before object_property_del_all() which would delete "drive" and call release_drive() which would free the node. So, no, I don't think we can use an unrealized callback. I though of trying to delete the "drive" property ahead of calling object_unparent() but I didn't figure out how to do so and it's maybe not possible. So either drain_call_rcu or adding call_rcu(xen_block_drive_destroy) seems to be the way, but since xen_block_drive_destroy uses qmp_blockdev_del, it seems better to drain_call_rcu. Cheers, -- Anthony PERARD