Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4210166ybz; Tue, 28 Apr 2020 07:32:45 -0700 (PDT) X-Google-Smtp-Source: APiQypK92jH4dsvR1vJiiFZz35+Ls8ZNRx2fygDqqWVdQseR8onkJ7gCY3DxJ5qxjedl6Cbw1Eoz X-Received: by 2002:a17:906:1199:: with SMTP id n25mr25957169eja.30.1588084365030; Tue, 28 Apr 2020 07:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588084365; cv=none; d=google.com; s=arc-20160816; b=qXgMWHLcsuKWpFXikI+4J3EPn7OGnN9F0xrWNrnG6ref5YjTWg7cprzF1bjUCTe9zB yVQ+y12c8+ATILq5IGusswLAOY0rPz3qrj7jEhrm3sZwFzHYxeb5MAtOQshew0ccOw+f 7y2qxiZK4f7UApYZ9lkqMQDjYbMaoWndgJ9gBM/ileTrCXhK3ogm8mqKjEi881Hp9W4S 9fJshsECtEb1BN6iEIRteU5DKS62xwwyo+gtXb1a6+FYclLeOwM50+dIi0CVf1B4p1qw kkkS7OioAl9wsRMqhDFbeiQbAa/xC/OHfaaQSAb2aGDH+qBy1Z8+096MWRwIt8m2/7BB eIKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LJYJOxQhIE1fE/bXXB2iJgsNhh+MEvSLEyy2mGQqHm4=; b=b7wK3+aK3EowBlg1pkbi4hSEmYx0PIfoQ/AjQy8i+PwqY64rdlBV2JboQQWK3VWnAE 13AdW40XgpKkY2+mEAGt1qxusNxTBeq5vt8sM2CHDNjTqN60wr/fYDmyU6IpCa4O15ju OmDVmmCSneMm+pOnlcLlA9I4lc0fIj05VLG2ZzxrqxVaGSDVWt27+IQGLSlWA/Ccm8Ii ghn4jr36W5nZARBotF8k6DP+VWEF3ItGAn01kMoLkuSSPbrQ5OecDTWb0lBiu5ghshuE ymQVGnGPdaqdIpk/Z5j2Uv/2ZWuBXkmslFndpfVBy77c+3oirlKAePTyelohnnqQXdes mWZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IYzh5KIY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p13si2054143ejo.283.2020.04.28.07.32.13; Tue, 28 Apr 2020 07:32:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IYzh5KIY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728024AbgD1OaX (ORCPT + 99 others); Tue, 28 Apr 2020 10:30:23 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44791 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727108AbgD1OaW (ORCPT ); Tue, 28 Apr 2020 10:30:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588084220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=LJYJOxQhIE1fE/bXXB2iJgsNhh+MEvSLEyy2mGQqHm4=; b=IYzh5KIYzjqKcO90s0hJ3ODb8ylnzYGiop+X6MqmuagioX/HB5myXRWMm4HgcG5G4dfEq+ 74qexznDIZZCRLd8x3ABZp4FDy6+1ifAGO+PfwYWZDipiUJG/Nyyg7qfaRsPH9jNi9MGig TzcKfdCmRk/Zw0rZYphUr3hyoW5chhA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-YWug8AwhN2qI8cWogNqfqg-1; Tue, 28 Apr 2020 10:30:17 -0400 X-MC-Unique: YWug8AwhN2qI8cWogNqfqg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 277D81005510; Tue, 28 Apr 2020 14:30:16 +0000 (UTC) Received: from localhost (ovpn-115-22.ams2.redhat.com [10.36.115.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 319AB60CD3; Tue, 28 Apr 2020 14:30:09 +0000 (UTC) From: Stefan Hajnoczi To: virtualization@lists.linux-foundation.org Cc: Paolo Bonzini , Jason Wang , linux-block@vger.kernel.org, Christoph Hellwig , "Michael S. Tsirkin" , Jens Axboe , linux-kernel@vger.kernel.org, cohuck@redhat.com, Stefano Garzarella , Stefan Hajnoczi , Lance Digby Subject: [PATCH v2] virtio-blk: handle block_device_operations callbacks after hot unplug Date: Tue, 28 Apr 2020 15:30:09 +0100 Message-Id: <20200428143009.107645-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: base64 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org QSB1c2Vyc3BhY2UgcHJvY2VzcyBob2xkaW5nIGEgZmlsZSBkZXNjcmlwdG9yIHRvIGEgdmlydGlv X2JsayBkZXZpY2UgY2FuCnN0aWxsIGludm9rZSBibG9ja19kZXZpY2Vfb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