Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1834612pxb; Thu, 7 Oct 2021 16:34:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGoSlB/NfSIV0YYvBWqSNMYq3t4jJ+qWsxMAyP8MRz1dM66DimVS+4ltMT4bRDsUw70H9n X-Received: by 2002:a17:902:7c94:b0:13b:8d10:cc4f with SMTP id y20-20020a1709027c9400b0013b8d10cc4fmr6480268pll.54.1633649650490; Thu, 07 Oct 2021 16:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633649650; cv=none; d=google.com; s=arc-20160816; b=wbTq2qWdZZx+zjGX82BpLnii5gJeRVCVCfv2snhsib8PjoA4MkR7cwISMBDNj0zw06 pEM69lDMbgtJ2/G/wQlXQur1DIOAXDnFDJ9m6Jlwr9VY5W/5dfvViVPftztq1ZJElukS ELlWUY4Q8M8fsxzygd/4r6VikrmXJr9hYTttOXuPHi5cZ53q31wxK+wc/0+chLMIquRJ j9f8FVr7qfUd7oNKnfU3k3BRRhxC1KH5lW9MAroC98h9biWU+qS/x8L5SfOwLfessjMS 8QJIKK7S/tMficZxeEfIzDF6yfCmt1HQbvqDfTw6/sODpLYxzNlA6ig49FS+ExKfXUai Uibw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Lwr19yU08/Xq7niJ43uaMZQodLgZ46tZlYj6Skt1VDA=; b=v6idNmiV8fq4LhBxhGR93BCKMRyU06+f7tWZ7sp+JcMyIp926ZgxniYRJaT8/ZrRBe i2gjSHbK1Fg7Em6A+WlG6LnmdgWnpEGrxpSbZ0KK8/mPyDsk45mbJee8Om74S2Gx0F3P +fO5/npt2p0cz4GWvGiV4WugpoG0qSK8hkDFKgNYNQT+1C6VlOpsYqcZp+ijoGGpOEMx WER+sfvVclmhHsntZ+Wu4jTGc7w7HGQYvXB4d/dT98Cp161j62qhNm/BpGDoif2v7lfv 5dnlBT4A1ljJeMkZ7Gth6YZKHrq+LMkz3pTYFWCSaahgvw+nas0qbsNPc7ix/GlmE06f plPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e3F4xCYE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l16si975038pgc.45.2021.10.07.16.33.54; Thu, 07 Oct 2021 16:34:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e3F4xCYE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbhJGXfb (ORCPT + 99 others); Thu, 7 Oct 2021 19:35:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59590 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231513AbhJGXfa (ORCPT ); Thu, 7 Oct 2021 19:35:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633649616; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=Lwr19yU08/Xq7niJ43uaMZQodLgZ46tZlYj6Skt1VDA=; b=e3F4xCYEFpy0XL4hMCQeV0Kesat8Pu+1Ictn0snZA5V19GBiXSgFc0qVeLDjT/nEtMAQIm ENckgnBjquwoPuIL9w+upHINevJKP846J94/VzJq2ZyrbMA8HKL6QPimdd3tOE5CGrmn9E N4yPzfv8TMWJ6yddb5wz87UPDMemZVs= 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-596-qiKg2VNXNuaoOHLv4I2SWA-1; Thu, 07 Oct 2021 19:33:34 -0400 X-MC-Unique: qiKg2VNXNuaoOHLv4I2SWA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A36FB10D34D9; Thu, 7 Oct 2021 23:32:13 +0000 (UTC) Received: from dwysocha.rdu.csb (unknown [10.22.8.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD9935D6D5; Thu, 7 Oct 2021 23:32:12 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: Matthew Wilcox , David Howells , Chuck Lever , linux-cachefs@redhat.com, linux-nfs@vger.kernel.org Subject: [PATCH 1/1] NFS: Convert from readpages() to readahead() Date: Thu, 7 Oct 2021 19:32:08 -0400 Message-Id: <1633649528-1321-2-git-send-email-dwysocha@redhat.com> In-Reply-To: <1633649528-1321-1-git-send-email-dwysocha@redhat.com> References: <1633649528-1321-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Convert to the new VM readahead() API which is the preferred API to read multiple pages, and rename the NFSIOS_* counters and the tracepoint as needed. Signed-off-by: Dave Wysochanski --- fs/nfs/file.c | 2 +- fs/nfs/nfstrace.h | 2 +- fs/nfs/read.c | 21 +++++++++++++++------ include/linux/nfs_fs.h | 3 +-- include/linux/nfs_iostat.h | 6 +++--- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 209dac208477..cc76d17fa97f 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -519,7 +519,7 @@ static void nfs_swap_deactivate(struct file *file) const struct address_space_operations nfs_file_aops = { .readpage = nfs_readpage, - .readpages = nfs_readpages, + .readahead = nfs_readahead, .set_page_dirty = __set_page_dirty_nobuffers, .writepage = nfs_writepage, .writepages = nfs_writepages, diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index 78b0f649dd09..d2b2080765a6 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -915,7 +915,7 @@ ) ); -TRACE_EVENT(nfs_aops_readpages, +TRACE_EVENT(nfs_aops_readahead, TP_PROTO( const struct inode *inode, unsigned int nr_pages diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 927504605e0f..5c2aab47cf1d 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -395,15 +395,19 @@ int nfs_readpage(struct file *file, struct page *page) return ret; } -int nfs_readpages(struct file *file, struct address_space *mapping, - struct list_head *pages, unsigned nr_pages) +void nfs_readahead(struct readahead_control *ractl) { + struct file *file = ractl->file; + struct address_space *mapping = ractl->mapping; + struct page *page; + unsigned int nr_pages = readahead_count(ractl); + struct nfs_readdesc desc; struct inode *inode = mapping->host; int ret; - trace_nfs_aops_readpages(inode, nr_pages); - nfs_inc_stats(inode, NFSIOS_VFSREADPAGES); + trace_nfs_aops_readahead(inode, nr_pages); + nfs_inc_stats(inode, NFSIOS_VFSREADAHEAD); ret = -ESTALE; if (NFS_STALE(inode)) @@ -420,13 +424,18 @@ int nfs_readpages(struct file *file, struct address_space *mapping, nfs_pageio_init_read(&desc.pgio, inode, false, &nfs_async_read_completion_ops); - ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); + ret = 0; + while (!ret && (page = readahead_page(ractl))) { + prefetchw(&page->flags); + ret = readpage_async_filler(&desc, page); + put_page(page); + } nfs_pageio_complete_read(&desc.pgio); put_nfs_open_context(desc.ctx); out: - return ret; + return; } int __init nfs_init_readpagecache(void) diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index b9a8b925db43..6cbe3f2c5669 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -580,8 +580,7 @@ extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred, s * linux/fs/nfs/read.c */ extern int nfs_readpage(struct file *, struct page *); -extern int nfs_readpages(struct file *, struct address_space *, - struct list_head *, unsigned); +extern void nfs_readahead(struct readahead_control *); /* * inline functions diff --git a/include/linux/nfs_iostat.h b/include/linux/nfs_iostat.h index 027874c36c88..418145f23700 100644 --- a/include/linux/nfs_iostat.h +++ b/include/linux/nfs_iostat.h @@ -22,7 +22,7 @@ #ifndef _LINUX_NFS_IOSTAT #define _LINUX_NFS_IOSTAT -#define NFS_IOSTAT_VERS "1.1" +#define NFS_IOSTAT_VERS "1.2" /* * NFS byte counters @@ -53,7 +53,7 @@ * NFS page counters * * These count the number of pages read or written via nfs_readpage(), - * nfs_readpages(), or their write equivalents. + * nfs_readahead(), or their write equivalents. * * NB: When adding new byte counters, please include the measured * units in the name of each byte counter to help users of this @@ -98,7 +98,7 @@ enum nfs_stat_eventcounters { NFSIOS_VFSACCESS, NFSIOS_VFSUPDATEPAGE, NFSIOS_VFSREADPAGE, - NFSIOS_VFSREADPAGES, + NFSIOS_VFSREADAHEAD, NFSIOS_VFSWRITEPAGE, NFSIOS_VFSWRITEPAGES, NFSIOS_VFSGETDENTS, -- 1.8.3.1