summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2021-05-11 23:41:10 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-20 16:16:11 +0200
commite409580b19ec7923082e90c1ec9505aa0867f21d (patch)
treefbd984149e6910abd00971dd3f10d4bd31f93f10 /fs
parent291ddd4e9c5352a4aace1dfb4f3100c743cd87c7 (diff)
downloadlinux-stable-e409580b19ec7923082e90c1ec9505aa0867f21d.tar.gz
linux-stable-e409580b19ec7923082e90c1ec9505aa0867f21d.tar.bz2
linux-stable-e409580b19ec7923082e90c1ec9505aa0867f21d.zip
NFS: nfs_find_open_context() may only select open files
[ Upstream commit e97bc66377bca097e1f3349ca18ca17f202ff659 ] If a file has already been closed, then it should not be selected to support further I/O. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> [Trond: Fix an invalid pointer deref reported by Colin Ian King] Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/inode.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index dc55ecc3bec4..2cdd8883b7c5 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1038,6 +1038,7 @@ EXPORT_SYMBOL_GPL(nfs_inode_attach_open_context);
void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx)
{
filp->private_data = get_nfs_open_context(ctx);
+ set_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
if (list_empty(&ctx->list))
nfs_inode_attach_open_context(ctx);
}
@@ -1057,6 +1058,8 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_c
continue;
if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode)
continue;
+ if (!test_bit(NFS_CONTEXT_FILE_OPEN, &pos->flags))
+ continue;
ctx = get_nfs_open_context(pos);
break;
}
@@ -1071,6 +1074,7 @@ void nfs_file_clear_open_context(struct file *filp)
if (ctx) {
struct inode *inode = d_inode(ctx->dentry);
+ clear_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
/*
* We fatal error on write before. Try to writeback
* every page again.