From patchwork Tue Mar 14 04:11:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13173604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E062AC7618A for ; Tue, 14 Mar 2023 04:11:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbjCNELO (ORCPT ); Tue, 14 Mar 2023 00:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbjCNELM (ORCPT ); Tue, 14 Mar 2023 00:11:12 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0E278F522 for ; Mon, 13 Mar 2023 21:11:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1678767071; x=1710303071; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dRmjslkP/dyFGhtAFnGamOw58rUd//QCOkJl56qSdu0=; b=UTZMJ2ZvnVMAUyC6YHYPOTeYDu/4mQyvvHWfad6CVv2rtHr9HPLVo21+ Nt+Qp4xXYp6k17iOGW48YhIWRtghCovRUorioWpid7kSeH1z8XETMs7Tv 6pdtuVy8zzUn47RRAlrVb6q7hZRIybd5Tn/crqXU9+j62qVUp5lv3UgNL wmn4j3nQW2Qv4R23iFzgz1axeg3wSE5v4XkxOb+PWZIZ4T0mPf1bY/ekl bEfKluxyZpf361wsa196VBQrnVB0RpaQ32LtHAUNj9Y4iAYHjalZwXlve JDxPUNqLt2mKO9e3/4bt7TpguKBF9eWaRiC6grFy1/MdYgVWuvySCKd85 w==; X-IronPort-AV: E=Sophos;i="5.98,258,1673884800"; d="scan'208";a="225349843" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Mar 2023 12:11:10 +0800 IronPort-SDR: aR9kTKOn+dGB2Kde5oSm5xtvOTjSoHsimixPOPwdpo+L0aMJeAmgAHHVMwxV9QT1HEkfPycTq4 N4/D+kJkdkkn1ThMSmF27adFA/MaiaVkKIFMruHPwxipDHkrsNNB8Xrhn7CnEOtldO9RUsPxrV 3AARgyKpDHmjdLcrHJLvjpSuRrByTzJkZBUT1m8Ykjeu510MTypGAhZtgJIiVjwzvsMfRUyE/5 44z9QosnkP6z+sCEKk5mCTbLeirkDKK53floSChMfl6Mz0KiWWTN31GdMHkmiE0jn9N3t7HNfy K0Y= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 13 Mar 2023 20:27:39 -0700 IronPort-SDR: fEM1KTs5lKpnfAUUNfUjJLfWQJXne1u8am4M/IwdbkNJH91m39oqeqivMRzowXQYwRUgq2iaPI OQRgNLpqij9qLv3XEMW/Uwrk8uO/ng2UBDqLKECjyB9T01HYnYsqjKhnbhEjCGFfP81m8Tl6/j FplQkZLVwfPPpRMTe9VfgD4l3XGNSEdk6xdsDXUdH+GKRyw+TGY/E9u9xXfQrs8U0Xk0/n7TlF Me/VhkPkwaYkzJ8mCoUkXf2Ait8aQ7l/KG6M8kCrz+dfGh09Yz9ZZ9XTeYzjDIwfGxbtbHhxf9 ciY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 13 Mar 2023 21:11:10 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4PbKp62yPGz1RtVq for ; Mon, 13 Mar 2023 21:11:10 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1678767070; x=1681359071; bh=dRmjslkP/dyFGhtAFn GamOw58rUd//QCOkJl56qSdu0=; b=oWND/ViT4tOfJl79cPze597ro1+7C6f0gg RA6rGw0Lk5+q88yoWcqQdKmm/PR1h7TnBcl0W8RuMn6qNy8otca4mzvoRnNdX9Ia MyBBA+NWdz4TR70nnd3Ul7gx3bd2rsZqx4CBHEnlHAiJEyJJVpIQ600KMcQYDxSk rT9yq2Crwve30JpUZmngxopKyAG4sgIYcK8QO0D0xv7ek3RLjdH/MkDcVo2h4YAN wFu2icGlF9FwCU26TB/HbEf9a17/vcjY6n6ks/1GZgadUoEkTlTy9Ucp3QVipKea 1rNemzdD1AOxVZmmzmAfzmtOg7OI0orLhqITGpP/z5Wa3/TGKlMQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zSFAv-onjyj7 for ; Mon, 13 Mar 2023 21:11:10 -0700 (PDT) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4PbKp53Twgz1RtVn; Mon, 13 Mar 2023 21:11:09 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Akinobu Mita Subject: [PATCH 1/2] block: null_blk: Fix handling of fake timeout request Date: Tue, 14 Mar 2023 13:11:05 +0900 Message-Id: <20230314041106.19173-2-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314041106.19173-1-damien.lemoal@opensource.wdc.com> References: <20230314041106.19173-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org When injecting a fake timeout into the null_blk driver using fail_io_timeout, the request timeout handler does not execute blk_mq_complete_request(), so the complete callback is never executed for a timedout request. The null_blk driver also has a driver-specific fake timeout mechanism which does not have this problem. Fix the problem with fail_io_timeout by using the same meachanism as null_blk internal timeout feature, using the fake_timeout field of null_blk commands. Reported-by: Akinobu Mita Fixes: de3510e52b0a ("null_blk: fix command timeout completion handling") Signed-off-by: Damien Le Moal Reviewed-by: Johannes Thumshirn --- drivers/block/null_blk/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 4c601ca9552a..7d95ad203c97 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1413,8 +1413,7 @@ static inline void nullb_complete_cmd(struct nullb_cmd *cmd) case NULL_IRQ_SOFTIRQ: switch (cmd->nq->dev->queue_mode) { case NULL_Q_MQ: - if (likely(!blk_should_fake_timeout(cmd->rq->q))) - blk_mq_complete_request(cmd->rq); + blk_mq_complete_request(cmd->rq); break; case NULL_Q_BIO: /* @@ -1675,7 +1674,8 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, cmd->rq = bd->rq; cmd->error = BLK_STS_OK; cmd->nq = nq; - cmd->fake_timeout = should_timeout_request(bd->rq); + cmd->fake_timeout = should_timeout_request(bd->rq) || + blk_should_fake_timeout(bd->rq->q); blk_mq_start_request(bd->rq); From patchwork Tue Mar 14 04:11:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 13173605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71C16C74A44 for ; Tue, 14 Mar 2023 04:11:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbjCNELP (ORCPT ); Tue, 14 Mar 2023 00:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbjCNELM (ORCPT ); Tue, 14 Mar 2023 00:11:12 -0400 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C10178FBC5 for ; Mon, 13 Mar 2023 21:11:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1678767071; x=1710303071; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Oo6LRSZ/MwpJ6ztvXZ9FoKMpk6/TPO+x4HbUUuvBG9A=; b=gDmGQp6kErosyAmzhrWrjUmlVMNUML/eZSXA58/55XxxVPX0FXs6G1Ab nXxcFFxyUSw5NvD06Wxqn5Wj1BfEDY9BGxfL8+gTydexyWwjrHUHiKb24 GiVtEJdo1fIe130y9WpozHs01qIyOatsIszkW9oPn7DBkli/DpvUKdSWv BulLn8ytNQwF0EVn4US/1/04tLoNCDQ1RTqgby6gfVocFPp3YkTiQyGn3 fEAYuRwiIF7aYpHhv/RiCP4KQNIA6utBcnTjulXtJ3DXECTbmy2umvnno RL62i2MXZQOYazXbOlPm3b6m15yWw2HB6kt4NFNWKvPxPAE5ltz9Pot1u w==; X-IronPort-AV: E=Sophos;i="5.98,258,1673884800"; d="scan'208";a="225349845" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Mar 2023 12:11:11 +0800 IronPort-SDR: 7geGWFc4Sr5gFsbtIeQB34Wmux0YZL6tro8y3u1AKS1Gzxae10B29+yzswjuz4f00OcepxCZPy Tfte6vCi2YbbiPEQFeND5hZpYdGRhv0rStRDhwy8vFoiBumwXXA60T5N/5R4pj2kOQxkaOu4xO gS8cDH5e6N1/eK8AjRY50yZGrYHrqY/qi8sEplGy/Tr8OBWRZk848Y9p4V6sgBp2u3lWH911xu BVK7dQIjPUCc88YQpkOntYAOo7b4D1ocarxez+9Fqz6Dm+FLEgTZLAyziE3Y7Byt0Seyj0YyEg Yxg= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 13 Mar 2023 20:27:39 -0700 IronPort-SDR: pnleP11yQn9oNPeHeTSH4K0hHZ12GK8pvK3XQQ2KQZhA0YQ2TFG5DT/I83eqGvYp2ljIqPoLBW UaFidaNc9y03DrZbb5FPYdW5WUH6K2mvOB7NuYPMNwItzZxt6obBmXfwAAXYFcsxFQxtS2/Vhn sB+LtsDPsAB2g8sABSGVJD1C5gx9gcqlWy233pVCRmB/c8AS3sxeyKcmtMeAgrAjo7dpGdMveU 7KZZFBuMRv/HmMeeZN4yFU8uMsoXt33WeiU23fhVc7OtNs5UWegIQAwphmybVHLrgVymc+wwDt MfA= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 13 Mar 2023 21:11:11 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4PbKp72GRMz1RtVq for ; Mon, 13 Mar 2023 21:11:11 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1678767070; x=1681359071; bh=Oo6LRSZ/MwpJ6ztvXZ 9FoKMpk6/TPO+x4HbUUuvBG9A=; b=k7QhX3ROvk+hg9avf7GIDFMdmWsFE2rSn5 1EyIpeeEBM58xl5L0xourE4/AfdDosvd6vbBN8OCxJcb375mU1+/Uw/OHJzMVQs7 /l9NMjRHSTF24WRioADbdFL5lS8CjFs6Y3ddvK9jFWlJ8RBuY8jAOyPcvHPJftJQ UxXiBW5ZX9dXPqsMdhH2ZnMPuMLk/4JoRjp04gbRoKVoF17gYKQZSy5+gSQGR/gz gnJd1nZ1Fx1QQXOe4/HXeANcbT4U71WqEcFZroAwj01qODVzW7COAOACnDFDAs0M 7nxLJeMVqCg2jDEaq0a96lBn7+BYPtRtsOk4WDSbKdBFlECPMOAg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id W3ckqLmyKLIt for ; Mon, 13 Mar 2023 21:11:10 -0700 (PDT) Received: from washi.fujisawa.hgst.com (washi.fujisawa.hgst.com [10.149.53.254]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4PbKp62Hqkz1RtVm; Mon, 13 Mar 2023 21:11:10 -0700 (PDT) From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org Cc: Akinobu Mita Subject: [PATCH 2/2] block: null_blk: cleanup null_queue_rq() Date: Tue, 14 Mar 2023 13:11:06 +0900 Message-Id: <20230314041106.19173-3-damien.lemoal@opensource.wdc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314041106.19173-1-damien.lemoal@opensource.wdc.com> References: <20230314041106.19173-1-damien.lemoal@opensource.wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use a local struct request pointer variable to avoid having to dereference struct blk_mq_queue_data multiple times. While at it, also fix the function argument indentation and remove a useless "else" after a return. Signed-off-by: Damien Le Moal Reviewed-by: Pankaj Raghav Reviewed-by: Johannes Thumshirn --- drivers/block/null_blk/main.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 7d95ad203c97..9e6b032c8ecc 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1657,12 +1657,13 @@ static enum blk_eh_timer_return null_timeout_rq(struct request *rq) } static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, - const struct blk_mq_queue_data *bd) + const struct blk_mq_queue_data *bd) { - struct nullb_cmd *cmd = blk_mq_rq_to_pdu(bd->rq); + struct request *rq = bd->rq; + struct nullb_cmd *cmd = blk_mq_rq_to_pdu(rq); struct nullb_queue *nq = hctx->driver_data; - sector_t nr_sectors = blk_rq_sectors(bd->rq); - sector_t sector = blk_rq_pos(bd->rq); + sector_t nr_sectors = blk_rq_sectors(rq); + sector_t sector = blk_rq_pos(rq); const bool is_poll = hctx->type == HCTX_TYPE_POLL; might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING); @@ -1671,15 +1672,15 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); cmd->timer.function = null_cmd_timer_expired; } - cmd->rq = bd->rq; + cmd->rq = rq; cmd->error = BLK_STS_OK; cmd->nq = nq; - cmd->fake_timeout = should_timeout_request(bd->rq) || - blk_should_fake_timeout(bd->rq->q); + cmd->fake_timeout = should_timeout_request(rq) || + blk_should_fake_timeout(rq->q); - blk_mq_start_request(bd->rq); + blk_mq_start_request(rq); - if (should_requeue_request(bd->rq)) { + if (should_requeue_request(rq)) { /* * Alternate between hitting the core BUSY path, and the * driver driven requeue path @@ -1687,22 +1688,20 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx, nq->requeue_selection++; if (nq->requeue_selection & 1) return BLK_STS_RESOURCE; - else { - blk_mq_requeue_request(bd->rq, true); - return BLK_STS_OK; - } + blk_mq_requeue_request(rq, true); + return BLK_STS_OK; } if (is_poll) { spin_lock(&nq->poll_lock); - list_add_tail(&bd->rq->queuelist, &nq->poll_list); + list_add_tail(&rq->queuelist, &nq->poll_list); spin_unlock(&nq->poll_lock); return BLK_STS_OK; } if (cmd->fake_timeout) return BLK_STS_OK; - return null_handle_cmd(cmd, sector, nr_sectors, req_op(bd->rq)); + return null_handle_cmd(cmd, sector, nr_sectors, req_op(rq)); } static void cleanup_queue(struct nullb_queue *nq)