Skip to content

Commit 1751fc1

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
NFSv4: nfs_atomic_open() can race when looking up a non-regular file
If the file type changes back to being a regular file on the server between the failed OPEN and our LOOKUP, then we need to re-run the OPEN. Fixes: 0dd2b47 ("nfs: implement i_op->atomic_open()") Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent ac79516 commit 1751fc1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/nfs/dir.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,12 +1999,17 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
19991999
if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
20002000
!S_ISDIR(inode->i_mode))
20012001
res = ERR_PTR(-ENOTDIR);
2002+
else if (inode && S_ISREG(inode->i_mode))
2003+
res = ERR_PTR(-EOPENSTALE);
20022004
} else if (!IS_ERR(res)) {
20032005
inode = d_inode(res);
20042006
if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
20052007
!S_ISDIR(inode->i_mode)) {
20062008
dput(res);
20072009
res = ERR_PTR(-ENOTDIR);
2010+
} else if (inode && S_ISREG(inode->i_mode)) {
2011+
dput(res);
2012+
res = ERR_PTR(-EOPENSTALE);
20082013
}
20092014
}
20102015
if (switched) {

0 commit comments

Comments
 (0)