From c74dfe97c104bda5144bfa8193d8e5ea67d5da7f Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Mon, 6 Jan 2020 15:39:37 -0500 Subject: NFS: Add mount option 'softreval' Add a mount option 'softreval' that allows attribute revalidation 'getattr' calls to time out, and causes them to fall back to using the cached attributes. The use case for this option is for ensuring that we can still (slowly) traverse paths and use cached information even when the server is down. Once the server comes back up again, the getattr calls start succeeding, and the caches will revalidate as usual. The 'softreval' mount option is automatically enabled if you have specified 'softerr'. It can be turned off using the options 'nosoftreval', or 'hard'. Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker --- fs/nfs/fs_context.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'fs/nfs/fs_context.c') diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 429315c011ae..0247dcb7b316 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -73,6 +73,7 @@ enum nfs_param { Opt_sloppy, Opt_soft, Opt_softerr, + Opt_softreval, Opt_source, Opt_tcp, Opt_timeo, @@ -128,6 +129,7 @@ static const struct fs_parameter_spec nfs_param_specs[] = { fsparam_flag ("sloppy", Opt_sloppy), fsparam_flag ("soft", Opt_soft), fsparam_flag ("softerr", Opt_softerr), + fsparam_flag ("softreval", Opt_softreval), fsparam_string("source", Opt_source), fsparam_flag ("tcp", Opt_tcp), fsparam_u32 ("timeo", Opt_timeo), @@ -460,11 +462,19 @@ static int nfs_fs_context_parse_param(struct fs_context *fc, ctx->flags &= ~NFS_MOUNT_SOFTERR; break; case Opt_softerr: - ctx->flags |= NFS_MOUNT_SOFTERR; + ctx->flags |= NFS_MOUNT_SOFTERR | NFS_MOUNT_SOFTREVAL; ctx->flags &= ~NFS_MOUNT_SOFT; break; case Opt_hard: - ctx->flags &= ~(NFS_MOUNT_SOFT|NFS_MOUNT_SOFTERR); + ctx->flags &= ~(NFS_MOUNT_SOFT | + NFS_MOUNT_SOFTERR | + NFS_MOUNT_SOFTREVAL); + break; + case Opt_softreval: + if (result.negated) + ctx->flags &= ~NFS_MOUNT_SOFTREVAL; + else + ctx->flags &= NFS_MOUNT_SOFTREVAL; break; case Opt_posix: if (result.negated) -- cgit v1.2.3-59-g8ed1b