2

My memory from working with different systems in the past is that the default behavior for many windows SMB clients writing to a Netapp share is that open files would automatically have a read lock on them. Other programs (like one running a backup) would get an error trying to read this open file.

Now someone has a workflow relying on this behavior and it doesn't seem to be true. I can either open a word doc or dd a file on a linux CIFS mount, and while it's open, I can read the whole thing from another CIFS client.

Assuming I haven't imagined this behavior, is there any way to recreate it? I've tried a netapp with and without SMB2 enabled and with and without oplocks enabled. I've tried filers with different versions of OnTap. I don't see any mount options on linux that would affect the behavior. None of these configurations give me a deny-read lock by default.

Goal: Allow clients to write to SMB share, but deny read access from other clients until the file is closed.

2
  • What version of ontap? Can you write to a file opened by another client?
    – Basil
    Commented Dec 29, 2016 at 22:14
  • 1
    Have tried 7.3.x, 8.1.x, 8.2.x, and 8.3.x. Doesn't seem OnTap related. The behavior is a collector process is picking up files in the middle of upload. This "didn't use to happen", presumably because the uploaded files were locked until complete.
    – BowlOfRed
    Commented Dec 29, 2016 at 22:15

2 Answers 2

2

From samba documentation:

Strictly speaking, an SMB server should check for locks before every read and write call on a file. Unfortunately, with the way fcntl() works, this can be slow and may overstress the rpc.lockd. This is almost always unnecessary because clients are independently supposed to make locking calls before reads and writes if locking is important to them. By default, Samba only makes locking calls when explicitly asked to by a client, but if you set strict locking = yes, it will make lock checking calls on every read and write call.

The second class of locking is the deny modes. These are set by an application when it opens a file to determine what types of access should be allowed simultaneously with its open. A client may ask for DENY_NONE, DENY_READ, DENY_WRITE, or DENY_ALL. There are also special compatibility modes called DENY_FCB and DENY_DOS.

In short, you can try using strict locking = yes and see if it make some differences. Anyway, the true solution would be to let the producer/writer process to open the file with the correct mode: DENY_ALL

1

This behavior is controlled by smb oplock or leases. The client side is where this is defined. In other words. It depends on your application. All this in pesumption that ontap fully complies to smb specs (which is 90 persent true)

1
  • Right. I'm more used to NFS setups, so this behavior has always felt like an OS or protocol issue, not a client app one. That makes sense, but is unfortunate because I have less control over the end-user apps and process.
    – BowlOfRed
    Commented Dec 30, 2016 at 16:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .