Skip to content

Commit 85d2c23

Browse files
Trond MyklebustAnna Schumaker
authored andcommitted
NFSv2/v3: Fix error handling in nfs_atomic_open_v23()
When nfs_do_create() returns an EEXIST error, it means that a regular file could not be created. That could mean that a symlink needs to be resolved. If that's the case, a lookup needs to be kicked off. Reported-by: Stephen Abbene <[email protected]> Link: https://bugzilla.kernel.org/show_bug.cgi?id=220710 Fixes: 7c6c524 ("NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly.") Signed-off-by: Trond Myklebust <[email protected]> Reviewed-by: NeilBrown <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 6a218b9 commit 85d2c23

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/nfs/dir.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,11 +2268,12 @@ int nfs_atomic_open_v23(struct inode *dir, struct dentry *dentry,
22682268
return -ENAMETOOLONG;
22692269

22702270
if (open_flags & O_CREAT) {
2271-
file->f_mode |= FMODE_CREATED;
22722271
error = nfs_do_create(dir, dentry, mode, open_flags);
2273-
if (error)
2272+
if (!error) {
2273+
file->f_mode |= FMODE_CREATED;
2274+
return finish_open(file, dentry, NULL);
2275+
} else if (error != -EEXIST || open_flags & O_EXCL)
22742276
return error;
2275-
return finish_open(file, dentry, NULL);
22762277
}
22772278
if (d_in_lookup(dentry)) {
22782279
/* The only flags nfs_lookup considers are

0 commit comments

Comments
 (0)