From patchwork Tue Jul 25 13:01:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 125625 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2480389vqg; Tue, 25 Jul 2023 06:45:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlE5O3plyzMtAVKEn2pBxP5Lra0es3ChectI/Im3Ugyeid3VzNrtH2dkAF/CA8KYPqXyO7pe X-Received: by 2002:a17:907:78d7:b0:993:e752:1a71 with SMTP id kv23-20020a17090778d700b00993e7521a71mr12684706ejc.9.1690292726697; Tue, 25 Jul 2023 06:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690292726; cv=none; d=google.com; s=arc-20160816; b=fWTYPgCcRWVtTo+P6KM1jA9FfEpf7lnTR6hu9zABljxgA0psQdZkDyU7ZqKfRZcoIz rV5HcjiPMnyoI3+3NI3wllyCBCBJF7PFkPe5qdg7VKiTtBNTXyIF2N93BC1d0v6XGYwm CmUwtmYYZxr+Epr0qzNDD246gcyooy/K2NqwgF7HcqlPh+SQKq2mXYeicwOmah/CwNxS xzl3WXZqLDdFEReSrAeBS6sjQQHxf5lhvVVJG9ATVu+xHHQZOyAo4AxtNfZFqHomMahQ VEvJd44PYKBrL1on1fwKxFSR9CbX+hQ/KUvc3YpIu4xEPCE2SjTjB5b6FUj7v6jkXZGs 6kTg== 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=JUddR5wiZ9cxmW/YJtgRqWXnFRr905MF2Tu61yP3IU0=; fh=4fzGWvE2LW7K10hgePOrl39slR3lbqz4nggQweyfPdc=; b=DdYAk5aB9Qae4y9td9ZHTHv/hsR/jAFLH2p4+Y2ZV/VYB0+af0sRSvFhyL4xlQl54e Xs9+9YTf0ih7lNu62Ay8pxt+vWcm70xcoLTS0MnJlmt3glKJ8rHi0bZVk6h4u7uKjLtg eKZ/+Ruugoted/2oPGTkSaW/MwUPvri1Yy9MerEHtcxPm4kQgsTa88kKHMRmRGzz9usA IIMBK2tDpCZfFbHvscbxDAa4EOmUu8q9TlUmDaoc2GnndqQLMP/6+z2WFcOr84usSxDJ mLPYLb0NANHbLruTPVOxrUPY8A8c8l7bSunuW4iIEp+AKqLNn42bgu7DXSvyBCyRq2n+ VbkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=rSKMhlIF; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a1709062f8800b00993398bcae2si7891151eji.122.2023.07.25.06.45.02; Tue, 25 Jul 2023 06:45:26 -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=rSKMhlIF; 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 S230040AbjGYNTU (ORCPT + 99 others); Tue, 25 Jul 2023 09:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbjGYNTP (ORCPT ); Tue, 25 Jul 2023 09:19:15 -0400 Received: from out-28.mta0.migadu.com (out-28.mta0.migadu.com [91.218.175.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1295B1FF3 for ; Tue, 25 Jul 2023 06:19:10 -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=1690291149; 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=JUddR5wiZ9cxmW/YJtgRqWXnFRr905MF2Tu61yP3IU0=; b=rSKMhlIFuqqMn3IHOfN8AP7mdsm25+x6DSm5KPAxRxGD47IVz6ycLH4I4AV4ZRiRNOhVvm 5XftPsf+x4V36bWCTlw5rKI3vavReqP7U0tbxcNaohBHS6d4IdyAyPa0WlQknaKP8VRD4n dw/7MPuxIL123WPEpdesOORx3TrJHig= 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 4/4] blk-flush: don't need to end rq twice for non postflush Date: Tue, 25 Jul 2023 21:01:02 +0800 Message-ID: <20230725130102.3030032-5-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 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=unavailable 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: INBOX X-GMAIL-THRID: 1772400386056572253 X-GMAIL-MSGID: 1772400386056572253 From: Chengming Zhou Now we unconditionally blk_rq_init_flush() to replace rq->end_io to make rq return twice back to the flush state machine for post-flush. Obviously, non post-flush requests don't need it, they don't need to end request twice, so they don't need to replace rq->end_io callback. And the same for requests with the FUA bit on hardware with FUA support. There are also some other good points: 1. all requests on hardware with FUA support won't have post-flush, so all of them don't need to end twice. 2. non post-flush requests won't have RQF_FLUSH_SEQ rq_flags set, so they can merge like normal requests. 3. we don't account non post-flush requests in flush_data_in_flight, since there is no point to defer pending flush for these requests. Signed-off-by: Chengming Zhou Reviewed-by: Christoph Hellwig --- block/blk-flush.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index ed195c760617..a299dae65350 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -178,7 +178,8 @@ static void blk_end_flush(struct request *rq, struct blk_flush_queue *fq, * normal completion and end it. */ list_del_init(&rq->queuelist); - blk_flush_restore_request(rq); + if (rq->rq_flags & RQF_FLUSH_SEQ) + blk_flush_restore_request(rq); blk_mq_end_request(rq, error); blk_kick_flush(q, fq); @@ -461,7 +462,8 @@ bool blk_insert_flush(struct request *rq) * Mark the request as part of a flush sequence and submit it * for further processing to the flush state machine. */ - blk_rq_init_flush(rq); + if (policy & REQ_FSEQ_POSTFLUSH) + blk_rq_init_flush(rq); spin_lock_irq(&fq->mq_flush_lock); blk_enqueue_preflush(rq, fq); spin_unlock_irq(&fq->mq_flush_lock);