From patchwork Wed Feb 24 16:44:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12102149 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=-16.5 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,URIBL_BLOCKED,USER_AGENT_GIT 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 35A36C433E0 for ; Wed, 24 Feb 2021 16:45:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CE8B064EF1 for ; Wed, 24 Feb 2021 16:45:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE8B064EF1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B7E376B0005; Wed, 24 Feb 2021 11:45:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ABBDA6B0071; Wed, 24 Feb 2021 11:45:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90FC06B0073; Wed, 24 Feb 2021 11:45:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 6A9616B0005 for ; Wed, 24 Feb 2021 11:45:09 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 24904180B372C for ; Wed, 24 Feb 2021 16:45:09 +0000 (UTC) X-FDA: 77853736338.05.56C3CCB Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by imf05.hostedemail.com (Postfix) with ESMTP id AA73BE00011A for ; Wed, 24 Feb 2021 16:45:05 +0000 (UTC) Received: by mail-io1-f42.google.com with SMTP id f6so2641451iop.11 for ; Wed, 24 Feb 2021 08:45:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AeRNuJwb26jecYMYshpZyYXTh8+P3sXAHEYap904nwc=; b=dBA4tatNquPbOX9jozxTqfDTxIugjGjAaNp/E8p8mGSEaTf5Vqp/X2Sw5upZoy3oDb pKdTyXBY9+G1HNiWIozAwLiNrkcVZAbzkYnNk/sNvi4BppTDVq4wssMn69Or3nAZsIlG v3LjOfV6S/1W4hQuCoMuHjMsC/pcXEoiiXEULEZz4wS177ArMHr3z3iwb8bRenhSE25f eeyzttn95ulHx2s/BeJYlKx5yl+y/Dp8N1ob3lU7vmNhs6JB5t7LrsdLLuCF9YwnNIwe jebKdgOpTuYtwITGdHusRTNV4F7qTXbXVTib5OaPnacajl1jSsgrlea0/N6CPKtsbiPm WQjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AeRNuJwb26jecYMYshpZyYXTh8+P3sXAHEYap904nwc=; b=HzrMI9GD0PnpQD+ZpYK94xrfEPBsqqCkNm6CpjlizEQJ6a5rnZwOu9/6oaZLOdvkz+ pARAGJuUy572OF1c99pu4CXoC7YVhU5xF4rOBrBubVCa9l/55stdXVGYI9RZ0gamJN34 Yz+86Ugkc2TneYK/LZRpjXm+CCSxc72LUd5O1r7ye+JhUHS9pnPv22q+KeV9nJQAZqkx nwxbYoQ5ykzaconG1Rt2dRKYr/gFMxuI3xf8aWj+VygmyxMtdmhDRp2E4h9dIJAOgqiN fY07HMqOZ2bz7eEFNUoBXerFlkyCaHo4CGy+1qlDntOEpSgGuaWOLLA/JbXD2uKZG2ML C7fA== X-Gm-Message-State: AOAM532p+F1px5ux7oZixFxm1JcJm0Ew29VLX83mDEiHfVcjj/un3wxN YKWPmG4uUNTEk4/v7oZpnATBbg== X-Google-Smtp-Source: ABdhPJyu6UQs/JPMF8a5cuR5B6fkZaVUvjWgzmMcs7a1pMpBdTKtP4C9yXuvh99wpYZ8leey8BJdkw== X-Received: by 2002:a05:6638:22e:: with SMTP id f14mr20097775jaq.96.1614185100654; Wed, 24 Feb 2021 08:45:00 -0800 (PST) Received: from p1.localdomain ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id f1sm2273652iov.3.2021.02.24.08.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Feb 2021 08:45:00 -0800 (PST) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 2/3] mm: use filemap_range_needs_writeback() for O_DIRECT reads Date: Wed, 24 Feb 2021 09:44:54 -0700 Message-Id: <20210224164455.1096727-3-axboe@kernel.dk> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210224164455.1096727-1-axboe@kernel.dk> References: <20210224164455.1096727-1-axboe@kernel.dk> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: AA73BE00011A X-Stat-Signature: owp4bptuat9716ikcry3y3rubwcup564 Received-SPF: none (kernel.dk>: No applicable sender policy available) receiver=imf05; identity=mailfrom; envelope-from=""; helo=mail-io1-f42.google.com; client-ip=209.85.166.42 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614185105-985961 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: 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 Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: Jan Kara --- mm/filemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 13338f877677..77f1b527541e 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2645,8 +2645,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)) return -EAGAIN; } else { retval = filemap_write_and_wait_range(mapping,