Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1998406pxb; Sat, 21 Nov 2020 05:31:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4POo5G1YfUbFSC8E7hmwF5OTZerULfjBsga5PbJWi9mkHbZOb4R3I+EYa5RLr6MBmL91i X-Received: by 2002:a17:906:5955:: with SMTP id g21mr11011897ejr.271.1605965494179; Sat, 21 Nov 2020 05:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605965494; cv=none; d=google.com; s=arc-20160816; b=pMCtYNuSn9a7IWvzI/vOn39Ve6Y1SmQOtyYcp5WHUFGuYKLsm0REqN6KWoHt7eHi6B XdQumNfG+ldgb50N4r6Zm8kio2QLdRt8VZzreewYp32T4hJQM4TSeS8/XARAZYdu5EdL 7RT1HWdR7dTveNDljjGSpYBHNZomZk3KLuPpQPowAOMhpvoTyhH655suXHcyeYmuFOyF il26155Z6fP2oQWIYvSbz8dA2YKvcm/eBlQTSOxGWfQMgSC5OgmMyoGMcJMklkFfUS1e llqTs/m85cn2Ye7zXjZRWJ0nIEKYYzaRmpSxyPLEfzCTaBgNx8E9H8SyBSCvt8+6JYaj cIew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=t6sT8eK0HKwBbciQaYAbZaxrD7klMu9hQd/5sSyOW/Q=; b=bDVkHhWORicCnIyEBBiL/hW5jhvQdCK9rRf0GqmdOsE3wL7Wzzu+r8e0xo54qsdvpk Eu5piIztJPeY4D13EAONFeUscHapdx/nbbWc9bm1stWwjJ71TsnFy4oXJopebeAYfnJi 6WUNuAoS8PaG7lUbFPd4WjEK/czlIBUV+t8Z1bTCXiEwIrtycXr0AnrSYDThQqkO8oxf Fln7BP6DrPVhOR7RI7g2bPe715rJCQ4YcPDgCfy/0FjWoon5wP55DGkO1rJtVrFo2QOp Y2t24PRpUE1JbwTLGOk14Bd+H8Z6CYxOUuOsPgwJhVLzdWHM66te5L0yt+5/nN3/2GC1 tZvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UyhGKrFX; 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 n25si3545761eda.190.2020.11.21.05.31.10; Sat, 21 Nov 2020 05:31:34 -0800 (PST) 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=UyhGKrFX; 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 S1727828AbgKUN3f (ORCPT + 99 others); Sat, 21 Nov 2020 08:29:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41191 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbgKUN3e (ORCPT ); Sat, 21 Nov 2020 08:29:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605965373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=t6sT8eK0HKwBbciQaYAbZaxrD7klMu9hQd/5sSyOW/Q=; b=UyhGKrFXbjG5upqYzKjtYsIBvGw2J3HDYZ/je2BJIlTpwcxO5dZz2TbpRMf842nxg2oh2X +p6wKINriNL0Nwf+YLHezDRnOip9uWze7vbahHvFhYNI4LTI02xkGJ74rTwA9a8uN3CUBr VjIG6k6AdwCIPX4czw9p4CUyixC8RGE= 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-445-7HubOquYPR6u9xprbWbIfA-1; Sat, 21 Nov 2020 08:29:30 -0500 X-MC-Unique: 7HubOquYPR6u9xprbWbIfA-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 EC141814411; Sat, 21 Nov 2020 13:29:28 +0000 (UTC) Received: from dwysocha.rdu.csb (ovpn-112-41.rdu2.redhat.com [10.10.112.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 804A412D7E; Sat, 21 Nov 2020 13:29:28 +0000 (UTC) From: Dave Wysochanski To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, dhowells@redhat.com Subject: [PATCH v1 08/13] NFS: Convert fscache_enable_cookie and fscache_disable_cookie Date: Sat, 21 Nov 2020 08:29:27 -0500 Message-Id: <1605965367-24746-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 The new FS-Cache API removes the fscache_enable_cookie() and fscache_disable_cookie() in favor of the new APIs fscache_use_cookie() and fscache_unuse_cookie(), so update these areas as needed. For NFS, we enable fscache on an inode only if the inode is open readonly and not if the inode is open for write. Use the new APIs and change the existing logic slightly and make a decision whether to "use" an inode based fscache cookie one time, by gating the call to fscache_use_cookie() and fscache_unuse_cookie() by the NFS_INO_FSCACHE flag on the nfs_inode. Signed-off-by: Dave Wysochanski --- fs/nfs/fscache.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index 7ef711ca9592..d0477e40aa32 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -285,7 +285,10 @@ 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); + if (test_and_clear_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags)) { + nfs_fscache_update_auxdata(&auxdata, nfsi); + fscache_unuse_cookie(cookie, &auxdata, NULL); + } fscache_relinquish_cookie(cookie, false); nfsi->fscache = NULL; } @@ -325,19 +328,17 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp) if (!fscache_cookie_valid(cookie)) return; - nfs_fscache_update_auxdata(&auxdata, nfsi); - if (inode_is_open_for_write(inode)) { - dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi); - clear_bit(NFS_INO_FSCACHE, &nfsi->flags); - fscache_disable_cookie(cookie, &auxdata, true); - fscache_uncache_all_inode_pages(cookie, inode); + if (test_and_clear_bit(NFS_INO_FSCACHE, &nfsi->flags)) { + dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi); + nfs_fscache_update_auxdata(&auxdata, nfsi); + fscache_unuse_cookie(cookie, &auxdata, NULL); + } } else { - dfprintk(FSCACHE, "NFS: nfsi 0x%p enabling cache\n", nfsi); - fscache_enable_cookie(cookie, &auxdata, nfsi->vfs_inode.i_size, - nfs_fscache_can_enable, inode); - if (fscache_cookie_enabled(cookie)) - set_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags); + if (!test_and_set_bit(NFS_INO_FSCACHE, &nfsi->flags)) { + dfprintk(FSCACHE, "NFS: nfsi 0x%p enabling cache\n", nfsi); + fscache_use_cookie(cookie, false); + } } } EXPORT_SYMBOL_GPL(nfs_fscache_open_file); -- 1.8.3.1