Score:0

Samba server not releasing record locks on network disconnection

jp flag

I was experimenting with a network file sharing scenario over SMB/samba. Record locks taken on a remote file remains valid, even after 1 hour of network disconnection. The following test case describes the set of activities done in chronological order:

->  A process (P1) on a windows client (C1) and another process (P2) on a Linux client (C2) are connected to 
    a common Linux server and accessing the same remote file.
->  Both P1 and P2 opens the remote file and gets a handle each.
->  P1 takes exclusive lock on offset 0.
->  P2 tries to take exclusive lock on offset 0 in a loop but does not get since P1 holds an exclusive 
    lock on the same offset.
->  Now, P1 is disconnected from remote file (C1 is disconnected from server).

Result: P2 does not get lock, returns ‘EACCES’ instantaneously, tried for around an hour.

The results were surprising, since in a Wi-Fi environment, where systems keep coming in and out, it can potentially stall the system.

OS specs of C1                  - Windows 10 Enterprise (version: 20H2, build: 19042.1237)
OS specs of C2                  - Ubuntu 20.04.3 LTS (GNU/Linux 5.13.0-1021-azure x86_64)
OS specs of Linux Server        - Ubuntu 20.04.1 LTS (GNU/Linux 5.13.0-37-generic x86_64)

Samba version on C2             - 4.13.17-Ubuntu                   Command used - smbststus
Samba version on Linux server   - 4.13.17-Ubuntu                   Command used - smbstatus
SMB version on C1               - SMBv2/v3                         Command used - sc.exe qc lanmanworkstation

Protocol version                - 3.1.1 (same on both connections) Command used - smbstatus

Is it possible to have a practical timeout on the server such that other clients will not have to wait for long to get exclusive locks? Any inputs would help.

These are the contents of smb config file in the Linux Server (name of share used - sambashare):

[global]
   workgroup = WORKGROUP
   server string = %h server (Samba, Ubuntu)
   log file = /var/log/samba/log.%m
   max log size = 1000
   logging = file
   panic action = /usr/share/samba/panic-action %d
   server role = standalone server
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n
*Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = bad user
   usershare allow guests = yes

[printers]
   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   create mask = 0700

[print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers

[sambashare]
    comment = Samba on Ubuntu
    path = /home/ubuntu/smb
    read only = no
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.