Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35381657rwd; Mon, 10 Jul 2023 06:45:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlEA8WwDZ9P8CFN2yvYDbz5pr7zfU+17wxMEfiID7jIH7iyh8O5oezBzKx1FLkLqNVtXO4AC X-Received: by 2002:a05:6a00:148b:b0:67a:8f2a:2cb2 with SMTP id v11-20020a056a00148b00b0067a8f2a2cb2mr12298936pfu.20.1688996745773; Mon, 10 Jul 2023 06:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688996745; cv=none; d=google.com; s=arc-20160816; b=lXftL5qyQ8qxF/ZrXvEWcQuCNF8/IopdK2sYjsCsJjYRsmdGqMzkah70QxsnxFAFf7 59hVl2A225kjdA60/SKcjtS9M/PSDJo+tGkZOrtEEhVeQ5XYsL/Ner5AwvauXAdWVDSO z3ep8j8AKnyC4LeFdx+3wo6iwX2XpQGQChIk6BlLuDqddFNDiCva0s8OXHKsqnkvPk7y CGdQoAGIKhSrmdY3Sw7efe6TRVTOPz0uc/53c4dOxipGMo/Oi/P8rXOwEWn2mLUWvvV1 bSRgrSb0YQGmRzGMPUeaZbGm2QSrKzv/6KY/DsDSyvGBXhLGSHVNZxbryyk7i6KAsPcN t8fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=cVJQ5mlkxPVZ1FdK16dBAbiKkyq5k15R/eerIDxXYto=; fh=1vuUTineNPguhZ+8zOKbSd1JaGAv1oLTdRFgyn7ljmw=; b=E541EshMQS60qNok6DTNKH2ptplB1M7wPgErjcak3CKq7TzJdHvvv6dsN1e1VGi9G2 TfRUpZ3mjBfLOX5t0TxlhfUsdTF8cioO1s3HckUFYhNm68eTIUalzE00M9RQbz9L/qLK gvhGihQt1MDh9b+YvaI2csmGeadY2KFaVE8w1LwwE3yxQIYFXsMe5nBnK4T75UbHJ6oL dPeP6k5xbmbmaHf99Hj0scHtmcGINP3u7HVTIXX7bMZ99GIPSmDVdLQWhEI5lajSumlf 9kRqas/uXo2weshedWL6GuDcoWm6SiTS7Pl0TgcIFOLbBhXfwTTNmSKoGTl09vF3jbGD B9BQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020a056a001a8800b0067adbac7ad6si9402623pfv.20.2023.07.10.06.45.33; Mon, 10 Jul 2023 06:45:45 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233009AbjGJNdq (ORCPT + 99 others); Mon, 10 Jul 2023 09:33:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232403AbjGJNdh (ORCPT ); Mon, 10 Jul 2023 09:33:37 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B232BA; Mon, 10 Jul 2023 06:33:13 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 2F1AA67373; Mon, 10 Jul 2023 15:33:09 +0200 (CEST) Date: Mon, 10 Jul 2023 15:33:08 +0200 From: Christoph Hellwig To: chengming.zhou@linux.dev Cc: axboe@kernel.dk, hch@lst.de, ming.lei@redhat.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhouchengming@bytedance.com Subject: Re: [PATCH 2/2] blk-flush: don't need to end rq twice for non post-flush requests Message-ID: <20230710133308.GB23157@lst.de> References: <20230710064705.1847287-1-chengming.zhou@linux.dev> <20230710064705.1847287-2-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230710064705.1847287-2-chengming.zhou@linux.dev> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,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 On Mon, Jul 10, 2023 at 02:47:05PM +0800, chengming.zhou@linux.dev wrote: > 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. > > So we move blk_rq_init_flush() to REQ_FSEQ_DATA stage and only replace > rq->end_io if it needs post-flush. Otherwise, it can end like normal > request and doesn't need to return back to the flush state machine. I really like the idea behind this optimization, but I kinda hate adding more magic to the already way too magic flush sequence. I wonder if a better idea would be to kill the flush sequence entirely, and just split the flush_queue into a preflush and a postflush queue. This would remove a field from struct request and lead to more readable code as well.