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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 81019C433DF for ; Fri, 16 Oct 2020 16:05:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D46B620866 for ; Fri, 16 Oct 2020 16:04:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="BHe6AO+v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D46B620866 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 2FCF394000F; Fri, 16 Oct 2020 12:04:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25E83940010; Fri, 16 Oct 2020 12:04:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1535294000F; Fri, 16 Oct 2020 12:04:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id 571E994000D for ; Fri, 16 Oct 2020 12:04:52 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4D5088249980 for ; Fri, 16 Oct 2020 16:04:51 +0000 (UTC) X-FDA: 77378261982.27.low47_4b0854d2721e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id 324093D669 for ; Fri, 16 Oct 2020 16:04:51 +0000 (UTC) X-HE-Tag: low47_4b0854d2721e X-Filterd-Recvd-Size: 3050 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 16:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=SLkkZEVg2bXTvSR+l8GXD0xD/a/pq4p09uWc4mwKVwc=; b=BHe6AO+vza2Np4NUh6KPo5ot0F kLgV4JNwWZMZ+ayua4JSYUQcgRs1bFGO+nAvuH7i0uWcO3FeMCh1eXZtvV+0IvjkQpmHT9d2R+lL7 I9A06AwCfemdpNbxQI44lLNClgazMJ9zlYq1XBIux6VAEkZoKc8H4xcnCyReGZT+9S9pw0A36BwM8 gx6kaFKaUEwe6j/IT+RMGrcBuA44V2OO0yeMetwU3d0LmFDHbe0bPwLQ+BSx90wONKODVwhh66nC9 ZwJy1V03eb0/j/q9TABYkLHU/QPN/RoWF2mi1J7SLY9Uv5DYxscV8X40fIbw4R8YIx+psul4kY6+l SGRnnaaA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTSDl-0004sG-ET; Fri, 16 Oct 2020 16:04:45 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v3 02/18] swap: Call aops->readahead if appropriate Date: Fri, 16 Oct 2020 17:04:27 +0100 Message-Id: <20201016160443.18685-3-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201016160443.18685-1-willy@infradead.org> References: <20201016160443.18685-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Some filesystems have a synchronous readpage and an asynchronous readahead. Call the readahead operation if we're trying to do swap readahead. Signed-off-by: Matthew Wilcox (Oracle) --- mm/page_io.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index e485a6e8a6cd..faf5ccb42946 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -367,6 +367,24 @@ int __swap_writepage(struct page *page, struct write= back_control *wbc, return ret; } =20 +static int mapping_readpage(struct file *file, struct address_space *map= ping, + struct page *page, bool synchronous) +{ + struct readahead_control ractl =3D { + .file =3D file, + .mapping =3D mapping, + ._index =3D page->index, + ._nr_pages =3D 1, + }; + + if (!synchronous && mapping->a_ops->readahead) { + mapping->a_ops->readahead(&ractl); + return 0; + } + + return mapping->a_ops->readpage(file, page); +} + int swap_readpage(struct page *page, bool synchronous) { struct bio *bio; @@ -395,9 +413,9 @@ int swap_readpage(struct page *page, bool synchronous= ) =20 if (data_race(sis->flags & SWP_FS)) { struct file *swap_file =3D sis->swap_file; - struct address_space *mapping =3D swap_file->f_mapping; =20 - ret =3D mapping->a_ops->readpage(swap_file, page); + ret =3D mapping_readpage(swap_file, swap_file->f_mapping, + page, synchronous); if (!ret) count_vm_event(PSWPIN); goto out; --=20 2.28.0