[ Upstream commit dea1bb35c5f35e0577cfc61f79261d80b8715221 ]
People are reporing seeing fscache errors being reported concerning
duplicate cookies even in cases where they are not setting up fscache
at all. The rule needs to be that if fscache is not enabled, then it
should have no side effects at all.
To ensure this is the case, we disable fscache completely on all superblocks
for which the 'fsc' mount option was not set. In order to avoid issues
with '-oremount', we also disable the ability to turn fscache on via
remount.
Fixes: f1fe29b4a02d ("NFS: Use i_writecount to control whether...")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=200145
Signed-off-by: Trond Myklebust <[email protected]>
Cc: Steve Dickson <[email protected]>
Cc: David Howells <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
fs/nfs/fscache.c | 7 ++++++-
fs/nfs/fscache.h | 2 +-
fs/nfs/super.c | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c
index 4dc887813c71d..a7bc4e0494f92 100644
--- a/fs/nfs/fscache.c
+++ b/fs/nfs/fscache.c
@@ -118,6 +118,10 @@ void nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq, int
struct rb_node **p, *parent;
int diff;
+ nfss->fscache_key = NULL;
+ nfss->fscache = NULL;
+ if (!(nfss->options & NFS_OPTION_FSCACHE))
+ return;
if (!uniq) {
uniq = "";
ulen = 1;
@@ -230,10 +234,11 @@ void nfs_fscache_release_super_cookie(struct super_block *sb)
void nfs_fscache_init_inode(struct inode *inode)
{
struct nfs_fscache_inode_auxdata auxdata;
+ struct nfs_server *nfss = NFS_SERVER(inode);
struct nfs_inode *nfsi = NFS_I(inode);
nfsi->fscache = NULL;
- if (!S_ISREG(inode->i_mode))
+ if (!(nfss->fscache && S_ISREG(inode->i_mode)))
return;
memset(&auxdata, 0, sizeof(auxdata));
diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h
index 161ba2edb9d04..6363ea9568581 100644
--- a/fs/nfs/fscache.h
+++ b/fs/nfs/fscache.h
@@ -186,7 +186,7 @@ static inline void nfs_fscache_wait_on_invalidate(struct inode *inode)
*/
static inline const char *nfs_server_fscache_state(struct nfs_server *server)
{
- if (server->fscache && (server->options & NFS_OPTION_FSCACHE))
+ if (server->fscache)
return "yes";
return "no ";
}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 6df9b85caf205..d90efdea9fbd6 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2239,6 +2239,7 @@ nfs_compare_remount_data(struct nfs_server *nfss,
data->acdirmin != nfss->acdirmin / HZ ||
data->acdirmax != nfss->acdirmax / HZ ||
data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) ||
+ (data->options & NFS_OPTION_FSCACHE) != (nfss->options & NFS_OPTION_FSCACHE) ||
data->nfs_server.port != nfss->port ||
data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
!rpc_cmp_addr((struct sockaddr *)&data->nfs_server.address,
--
2.20.1
On Tue 2019-08-27 09:50:14, Greg Kroah-Hartman wrote:
> [ Upstream commit dea1bb35c5f35e0577cfc61f79261d80b8715221 ]
>
> People are reporing seeing fscache errors being reported concerning
> duplicate cookies even in cases where they are not setting up fscache
> at all. The rule needs to be that if fscache is not enabled, then it
> should have no side effects at all.
>
> To ensure this is the case, we disable fscache completely on all superblocks
> for which the 'fsc' mount option was not set. In order to avoid issues
> with '-oremount', we also disable the ability to turn fscache on via
> remount.
Actually, the code seems to suggest that you disable the ability to
turn fscache _off_ via remount, too.
Is that intentional?
Best regards,
Pavel
> @@ -2239,6 +2239,7 @@ nfs_compare_remount_data(struct nfs_server *nfss,
> data->acdirmin != nfss->acdirmin / HZ ||
> data->acdirmax != nfss->acdirmax / HZ ||
> data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) ||
> + (data->options & NFS_OPTION_FSCACHE) != (nfss->options & NFS_OPTION_FSCACHE) ||
> data->nfs_server.port != nfss->port ||
> data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
> !rpc_cmp_addr((struct sockaddr *)&data->nfs_server.address,
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
On Wed, 2019-08-28 at 09:11 +0200, Pavel Machek wrote:
> On Tue 2019-08-27 09:50:14, Greg Kroah-Hartman wrote:
> > [ Upstream commit dea1bb35c5f35e0577cfc61f79261d80b8715221 ]
> >
> > People are reporing seeing fscache errors being reported concerning
> > duplicate cookies even in cases where they are not setting up
> > fscache
> > at all. The rule needs to be that if fscache is not enabled, then
> > it
> > should have no side effects at all.
> >
> > To ensure this is the case, we disable fscache completely on all
> > superblocks
> > for which the 'fsc' mount option was not set. In order to avoid
> > issues
> > with '-oremount', we also disable the ability to turn fscache on
> > via
> > remount.
>
> Actually, the code seems to suggest that you disable the ability to
> turn fscache _off_ via remount, too.
>
> Is that intentional?
>
Yes. That is intentional. Otherwise we would have to clear all the
fscache cookies from the inodes.
> Best regards,
> Pavel
>
> > @@ -2239,6 +2239,7 @@ nfs_compare_remount_data(struct nfs_server
> > *nfss,
> > data->acdirmin != nfss->acdirmin / HZ ||
> > data->acdirmax != nfss->acdirmax / HZ ||
> > data->timeo != (10U * nfss->client->cl_timeout->to_initval
> > / HZ) ||
> > + (data->options & NFS_OPTION_FSCACHE) != (nfss->options &
> > NFS_OPTION_FSCACHE) ||
> > data->nfs_server.port != nfss->port ||
> > data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
> > !rpc_cmp_addr((struct sockaddr *)&data->nfs_server.address,
--
Trond Myklebust
CTO, Hammerspace Inc
4300 El Camino Real, Suite 105
Los Altos, CA 94022
http://www.hammer.space