From patchwork Tue Sep 1 16:28:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 11749091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39793109A for ; Tue, 1 Sep 2020 16:28:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0D4F2100A for ; Tue, 1 Sep 2020 16:28:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DD9ihPBH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0D4F2100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2D41C6B009C; Tue, 1 Sep 2020 12:28:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2846F6B009F; Tue, 1 Sep 2020 12:28:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 199696B00A0; Tue, 1 Sep 2020 12:28:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id 057F96B009C for ; Tue, 1 Sep 2020 12:28:37 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BF7613623 for ; Tue, 1 Sep 2020 16:28:36 +0000 (UTC) X-FDA: 77215025832.19.print66_060150727099 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 8D2811AD1B1 for ; Tue, 1 Sep 2020 16:28:36 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,dhowells@redhat.com,,RULES_HIT:30036:30045:30054,0,RBL:205.139.110.120:@redhat.com:.lbl8.mailshell.net-66.10.201.10 62.18.0.100;04y8yceqyjyd8y6ib3kfzxyzymuajop1pgfo1kdbh3f4mm3dfkei7tpnwax8e5s.uk4qt31hrax4j9a13gty1n6bdou9fzjx9zopi9jjo5nwdx4zjn5nun7cpzp475m.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: print66_060150727099 X-Filterd-Recvd-Size: 6388 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 16:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598977715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ezAmTShFf1lpnkxSzlatynP4JebRzAzt5S9sCe1UvW4=; b=DD9ihPBHb/8qwx1nB1dQZG2tXdZwkdxndt0ss9mlT0zqZF9Xyw2Dxe10vltL9MJCtniZPl edZovVhTQD3r6Oqc1iETVUgUTjiWWodopptaur1urdBayHwkOquyAAjkTRaJBo8QyaWQjx gAYIZxVE4aNdDe4/ByyTeqc3i0qCSNs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-TaUdUYt9NE6gk3tKY-XS6A-1; Tue, 01 Sep 2020 12:28:33 -0400 X-MC-Unique: TaUdUYt9NE6gk3tKY-XS6A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 84DAB807333; Tue, 1 Sep 2020 16:28:32 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-113-231.rdu2.redhat.com [10.10.113.231]) by smtp.corp.redhat.com (Postfix) with ESMTP id B56587EB7D; Tue, 1 Sep 2020 16:28:30 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [RFC PATCH 2/7] mm: Make ondemand_readahead() take a readahead_control struct From: David Howells To: willy@infradead.org Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 01 Sep 2020 17:28:29 +0100 Message-ID: <159897770995.405783.3301406968621486886.stgit@warthog.procyon.org.uk> In-Reply-To: <159897769535.405783.17587409235571100774.stgit@warthog.procyon.org.uk> References: <159897769535.405783.17587409235571100774.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Rspamd-Queue-Id: 8D2811AD1B1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: Make ondemand_readahead() take a readahead_control struct in preparation for making do_sync_mmap_readahead() pass down an RAC struct. Signed-off-by: David Howells --- mm/readahead.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 91859e6e2b7d..0e16fb4809f5 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -511,14 +511,15 @@ static bool page_cache_readahead_order(struct readahead_control *rac, /* * A minimal readahead algorithm for trivial sequential/random reads. */ -static void ondemand_readahead(struct address_space *mapping, - struct file_ra_state *ra, struct file *file, - struct page *page, pgoff_t index, unsigned long req_size) +static void ondemand_readahead(struct readahead_control *rac, + struct file_ra_state *ra, + struct page *page) { - DEFINE_READAHEAD(rac, file, mapping, index); - struct backing_dev_info *bdi = inode_to_bdi(mapping->host); + struct backing_dev_info *bdi = inode_to_bdi(rac->mapping->host); unsigned long max_pages = ra->ra_pages; unsigned long add_pages; + unsigned long req_size = rac->_nr_pages; + unsigned long index = rac->_index; pgoff_t prev_index; /* @@ -556,7 +557,7 @@ static void ondemand_readahead(struct address_space *mapping, pgoff_t start; rcu_read_lock(); - start = page_cache_next_miss(mapping, index + 1, max_pages); + start = page_cache_next_miss(rac->mapping, index + 1, max_pages); rcu_read_unlock(); if (!start || start - index > max_pages) @@ -589,14 +590,14 @@ static void ondemand_readahead(struct address_space *mapping, * Query the page cache and look for the traces(cached history pages) * that a sequential stream would leave behind. */ - if (try_context_readahead(mapping, ra, index, req_size, max_pages)) + if (try_context_readahead(rac->mapping, ra, index, req_size, max_pages)) goto readit; /* * standalone, small random read * Read as is, and do not pollute the readahead state. */ - __do_page_cache_readahead(&rac, req_size, 0); + __do_page_cache_readahead(rac, req_size, 0); return; initial_readahead: @@ -622,10 +623,10 @@ static void ondemand_readahead(struct address_space *mapping, } } - rac._index = ra->start; - if (page && page_cache_readahead_order(&rac, ra, thp_order(page))) + rac->_index = ra->start; + if (page && page_cache_readahead_order(rac, ra, thp_order(page))) return; - __do_page_cache_readahead(&rac, ra->size, ra->async_size); + __do_page_cache_readahead(rac, ra->size, ra->async_size); } /** @@ -645,6 +646,9 @@ void page_cache_sync_readahead(struct address_space *mapping, struct file_ra_state *ra, struct file *filp, pgoff_t index, unsigned long req_count) { + DEFINE_READAHEAD(rac, filp, mapping, index); + rac._nr_pages = req_count; + /* no read-ahead */ if (!ra->ra_pages) return; @@ -659,7 +663,7 @@ void page_cache_sync_readahead(struct address_space *mapping, } /* do read-ahead */ - ondemand_readahead(mapping, ra, filp, NULL, index, req_count); + ondemand_readahead(&rac, ra, NULL); } EXPORT_SYMBOL_GPL(page_cache_sync_readahead); @@ -683,7 +687,10 @@ page_cache_async_readahead(struct address_space *mapping, struct page *page, pgoff_t index, unsigned long req_count) { - /* no read-ahead */ + DEFINE_READAHEAD(rac, filp, mapping, index); + rac._nr_pages = req_count; + + /* No Read-ahead */ if (!ra->ra_pages) return; @@ -705,7 +712,7 @@ page_cache_async_readahead(struct address_space *mapping, return; /* do read-ahead */ - ondemand_readahead(mapping, ra, filp, page, index, req_count); + ondemand_readahead(&rac, ra, page); } EXPORT_SYMBOL_GPL(page_cache_async_readahead);