Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4483206rwo; Tue, 25 Jul 2023 06:50:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlGg0TxGoCyIvZAqm91+Om9XMMh0suNX++Jn8CJErPYlFqRSm3RfLYEyby5v4ZZwqyFTkvFA X-Received: by 2002:a17:907:7606:b0:994:522f:3f4a with SMTP id jx6-20020a170907760600b00994522f3f4amr12304818ejc.29.1690293048968; Tue, 25 Jul 2023 06:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690293048; cv=none; d=google.com; s=arc-20160816; b=c+0SINAq2JIutD1Fi8WrQLyEjE1YBdqaIuzP8P2IQG/lgLTRW2p1qPqykWVkl3aGgV 5DnpyPfucVglIco0wAf+ugeTtuihGUSpvzx6kd+INjJdW563yBZgR7Sgidm8MCBofTvv ByK7RpnAT67AonO2Fonv7ZsIWW9JOVC9EExOHXii8vyHJa1kBvSKwc0XPO8gq1zy0U1Z P9lm1REX0+sM3MqRi4/txfm5+IKX2WuFGHjTzzCs1vaFBMV8fwpGlJzLDi7Wl5xXDhxB JdgP3fIb8cNFRS/oJB8L4oXk7jYjkAaXHjrFoxhrZKinQ3AVHmxkpBz2DLT7Pd5bGD4i YHFw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/QeLRD3PFm/UhjbcDO63KGqnRYCXFOsqKzmt3mk4Vfs=; fh=4fzGWvE2LW7K10hgePOrl39slR3lbqz4nggQweyfPdc=; b=eOciJsvxAPQGZwalPgnheicIE9oHfLGVUXhqZYRNCSbAnXTHhzBFiwRZ4k6gzH1hcy YIIOwueohXdnEJTUgJZRU3NXIAY69zjGoORZd8sNAUzdpPtxOqlQv4sa4vD+xpsJ9k1L Sz3SmyPE//iFEQ3367y+jakfz+gIkmaXKf2Mfcjrbj7olFmD53yY2sBoCc/NljPkFCci PIqHDo+au90RWlm+0dAqS9wPkiTCPu9lky9rhAmnFzacuohmYzQaYojA9C+zBVVSc65b nDwMf0WdA+2hClrCL1QDNp5yYO1zhs7E1tBIDTfqRVF5AO28UuVHnbH40H+PNtGL/hK5 BA4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=dYoyHX5V; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb10-20020a170906b88a00b00993689daad0si7473089ejb.269.2023.07.25.06.50.24; Tue, 25 Jul 2023 06:50:48 -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=@linux.dev header.s=key1 header.b=dYoyHX5V; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbjGYNTG (ORCPT + 99 others); Tue, 25 Jul 2023 09:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjGYNTF (ORCPT ); Tue, 25 Jul 2023 09:19:05 -0400 Received: from out-27.mta0.migadu.com (out-27.mta0.migadu.com [91.218.175.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5825F19BA for ; Tue, 25 Jul 2023 06:18:59 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1690291137; 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: in-reply-to:in-reply-to:references:references; bh=/QeLRD3PFm/UhjbcDO63KGqnRYCXFOsqKzmt3mk4Vfs=; b=dYoyHX5VNzJ1aicvzztBVYudt9ptphJkTO29hYSGPPfG0Z0U7+n46WMtbxZ4J7Q35KtYcO VI3RNCkVOFCy/kp957wNpvXCnsfHnxP/W8pdkhTwK+I9mj16ZUuVEqp1sFFDxTF5iSA752 y0QkHtWqGy1/KK6cPZOi18C8u5+TCYc= From: chengming.zhou@linux.dev To: axboe@kernel.dk, hch@lst.de, ming.lei@redhat.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhouchengming@bytedance.com Subject: [PATCH v2 1/4] blk-flush: flush_rq should inherit first_rq's cmd_flags Date: Tue, 25 Jul 2023 21:00:59 +0800 Message-ID: <20230725130102.3030032-2-chengming.zhou@linux.dev> In-Reply-To: <20230725130102.3030032-1-chengming.zhou@linux.dev> References: <20230725130102.3030032-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: Chengming Zhou The cmd_flags in blk_kick_flush() should inherit the original request's cmd_flags, but the current code looks buggy to me: flush_end_io() blk_flush_complete_seq() // requests on flush running list blk_kick_flush() So the request passed to blk_flush_complete_seq() may will be ended before blk_kick_flush(). On the other hand, flush_rq will inherit first_rq's tag, it should use first_rq's cmd_flags too. This patch is just preparation for the following patches, no bugfix intended. Signed-off-by: Chengming Zhou --- block/blk-flush.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index e73dc22d05c1..fc25228f7bb1 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -92,7 +92,7 @@ enum { }; static void blk_kick_flush(struct request_queue *q, - struct blk_flush_queue *fq, blk_opf_t flags); + struct blk_flush_queue *fq); static inline struct blk_flush_queue * blk_get_flush_queue(struct request_queue *q, struct blk_mq_ctx *ctx) @@ -166,11 +166,9 @@ static void blk_flush_complete_seq(struct request *rq, { struct request_queue *q = rq->q; struct list_head *pending = &fq->flush_queue[fq->flush_pending_idx]; - blk_opf_t cmd_flags; BUG_ON(rq->flush.seq & seq); rq->flush.seq |= seq; - cmd_flags = rq->cmd_flags; if (likely(!error)) seq = blk_flush_cur_seq(rq); @@ -210,7 +208,7 @@ static void blk_flush_complete_seq(struct request *rq, BUG(); } - blk_kick_flush(q, fq, cmd_flags); + blk_kick_flush(q, fq); } static enum rq_end_io_ret flush_end_io(struct request *flush_rq, @@ -277,7 +275,6 @@ bool is_flush_rq(struct request *rq) * blk_kick_flush - consider issuing flush request * @q: request_queue being kicked * @fq: flush queue - * @flags: cmd_flags of the original request * * Flush related states of @q have changed, consider issuing flush request. * Please read the comment at the top of this file for more info. @@ -286,8 +283,7 @@ bool is_flush_rq(struct request *rq) * spin_lock_irq(fq->mq_flush_lock) * */ -static void blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq, - blk_opf_t flags) +static void blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq) { struct list_head *pending = &fq->flush_queue[fq->flush_pending_idx]; struct request *first_rq = @@ -336,7 +332,8 @@ static void blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq, flush_rq->internal_tag = first_rq->internal_tag; flush_rq->cmd_flags = REQ_OP_FLUSH | REQ_PREFLUSH; - flush_rq->cmd_flags |= (flags & REQ_DRV) | (flags & REQ_FAILFAST_MASK); + flush_rq->cmd_flags |= (first_rq->cmd_flags & REQ_DRV) | + (first_rq->cmd_flags & REQ_FAILFAST_MASK); flush_rq->rq_flags |= RQF_FLUSH_SEQ; flush_rq->end_io = flush_end_io; /* -- 2.41.0