Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp523748ybh; Wed, 15 Jul 2020 08:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0FX7UehwlacEBNx+nPvXw7Al7aTpvaMyeeoFr9/wpjaTjgDSLDhjdlzHE8qFKevRrk8pH X-Received: by 2002:aa7:da89:: with SMTP id q9mr60638eds.273.1594825991824; Wed, 15 Jul 2020 08:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594825991; cv=none; d=google.com; s=arc-20160816; b=SMZGNWI/MibsPqeUDTDZrCn3fSEy8b7Uo4aHQrOApWhm7M2VZGx76FpPfF4NiTG3fn UefAj/0Qz6AyMYgXNcOLkY7fKtPejjOfdYdlJuNv/VkyHu88oiQ38nFvbPg6zk5nScjw SY84RIdvSmmvrrvkngm8A8wyq0l2Ry6m7CgFF5fVOHUc68vRpUhAHaS3GcmGYUsClqXp emiVUNC9rQktqXHVQaa6mm27ZB/ERoSAZRWpsrr5JvL/UnOTVbMh+uAJd0mBVmJhx35A KyRcROc4ZoJO8lhtdFcrv37jpCMaZ/0QxWd7Cu4tHJ2S4M31U4Hl28b5smcF63pDM0x/ j9EQ== 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=S8O46zlsUIJoct/aV2hlzdS++g/4miZpiXoEJxt6FCM=; b=aXLQR1VtB7Y6f2csT+zha+WFnx6g6JD0QeTRQPgBbXvXqHbzC04f4gWk+/4bL+rPCI TUa6bz3xXRytJQW6E9AOpCbaYlOVTFDp/tEkyF2QKWBGWYjziUWfWhQQuqVsuJQFOTQ8 ltqQ1KOZwYGRTYgGXcDFjCNu7N6CUSqPXLFBwwUXnOUjtNLWUEenzL7eDhSIIsC6MYqJ sh9IKiBAxQVznxwlZCKH2QugUZYZrUuEZKbrdvhTSEPTv94LHkrmAYqBLzSuvs38UltO gcAyrtzfKZL5KKGk3fVnDX3nH5veNDjhhDUjiZZjAvKSrEeSWK9cZtJGxqI6/Y9ZnpxG 2uDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KPW13E3F; 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 x11si1419766edq.363.2020.07.15.08.12.47; Wed, 15 Jul 2020 08:13:11 -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=KPW13E3F; 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 S1726384AbgGOPLs (ORCPT + 99 others); Wed, 15 Jul 2020 11:11:48 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:31427 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725770AbgGOPLs (ORCPT ); Wed, 15 Jul 2020 11:11:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594825906; 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=S8O46zlsUIJoct/aV2hlzdS++g/4miZpiXoEJxt6FCM=; b=KPW13E3F8zE0EcAkqlqUbwJS1HSeueTXtlu7Qg5kkjjjwdOa/uSYckvoyZDv9eBWJ9wmKI 5Ps7ajMSsrvF10E7vBSQsxnGHPjzyG072gnugCKuBfT0zy2xS2yNmqK9V3Pj+iGLiQD6i6 dFQN3phixY5H7TqXNk8Katj6NeaJp9c= 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-414-pO4gIpPeMsa0W6e-Y18ySg-1; Wed, 15 Jul 2020 11:11:44 -0400 X-MC-Unique: pO4gIpPeMsa0W6e-Y18ySg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 419DA802807; Wed, 15 Jul 2020 15:10:53 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-118-79.rdu2.redhat.com [10.10.118.79]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9C9360BF1; Wed, 15 Jul 2020 15:10:52 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-cachefs@redhat.com Subject: [RFC PATCH v1 03/13] NFS: Refactor nfs_readpage() and nfs_readpage_async() to use nfs_readdesc Date: Wed, 15 Jul 2020 11:10:39 -0400 Message-Id: <1594825849-24991-4-git-send-email-dwysocha@redhat.com> In-Reply-To: <1594825849-24991-1-git-send-email-dwysocha@redhat.com> References: <1594825849-24991-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Both nfs_readpage() and nfs_readpages() use similar code. This patch should be no functional change, and refactors nfs_readpage_async() to use nfs_readdesc to enable future merging of nfs_readpage_async() and nfs_readpage_async_filler(). Signed-off-by: Dave Wysochanski --- fs/nfs/read.c | 50 ++++++++++++++++++++++++++------------------------ include/linux/nfs_fs.h | 3 +-- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 1153c4e0a155..d635f635d8e3 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -114,18 +114,23 @@ static void nfs_readpage_release(struct nfs_page *req, int error) nfs_release_request(req); } -int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, +struct nfs_readdesc { + struct nfs_pageio_descriptor *pgio; + struct nfs_open_context *ctx; +}; + +int nfs_readpage_async(void *data, struct inode *inode, struct page *page) { + struct nfs_readdesc *desc = (struct nfs_readdesc *)data; struct nfs_page *new; unsigned int len; - struct nfs_pageio_descriptor pgio; struct nfs_pgio_mirror *pgm; len = nfs_page_length(page); if (len == 0) return nfs_return_empty_page(page); - new = nfs_create_request(ctx, page, 0, len); + new = nfs_create_request(desc->ctx, page, 0, len); if (IS_ERR(new)) { unlock_page(page); return PTR_ERR(new); @@ -133,21 +138,21 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, if (len < PAGE_SIZE) zero_user_segment(page, len, PAGE_SIZE); - nfs_pageio_init_read(&pgio, inode, false, + nfs_pageio_init_read(desc->pgio, inode, false, &nfs_async_read_completion_ops); - if (!nfs_pageio_add_request(&pgio, new)) { + if (!nfs_pageio_add_request(desc->pgio, new)) { nfs_list_remove_request(new); - nfs_readpage_release(new, pgio.pg_error); + nfs_readpage_release(new, desc->pgio->pg_error); } - nfs_pageio_complete(&pgio); + nfs_pageio_complete(desc->pgio); /* It doesn't make sense to do mirrored reads! */ - WARN_ON_ONCE(pgio.pg_mirror_count != 1); + WARN_ON_ONCE(desc->pgio->pg_mirror_count != 1); - pgm = &pgio.pg_mirrors[0]; + pgm = &desc->pgio->pg_mirrors[0]; NFS_I(inode)->read_io += pgm->pg_bytes_written; - return pgio.pg_error < 0 ? pgio.pg_error : 0; + return desc->pgio->pg_error < 0 ? desc->pgio->pg_error : 0; } static void nfs_page_group_set_uptodate(struct nfs_page *req) @@ -312,7 +317,8 @@ static void nfs_readpage_result(struct rpc_task *task, */ int nfs_readpage(struct file *filp, struct page *page) { - struct nfs_open_context *ctx; + struct nfs_pageio_descriptor pgio; + struct nfs_readdesc desc; struct inode *inode = page_file_mapping(page)->host; int ret; @@ -339,39 +345,35 @@ int nfs_readpage(struct file *filp, struct page *page) if (filp == NULL) { ret = -EBADF; - ctx = nfs_find_open_context(inode, NULL, FMODE_READ); - if (ctx == NULL) + desc.ctx = nfs_find_open_context(inode, NULL, FMODE_READ); + if (desc.ctx == NULL) goto out_unlock; } else - ctx = get_nfs_open_context(nfs_file_open_context(filp)); + desc.ctx = get_nfs_open_context(nfs_file_open_context(filp)); if (!IS_SYNC(inode)) { - ret = nfs_readpage_from_fscache(ctx, inode, page); + ret = nfs_readpage_from_fscache(desc.ctx, inode, page); if (ret == 0) goto out; } - xchg(&ctx->error, 0); - ret = nfs_readpage_async(ctx, inode, page); + desc.pgio = &pgio; + xchg(&desc.ctx->error, 0); + ret = nfs_readpage_async(&desc, inode, page); if (!ret) { ret = wait_on_page_locked_killable(page); if (!PageUptodate(page) && !ret) - ret = xchg(&ctx->error, 0); + ret = xchg(&desc.ctx->error, 0); } nfs_add_stats(inode, NFSIOS_READPAGES, 1); out: - put_nfs_open_context(ctx); + put_nfs_open_context(desc.ctx); return ret; out_unlock: unlock_page(page); return ret; } -struct nfs_readdesc { - struct nfs_pageio_descriptor *pgio; - struct nfs_open_context *ctx; -}; - static int readpage_async_filler(void *data, struct page *page) { diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 6ee9119acc5d..7e5b9df9cfe6 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -553,8 +553,7 @@ 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(struct nfs_open_context *, struct inode *, - struct page *); +extern int nfs_readpage_async(void *, struct inode *, struct page *); /* * inline functions -- 1.8.3.1