Why ERRlock on Read [was Interleaved cifs_read/cifs_readpage calls cause problems?]

Steven French sfrench at us.ibm.com
Mon Dec 12 14:49:24 GMT 2005

>Our test machines that have a number of read-only cifs mounts with
>various versions of windows and samba on the other end. We're running an
>application that walks the tree of mounts and spawns about 8 concurrent
>threads to visit all the leaf nodes.
> Dec  6 16:26:38 oyabox-2p6p14p2 kernel:  fs/cifs/netmisc.c:  !!Mapping
smb error code 33 to POSIX err -13 !!
> Dec  6 16:26:38 oyabox-2p6p14p2 kernel:  fs/cifs/file.c: CIFS VFS:
leaving cifs_read (xid = 25555407) rc = -13

ERRlock on read is coming from the server - it would be useful to know
which type of server(s) is returning this.  This is a legal return code
that would be intuitive if your application does posix byte range locks -
e.g. it is possible that the application locked a byte range in the file
(denying read) with a different handle than it is using to read the file (I
have seen this kind of "bug" in a few Linux apps) which will work in POSIX
(albeit not really what you want if you want to be clearest) but not in
Windows (which expects that a byte range lock really means a byte range
lock and enforces them and expects you to use the right file handle etc.).
There are still some compensations that may be possible in the advisory
(posix) -> mandatory (cifs) byte range lock code but I won't be convinced
that this is the likely cause until I see whether mounting with "nobrl"
mount option avoids the problem.    If nobrl does not solve the problem,
then we have to look at the server side and see how a file which is not
byte range locked can return ERRlock on SMB ReadX (e.g. trace through the
Samba smbd code which does the read handling) but I think it is more likely
that the file is locked and the wrong file handle is being used by the
application for the read (if so disabling sending locks remotely, they
still work locally ala posix) via nobrl will help if the app can't be

Steve French
Senior Software Engineer
Linux Technology Center - IBM Austin
phone: 512-838-2294
email: sfrench at-sign us dot ibm dot com

More information about the samba-technical mailing list