Yannis Tzavellas
1999-Nov-27 22:01 UTC
File caching while "oplocks=False", black magic or what?
NOTE: I have definitely put "oplocks=False" in my smb.conf. I use a program running on 2 machines (win95 and win98) to access data on my samba server (samba 2.0.3-8, on Redhat 6.0). The programs, when accessing data on the server, go like this: int get_record(..) int put_record(..) { { if (lock(...)) { if (lock(...)) { if (read(...)) { if (write(...)) { .... .... } else ... } else ... } else ... } else ... } } i.e they simply lock the file and perform a read or write on it. Files are flushed after writing. So whenever anyone of the 2 windows clients changes a record, this change is actually stored in samba. (A linux-version of the "client" program that runs on the Linux box, sees the change.) BUT this does't work the other way around: A change performed by the linux-client IS NOT SEEN by any of the windows clients. They behave lazily on reading (as if they are caching data). /* After 2 days of debugging, reading docs, drinking coffe and NOT eating pizza (or almost anything), .... I finaly find "a way" to get rid of the problem. But what a way it is... */ The cure I used is absolutely incomprehensible to me: ==>> I just added a little delay (?) loop at the beginning of the ==>> get_record() function as in : int get_record(..) { // this little delay (?) loop seems to cure the problem for (int i=0; i<4; i++) { // 4 or more works, 3 does't ! lock(fh, 0L, 0); // fh = the file handle read(...); // no matter what. I read 10 bytes } // nothing else touched anywhere... if (lock(...)) { if (read(...)) { .... } else ... } else ... } and after this everything seems to work fine ! So my questions are: 1. Why windows clients insist to cache data despite of "oplocks=False" ? 2. Does anybody understand what is going on with my "solution" and how it actualy manages to force the clients NOT to cache data? Thanks ! -------------- next part -------------- HTML attachment scrubbed and removed
Just for fun can you add strict sync=yes, and see whether the symptom changes? Thanks Steve Litt At 09:02 AM 11/28/1999 +1100, Yannis Tzavellas wrote:> NOTE: I have definitely put "oplocks=False" in my smb.conf. I use a >program running on 2 machines (win95 and win98) to access data on my samba >server (samba 2.0.3-8, on Redhat 6.0). The programs, when accessing data on >the server, go like this: int put_record(..) > { > if (lock(...)) { > if (write(...)) { > ... > } else ... > } else ... > } i.e they simply lock the file and perform a >read or write on it. Files are flushed after writing. So whenever anyone >of the 2 windows clients changes a record, this change is actually stored >in samba. (A linux-version of the "client" program that runs on the Linux >box, sees the change.) BUT this does't work the other way around: A change >performed by the linux-client IS NOT SEEN by any of the windows clients. >They behave lazily on reading (as if they are caching data). /* >After 2 days of debugging, reading docs, drinking coffe and NOT eating >pizza (or almost anything), >.... I finaly find "a way" to get rid of the problem. But what a way itis...>*/ The cure I used is absolutely incomprehensible to me: ==>> I just >added a little delay (?) loop at the beginning of the >==>> get_record() function as in : int get_record(..) >{ > // this little delay (?) loop seems to cure the problem > <4; i++) { // 4 or more works, 3 does't ! > // fh = the file handle > // no matter what. I read 10 bytes > } > // nothing else touched anywhere... if (lock(...)) { > if (read(...)) { > .... > } else ... > } else ... >} and after this everything seems to work fine ! So my questions are: >1. Why windows clients insist to cache data despite of "oplocks=False" ? >2. Does anybody understand what is going on with my "solution" and how it >actualy manages to force the clients NOT to cache data? Thanks ! >
Also, experiment with strict locking=yes and see if it changes the symptom Steve Litt At 09:26 AM 11/28/1999 +1100, Steve Litt wrote:>Just for fun can you add strict sync=yes, and see whether the symptomchanges?> >Thanks > >Steve Litt > > >At 09:02 AM 11/28/1999 +1100, Yannis Tzavellas wrote: >> NOTE: I have definitely put "oplocks=False" in my smb.conf. I use a >>program running on 2 machines (win95 and win98) to access data on my samba >>server (samba 2.0.3-8, on Redhat 6.0). The programs, when accessing data on >>the server, go like this: int put_record(..) >> { >> if (lock(...)) { >> if (write(...)) { >> ... >> } else ... >> } else ... >> } i.e they simply lock the file and perform a >>read or write on it. Files are flushed after writing. So whenever anyone >>of the 2 windows clients changes a record, this change is actually stored >>in samba. (A linux-version of the "client" program that runs on the Linux >>box, sees the change.) BUT this does't work the other way around: A change >>performed by the linux-client IS NOT SEEN by any of the windows clients. >>They behave lazily on reading (as if they are caching data). /* >>After 2 days of debugging, reading docs, drinking coffe and NOT eating >>pizza (or almost anything), >>.... I finaly find "a way" to get rid of the problem. But what a way it >is... >>*/ The cure I used is absolutely incomprehensible to me: ==>> I just >>added a little delay (?) loop at the beginning of the >>==>> get_record() function as in : int get_record(..) >>{ >> // this little delay (?) loop seems to cure the problem >> <4; i++) { // 4 or more works, 3 does't ! >> // fh = the file handle >> // no matter what. I read 10 bytes >> } >> // nothing else touched anywhere... if (lock(...)) { >> if (read(...)) { >> .... >> } else ... >> } else ... >>} and after this everything seems to work fine ! So my questions are: >>1. Why windows clients insist to cache data despite of "oplocks=False" ? >>2. Does anybody understand what is going on with my "solution" and how it >>actualy manages to force the clients NOT to cache data? Thanks ! >> > >
Eric Rosello
1999-Nov-29 04:26 UTC
File caching while "oplocks=False", black magic or what?
Hi!>>... A change >>performed by the linux-client IS NOT SEEN by any of the windows clients. >>They behave lazily on reading (as if they are caching data). /*I've seen a very similar behaviour when using ACCESS (MDB) database files. In my case it was possible to have 2 PCs doing modifications at the same time to the same record, so each client was working with his own version of the data even after stopping and restarting ACCESS on each machine!!! The problem (already mentioned in this list) is related to major bugs in the WIN95 "Network Redirector". In fact, I was even able to update records in the shared file with the network cable unplugged!!! The lack of network communication is not detected until you try to browse data outside the range of records available in the client's cache for the shared volume. I haven't seen that under WIN98 (yet... :-/ ). For info:> Date: Sat, 25 Sep 1999 15:12:05 +0100 > From: Paul Sherwin <psherwin@telinco.co.uk> > To: samba@samba.org > Cc: office@hantsch.co.at > Subject: Re: Troubles with File-/Record locking from Windows clients... > Message-ID: <3.0.6.32.19990925151205.007cfe80@mail.telinco.co.uk> > Mime-Version: 1.0 > Content-Type: text/plain; charset="us-ascii" > > >Date: Fri, 24 Sep 1999 15:46:03 +0200 > >From: Rainer Hantsch <office@hantsch.co.at> > > > >While my application worked fine in DOS with NEXOS (it is 100% MS > Network > >compatible), I get biggest troubles with Win95 and Samba(1.9.18p8), > because > >the data files stay permanently locked by that application which opens > them > >first. All other clients have no access. > > Check the version of VREDIR.VXD you have. The Windows network redirecter > > has had zillions of bugs through many versions. I wasted hours trying to > > get locking to work with 4.00.955. 4.00.1111 seems to be OK but I > believe > the most recent version is 4.00.1116. You can download an update from > > http://support.microsoft.com/download/support/mslfiles/vrdrupd.exe > > This may not be your problem but you should check it out before doing > anything else. > > Best regards, Paul > > Paul Sherwin Consulting 22 Monmouth Road, Oxford OX1 4TD, UK > Phone +44 (0)1865 721438 http://www.telinco.co.uk/psherwin/index.htm > Mobile +44 (0)7931 578334 mailto:psherwin@telinco.co.uk > Pager +44 (0)7666 797228Good luck! Eric Rosello Simulator Development Engineer Gulf Air Simulator Centre Po. Box 22082 Doha State of Qatar Tel: +974 351325 FAX: +974 351240
Jeremy Allison
1999-Dec-03 19:04 UTC
File caching while "oplocks=False", black magic or what?
Yannis Tzavellas wrote:> > NOTE: I have definitely put "oplocks=False" in my smb.conf. > > I use a program running on 2 machines (win95 and win98) to access data on my samba server (samba 2.0.3-8, on Redhat 6.0). The programs, when accessing data on the server, go like this: > > int get_record(..) int put_record(..) > { { > if (lock(...)) { if (lock(...)) { > if (read(...)) { if (write(...)) { > .... ... > } else ... } else ... > } else ... } else ... > } } > > i.e they simply lock the file and perform a read or write on it. >Exactly *how* are you doing the "lock()" function in the Linux code ? You need to use fcntl locks in order for this to work. Regards, Jeremy Allison, Samba Team. -- -------------------------------------------------------- Buying an operating system without source is like buying a self-assembly Space Shuttle with no instructions. --------------------------------------------------------