[Samba] Auto-Removal of Straggling File locks due to Ungraceful Client Disconnects

Vincent Callanan vincent at callanan.ie
Fri Jan 7 03:38:55 MST 2011


Thanks Volker,

Yes, while awaiting a reply, I had already zoned in on the Linux TCP/IP
keepalive mechanism and it works perfectly. I ended up using samba's
SO_KEEPALIVE socket option but tweaked the OS parameters directly using
sysctl.conf (my distro is CentOS 5). The default OS check interval is 2
hours which is far too long for my purposes. I changed this to 5 mins
(actually 10 mins in total allowing for retry probes). Now, when the OS
disconnects an inactive client, Samba picks up the disconnection and kills
the relevant process, releasing any locked files. In the unusual scenario
that the disconnected client only had an intermittent problem (e.g. network
issue) which eventually fixed itself, the client CIFS stack will simply
reconnect under the covers (that's where the samba "reset on zero vc" option
is important).

IMHO, this tweak should be part-and-parcel of any self-contained LAN
deployment e.g. a Windows-Server replacement in a business network.

In summary -- and as I anticipated -- the heart of the matter is the OS
stack (with some helpful prodding from Samba).

BTW, my allusion to Windows Server not having this problem was incorrect as
a further web search showed up -- I want to put the record straight on that
one. After a long, sometimes frustrating, journey with Samba over three
years, I am hugely impressed with the work you guys have done. Apart from
this particular problem/corner case (which is now solved), my CentOS 5 based
PDC just runs and runs and runs with minimal maintenance and performance is
superb.

Regards,
Vincent

On 6 January 2011 16:55, Volker Lendecke <Volker.Lendecke at sernet.de> wrote:

> On Thu, Dec 30, 2010 at 03:36:04AM +0000, Vincent Callanan wrote:
> > This question has come up many times before in a number of guises.
> > But I do not believe that it has ever been answered satisfactorily.
>
> That's because it can't be anwered really satisfactorily
> given that the CIFS protocol does not allow the server to
> ping the client if it's still around. All you can do is to
> apply heuristics.
>
> > This may well reflect fundamental difficulties in the CIFS protocol
> > However, recent incarnations of Windows Server seem to handle the problem
> > better
> > possibly due to tweaks in the underlying TCP/IP stack vis-a-vis Linux.
>
> If you're on moderately recent Linux, you might want to play
> with something like
>
> socket options = SO_KEEPALIVE TCP_KEEPIDLE=300 TCP_KEEPINTVL=10
> TCP_KEEPCNT=5
>
> This should kick dead clients after something like 6
> minutes. A description of these parameters can be found in
> "man tcp".
>
> With best regards,
>
> Volker Lendecke
>
> --
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
>



-- 
Regards,
Vincent Callanan
+353-86-8511625


More information about the samba mailing list