Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFS: nfs_find_open_context() may only select open files

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]

+5
+4
fs/nfs/inode.c
··· 1101 1101 void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx) 1102 1102 { 1103 1103 filp->private_data = get_nfs_open_context(ctx); 1104 + set_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags); 1104 1105 if (list_empty(&ctx->list)) 1105 1106 nfs_inode_attach_open_context(ctx); 1106 1107 } ··· 1121 1120 continue; 1122 1121 if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode) 1123 1122 continue; 1123 + if (!test_bit(NFS_CONTEXT_FILE_OPEN, &pos->flags)) 1124 + continue; 1124 1125 ctx = get_nfs_open_context(pos); 1125 1126 if (ctx) 1126 1127 break; ··· 1138 1135 if (ctx) { 1139 1136 struct inode *inode = d_inode(ctx->dentry); 1140 1137 1138 + clear_bit(NFS_CONTEXT_FILE_OPEN, &ctx->flags); 1141 1139 /* 1142 1140 * We fatal error on write before. Try to writeback 1143 1141 * every page again.
+1
include/linux/nfs_fs.h
··· 84 84 #define NFS_CONTEXT_RESEND_WRITES (1) 85 85 #define NFS_CONTEXT_BAD (2) 86 86 #define NFS_CONTEXT_UNLOCK (3) 87 + #define NFS_CONTEXT_FILE_OPEN (4) 87 88 int error; 88 89 89 90 struct list_head list;