Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1155632ybg; Wed, 29 Jul 2020 07:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNo9wj1tTTbl5hM+RT3IiRJKULEnvqb3UqLywESs+DD0bWdcHao2SiQuqb56LjauZP2tsU X-Received: by 2002:a17:906:7b48:: with SMTP id n8mr19545348ejo.110.1596032062323; Wed, 29 Jul 2020 07:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596032062; cv=none; d=google.com; s=arc-20160816; b=zikxgkjxEPE/HmyR0RO5RBKqyYHYoKZBtKRPD1C/c1xZJkoIkoBN5kzhsfw+dq7Nkv klB38eZx9Ewy6ne9hCJ9D5i1pyGtxx30C56Ajsv2NUs7fV81FW+DaqxvuY15TsT1ubpo MY8gZTDVpt8tcxeakXlzauPOmIobuTyeElyh5XwWSznDH22XKJnf9s1rQ4XHpm/50leg PD7VXkCMeLtLogk8gsX5LqT/EiZi0bjbiQdD9k43ru5qCWXj7l2+ShNG7LXKrOL2f0ff Zyv7K6RYM99yueEKcd/R6QfEnr9e3ZGL2CMIiXAT+KB04yW5anxYSgjdJ23okRJj+ZhF 3C1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Vsj0gEJXfzG0erCq90JH3XhrJ0ou+TOkyyJxHmJIqss=; b=wQepzOXuniBW0OK72tMNKsfMK3YTs/5tGgLzAQXaKEfi7eKzZpPNul3MioO6yNSyBm wtzzEBnGAgfk4CcWPVkElEP9I4GyhC3RrgVXKYX+oKD+UNxIQjY/DWoPfbgx7olO0jvA 5iHrY/Llu0xGrZt1O1vPXBTRRzEh3+d56bZZ2C2ecn8jyudkzWNW3Rb8/NI1Acw+t4Hh DlwUFfQ2FHiTPToH0pi+GmNCbI5skgQdd7LluJzbz+PMvZ0VLQ3pzSHG8crCcslqFarb hGN1GGOZagAcQyIuSjY+6fUW81qUNU2/waoyDqAQvMvtVrteBBgVpZr20rYFComysWNT YHdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y7X23Nmq; 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 ds18si1538323ejc.591.2020.07.29.07.13.58; Wed, 29 Jul 2020 07:14:22 -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=Y7X23Nmq; 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 S1726476AbgG2OMs (ORCPT + 99 others); Wed, 29 Jul 2020 10:12:48 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:25343 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726365AbgG2OMs (ORCPT ); Wed, 29 Jul 2020 10:12:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596031967; 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=Vsj0gEJXfzG0erCq90JH3XhrJ0ou+TOkyyJxHmJIqss=; b=Y7X23NmqgojH9ZWC1Gub/ZYzvXK3J4m0nXGIUecqtH7zx3g95Rex5uQ3zwMckACTkbG+Kx HdnN/zr/aoEhdfyrJKO+13ixZ+cFWSKPU+Nvixf3OgLorb4D9ztmpi3fzkuhJ+OoHVr7HX ITdZYnBLqZnd5A887qrnRewk5sq1FdQ= 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-230-RA9OMcrSNx2klSmIkKw2Iw-1; Wed, 29 Jul 2020 10:12:45 -0400 X-MC-Unique: RA9OMcrSNx2klSmIkKw2Iw-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 60B99801504; Wed, 29 Jul 2020 14:12:44 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-113-23.rdu2.redhat.com [10.10.113.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD4A171906; Wed, 29 Jul 2020 14:12:43 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-cachefs@redhat.com Subject: [RFC PATCH v2 05/14] NFS: Add nfs_pageio_complete_read() and remove nfs_readpage_async() Date: Wed, 29 Jul 2020 10:12:20 -0400 Message-Id: <1596031949-26793-6-git-send-email-dwysocha@redhat.com> In-Reply-To: <1596031949-26793-1-git-send-email-dwysocha@redhat.com> References: <1596031949-26793-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add nfs_pageio_complete_read() and call this from both nfs_readpage() and nfs_readpages(), since the submission and accounting is the same for both functions. Signed-off-by: Dave Wysochanski --- fs/nfs/read.c | 137 ++++++++++++++++++++++--------------------------- include/linux/nfs_fs.h | 1 - 2 files changed, 61 insertions(+), 77 deletions(-) diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 1401f1c734c0..c2df4040f26c 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -74,6 +74,24 @@ void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, } EXPORT_SYMBOL_GPL(nfs_pageio_init_read); +static void nfs_pageio_complete_read(struct nfs_pageio_descriptor *pgio, + struct inode *inode) +{ + struct nfs_pgio_mirror *pgm; + unsigned long npages; + + nfs_pageio_complete(pgio); + + /* It doesn't make sense to do mirrored reads! */ + WARN_ON_ONCE(pgio->pg_mirror_count != 1); + + pgm = &pgio->pg_mirrors[0]; + NFS_I(inode)->read_io += pgm->pg_bytes_written; + npages = (pgm->pg_bytes_written + PAGE_SIZE - 1) >> PAGE_SHIFT; + nfs_add_stats(inode, NFSIOS_READPAGES, npages); +} + + void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio) { struct nfs_pgio_mirror *mirror; @@ -119,36 +137,6 @@ struct nfs_readdesc { struct nfs_open_context *ctx; }; -static int readpage_async_filler(void *data, struct page *page); - -int nfs_readpage_async(void *data, struct inode *inode, - struct page *page) -{ - struct nfs_readdesc *desc = (struct nfs_readdesc *)data; - struct nfs_pgio_mirror *pgm; - int error; - - nfs_pageio_init_read(&desc->pgio, inode, false, - &nfs_async_read_completion_ops); - - error = readpage_async_filler(desc, page); - if (error) - goto out; - - nfs_pageio_complete(&desc->pgio); - - /* It doesn't make sense to do mirrored reads! */ - WARN_ON_ONCE(desc->pgio.pg_mirror_count != 1); - - pgm = &desc->pgio.pg_mirrors[0]; - NFS_I(inode)->read_io += pgm->pg_bytes_written; - - return desc->pgio.pg_error < 0 ? desc->pgio.pg_error : 0; - -out: - return error; -} - static void nfs_page_group_set_uptodate(struct nfs_page *req) { if (nfs_page_group_sync_on_bit(req, PG_UPTODATE)) @@ -170,8 +158,7 @@ static void nfs_read_completion(struct nfs_pgio_header *hdr) if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) { /* note: regions of the page not covered by a - * request are zeroed in nfs_readpage_async / - * readpage_async_filler */ + * request are zeroed in readpage_async_filler */ if (bytes > hdr->good_bytes) { /* nothing in this request was good, so zero * the full extent of the request */ @@ -303,6 +290,38 @@ static void nfs_readpage_result(struct rpc_task *task, nfs_readpage_retry(task, hdr); } +static int +readpage_async_filler(void *data, struct page *page) +{ + struct nfs_readdesc *desc = (struct nfs_readdesc *)data; + struct nfs_page *new; + unsigned int len; + int error; + + len = nfs_page_length(page); + if (len == 0) + return nfs_return_empty_page(page); + + new = nfs_create_request(desc->ctx, page, 0, len); + if (IS_ERR(new)) + goto out_error; + + if (len < PAGE_SIZE) + zero_user_segment(page, len, PAGE_SIZE); + if (!nfs_pageio_add_request(&desc->pgio, new)) { + nfs_list_remove_request(new); + error = desc->pgio.pg_error; + nfs_readpage_release(new, error); + goto out; + } + return 0; +out_error: + error = PTR_ERR(new); + unlock_page(page); +out: + return error; +} + /* * Read a page over NFS. * We read the page synchronously in the following case: @@ -351,13 +370,20 @@ int nfs_readpage(struct file *filp, struct page *page) } xchg(&desc.ctx->error, 0); - ret = nfs_readpage_async(&desc, inode, page); + nfs_pageio_init_read(&desc.pgio, inode, false, + &nfs_async_read_completion_ops); + + ret = readpage_async_filler(&desc, page); + + if (!ret) + nfs_pageio_complete_read(&desc.pgio, inode); + + ret = desc.pgio.pg_error < 0 ? desc.pgio.pg_error : 0; if (!ret) { ret = wait_on_page_locked_killable(page); if (!PageUptodate(page) && !ret) ret = xchg(&desc.ctx->error, 0); } - nfs_add_stats(inode, NFSIOS_READPAGES, 1); out: put_nfs_open_context(desc.ctx); return ret; @@ -366,45 +392,11 @@ int nfs_readpage(struct file *filp, struct page *page) return ret; } -static int -readpage_async_filler(void *data, struct page *page) -{ - struct nfs_readdesc *desc = (struct nfs_readdesc *)data; - struct nfs_page *new; - unsigned int len; - int error; - - len = nfs_page_length(page); - if (len == 0) - return nfs_return_empty_page(page); - - new = nfs_create_request(desc->ctx, page, 0, len); - if (IS_ERR(new)) - goto out_error; - - if (len < PAGE_SIZE) - zero_user_segment(page, len, PAGE_SIZE); - if (!nfs_pageio_add_request(&desc->pgio, new)) { - nfs_list_remove_request(new); - error = desc->pgio.pg_error; - nfs_readpage_release(new, error); - goto out; - } - return 0; -out_error: - error = PTR_ERR(new); - unlock_page(page); -out: - return error; -} - int nfs_readpages(struct file *filp, struct address_space *mapping, struct list_head *pages, unsigned nr_pages) { - struct nfs_pgio_mirror *pgm; struct nfs_readdesc desc; struct inode *inode = mapping->host; - unsigned long npages; int ret; dprintk("NFS: nfs_readpages (%s/%Lu %d)\n", @@ -437,16 +429,9 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, &nfs_async_read_completion_ops); ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); - nfs_pageio_complete(&desc.pgio); - /* It doesn't make sense to do mirrored reads! */ - WARN_ON_ONCE(desc.pgio.pg_mirror_count != 1); + nfs_pageio_complete_read(&desc.pgio, inode); - pgm = &desc.pgio.pg_mirrors[0]; - NFS_I(inode)->read_io += pgm->pg_bytes_written; - npages = (pgm->pg_bytes_written + PAGE_SIZE - 1) >> - PAGE_SHIFT; - nfs_add_stats(inode, NFSIOS_READPAGES, npages); read_complete: put_nfs_open_context(desc.ctx); out: diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 7e5b9df9cfe6..b52ff4f2014c 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -553,7 +553,6 @@ extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh, extern int nfs_readpage(struct file *, struct page *); extern int nfs_readpages(struct file *, struct address_space *, struct list_head *, unsigned); -extern int nfs_readpage_async(void *, struct inode *, struct page *); /* * inline functions -- 1.8.3.1