From patchwork Thu Aug 20 16:58:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 275988 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 799B4C433DF for ; Thu, 20 Aug 2020 17:00:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 41C9A2072D for ; Thu, 20 Aug 2020 17:00:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gICMijik" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41C9A2072D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nvE-0004a0-E4 for qemu-devel@archiver.kernel.org; Thu, 20 Aug 2020 13:00:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuL-0002rj-9Q for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:21 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:45968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nuI-0006Bk-CW for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=969biaX/G7f1D/6G5QoxlHmmKW8KQsbMUTT5iH7LPeo=; b=gICMijik9Gxjerw5fl0/huO5++3bfxnwVN+PjvZbJ+8dkEtNNXvs9F8dK9K2chYucZdOCr G53QPLm7UmQVVthRRLse+BQfbspeS5gP5lZ4E8kmQWg0IOab9LlBLVO1CJtqA94xBWZqM8 BZmey4zfjxu6zgPerLeRP668F57aIlY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-3-aFmcf4dPNzSxntWvncaNCw-1; Thu, 20 Aug 2020 12:59:16 -0400 X-MC-Unique: aFmcf4dPNzSxntWvncaNCw-1 Received: by mail-wr1-f70.google.com with SMTP id b13so858856wrq.19 for ; Thu, 20 Aug 2020 09:59:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=969biaX/G7f1D/6G5QoxlHmmKW8KQsbMUTT5iH7LPeo=; b=AqiLG3Hy12dJywZ//3v06umtJq+fW/VMvNTjzVssS3PrP5yss16PgNo3rknzSsR5hs H6NSY/Wu7VUADtSRXIHmJkEQKqdVf+JpZjrJWD6ieAzZ9gyiV3kU8D7UgoBbycs/0Gaj K3w81ZqgnJ164f+mwWQs+XgssZ9csPvHrHpSwc+EaSqsHcUg5rt8knIA0rOPuJR0Yfj7 +/zD3T7nuQnXZZvlXjYwTn0jjDffXg7DfM3O5CsYdHC9kHxRr2/dHHpVo2JmFsLEwpwd dvqBR62WlzkNXen5LvDqquhd/U0m7SCiF/1ndyicT1t8abMz1i/YNKx5HvCTnZe89jbb nu7w== X-Gm-Message-State: AOAM530yeMXEWpQrTQEPBwiDfYG0Q+G1itEO4HAkXonzWl9SkxUFw/RR zyFo/5yBSQTpEPgk75VJGtz9mOpY1HO2aVKwgEyTiVbf04Ypi2dPIvS2M8vIZvOwCJ7CvT6r4l7 ZC9gGU5DcAYyf+64= X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr4527093wmh.144.1597942754949; Thu, 20 Aug 2020 09:59:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpAZRQsucfAlWmgf3Z92nfj1GPVqihI5RimRNPIm7nB2a2UeIIZIehaKoQs0Jjx0Ang7SPdw== X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr4527082wmh.144.1597942754736; Thu, 20 Aug 2020 09:59:14 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id g70sm5873153wmg.24.2020.08.20.09.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 02/15] block/nvme: Avoid further processing if trace event not enabled Date: Thu, 20 Aug 2020 18:58:48 +0200 Message-Id: <20200820165901.1139109-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is not enabled. This is an untested intend of performance optimization. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index 2f5e3c2adfa..8c30a5fee28 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -441,6 +441,9 @@ static void nvme_trace_command(const NvmeCmd *cmd) { int i; + if (!trace_event_get_state_backends(TRACE_NVME_SUBMIT_COMMAND_RAW)) { + return; + } for (i = 0; i < 8; ++i) { uint8_t *cmdp = (uint8_t *)cmd + i * 8; trace_nvme_submit_command_raw(cmdp[0], cmdp[1], cmdp[2], cmdp[3], From patchwork Thu Aug 20 16:58:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 275987 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 C1714C433E1 for ; Thu, 20 Aug 2020 17:02:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 6B00D208A9 for ; Thu, 20 Aug 2020 17:02:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HRB/u5DD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B00D208A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nxN-0007kW-Cb for qemu-devel@archiver.kernel.org; Thu, 20 Aug 2020 13:02:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nua-0003VK-AG for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:36 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:21625 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nuX-0006DH-Np for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xMDzywp//OugMrKjSizTC3WTyFIJ7uQWbux4Y7eWkQY=; b=HRB/u5DDJLJNVgnnSJRdSYTdJMXUWgSJNBUrzQTW6fEs0u1KMWTnXUX9QkVknACe2+VXHT mw2OeyXQ644cy3zdPfTJxKCvDoWpkCTHfistWBKgCN+YuAXbxUM3Eo0Ha/guV8X8MM6RE1 7Am6TWU0f6QmV42M50cR85+4VUqfpBw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-dY8FWrNnN9eTG7CwsF4nOA-1; Thu, 20 Aug 2020 12:59:31 -0400 X-MC-Unique: dY8FWrNnN9eTG7CwsF4nOA-1 Received: by mail-wm1-f70.google.com with SMTP id u14so1941791wml.0 for ; Thu, 20 Aug 2020 09:59:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xMDzywp//OugMrKjSizTC3WTyFIJ7uQWbux4Y7eWkQY=; b=rumhFKVe1rqq7nx50A4Pox7PV/wGtUhs71KSxTTnsdMu2+RQrsicjA7FpfdFmd/Gyj mAT+u2v4cduqrdFJJa48DCX+xf4BKZlt/hL4TdcqK/aCtMfKyx7u8+8/37kOnQWWDxea rkCXIp+tvS+2lCHbu5hMNyzM95JeuXspIpUoWClhJr7SxBne4t4jQ8m3KJwCcgUgKmXU 0X2lXMFvBeOOYygj62cAnyjrEHhyS4/KKaC73GWbveqLXODhlAz+DL+jviSB8jl3qN21 /EBhzLlONGL7gTm5sWYD2PK+hvtvEjPK0eLhrx/SbYoTXPCFYrzhH0SaXfhSxgomuvpC pLyA== X-Gm-Message-State: AOAM531fuqhyZXSOanfbGeHRYPsR8q801Oz0D73JbpKMZ4PcgCMBOUlg maLM9GnreTbl0s3S/7rliIqEFvLn1wTDqG+uJ7rTPy4XwPgkPg5EvdtIg5NWRNV8Y/otXWCvEzV QMSXae69MagjsV+s= X-Received: by 2002:a7b:c401:: with SMTP id k1mr4259211wmi.18.1597942770038; Thu, 20 Aug 2020 09:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIlDAdqewr7poOXewRpVpML2nR7umyFdrOqfMoM0E+zIsKaFM90r1HpKBZxKX7NTWwSS9XKA== X-Received: by 2002:a7b:c401:: with SMTP id k1mr4259203wmi.18.1597942769906; Thu, 20 Aug 2020 09:59:29 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id j4sm5136932wmi.48.2020.08.20.09.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 05/15] block/nvme: Improve error message when IO queue creation failed Date: Thu, 20 Aug 2020 18:58:51 +0200 Message-Id: <20200820165901.1139109-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/20 03:03:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Do not use the same error message for different failures. Display a different error whether it is the CQ or the SQ. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 003809fbd83..53448b7d230 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -648,7 +648,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw11 = cpu_to_le32(0x3), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { - error_setg(errp, "Failed to create io queue [%d]", n); + error_setg(errp, "Failed to create CQ io queue [%d]", n); nvme_free_queue_pair(q); return false; } @@ -659,7 +659,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw11 = cpu_to_le32(0x1 | (n << 16)), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { - error_setg(errp, "Failed to create io queue [%d]", n); + error_setg(errp, "Failed to create SQ io queue [%d]", n); nvme_free_queue_pair(q); return false; } From patchwork Thu Aug 20 16:58:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 275985 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 84EE3C433E1 for ; Thu, 20 Aug 2020 17:04:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 4F3AA208A9 for ; Thu, 20 Aug 2020 17:04:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Il/zBo9Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F3AA208A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nzQ-00031F-MO for qemu-devel@archiver.kernel.org; Thu, 20 Aug 2020 13:04:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nug-0003js-2G for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nud-0006Dc-88 for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QyQg0f8W8M9I/uKJA3ih2AcbkHq7TajNoPXSDgqGq4I=; b=Il/zBo9ZrqRuyvdXYWFkYvSxrh18wI4SyXttKzt6AIUNGc2P/+qCjorU1A4i6qMX3NuetZ joUntxHIPK2HWNopPqyT7xGpl3znsx1Y4DDPS4Tm7DEl2S+nh64CXBqpR2Kbr9i+iTs2dZ tZD5M6CGeQikYaOBpZ67i4zBpN+ejQw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-vha2TIT5P8eEXpSbskUbqw-1; Thu, 20 Aug 2020 12:59:36 -0400 X-MC-Unique: vha2TIT5P8eEXpSbskUbqw-1 Received: by mail-wm1-f70.google.com with SMTP id d22so1006094wmd.2 for ; Thu, 20 Aug 2020 09:59:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QyQg0f8W8M9I/uKJA3ih2AcbkHq7TajNoPXSDgqGq4I=; b=aPbfLyTNge1E8qJ7x0Gj6F2QUWEV6SXGoV7C/0kh7QaU2o0VLIUO+0uuIu1xIECmPH Wxb2NGyifxpRvzwnJQBvnIEknn/bhFK9dLIRBvIpSeMrbxkqm8TUeBn2gxr0uPdbqlmi rNEow7Rsb91kMN2wDj1h15utTE91n386K02JKvadNM0Mfzxh7d1eq74Msvu8IjYoeSGo w6rZR2qbkRhL4XgZTHhZD/S1O4G1cFhP5OI3AizSpgmg77WINlYps8F9hj9KWvoiUcvZ vp/99MzgmtPyYf/iyMYxnRxkzFaeUB+FBy9rhXQITyAo2lhQFFVzx34k3Ktq/pBrqB3y 7Y/Q== X-Gm-Message-State: AOAM532EUlNBvi0YBwP+jyLUogTae5ZCv0jyl4fwN+n0jwWGwsGBjUdM vr2oaB7jcTet4NYzTHzJD2+Fq0h3QEGd6O4eU44lnYVgADI1evvkNBT4m7msBkHTTfYkIM7QLXm diM90lRinGVqDvaw= X-Received: by 2002:adf:fac8:: with SMTP id a8mr4111289wrs.368.1597942775259; Thu, 20 Aug 2020 09:59:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydMsAUhYQbfhGtVA5j/dvyfPGyX+ZXJ2dmEgjyQE5ING4JH30IKSDnuP94sT2fxWnFq3Ngdg== X-Received: by 2002:adf:fac8:: with SMTP id a8mr4111278wrs.368.1597942775110; Thu, 20 Aug 2020 09:59:35 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id o125sm5413165wma.27.2020.08.20.09.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 06/15] block/nvme: Use common error path in nvme_add_io_queue() Date: Thu, 20 Aug 2020 18:58:52 +0200 Message-Id: <20200820165901.1139109-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/20 06:28:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Rearrange nvme_add_io_queue() by using a common error path. This will be proven useful in few commits where we add IRQ notification to the IO queues. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 53448b7d230..3101f1ad55d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -649,8 +649,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create CQ io queue [%d]", n); - nvme_free_queue_pair(q); - return false; + goto out_error; } cmd = (NvmeCmd) { .opcode = NVME_ADM_CMD_CREATE_SQ, @@ -660,13 +659,15 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create SQ io queue [%d]", n); - nvme_free_queue_pair(q); - return false; + goto out_error; } s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1); s->queues[n] = q; s->nr_queues++; return true; +out_error: + nvme_free_queue_pair(q); + return false; } static bool nvme_poll_cb(void *opaque) From patchwork Thu Aug 20 16:58:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 275986 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 7892AC433E1 for ; Thu, 20 Aug 2020 17:03:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 41F8D208A9 for ; Thu, 20 Aug 2020 17:03:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bAK+y92y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41F8D208A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nyB-0000kp-GN for qemu-devel@archiver.kernel.org; Thu, 20 Aug 2020 13:03:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuq-0004CL-KQ for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:52 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:27208 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nuo-0006En-0X for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CGQmSUZkaMTSA5n136vQxwh8WIRKspK6NFocfmUCdbc=; b=bAK+y92yvy+BPZMes51JY1PManRDBCifPjnE7ytloo+qPH7WoLbVSKrlD4v2mOTkeFZLaQ wKvCUcK4n9dz97smn7OH4QF4bFTtbqfnm+VgvKylI8AUd5AAwL0/46fPD9upTIHwt1TfRQ zcZN0XUwXQxi64aLdd+cdIHl1ZyMils= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-224-fCZgmUW9PuGd6hvd1rXcNw-1; Thu, 20 Aug 2020 12:59:47 -0400 X-MC-Unique: fCZgmUW9PuGd6hvd1rXcNw-1 Received: by mail-wr1-f71.google.com with SMTP id s23so854923wrb.12 for ; Thu, 20 Aug 2020 09:59:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CGQmSUZkaMTSA5n136vQxwh8WIRKspK6NFocfmUCdbc=; b=MZ2t9LZPkAOrYFMo9pCOdZLj3XjW1vMyks7s2gva7yOzzs4HQz0mFAkQw0g8afz6Dk oY4Rn0DbLSmXaqyRKDIFaJ5Nf4M+qd5Vqb1eZE4I1w21EY8Fnk0kOOIWhHxfLA2JTns+ 4FdaDTd29C6VzrYsc5wPg1seEiNHdjMjYzF3cVN33VjemtQmixo0UkyHsk1QuIudcKJr +fOwrOoV5NyYCRwlVVMM7UvL/xP4uByf/ijxinAZPmEJBJ9ZtksGxfdSt50Pu8YCmtY5 KLh7PLcOzIf8AGwe3F/PlkLSGpPP8jGxBkGIO0a1cnT2IVItDDis6jQaS9/e1mfCeSRf 5MYQ== X-Gm-Message-State: AOAM5317DXFYNHbv+PvYNOFZKKK89xCVKMLQb+jW90RmJbT686QffsLJ yFgOZ1f20sOw+xwyl3i3XkVk5pclgFQ5gHLD5akahzE8hUiTKk2CiGgAVz0t+Am/SqxT13Pif3L 3Y1sAqnfxqHlg06c= X-Received: by 2002:a5d:544a:: with SMTP id w10mr4154965wrv.317.1597942786207; Thu, 20 Aug 2020 09:59:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhLAJ3NVuCtT/npjOh2UbgEKqPgWCz10FStUVVGH1i2UiOSfLdArNqk/xdVUchZMA+PpBJkw== X-Received: by 2002:a5d:544a:: with SMTP id w10mr4154947wrv.317.1597942785937; Thu, 20 Aug 2020 09:59:45 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id j5sm5539991wma.45.2020.08.20.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 08/15] block/nvme: Use union of NvmeIdCtrl / NvmeIdNs structures Date: Thu, 20 Aug 2020 18:58:54 +0200 Message-Id: <20200820165901.1139109-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/20 03:03:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We allocate an unique chunk of memory then use it for two different structures. By using an union, we make it clear the data is overlapping (and we can remove the casts). Suggested-by: Stefan Hajnoczi Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 99822d9fd36..2bd1935f951 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -508,9 +508,10 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; - NvmeIdCtrl *idctrl; - NvmeIdNs *idns; - uint8_t *id; + union { + NvmeIdCtrl ctrl; + NvmeIdNs ns; + } *id; NvmeLBAF *lbaf; uint16_t oncs; int r; @@ -520,14 +521,12 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) .cdw10 = cpu_to_le32(0x1), }; - id = qemu_try_blockalign0(bs, sizeof(NvmeIdCtrl)); + id = qemu_try_blockalign0(bs, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - idctrl = (NvmeIdCtrl *)id; - idns = (NvmeIdNs *)id; - r = qemu_vfio_dma_map(s->vfio, id, sizeof(NvmeIdCtrl), true, &iova); + r = qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova); if (r) { error_setg(errp, "Cannot map buffer for DMA"); goto out; @@ -539,22 +538,22 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) goto out; } - if (le32_to_cpu(idctrl->nn) < namespace) { + if (le32_to_cpu(id->ctrl.nn) < namespace) { error_setg(errp, "Invalid namespace"); goto out; } - s->write_cache_supported = le32_to_cpu(idctrl->vwc) & 0x1; - s->max_transfer = (idctrl->mdts ? 1 << idctrl->mdts : 0) * s->page_size; + s->write_cache_supported = le32_to_cpu(id->ctrl.vwc) & 0x1; + s->max_transfer = (id->ctrl.mdts ? 1 << id->ctrl.mdts : 0) * s->page_size; /* For now the page list buffer per command is one page, to hold at most * s->page_size / sizeof(uint64_t) entries. */ s->max_transfer = MIN_NON_ZERO(s->max_transfer, s->page_size / sizeof(uint64_t) * s->page_size); - oncs = le16_to_cpu(idctrl->oncs); + oncs = le16_to_cpu(id->ctrl.oncs); s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROS); s->supports_discard = !!(oncs & NVME_ONCS_DSM); - memset(id, 0, 4096); + memset(id, 0, sizeof(*id)); cmd.cdw10 = 0; cmd.nsid = cpu_to_le32(namespace); if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { @@ -562,11 +561,11 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) goto out; } - s->nsze = le64_to_cpu(idns->nsze); - lbaf = &idns->lbaf[NVME_ID_NS_FLBAS_INDEX(idns->flbas)]; + s->nsze = le64_to_cpu(id->ns.nsze); + lbaf = &id->ns.lbaf[NVME_ID_NS_FLBAS_INDEX(id->ns.flbas)]; - if (NVME_ID_NS_DLFEAT_WRITE_ZEROES(idns->dlfeat) && - NVME_ID_NS_DLFEAT_READ_BEHAVIOR(idns->dlfeat) == + if (NVME_ID_NS_DLFEAT_WRITE_ZEROES(id->ns.dlfeat) && + NVME_ID_NS_DLFEAT_READ_BEHAVIOR(id->ns.dlfeat) == NVME_ID_NS_DLFEAT_READ_BEHAVIOR_ZEROES) { bs->supported_write_flags |= BDRV_REQ_MAY_UNMAP; } From patchwork Thu Aug 20 16:58:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 275983 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 5D8ADC433E1 for ; Thu, 20 Aug 2020 17:06:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 2414A208A9 for ; Thu, 20 Aug 2020 17:06:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dFjVBwfd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2414A208A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o0w-0006HR-C3 for qemu-devel@archiver.kernel.org; Thu, 20 Aug 2020 13:06:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuw-0004U6-PN for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:58 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:32770 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nut-0006FB-FE for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z6BpEV2cAZCoO+2PvXqrFXBtVGoZXhqod7yrp9Ptrs4=; b=dFjVBwfdfgkWmMlYNI0hWOUeTaqfFu/4MniuX7XZLR9MiEklR3EWmQbkCYgVBsMogVuT2l 8O9ngZ3WA2ONsqlIDnO1QrLfsud6NACqSv92KE+jRv08cViLZ4qW6WzP2u5zcpEld5LEwA J4i3Tqw/I+r2keLKyi3VgI6LmxlkbMQ= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-240-xQVAlfBzNfWV7qaFy6veNw-1; Thu, 20 Aug 2020 12:59:53 -0400 X-MC-Unique: xQVAlfBzNfWV7qaFy6veNw-1 Received: by mail-wr1-f70.google.com with SMTP id k11so859197wrv.1 for ; Thu, 20 Aug 2020 09:59:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z6BpEV2cAZCoO+2PvXqrFXBtVGoZXhqod7yrp9Ptrs4=; b=dWoOJHSMYZcF8rYQvRIm9gD1oA33FFIC38QYbS462wlDj9t+X3FhrrsXg5VYN/V4fu +63fwCp5aDBiAreEkvQU3UOLsf9SX4iGU7MxtNT6xms3JvG1MgYjn47yybeNj1PpBPDA EDq/hGSstw/TqD1TD/Ke32tuP/l74bH6u3BprwG9myW7QqcRVD/G5zfQXl7fFH3+Kb// snd1h7vwnwcO/n2kSTUiUXlrnlxqDVfRWUDwOcOw+h2FERA9W0iinyD94/JvC9JBCos9 Q8GsEuvVSe+HWU16jGJ1DUG6E4Fi+7OUpLsJCIeAJ2iE5fhGLQID7E4+eJZIgRARsNjh ip9Q== X-Gm-Message-State: AOAM531IyN5L8FHTu9KFMw/3OxPMOCbfJywCYtw6WWRI/Gqv0sFThycI b41pYYXX3We5NqpMR3DvgSbeSZwpfbioTj8wsz8HOdUj90td/1fxxr4fvt2rv3x9KVhFK8+IVJi T6AbqUvOUePz02cM= X-Received: by 2002:adf:9487:: with SMTP id 7mr3916203wrr.133.1597942791779; Thu, 20 Aug 2020 09:59:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEpqkGZDH9TK1DCoOn36iPjQiqMxIzKxeeLBHvL1hZAk3Fq8CgkXF9pjKjyRd9q9WY/iUZfg== X-Received: by 2002:adf:9487:: with SMTP id 7mr3916185wrr.133.1597942791548; Thu, 20 Aug 2020 09:59:51 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id w64sm5977910wmb.26.2020.08.20.09.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 09/15] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset Date: Thu, 20 Aug 2020 18:58:55 +0200 Message-Id: <20200820165901.1139109-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/20 03:03:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In the next commit we'll get rid of qemu_try_blockalign(). To ease review, first replace qemu_try_blockalign0() by explicit calls to qemu_try_blockalign() and memset(). Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 2bd1935f951..ac6bb52043d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -174,12 +174,12 @@ static void nvme_init_queue(BlockDriverState *bs, NVMeQueue *q, bytes = ROUND_UP(nentries * entry_bytes, s->page_size); q->head = q->tail = 0; - q->queue = qemu_try_blockalign0(bs, bytes); - + q->queue = qemu_try_blockalign(bs, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); return; } + memset(q->queue, 0, bytes); r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); if (r) { error_setg(errp, "Cannot map queue"); @@ -223,11 +223,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, if (!q) { return NULL; } - q->prp_list_pages = qemu_try_blockalign0(bs, + q->prp_list_pages = qemu_try_blockalign(bs, s->page_size * NVME_QUEUE_SIZE); if (!q->prp_list_pages) { goto fail; } + memset(q->prp_list_pages, 0, s->page_size * NVME_QUEUE_SIZE); qemu_mutex_init(&q->lock); q->s = s; q->index = idx; @@ -521,7 +522,7 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) .cdw10 = cpu_to_le32(0x1), }; - id = qemu_try_blockalign0(bs, sizeof(*id)); + id = qemu_try_blockalign(bs, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; @@ -531,8 +532,9 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) error_setg(errp, "Cannot map buffer for DMA"); goto out; } - cmd.prp1 = cpu_to_le64(iova); + memset(id, 0, sizeof(*id)); + cmd.prp1 = cpu_to_le64(iova); if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify controller"); goto out; @@ -1283,11 +1285,11 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, assert(s->nr_queues > 1); - buf = qemu_try_blockalign0(bs, s->page_size); + buf = qemu_try_blockalign(bs, s->page_size); if (!buf) { return -ENOMEM; } - + memset(buf, 0, s->page_size); buf->nlb = cpu_to_le32(bytes >> s->blkshift); buf->slba = cpu_to_le64(offset >> s->blkshift); buf->cattr = 0; From patchwork Thu Aug 20 16:58:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 275984 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 57717C433DF for ; Thu, 20 Aug 2020 17:05:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 25E9A208A9 for ; Thu, 20 Aug 2020 17:05:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GH0dcBlF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25E9A208A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o0I-0004nX-Eg for qemu-devel@archiver.kernel.org; Thu, 20 Aug 2020 13:05:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nv7-0004sh-JE for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:09 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:36256 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nv4-0006Iq-5J for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=89Wjp5YSaeU8EmV0B/KKiK2s/vD3kpR2gM6yq2fyUAE=; b=GH0dcBlFVvTQnrHkvliw6VwvFwoC3c7MqaBFvEx6Hx+cXeDrpAzZUY1UzyKYN0+6QXBp+b ZaLcB7APcvbkM5omp4c2V9GhmIHhcbj8ndIGLpFLos3Vui/iMDyNLuxQipPlmUHuL85GUB IT3JwKqSTo3qYUO2KPIvoXIL4Ph4Z6I= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-5KdO5mE0MR6DKTnkYekTyg-1; Thu, 20 Aug 2020 13:00:03 -0400 X-MC-Unique: 5KdO5mE0MR6DKTnkYekTyg-1 Received: by mail-wr1-f71.google.com with SMTP id t12so863101wrp.0 for ; Thu, 20 Aug 2020 10:00:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=89Wjp5YSaeU8EmV0B/KKiK2s/vD3kpR2gM6yq2fyUAE=; b=ZTVRwQgWdXqAeQDBdmv95aCNZ52j02/sll3y5t7kLGwEsa0Lotg+7X5zn5Sl5+fnCh 6beN/vApGOj0dJIRmJRItpDV+5c9NDoNE2p/5j7k0iJfK9dsW+TyagimhCIEUpMcl+ne 3DibJIrRwZwhfmibV738K3jqBNftfYBSelq/e/sv1afciTQY31m6pY7LsDQap9Xb6LVP vt9UK51GeWO+rpcpYH03fpBu/fIpyMlj4LmNBMZE4Grlt8J0s9FeGtAXoYwXrbbCEcBU DAAISBrMs9Quju6osZGtLdSVkRlpiMVFNLPdkn8z4TNTyQeSp5kpHHqHTM5LtQpl/+nL lTew== X-Gm-Message-State: AOAM530iVdn63Qzygy66U3ehHPVeob/Jy1VhYutecLMt4exT/ldyC0Wo 9B+5Fdwo/yCkZ/uyIEWRvqU4BbNKlk9toAjP0mTCbZ3cUl93VVhQhpyHwG3STBAigNDswsgZMF7 RjBJQhPzBZCy7Bew= X-Received: by 2002:a1c:4e10:: with SMTP id g16mr4082112wmh.146.1597942802268; Thu, 20 Aug 2020 10:00:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+ZuOvD8GbaS8VltipExEIdiLWXcqS8uRCrSOJugg9wZ4Kxifn7KyGDPRqBu/5p5Ah7YHxzg== X-Received: by 2002:a1c:4e10:: with SMTP id g16mr4082097wmh.146.1597942802068; Thu, 20 Aug 2020 10:00:02 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id k4sm5776361wrd.72.2020.08.20.10.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 10:00:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 11/15] block/nvme: Simplify nvme_init_queue() arguments Date: Thu, 20 Aug 2020 18:58:57 +0200 Message-Id: <20200820165901.1139109-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_init_queue() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState to simplify. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index f180078e781..5b69fc75a60 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -165,10 +165,9 @@ static QemuOptsList runtime_opts = { }, }; -static void nvme_init_queue(BlockDriverState *bs, NVMeQueue *q, +static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, int nentries, int entry_bytes, Error **errp) { - BDRVNVMeState *s = bs->opaque; size_t bytes; int r; @@ -251,14 +250,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, req->prp_list_iova = prp_list_iova + i * s->page_size; } - nvme_init_queue(bs, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); + nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; } q->sq.doorbell = &s->regs->doorbells[idx * 2 * s->doorbell_scale]; - nvme_init_queue(bs, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); + nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; From patchwork Thu Aug 20 16:58:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 275982 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 A8133C433E1 for ; Thu, 20 Aug 2020 17:07:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 499C3208A9 for ; Thu, 20 Aug 2020 17:07:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bT9RmzTw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 499C3208A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o2I-0000EM-FE for qemu-devel@archiver.kernel.org; Thu, 20 Aug 2020 13:07:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nvB-00050o-Fw for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:13 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:27943 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nv9-0006Jv-1S for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942810; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HJf25gsH+6Qwxz9ynms3bXAs8zm6lq5Rrdtx+rf3EyY=; b=bT9RmzTwIUn8kNmKvbTEop1B+2sn0vAWQXoOBkgiReRqogJmXPO4wr/JcJysL+QOpKOxfp QEirCu7LNMTxitjjzpM8qBJWt5+nGmyOqTc0FjWoEUsfVX/6TtxVZwCoGvbq/+0zy2K8AF hNXnPgSKF5rrmWldBivRzuL6dmh8NKU= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-9RUehUs7OdCAlbXHudOKNQ-1; Thu, 20 Aug 2020 13:00:09 -0400 X-MC-Unique: 9RUehUs7OdCAlbXHudOKNQ-1 Received: by mail-wm1-f71.google.com with SMTP id h7so998961wmm.7 for ; Thu, 20 Aug 2020 10:00:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HJf25gsH+6Qwxz9ynms3bXAs8zm6lq5Rrdtx+rf3EyY=; b=Bufo5SSD8Lgthk8pNO8CLyEFR4QPNgLBdZEMlN4PUMegepyzAPDU5LmMgoJVBb2kNk 1zAfPJDL7xtjE1hNxIcCvqD2IQVhtcZUblh8Zp0dkOKIItKlws0ldrGbcFu9TYRKetlH LGRtfTCAtOvRNp5huMlJ2v1VTlrJnLPDVbZXC1nXssjIQkPtNN30BYHDTOAUi1gF2zGX Dejpz4HKIS4PVCbIx9bGMCTHv6hjboypblAm3yVbyDtkkjMAqEU/rcsYT/y6Jb2aP9FD ckxDuK774xpx9gn9Dzi6J5wKAtb0X49W+aXoy4srpMWfxc9Yq5Tmpk3vJcCGD2l0C039 KBxA== X-Gm-Message-State: AOAM530LKRurGKVe5MmuvZ9yRz31qC6MPK5LMbg66ONlSZxgnq1CR7I3 Q0AGaqSzOn8PKkj/HtQQXtKqLhAGimIJAOkYGGGrqxxya6S0ONCed/DCdcAFNsmh+d8VHFgh9ab OdZcbU3/+f0pk9uQ= X-Received: by 2002:adf:fc45:: with SMTP id e5mr4390238wrs.226.1597942807478; Thu, 20 Aug 2020 10:00:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0LX1iEI5sG5+0WY5A4i9+FbisCQGjIP/NsUK+/7fAKoe+5ce7ba4ZbySCKmXmtY+7OwWBSw== X-Received: by 2002:adf:fc45:: with SMTP id e5mr4390210wrs.226.1597942807227; Thu, 20 Aug 2020 10:00:07 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id l10sm5109782wru.3.2020.08.20.10.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 10:00:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 12/15] block/nvme: Replace BDRV_POLL_WHILE by AIO_WAIT_WHILE Date: Thu, 20 Aug 2020 18:58:58 +0200 Message-Id: <20200820165901.1139109-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" BDRV_POLL_WHILE() is defined as: #define BDRV_POLL_WHILE(bs, cond) ({ \ BlockDriverState *bs_ = (bs); \ AIO_WAIT_WHILE(bdrv_get_aio_context(bs_), \ cond); }) As we will remove the BlockDriverState use in the next commit, start by using the exploded version of BDRV_POLL_WHILE(). Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 5b69fc75a60..456fe61f5ea 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -493,6 +493,7 @@ static void nvme_cmd_sync_cb(void *opaque, int ret) static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, NvmeCmd *cmd) { + AioContext *aio_context = bdrv_get_aio_context(bs); NVMeRequest *req; int ret = -EINPROGRESS; req = nvme_get_free_req(q); @@ -501,7 +502,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, } nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); - BDRV_POLL_WHILE(bs, ret == -EINPROGRESS); + AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); return ret; }