提交 21cdc256 编写于 作者: T Trond Myklebust 提交者: Yang Yingliang

NFS: nfs_find_open_context() may only select open files

stable inclusion
from linux-4.19.198
commit e409580b19ec7923082e90c1ec9505aa0867f21d

--------------------------------

[ Upstream commit e97bc663 ]

If a file has already been closed, then it should not be selected to
support further I/O.
Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
[Trond: Fix an invalid pointer deref reported by Colin Ian King]
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 81d002fa
...@@ -1040,6 +1040,7 @@ EXPORT_SYMBOL_GPL(nfs_inode_attach_open_context); ...@@ -1040,6 +1040,7 @@ EXPORT_SYMBOL_GPL(nfs_inode_attach_open_context);
void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx) void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx)
{ {
filp->private_data = get_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)) if (list_empty(&ctx->list))
nfs_inode_attach_open_context(ctx); nfs_inode_attach_open_context(ctx);
} }
...@@ -1059,6 +1060,8 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_c ...@@ -1059,6 +1060,8 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_c
continue; continue;
if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode) if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode)
continue; continue;
if (!test_bit(NFS_CONTEXT_FILE_OPEN, &pos->flags))
continue;
ctx = get_nfs_open_context(pos); ctx = get_nfs_open_context(pos);
break; break;
} }
...@@ -1073,6 +1076,7 @@ void nfs_file_clear_open_context(struct file *filp) ...@@ -1073,6 +1076,7 @@ void nfs_file_clear_open_context(struct file *filp)
if (ctx) { if (ctx) {
struct inode *inode = d_inode(ctx->dentry); struct inode *inode = d_inode(ctx->dentry);
clear_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags);
/* /*
* We fatal error on write before. Try to writeback * We fatal error on write before. Try to writeback
* every page again. * every page again.
......
...@@ -78,6 +78,7 @@ struct nfs_open_context { ...@@ -78,6 +78,7 @@ struct nfs_open_context {
#define NFS_CONTEXT_RESEND_WRITES (1) #define NFS_CONTEXT_RESEND_WRITES (1)
#define NFS_CONTEXT_BAD (2) #define NFS_CONTEXT_BAD (2)
#define NFS_CONTEXT_UNLOCK (3) #define NFS_CONTEXT_UNLOCK (3)
#define NFS_CONTEXT_FILE_OPEN (4)
int error; int error;
struct list_head list; struct list_head list;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册