From: NeilBrown Now that we have the -EFTYPE error code, we can return it from ->open_context when the server returns NFS4ERR_WRONG_TYPE. This can be directly returned when __O_REGULAR is in effect, or can trigger a lookup and finish_no_open(). Also don't over-ride the err code when __O_REGULAR is in effect - nfsd wants the see the original error, and VFS code will map when needed. Finally don't consult __O_REGULAR for -ENOTDIR. It isn't clear what that means and is safest to leave the original handling. Signed-off-by: NeilBrown --- fs/nfs/dir.c | 8 ++++---- fs/nfs_common/common.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 49394123bd09..11bcc922198e 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2191,11 +2191,11 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, d_splice_alias(NULL, dentry); break; case -EISDIR: - case -ENOTDIR: - if (open_flags & __O_REGULAR) { - err = -EFTYPE; + case -EFTYPE: + if (open_flags & __O_REGULAR) break; - } + goto no_open; + case -ENOTDIR: goto no_open; case -ELOOP: if (!(open_flags & O_NOFOLLOW)) diff --git a/fs/nfs_common/common.c b/fs/nfs_common/common.c index 0778743ae2c2..24add750c8d5 100644 --- a/fs/nfs_common/common.c +++ b/fs/nfs_common/common.c @@ -102,6 +102,7 @@ static const struct { { NFS4ERR_BADTYPE, -EBADTYPE }, { NFS4ERR_SYMLINK, -ELOOP }, { NFS4ERR_DEADLOCK, -EDEADLK }, + { NFS4ERR_WRONG_TYPE, -EFTYPE }, }; static const struct { -- 2.50.0.107.gf914562f5916.dirty