mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
NFSv4: nfs_atomic_open() can race when looking up a non-regular file
commit1751fc1db3
upstream. 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:0dd2b474d0
("nfs: implement i_op->atomic_open()") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0dfacee400
commit
4fd45ff2b4
1 changed files with 5 additions and 0 deletions
|
@ -1643,12 +1643,17 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
|
||||||
if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
|
if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
|
||||||
!S_ISDIR(inode->i_mode))
|
!S_ISDIR(inode->i_mode))
|
||||||
res = ERR_PTR(-ENOTDIR);
|
res = ERR_PTR(-ENOTDIR);
|
||||||
|
else if (inode && S_ISREG(inode->i_mode))
|
||||||
|
res = ERR_PTR(-EOPENSTALE);
|
||||||
} else if (!IS_ERR(res)) {
|
} else if (!IS_ERR(res)) {
|
||||||
inode = d_inode(res);
|
inode = d_inode(res);
|
||||||
if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
|
if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
|
||||||
!S_ISDIR(inode->i_mode)) {
|
!S_ISDIR(inode->i_mode)) {
|
||||||
dput(res);
|
dput(res);
|
||||||
res = ERR_PTR(-ENOTDIR);
|
res = ERR_PTR(-ENOTDIR);
|
||||||
|
} else if (inode && S_ISREG(inode->i_mode)) {
|
||||||
|
dput(res);
|
||||||
|
res = ERR_PTR(-EOPENSTALE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (switched) {
|
if (switched) {
|
||||||
|
|
Loading…
Reference in a new issue