Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2901943iog; Mon, 27 Jun 2022 05:25:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t3ZuooptoD1C6Vn3xHEQT1CQKz0U0X6kcdvmsBTMl8aQLToK1+DWoYOZvHNHIJe6+DTg3s X-Received: by 2002:a05:6a00:2295:b0:525:72fa:658c with SMTP id f21-20020a056a00229500b0052572fa658cmr14491885pfe.42.1656332704313; Mon, 27 Jun 2022 05:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332704; cv=none; d=google.com; s=arc-20160816; b=Q2FtIpsZdSTJIecmb/wwcamdNlFXIj8pedMEqOQ75NQKdjdHxv+Xp4doTMuDDWlTTA EcTQeFUhTb2L62olHoMEh0YDrHrzNAMXt1bD+MYvt+PZpH7usfAsjzJhR8Kyzi/SEkz3 1H2s6RNL2H94kD8V6ztQXPy87GnURlqHmznV1cKt7lvGK5aJlSFupNz1pe8nsRuL+Iwm XNV5TLDnubs9xnSt0jB1FIiotb/EQRA3s2Od2Mx6+OoPQWhDqMV/a4wwtjfNNOI6l1VA bgpWsgOqZ7LBAB5d88W/korIAquHgKo7esM1s87W7hn1bpQud9qCC8LHwiNKsAtQnKQ/ 2HTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VTFJEgJhVzdNhmOsbRx3pgFKLolvoLzhANoWzl1Y5oc=; b=fwmoymdKFf6MXiDpsfvrDhbWGLSXM8EqSomi76WR5odaI+cR10pOSXqg2uM1HUA0mn DF6UThgoOIclDVE40wnGZGc7qXdlzfPzAngmgMVVCHN3HOhA0PFD+KcCuqgLwSQcknfc QhpKmT0EOj5R3ToJgr0lksHgxMgPzxFEFTQzd4Isr0CQ9h77Hfqvpdz5Tzump1MUcuUj ef432sH4uKQVT6Ohj72AWyeaY5CSv32zc5erfShrIq5dfmTKUTJ0a4vMa7Oh3GYOkpkS exiHv7/leMo1G7cUeYP92LQM7f0UYpe2ATptEmNoAPwkOdd5aEkBq4gaD9w5SiagqWeW HOMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JlKsdM20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d126-20020a636884000000b003a6d2c0b6f3si13621436pgc.573.2022.06.27.05.24.52; Mon, 27 Jun 2022 05:25:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JlKsdM20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235053AbiF0L0V (ORCPT + 99 others); Mon, 27 Jun 2022 07:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234949AbiF0LZh (ORCPT ); Mon, 27 Jun 2022 07:25:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7545659D; Mon, 27 Jun 2022 04:25:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 257EC61459; Mon, 27 Jun 2022 11:25:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 284EDC341C7; Mon, 27 Jun 2022 11:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329118; bh=Xs774V0mF+K9kaKGqJ0IKq9qDk6UomBqM7x0sPzgZWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JlKsdM20MQzMKjXLsgjmSvmpp9mZcwmfrFc2HhqNq5kWzbl6F1hCKF/Ip1f5BZQqt GHSSaacJEmu2qqHXx1LXrSOnwG86jA7uESNGGclzzg3nQZlgwiofOfMo1CQyX+iTwe hGS2IWJD8bp9LtYlEPe0roZPOgwP1irKtq730SXM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chaitanya Kulkarni , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.10 057/102] nvme: dont check nvme_req flags for new req Date: Mon, 27 Jun 2022 13:21:08 +0200 Message-Id: <20220627111935.162378464@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chaitanya Kulkarni [ Upstream commit c03fd85de293a4f65fcb94a795bf4c12a432bb6c ] nvme_clear_request() has a check for flag REQ_DONTPREP and it is called from nvme_init_request() and nvme_setuo_cmd(). The function nvme_init_request() is called from nvme_alloc_request() and nvme_alloc_request_qid(). From these two callers new request is allocated everytime. For newly allocated request RQF_DONTPREP is never set. Since after getting a tag, block layer sets the req->rq_flags == 0 and never sets the REQ_DONTPREP when returning the request :- nvme_alloc_request() blk_mq_alloc_request() blk_mq_rq_ctx_init() rq->rq_flags = 0 <---- nvme_alloc_request_qid() blk_mq_alloc_request_hctx() blk_mq_rq_ctx_init() rq->rq_flags = 0 <---- The block layer does set req->rq_flags but REQ_DONTPREP is not one of them and that is set by the driver. That means we can unconditinally set the REQ_DONTPREP value to the rq->rq_flags when nvme_init_request()->nvme_clear_request() is called from above two callers. Move the check for REQ_DONTPREP from nvme_clear_nvme_request() into nvme_setup_cmd(). This is needed since nvme_alloc_request() now gets called from fast path when NVMeOF target isĀ configured with passthru backend to avoid unnecessary checks in the fast path. Signed-off-by: Chaitanya Kulkarni Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d81b0cff15e0..c42ad0b8247b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -531,11 +531,9 @@ EXPORT_SYMBOL_NS_GPL(nvme_put_ns, NVME_TARGET_PASSTHRU); static inline void nvme_clear_nvme_request(struct request *req) { - if (!(req->rq_flags & RQF_DONTPREP)) { - nvme_req(req)->retries = 0; - nvme_req(req)->flags = 0; - req->rq_flags |= RQF_DONTPREP; - } + nvme_req(req)->retries = 0; + nvme_req(req)->flags = 0; + req->rq_flags |= RQF_DONTPREP; } static inline unsigned int nvme_req_op(struct nvme_command *cmd) @@ -854,7 +852,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, struct nvme_ctrl *ctrl = nvme_req(req)->ctrl; blk_status_t ret = BLK_STS_OK; - nvme_clear_nvme_request(req); + if (!(req->rq_flags & RQF_DONTPREP)) + nvme_clear_nvme_request(req); memset(cmd, 0, sizeof(*cmd)); switch (req_op(req)) { -- 2.35.1