From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5AB8C433E0 for ; Tue, 9 Feb 2021 07:48:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2A25064DAD for ; Tue, 9 Feb 2021 07:48:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A25064DAD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 99E656B006C; Tue, 9 Feb 2021 02:48:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 94EB36B006E; Tue, 9 Feb 2021 02:48:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83E5F6B0070; Tue, 9 Feb 2021 02:48:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id 6CDCD6B006C for ; Tue, 9 Feb 2021 02:48:26 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4435D180ACF84 for ; Tue, 9 Feb 2021 07:48:26 +0000 (UTC) X-FDA: 77797951812.13.birth92_450402827605 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 258B518024A50 for ; Tue, 9 Feb 2021 07:48:26 +0000 (UTC) X-HE-Tag: birth92_450402827605 X-Filterd-Recvd-Size: 2850 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 07:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=7v/LXSCkJaQecTj466+HivjlsG5ba0k/dU73SoyjJLM=; b=VdTvV906S8cfRAkeIknqhQN3ni ZbIQo5nAxQ+z2ECnciE7j3MoWs9mYfRREgchNzcLv5g9JxHkD/xNaPzxvzAwMUh7CJZw5wmE3e27P d+a4gK5eSXSPZg7/j8PTljZ5bXTmas3UMsG8WaSsp+JOaI3ukIwitg8GO6xdj0SA/huuZSLlsVx1C B7WQbycrKI9kP+qcRikFmJB3vR/5S2dbsrIcALf7HMfAeyf2V1Vp3ZaRoHVtBA0QRejsMofhjcpD3 JaOc4o9pi/KlOuIFFe/Bq+s1O+VePA5V14py1R0uIis27c/90jhgwAWGmVW3o6h+rLKldbLIf7pc4 tAdCPI/w==; Received: from hch by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l9Nks-0077ge-JF; Tue, 09 Feb 2021 07:48:16 +0000 Date: Tue, 9 Feb 2021 07:48:14 +0000 From: Christoph Hellwig To: Jens Axboe Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@infradead.org, akpm@linux-foundation.org Subject: Re: [PATCH 2/3] mm: use filemap_range_needs_writeback() for O_DIRECT reads Message-ID: <20210209074814.GB1696555@infradead.org> References: <20210209023008.76263-1-axboe@kernel.dk> <20210209023008.76263-3-axboe@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210209023008.76263-3-axboe@kernel.dk> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Feb 08, 2021 at 07:30:07PM -0700, Jens Axboe wrote: > For the generic page cache read helper, use the better variant of checking > for the need to call filemap_write_and_wait_range() when doing O_DIRECT > reads. This avoids falling back to the slow path for IOCB_NOWAIT, if there > are no pages to wait for (or write out). > > Signed-off-by: Jens Axboe > --- > mm/filemap.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/filemap.c b/mm/filemap.c > index 6a58d50fbd31..c80acb80e8f7 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -2643,8 +2643,8 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) > > size = i_size_read(inode); > if (iocb->ki_flags & IOCB_NOWAIT) { > - if (filemap_range_has_page(mapping, iocb->ki_pos, > - iocb->ki_pos + count - 1)) > + if (filemap_range_needs_writeback(mapping, iocb->ki_pos, > + iocb->ki_pos + count - 1)) Please avoid the overy long line, which is trivial to do by using the normal two tab indent for the continuation.