Skip to contentSkip to conversation

cifs: openat with O_TMPFILE returns -1 ENOENT (STATUS_OBJECT_NAME_NOT_FOUND)

REGRESSION Mikhail Stefantsev 2 participants 3 messages Aug 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hello,

I have run into a kernel regression where openat() with O_TMPFILE fails with ENOENT on CIFS/SMB3 mounts, breaking atomic file saving in applications like Krita. According to the open() manual page, the ENOENT error is supposed to be returned when the path (a target directory in this case) does not exist, while a lack of support of O_TMPFILE by the target file system should be indicated by EOPNOTSUPP. Applications receiving ENOENT wrongly assume that the parent directory of an unnamed temporary file is itself missing or inaccessible, aborting the save process.

Downstream bug report: https://bugzilla.redhat.com/show_bug.cgi?id=2499750

[REGRESSION DETAILS]
- Broken in: v7.1.3-200.fc44.x86_64 / upstream v7.2.0-rc2
- Servers: Synology (Samba 4.15.13), Windows 11 Pro (25H2)

[STRACE EVIDENCE]
openat(AT_FDCWD, "/mnt/vault/home/Drive/Sketchbook/Studies/6.07.26.kra", O_RDONLY|O_CLOEXEC) = 37 openat(AT_FDCWD, "/mnt/vault/home/Drive/Sketchbook/Studies", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = -1 ENOENT (No such file or directory)

[DETAILED LOGS]

[  106.251673] CIFS: fs/smb/client/dir.c: VFS: in cifs_tmpfile as Xid: 2886 with uid: 1000
[  106.252152] CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
[  106.252154] CIFS: fs/smb/client/smb2maperror.c: Mapping SMB2 status code 0xc0000034 to POSIX err -2
[  106.252157] CIFS: fs/smb/client/dir.c: cifs_create returned 0xfffffffe
[  106.252159] CIFS: fs/smb/client/dir.c: VFS: leaving cifs_tmpfile (xid = 2886) rc = -2

[MOUNT OPTIONS]
//vault/home on /mnt/vault/home type cifs (rw,relatime,vers=3.1.1,cache=strict,upcall_target=app,username=MStefan99,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0755,dir_mode=0755,iocharset=utf8,soft,nounix,serverino,mapposix,reparse=nfs,nativesocket,symlink=native,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1,closetimeo=1,_netdev)

Please let me know if you need any additional information.

Regards,
Mikhail

reviewer
#1 lore raw

Hi Mikhail,

I have submitted a fix patch, please test it and check whether it fixes the issue you encountered:
https://lore.kernel.org/linux-cifs/[email protected]/

Quoted 30 lines · Mikhail Stefantsev

Hello,

I have run into a kernel regression where openat() with O_TMPFILE fails with ENOENT on CIFS/SMB3 mounts, breaking atomic file saving in applications like Krita. According to the open() manual page, the ENOENT error is supposed to be returned when the path (a target directory in this case) does not exist, while a lack of support of O_TMPFILE by the target file system should be indicated by EOPNOTSUPP. Applications receiving ENOENT wrongly assume that the parent directory of an unnamed temporary file is itself missing or inaccessible, aborting the save process.

Downstream bug report: https://bugzilla.redhat.com/show_bug.cgi?id=2499750

[REGRESSION DETAILS]
- Broken in: v7.1.3-200.fc44.x86_64 / upstream v7.2.0-rc2
- Servers: Synology (Samba 4.15.13), Windows 11 Pro (25H2)

[STRACE EVIDENCE]
openat(AT_FDCWD, "/mnt/vault/home/Drive/Sketchbook/Studies/6.07.26.kra", O_RDONLY|O_CLOEXEC) = 37 openat(AT_FDCWD, "/mnt/vault/home/Drive/Sketchbook/Studies", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = -1 ENOENT (No such file or directory)

[DETAILED LOGS]

[  106.251673] CIFS: fs/smb/client/dir.c: VFS: in cifs_tmpfile as Xid: 2886 with uid: 1000
[  106.252152] CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
[  106.252154] CIFS: fs/smb/client/smb2maperror.c: Mapping SMB2 status code 0xc0000034 to POSIX err -2
[  106.252157] CIFS: fs/smb/client/dir.c: cifs_create returned 0xfffffffe
[  106.252159] CIFS: fs/smb/client/dir.c: VFS: leaving cifs_tmpfile (xid = 2886) rc = -2

[MOUNT OPTIONS]
//vault/home on /mnt/vault/home type cifs (rw,relatime,vers=3.1.1,cache=strict,upcall_target=app,username=MStefan99,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0755,dir_mode=0755,iocharset=utf8,soft,nounix,serverino,mapposix,reparse=nfs,nativesocket,symlink=native,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1,closetimeo=1,_netdev)

Please let me know if you need any additional information.

Regards,
Mikhail

Signature · 3 lines
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
#2 lore raw

Hi ChenXiaoSong,

I have tested the patch, it works on my machine. EOPNOTSUPP is returned and apps fall back to saving without relying on O_TMPFILE.

Thank you
Regards, Mikhail

Quoted 42 lines · ChenXiaoSong

Hi Mikhail,

I have submitted a fix patch, please test it and check whether it fixes the issue you encountered:
https://lore.kernel.org/linux-cifs/[email protected]/

Quoted 30 lines · Mikhail Stefantsev

Hello,

I have run into a kernel regression where openat() with O_TMPFILE fails with ENOENT on CIFS/SMB3 mounts, breaking atomic file saving in applications like Krita. According to the open() manual page, the ENOENT error is supposed to be returned when the path (a target directory in this case) does not exist, while a lack of support of O_TMPFILE by the target file system should be indicated by EOPNOTSUPP. Applications receiving ENOENT wrongly assume that the parent directory of an unnamed temporary file is itself missing or inaccessible, aborting the save process.

Downstream bug report: https://bugzilla.redhat.com/show_bug.cgi?id=2499750

[REGRESSION DETAILS]
- Broken in: v7.1.3-200.fc44.x86_64 / upstream v7.2.0-rc2
- Servers: Synology (Samba 4.15.13), Windows 11 Pro (25H2)

[STRACE EVIDENCE]
openat(AT_FDCWD, "/mnt/vault/home/Drive/Sketchbook/Studies/6.07.26.kra", O_RDONLY|O_CLOEXEC) = 37 openat(AT_FDCWD, "/mnt/vault/home/Drive/Sketchbook/Studies", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = -1 ENOENT (No such file or directory)

[DETAILED LOGS]

[  106.251673] CIFS: fs/smb/client/dir.c: VFS: in cifs_tmpfile as Xid: 2886 with uid: 1000
[  106.252152] CIFS: Status code returned 0xc0000034 STATUS_OBJECT_NAME_NOT_FOUND
[  106.252154] CIFS: fs/smb/client/smb2maperror.c: Mapping SMB2 status code 0xc0000034 to POSIX err -2
[  106.252157] CIFS: fs/smb/client/dir.c: cifs_create returned 0xfffffffe
[  106.252159] CIFS: fs/smb/client/dir.c: VFS: leaving cifs_tmpfile (xid = 2886) rc = -2

[MOUNT OPTIONS]
//vault/home on /mnt/vault/home type cifs (rw,relatime,vers=3.1.1,cache=strict,upcall_target=app,username=MStefan99,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.1.10,file_mode=0755,dir_mode=0755,iocharset=utf8,soft,nounix,serverino,mapposix,reparse=nfs,nativesocket,symlink=native,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1,closetimeo=1,_netdev)

Please let me know if you need any additional information.

Regards,
Mikhail

Signature · 3 lines
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en