Bug 14389 - Bad file descriptor with io_uring:sqpoll = yes
Summary: Bad file descriptor with io_uring:sqpoll = yes
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 4.12.3
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-20 12:54 UTC by yannick
Modified: 2020-05-20 13:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yannick 2020-05-20 12:54:08 UTC
Hi,

Since updating to Samba 4.12.3 we are unable to open any file if "io_uring:sqpoll = yes" is set in smb.conf.

Our setup:

- Debian 10 (Buster) with Linux 5.4 from backports running on VMWare ESXi
- Samba 4.12.3 stable release
- - configured with: ./configure --enable-fhs --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-systemd --systemd-install-services
- liburing v0.6
- Windows 10 File Explorer as client (GNOME's Nautilus as client does the same though)

We use Samba to re-share NFS mounts. NFS is mounted with the following options:

xxx.xxx.xxx.xxx:/xxx/datapool/      /mnt/storagepod/datapool         nfs     rw,nfsvers=3,noacl,noatime,async,tcp,nolock,rsize=1048576,wsize=1048576,x-systemd.automount   0       0

Our share in smb.conf looks like this:

[datapool]
  comment = Data Pool
  read only = yes
  write list = xxx
  valid users = xxx
  public = no
  path = /mnt/storagepod/datapool
  create mask = 0775
  directory mask = 0775
  oplocks = yes

We use these options:

  kernel change notify = yes
  kernel oplocks = yes
  vfs objects = io_uring
  io_uring:sqpoll = yes
  log level = 3

How to reproduce:

1. Open the network share
2. Browse to a file (I tested this with a batch file)
3. Try to edit it (right mouse button -> edit)
4. Error appears:

"Cannot open the Z:\path\to\file.bat file.

Make sure a disk is in the drive you specified."

In the log.<hostname> file the following appears (this is when trying to open a file with Windows 10's File Explorer):

[2020/05/20 14:47:41.766235,  2] ../../source3/smbd/open.c:1458(open_file)
  xxx opened file path/to/file.bat read=Yes write=No (numopen=6)
[2020/05/20 14:47:41.766424,  3] ../../source3/smbd/oplock_linux.c:151(linux_set_kernel_oplock)
  linux_set_kernel_oplock: Refused oplock on file path/to/file.bat, fd = 14, file_id = 67:96683:0. (Invalid argument)
[2020/05/20 14:47:41.774357,  3] ../../source3/lib/util.c:1083(fcntl_getlock)
  fcntl_getlock: fd 14 is returned info 2 pid 0
[2020/05/20 14:47:41.774605,  3] ../../source3/smbd/smb2_read.c:396(smb2_read_complete)
  smb2_read_complete: file path/to/file.bat nread = -1. Error = Bad file descriptor (NTSTATUS NT_STATUS_INVALID_HANDLE)
[2020/05/20 14:47:41.774716,  3] ../../source3/smbd/smb2_server.c:3266(smbd_smb2_request_error_ex)
  smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_INVALID_HANDLE] || at ../../source3/smbd/smb2_read.c:133
[2020/05/20 14:47:41.788221,  3] ../../source3/lib/util.c:1083(fcntl_getlock)
  fcntl_getlock: fd 14 is returned info 2 pid 0
[2020/05/20 14:47:41.788450,  3] ../../source3/smbd/smb2_read.c:396(smb2_read_complete)
  smb2_read_complete: file path/to/file.bat nread = -1. Error = Bad file descriptor (NTSTATUS NT_STATUS_INVALID_HANDLE)
[2020/05/20 14:47:41.788560,  3] ../../source3/smbd/smb2_server.c:3266(smbd_smb2_request_error_ex)
  smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_INVALID_HANDLE] || at ../../source3/smbd/smb2_read.c:133

How to workaround:

Change

  io_uring:sqpoll = yes

to

  io_uring:sqpoll = no

Extra notes:

I have tried the following to try and see if it fixes anything:

- Comment the oplock lines in smb.conf
- Open a file on a share that is not located on an NFS share (local disk)
Comment 1 Stefan Metzmacher 2020-05-20 13:50:40 UTC
(In reply to yannick from comment #0)

It seems the IORING_SETUP_SQPOLL feature only works together
with IOSQE_FIXED_FILE.

And Samba doesn't use IOSQE_FIXED_FILE.

Before 4.12.3 "io_uring:sqpoll" was implemented as "vfs_io_uring:sqpoll = yes",
so it was sadly never really tested.

Just use "io_uring:sqpoll = no" (or better remove the option)
for now.
Comment 2 yannick 2020-05-20 13:56:08 UTC
(In reply to Stefan Metzmacher from comment #1)
Hi Stefan,

Thanks for your swift reply! We'll keep sqpoll on no for now then. :)