From patchwork Wed Oct 26 10:35:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp165868wru; Wed, 26 Oct 2022 03:07:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QjXLq+03BdJUbPbRnIaJt7wPWdESX7Yg9uNF6KGdh12Ppg6MXWdm8O47EWJmP4Xk7VU7V X-Received: by 2002:a17:90b:1e51:b0:212:d06b:b5fa with SMTP id pi17-20020a17090b1e5100b00212d06bb5famr3317701pjb.171.1666778848248; Wed, 26 Oct 2022 03:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666778848; cv=none; d=google.com; s=arc-20160816; b=zdrClLv3hud1okkKX4ATqG6Hdtpgt15+wxrjCTZsS9evr4GmRsaCvzLzdbchW2Vrb7 9fvN8Z+A1WHoOHT0SiW2D64MCR0aklSGJTF/UF0YodlhRAaJX15VbNEOCjtTIBk6or9Y Lp1VGI7GvG+1Od5gSpom6aL1nCySIoSRymImPNSHg+3hY/tISWdtho9ZblbvcD1gdkcM zb13bK5cmooT2QtUDxbDVZeUIgaLgAAdHuHldAXyT1M/mlMS3pr4mzv9BANc+d78fyzI LKrIk5qzBrH/+LRq4PWNyoB7S2GdngKYc6ZIPeaOQZ/dVVNSqlXMhFA/+A6EWg8zaLA2 w4Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=qkLWdEMt+/WKAKbXrawN4pbUgn/S+mF84AAyIHs9dXE=; b=YxGmJetCm6qUrQBP+yQq++HQh7oqoVf4XsFpRVifg8l5WxLbOOf2SCEg+M3sfjSYKM 1SUZkL+xV6tLLJeZAB51nwAXQnaTRqDJOlAa9yec07JTF5f8frmeHi9C0qVkXgi4gxPp Q8q6+7lSJ3vKQ46O5T0jNb6ORuQOff1feWsggzWeA7EeeHW6RaOe3cc0ydMRGIo09Ifo KV/1ICb3yEVId+MZAWetDnVP2ByLvEDqC8oJmlWdhLlB++gfpkvJTwzPLSUz3D2sbMbw tprw+yR7vaycd1k029e+jnYGe5+4N31Xy286Qs5OSZ1aNqwHrMhdLNdUSrxjl7H/+8ZL 0fhg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a170903121100b001786399ba31si7517859plh.590.2022.10.26.03.07.14; Wed, 26 Oct 2022 03:07:28 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233142AbiJZKEv (ORCPT + 99 others); Wed, 26 Oct 2022 06:04:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbiJZKEs (ORCPT ); Wed, 26 Oct 2022 06:04:48 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A862C15A3E; Wed, 26 Oct 2022 03:04:44 -0700 (PDT) Received: from frapeml500002.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4My4BZ3219z67KQL; Wed, 26 Oct 2022 18:03:18 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by frapeml500002.china.huawei.com (7.182.85.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 26 Oct 2022 12:04:42 +0200 Received: from localhost.localdomain (10.69.192.58) by lhrpeml500003.china.huawei.com (7.191.162.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 26 Oct 2022 11:04:39 +0100 From: John Garry To: CC: , , , , , John Garry Subject: [PATCH v2] blk-mq: Properly init requests from blk_mq_alloc_request_hctx() Date: Wed, 26 Oct 2022 18:35:13 +0800 Message-ID: <1666780513-121650-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747744297083214971?= X-GMAIL-MSGID: =?utf-8?q?1747744297083214971?= Function blk_mq_alloc_request_hctx() is missing zeroing/init of rq->bio, biotail, __sector, and __data_len members, which blk_mq_alloc_request() has, so duplicate what we do in blk_mq_alloc_request(). Fixes: 1f5bd336b9150 ("blk-mq: add blk_mq_alloc_request_hctx") Signed-off-by: John Garry Reviewed-by: Ming Lei Reviewed-by: Christoph Hellwig --- Difference to v1: - init rq members in blk_mq_alloc_request_hctx(), rather than blk_mq_rq_ctx_init() (Ming Lei) diff --git a/block/blk-mq.c b/block/blk-mq.c index 497c413bce80..a1b6afe43913 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -611,6 +611,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, .nr_tags = 1, }; u64 alloc_time_ns = 0; + struct request *rq; unsigned int cpu; unsigned int tag; int ret; @@ -660,8 +661,12 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, tag = blk_mq_get_tag(&data); if (tag == BLK_MQ_NO_TAG) goto out_queue_exit; - return blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag, + rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag, alloc_time_ns); + rq->__data_len = 0; + rq->__sector = (sector_t) -1; + rq->bio = rq->biotail = NULL; + return rq; out_queue_exit: blk_queue_exit(q);