From patchwork Wed Nov 17 22:17:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wysochanski X-Patchwork-Id: 12625653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10E02C433F5 for ; Wed, 17 Nov 2021 22:17:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA3B461B39 for ; Wed, 17 Nov 2021 22:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241114AbhKQWUe (ORCPT ); Wed, 17 Nov 2021 17:20:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60209 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241116AbhKQWU3 (ORCPT ); Wed, 17 Nov 2021 17:20:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637187450; 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=D72EGa9lgFd9iMcU2FjgBVw/mB/UbN+sEs2moKzridc=; b=OManvD2iDiQ5gCr7Ih/P59J5Us99AAZ/YTa4z/GjYf4g7xhIJU9xRWPfeSRPnsPE8lESWS 1mY4x2K5oxB8vTh9CEeBvel0T8ax82GH90pyrnnFcvodGPA5Y5bL5/TtYlA50Z8ThaeVxp p7MmitFqVCD+lU1rXdNLS7V5tbixYAA= 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-591-7X621R0gMMaL4kTcy0w9Rg-1; Wed, 17 Nov 2021 17:17:27 -0500 X-MC-Unique: 7X621R0gMMaL4kTcy0w9Rg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44A7F1808312; Wed, 17 Nov 2021 22:17:26 +0000 (UTC) Received: from dwysocha.rdu.csb (unknown [10.22.32.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B770760657; Wed, 17 Nov 2021 22:17:25 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-cachefs@redhat.com Subject: [PATCH 2/7] NFS: Cleanup usage of nfs_inode in fscache interface and handle i_size properly Date: Wed, 17 Nov 2021 17:17:13 -0500 Message-Id: <1637187438-18858-3-git-send-email-dwysocha@redhat.com> In-Reply-To: <1637187438-18858-1-git-send-email-dwysocha@redhat.com> References: <1637187438-18858-1-git-send-email-dwysocha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org A number of places in the fscache interface used nfs_inode when inode could be used, simplifying the code. Also, handle the read of i_size properly by utilizing the i_size_read() interface. Signed-off-by: Dave Wysochanski --- fs/nfs/fscache.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index d743629e05e1..ebc91e4b7655 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -226,16 +226,16 @@ void nfs_fscache_release_super_cookie(struct super_block *sb) } static void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *auxdata, - struct nfs_inode *nfsi) + struct inode *inode) { memset(auxdata, 0, sizeof(*auxdata)); - auxdata->mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; - auxdata->mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; - auxdata->ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; - auxdata->ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; + auxdata->mtime_sec = inode->i_mtime.tv_sec; + auxdata->mtime_nsec = inode->i_mtime.tv_nsec; + auxdata->ctime_sec = inode->i_ctime.tv_sec; + auxdata->ctime_nsec = inode->i_ctime.tv_nsec; - if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) - auxdata->change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode); + if (NFS_SERVER(inode)->nfs_client->rpc_ops->version == 4) + auxdata->change_attr = inode_peek_iversion_raw(inode); } /* @@ -251,13 +251,13 @@ void nfs_fscache_init_inode(struct inode *inode) if (!(nfss->fscache && S_ISREG(inode->i_mode))) return; - nfs_fscache_update_auxdata(&auxdata, nfsi); + nfs_fscache_update_auxdata(&auxdata, inode); nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache, &nfs_fscache_inode_object_def, nfsi->fh.data, nfsi->fh.size, &auxdata, sizeof(auxdata), - nfsi, nfsi->vfs_inode.i_size, false); + nfsi, i_size_read(inode), false); } /* @@ -271,7 +271,7 @@ void nfs_fscache_clear_inode(struct inode *inode) dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie); - nfs_fscache_update_auxdata(&auxdata, nfsi); + nfs_fscache_update_auxdata(&auxdata, inode); fscache_relinquish_cookie(cookie, &auxdata, false); nfsi->fscache = NULL; } @@ -311,7 +311,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp) if (!fscache_cookie_valid(cookie)) return; - nfs_fscache_update_auxdata(&auxdata, nfsi); + nfs_fscache_update_auxdata(&auxdata, inode); if (inode_is_open_for_write(inode)) { dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi); @@ -320,7 +320,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp) fscache_uncache_all_inode_pages(cookie, inode); } else { dfprintk(FSCACHE, "NFS: nfsi 0x%p enabling cache\n", nfsi); - fscache_enable_cookie(cookie, &auxdata, nfsi->vfs_inode.i_size, + fscache_enable_cookie(cookie, &auxdata, i_size_read(inode), nfs_fscache_can_enable, inode); if (fscache_cookie_enabled(cookie)) set_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags);