From patchwork Tue Jun 11 18:25:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10988115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AB831398 for ; Tue, 11 Jun 2019 18:27:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69F9728718 for ; Tue, 11 Jun 2019 18:27:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58E0928716; Tue, 11 Jun 2019 18:27:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UPPERCASE_50_75 autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 018FE28716 for ; Tue, 11 Jun 2019 18:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407078AbfFKS1V (ORCPT ); Tue, 11 Jun 2019 14:27:21 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:40834 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407075AbfFKS1V (ORCPT ); Tue, 11 Jun 2019 14:27:21 -0400 Received: by mail-io1-f68.google.com with SMTP id n5so10728044ioc.7 for ; Tue, 11 Jun 2019 11:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=v0OkLxrQq/55+L6unlXoMOkNyHb2TA9TF2IJuUzD/5o=; b=KtBqAk9YxXZrtEJ3BEa3RaJonlGQ7nyAl5Vk7KU1kMfQaFl+tEFnfjV0K6rBpSnIIN i34NK3VP3aFL8xr2mZdw9O0VE7MkCL5Ubpzf1bK4VOEardVc60zXDkGTVD3uMTAJb1yP ehjANFtbaYkVc0SzHcbTLfuxoakEyQpFpJfiYPrM2wJzHbL+tCp4/DqB+Z4CyiAqlVey ZK3kvT50zDqQTfxxHOQ9soLmuPY5hSjpRJixaJ+DeV+Mff48z0pOGhEsbiwrMV1C7WHw tDg9x7Km6FiIlaraAVZ0LU/XsoGN+c+IWiIU4EpGZAcOUV1gFJM++6bRXxMGHF2iRna0 FudA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v0OkLxrQq/55+L6unlXoMOkNyHb2TA9TF2IJuUzD/5o=; b=KC8MTuoa8BXZD5UqyJO7RcA8sm8D7265nLKgyAUpNmmSbsCTiVXpq3KoyXp4tVfFgR tyVGI2fLTNYR+miWV6sfTrUycLfR0Mp1ajHWE837joD7rrGfTOyRHOyiJ8Wcs9Eq/E4g iJiwFq3HfHpiKs9vstEJwyYZb5fAZLrrGpPlnMon6/Z7sGhhBvRlugAv1RW5PmlrbzhN jpUG9FR1Lr+pPCXptZboK4I8e/+rhsYMZChW4N5USAXzQ9jeaaSQ5okr2CxF4GsGHG0I 9OIPh/6XKri7O5omJb5kmt3K+Avxg4rsyoSuyJy27wK9JpuHauU52dysw72rCF3sPnyX 7uAA== X-Gm-Message-State: APjAAAWRv4Bx4ZNESk9AhZRsccgHECPosnH+nvBYvlSv3zKhOvDCBB3A BDxbSEH6//A2HgfQmDBTaAj5eTg= X-Google-Smtp-Source: APXvYqyAMsViZrHG6rtTsKQownM86FxTHCJaj8mxrSB592UihhrcVNMC7RWr20FIyj+xywABuJY3bg== X-Received: by 2002:a6b:b593:: with SMTP id e141mr34195012iof.203.1560277639823; Tue, 11 Jun 2019 11:27:19 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id q9sm4789830iot.80.2019.06.11.11.27.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 11 Jun 2019 11:27:19 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 1/3] NFS: Fix up ftrace printout of the cache invalidation flags Date: Tue, 11 Jun 2019 14:25:09 -0400 Message-Id: <20190611182511.120074-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190611182511.120074-1-trond.myklebust@hammerspace.com> References: <20190611182511.120074-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update the ftrace printouts so they correctly reflect the cache invalidation flags. Signed-off-by: Trond Myklebust --- fs/nfs/nfstrace.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index a0d6910aa03a..c40aad6ef3ff 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -25,14 +25,18 @@ #define nfs_show_cache_validity(v) \ __print_flags(v, "|", \ - { NFS_INO_INVALID_ATTR, "INVALID_ATTR" }, \ { NFS_INO_INVALID_DATA, "INVALID_DATA" }, \ { NFS_INO_INVALID_ATIME, "INVALID_ATIME" }, \ { NFS_INO_INVALID_ACCESS, "INVALID_ACCESS" }, \ { NFS_INO_INVALID_ACL, "INVALID_ACL" }, \ { NFS_INO_REVAL_PAGECACHE, "REVAL_PAGECACHE" }, \ { NFS_INO_REVAL_FORCED, "REVAL_FORCED" }, \ - { NFS_INO_INVALID_LABEL, "INVALID_LABEL" }) + { NFS_INO_INVALID_LABEL, "INVALID_LABEL" }, \ + { NFS_INO_INVALID_CHANGE, "INVALID_CHANGE" }, \ + { NFS_INO_INVALID_CTIME, "INVALID_CTIME" }, \ + { NFS_INO_INVALID_MTIME, "INVALID_MTIME" }, \ + { NFS_INO_INVALID_SIZE, "INVALID_SIZE" }, \ + { NFS_INO_INVALID_OTHER, "INVALID_OTHER" }) #define nfs_show_nfsi_flags(v) \ __print_flags(v, "|", \ From patchwork Tue Jun 11 18:25:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10988119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28AF718A6 for ; Tue, 11 Jun 2019 18:27:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1965A28716 for ; Tue, 11 Jun 2019 18:27:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DC2C28718; Tue, 11 Jun 2019 18:27:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UPPERCASE_50_75 autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B67412871E for ; Tue, 11 Jun 2019 18:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407079AbfFKS1W (ORCPT ); Tue, 11 Jun 2019 14:27:22 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:39263 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406804AbfFKS1V (ORCPT ); Tue, 11 Jun 2019 14:27:21 -0400 Received: by mail-it1-f193.google.com with SMTP id j204so6372518ite.4 for ; Tue, 11 Jun 2019 11:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ALlSwKx47PAkBIuYQSOTzntZen30W3HZ6oSQbt2Hs0Y=; b=vJmZC+A0DvBXo8NM8NL0VGpP73wGutKis6toCbH/hX4cYZRGmgOAb2PFOaSf8aFVYz i4irkifRtWcRoRQGmf7g7do2ivBpwms/gKGLYhVRN/txdEWaejHizhoM98lccCf6/t1J hPRAGTSKA0DJYu8rKEXrI6rktuYRQPsqR/pIiMByZbHAYKC1a2IpAtD5Pxag+HvGk3gl QSk6CYae/zDsgZI5X1t/b4WwhKz+PZCa7yeXWX/3vnZetBzctt+6FI/fqNeWPu39bU9h 2dHo0xvWVSSkkyuUVPdZJCPRnpk/EoONKvwqtd8DqXz4K3IfDVuwc72ev3DmHhDfSXBo L69g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ALlSwKx47PAkBIuYQSOTzntZen30W3HZ6oSQbt2Hs0Y=; b=F5gw1MB9S5euDqIpDJKrcuD8pdugG9R+jKyrjwLVdKnEhy0iHVV6JOaSj4EJuK/jUq ZZKRy08w1R/YDx4Q3+OgqJzVWHNeMBHE7qSen61uzIeQWj7BymOdzpLW6Hdc/qwzGMqG YAZKbR9l1U2duktUp31u2XArRHM5a7m6EiVr0pl2rnGuU+8uJ/X/Z1QYkMTH4vA6YOuZ bCEmmhw4Z0NdQnFYaaZUvkTX7+E18g6FfKKSKIjI6r72ms+qxkhWK2kJ0Zmpzt5BtRTE ljy7q0PUcyeI0pV/TD3EMLKOyPKrJ4Mt61mODWyVqa1rLQdPN/JKpl5v8zT7csBbNeVF jJIQ== X-Gm-Message-State: APjAAAV6vWCEM1M1LJY8MV5gobyT2qhRgEdR08UnlCRRwrJ0LTyOJAZU FWtcLaXWf5W+kvyegxXErVi1mPA= X-Google-Smtp-Source: APXvYqymk3nga7qAtGhqeaM0okbkud8FYLlRUD3RtLG18fWDP2YukiuK5O/gsmbCCvoiUvUcGpmwSg== X-Received: by 2002:a24:ee47:: with SMTP id b68mr18514017iti.36.1560277640501; Tue, 11 Jun 2019 11:27:20 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id q9sm4789830iot.80.2019.06.11.11.27.19 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 11 Jun 2019 11:27:20 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 2/3] NFS: Fix up ftrace logging of nfs_inode flags Date: Tue, 11 Jun 2019 14:25:10 -0400 Message-Id: <20190611182511.120074-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190611182511.120074-2-trond.myklebust@hammerspace.com> References: <20190611182511.120074-1-trond.myklebust@hammerspace.com> <20190611182511.120074-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Also print out the layoutstats and O_DIRECT flag settings. Signed-off-by: Trond Myklebust --- fs/nfs/nfstrace.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h index c40aad6ef3ff..864ae1c11bd2 100644 --- a/fs/nfs/nfstrace.h +++ b/fs/nfs/nfstrace.h @@ -40,12 +40,14 @@ #define nfs_show_nfsi_flags(v) \ __print_flags(v, "|", \ - { 1 << NFS_INO_ADVISE_RDPLUS, "ADVISE_RDPLUS" }, \ - { 1 << NFS_INO_STALE, "STALE" }, \ - { 1 << NFS_INO_INVALIDATING, "INVALIDATING" }, \ - { 1 << NFS_INO_FSCACHE, "FSCACHE" }, \ - { 1 << NFS_INO_LAYOUTCOMMIT, "NEED_LAYOUTCOMMIT" }, \ - { 1 << NFS_INO_LAYOUTCOMMITTING, "LAYOUTCOMMIT" }) + { BIT(NFS_INO_ADVISE_RDPLUS), "ADVISE_RDPLUS" }, \ + { BIT(NFS_INO_STALE), "STALE" }, \ + { BIT(NFS_INO_INVALIDATING), "INVALIDATING" }, \ + { BIT(NFS_INO_FSCACHE), "FSCACHE" }, \ + { BIT(NFS_INO_LAYOUTCOMMIT), "NEED_LAYOUTCOMMIT" }, \ + { BIT(NFS_INO_LAYOUTCOMMITTING), "LAYOUTCOMMIT" }, \ + { BIT(NFS_INO_LAYOUTSTATS), "LAYOUTSTATS" }, \ + { BIT(NFS_INO_ODIRECT), "O_DIRECT" }) DECLARE_EVENT_CLASS(nfs_inode_event, TP_PROTO( From patchwork Tue Jun 11 18:25:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10988121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB6881398 for ; Tue, 11 Jun 2019 18:27:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D7C128716 for ; Tue, 11 Jun 2019 18:27:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91D8E28718; Tue, 11 Jun 2019 18:27:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 266022871E for ; Tue, 11 Jun 2019 18:27:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406910AbfFKS1X (ORCPT ); Tue, 11 Jun 2019 14:27:23 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:43423 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407075AbfFKS1W (ORCPT ); Tue, 11 Jun 2019 14:27:22 -0400 Received: by mail-io1-f68.google.com with SMTP id k20so10722465ios.10 for ; Tue, 11 Jun 2019 11:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=jnJfHc433JUSUzdy8Ofjg6zHCGsQ8SqWzcQXIx3do5w=; b=eRwLQJXQzdkCU51LKCNwMQnzonBP8SwvHza0WXfQy8qqamkz0P3IJoom4wDGjnAYtr cxLINz8cyICSyuo5HF8DkpGBSNAzWGZDStf19/I9FW8GXvX/1FmXzaIv8ZIl7Wr44M1b y4uWvtlJFfWNGQMykMTUvKZmu99CSadhUrUTAKkVK6HiaaKHTvFmp8OL4OdCrw6xAHMv Un8altPCGvNSofjt3t7VeIQpoeCPq6hx0pUzxtStDJ131RVCfQyE4V5ldBsQuN/XPYl7 DSR/vmONBKuzVyCUuQKPaph+tpBW+/eAMT9vJhbyvTqxjVxAtpunE0yGfGz6DFE6N8XA ba8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jnJfHc433JUSUzdy8Ofjg6zHCGsQ8SqWzcQXIx3do5w=; b=pwMYhJ5iqYeQZtNhZa4VVGNGJzx5gOvg18G1MUhhNI01GXopxBoByIezVVvvehkbRg V4uQKgh4daZxJ5FN6pa/XP/ql7sBqnLsuaAQGO1krA17mZd63aSRM9QMFZOTdUYjbiJZ cHTHax9GAp56j1mgD3f10n1/lAdeCqn4POQhKBHz/3b7x4gJxHBfpsX08YnLjz4Fz6aA 4o5DrU2ByXOorh+4w6KTSaNN0wyz9rZ/aiFFFNG62p8EPmN9soC++e00gAvTixJuB1u0 8H1OjnwmSPxo4SROinmnHR+4wD5aStQ5++QPMW9P0QAekr1B7AVYaEVuDamUgz1rFA0O DwfQ== X-Gm-Message-State: APjAAAV6Qbauod2T/oq5lQEdpCwUKpLp8fgpV5O3k6MsoSTG3MmA/tS7 CoENRUUwxM9bgqcB7K2NIURbgXo= X-Google-Smtp-Source: APXvYqxsZ44plEpzqV0ik1yPtYLjbJ4ZQTu6oc2I74ZlIpJQXfgLmIDx8aedwFdQQjfLwM/ZiLN95Q== X-Received: by 2002:a6b:8b51:: with SMTP id n78mr51314530iod.192.1560277641128; Tue, 11 Jun 2019 11:27:21 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id q9sm4789830iot.80.2019.06.11.11.27.20 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 11 Jun 2019 11:27:20 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 3/3] NFS: Add deferred cache invalidation for close-to-open consistency violations Date: Tue, 11 Jun 2019 14:25:11 -0400 Message-Id: <20190611182511.120074-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190611182511.120074-3-trond.myklebust@hammerspace.com> References: <20190611182511.120074-1-trond.myklebust@hammerspace.com> <20190611182511.120074-2-trond.myklebust@hammerspace.com> <20190611182511.120074-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the client detects that close-to-open cache consistency has been violated, and that the file or directory has been changed on the server, then do a cache invalidation when we're done working with the file. The reason we don't do an immediate cache invalidation is that we want to avoid performance problems due to false positives. Also, note that we cannot guarantee cache consistency in this situation even if we do invalidate the cache. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 4 ++++ fs/nfs/inode.c | 15 +++++++++++---- include/linux/nfs_fs.h | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 57b6a45576ad..bd1f9555447b 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -80,6 +80,10 @@ static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir ctx->dup_cookie = 0; ctx->cred = get_cred(cred); spin_lock(&dir->i_lock); + if (list_empty(&nfsi->open_files) && + (nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER)) + nfsi->cache_validity |= NFS_INO_INVALID_DATA | + NFS_INO_REVAL_FORCED; list_add(&ctx->list, &nfsi->open_files); spin_unlock(&dir->i_lock); return ctx; diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 0b4a1a974411..8274d021d46a 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -208,7 +208,7 @@ static void nfs_set_cache_invalid(struct inode *inode, unsigned long flags) } if (inode->i_mapping->nrpages == 0) - flags &= ~NFS_INO_INVALID_DATA; + flags &= ~(NFS_INO_INVALID_DATA|NFS_INO_DATA_INVAL_DEFER); nfsi->cache_validity |= flags; if (flags & NFS_INO_INVALID_DATA) nfs_fscache_invalidate(inode); @@ -652,7 +652,8 @@ static int nfs_vmtruncate(struct inode * inode, loff_t offset) i_size_write(inode, offset); /* Optimisation */ if (offset == 0) - NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_DATA; + NFS_I(inode)->cache_validity &= ~(NFS_INO_INVALID_DATA | + NFS_INO_DATA_INVAL_DEFER); NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_SIZE; spin_unlock(&inode->i_lock); @@ -1032,6 +1033,10 @@ void nfs_inode_attach_open_context(struct nfs_open_context *ctx) struct nfs_inode *nfsi = NFS_I(inode); spin_lock(&inode->i_lock); + if (list_empty(&nfsi->open_files) && + (nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER)) + nfsi->cache_validity |= NFS_INO_INVALID_DATA | + NFS_INO_REVAL_FORCED; list_add_tail_rcu(&ctx->list, &nfsi->open_files); spin_unlock(&inode->i_lock); } @@ -1312,7 +1317,8 @@ int nfs_revalidate_mapping(struct inode *inode, set_bit(NFS_INO_INVALIDATING, bitlock); smp_wmb(); - nfsi->cache_validity &= ~NFS_INO_INVALID_DATA; + nfsi->cache_validity &= ~(NFS_INO_INVALID_DATA| + NFS_INO_DATA_INVAL_DEFER); spin_unlock(&inode->i_lock); trace_nfs_invalidate_mapping_enter(inode); ret = nfs_invalidate_mapping(inode, mapping); @@ -1870,7 +1876,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) dprintk("NFS: change_attr change on server for file %s/%ld\n", inode->i_sb->s_id, inode->i_ino); - } + } else if (!have_delegation) + nfsi->cache_validity |= NFS_INO_DATA_INVAL_DEFER; inode_set_iversion_raw(inode, fattr->change_attr); attr_changed = true; } diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index d363d5765cdf..0a11712a80e3 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -223,6 +223,8 @@ struct nfs4_copy_state { #define NFS_INO_INVALID_MTIME BIT(10) /* cached mtime is invalid */ #define NFS_INO_INVALID_SIZE BIT(11) /* cached size is invalid */ #define NFS_INO_INVALID_OTHER BIT(12) /* other attrs are invalid */ +#define NFS_INO_DATA_INVAL_DEFER \ + BIT(13) /* Deferred cache invalidation */ #define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \ | NFS_INO_INVALID_CTIME \