Solved

Sharing ISAM databases via SAMBA

Posted on 2004-09-09
26
577 Views
Last Modified: 2010-05-18
I have a heterogeneous network with a R.H. Linux server running Samba 3.0.5 and various
Win clients (from Win 98 to Win XP Pro). On a Samba share I have an ISAM database (Access, FoxPro etc. like)
that is being accessed by applications running on the Win clients and by applications running in Linux.
I have disabled "opplocks" in both Win9x clients and on the Samba share.
I have "mounted" the Samba share on the Linux server so that Linux applications are "pathed"
to the share and accessing the data there.

The problem arises with locks. Files locked by the Win clients are seeing as locked by Win
clients but not by Linux and viceversa.

Any solution for this?
I have "played" with options in Samba (level2 oplocks, veto oplocks, locking,
kernel oplocks, etc.) without any improvements. One thing that I have clear is oplocks = no.

TIA

0
Comment
Question by:moose25
  • 13
  • 7
  • 6
26 Comments
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Since the locks are placed/released/honored by the application and since Linux and windows  file systems implement locks differently I don't believe you'll get both to work without a modification to Samba. What you'd need would be for Samba to honor the Linux FS lock and to place a Linux FS lock when a windows client locks a file. And as far as I know that functionality doesn't exist with Samba.
0
 

Author Comment

by:moose25
Comment Utility
I know it is possible because it has been done before. At one stage I managed from a Win client to make a lock "visible" to Linux.

Mounting a linux drive to the Samba share on the same machine  I hand to Samba to take care of locking and buffering for both Win and Linux applications.

Now I need the settings for Samba, WIn clients etc....
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
You might be able to do this by forcing all file access to be via Samba, And by that I mean creating a mount point on the Linux server (say /mnt/smb-data), mounting the share that the windows boxes use on /mnt/smb-data, and telling your linux apps to use /mnt/smb-data/path-to/some-file.
0
 

Author Comment

by:moose25
Comment Utility
As  I mentioned on the original thread that is what I have been doing.

To be more specific:
Network name for Linux machine: pepe
Name of Samba share (as seen by Win clients) : testdata
Directory where data is on linux machine : /u/testdata

Thus data can be accessed by: //pepe/testdata

Mount point for Samba share in Linux: /

Comand given to mount Samba share:

mount -t smbfs -o username=whatever,password=key //pepe/testdata /testdata

Checked mounting with:

mount

gives me : //pepe/testdata mounted on /testdata type smbfs (o)    <--- By the way: what means the (o)?

Then I make the paths to access the data from Linux to be /testdata and fron win clients to be //pepe/testdata

Can you see anything wrong?

Tests I am going to make are:

1-Modify the name of the Samba share so that  "share name <> name linux directory"
2-Mount the Samba share at another point rather than /
3-Try to access the data from Linux with the same full path as Win clients. In the above case //pepe/testdata rather than /testdata

Any suggestion you would like to add?

TIA

0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
That's exactly what I had in mind. What's not clear to me is how the Linux flock() or lockf() is going to make it through to Samba. From the Linux app's perspective it is using ordinary Linux file operations, regardless of whether the files are on local disk, an SMB, or an NFS mount. I'd presume that passing of the locks would be something that mount.smbfs would have to be prepared to deal with.
0
 

Author Comment

by:moose25
Comment Utility
Modifications as above yeld the same negative results.

I am getting really desesperate !!!!

Anyone, please, please,... with suggestions, solutions, .....
0
 
LVL 20

Expert Comment

by:Gns
Comment Utility
Um, shouldn't "posix locking = yes" in smb.conf give consistent locking between SMB and posix (NFS or local) access?
Also magy play with setting "strict locking = yes" although this shouldn't be needed.

-- Glenn
0
 
LVL 20

Expert Comment

by:Gns
Comment Utility
BTW, how would you access an Access JetDB from linux in such a way that you'd lock the file?
Or are we talking some ISAM that have portable interface lib?

-- Glenn
0
 

Author Comment

by:moose25
Comment Utility
GNs,

I am nor at the office at the moment. I will try tonight  the posix locking option. I did have tried strict locking before.

As far as your question goes we are not talking about Access. I just gave it as an example of an ISAM database, as FoxPro etc.

I am working with a database which has  an OOP language for character mode with versions for Win, Linux, etc and they have another version which is a RAD tool OO for GUI which has the same database as the character mode. I have been sharing data between both environments without problem, and I do have some isntallations using Linux as the server, and that database being simultaneously being accessed by Win clients (GUI interface) and Linux character applications (telneted). It has worked faultlessy.

Now I need the file locks being requested by either the character application or by the GUI app. to be recognized by the other so that writing to the files can be acomplished without risking for record corruption (if a user from the character app. and a user from the GUI app write simoultaneously to the same record I might have problems).

I hope I have answered or clarified your question.

TIA
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Might be a silly question, but...

Have you tested the Linux command line version of the tool to see if it will lock the db and prevent another Linux command line instance from changing the db? And  have you done the same test with the Linux Gui interface? Obviously if the Linux apps don't lock the db there's no hope of having windows honor it.
0
 

Author Comment

by:moose25
Comment Utility
Thanks for your interest. Any idea is welcomed.
First one thing: When I mentioned GUI apps I mean a Win apps.
Second I have tried: linux apps locks linux apps. Win apps locks win  apps

0
 
LVL 20

Expert Comment

by:Gns
Comment Utility
Ok.
As eben mentioned before, locking is done quite differently between the both, so usually one hopes that there will be an "application lock layer" taking care of things  like this, or that one can "thrust" one kind of looking on the both (as we're doing here by using samba). I'm certyain mentioneing going to one of the free RDBMSes aren't in order here:-).
Tell us what you find with "posix locking" thing.

-- Glenn
0
 

Author Comment

by:moose25
Comment Utility
Hi,

Going to RDBMS or a comercial client-server solution is one thing to be done but not right now.

I have been trying over the weekend the "posix locking" but  I keep getting the same negative results. I have beeb doing it with the Samba share "mounted" on the Linux system. This afternoon I will try it with it unmounted.

Any more suggestions thru were I can lead the "investigation"?

I am willing to try anything -related to this problem  :)

Regards
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:moose25
Comment Utility
Some news:

Removing the mount of the Samba share in Linux I get the locks to work properly. But now I have a problem I didn't have before: If a file is opened by the Linux app I can not create new records in that file thru the Win app. I can modify records in it, but I can not create new ones.

Suggestions?
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
Are you saying that once a Linux app has modified the DB that you can't later add records?

If that's the case it might be the difference in line/record terminators. The standard Linux/Unix line terminator is a new-line, but on windows it is a carriage return new-line. I seem to remember that this is transparently handled by the smbfs ( a new-line is written to the file as a carriage return new-line).
0
 

Author Comment

by:moose25
Comment Utility
No. What I meant is that while the Linux program has a file open I can't add records using the Windows program. Program is not locked but when you try to save that new record you get an error and no record is written to that file. Once you close the  Linux program you can continue adding new records to the file using the win program
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
That sounds like Samba recognizes that there's a lock on the file, but it fails to communicate that information to to windows. Did you include Gns' posix locking suggestion in your smb.conf?
0
 

Author Comment

by:moose25
Comment Utility
Yes I have.

Since there has been quite a few comments here is a recapitulation so far:

-Mounting a samba share on Linux: if a file is locked  by a Win program a Linux program won't recogize the lock and viceversa. A lock triggred by a Win program is recognized by other Win programs. A lock triggered by a Linux program is recognized by other linux programs.


-Without a Samba share mounted on Linux: locks are recognize in any situation. Problem: while a file is open by a Linux program you can not add new records to that file from a Win program.

I have been suggested to try mounting the share as CIFS instead of smbfs. I will try that. Any comments on this?
0
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
> I have been suggested to try mounting the share as CIFS instead of smbfs.

Dunno, but it is worth a try.
0
 
LVL 20

Expert Comment

by:Gns
Comment Utility
CC.

To me it sounds like some "oppotunistic locking" was done by the smbfs client... No real options to work with though.

-- Glenn
0
 

Author Comment

by:moose25
Comment Utility
When I mount the smbfs share on Linux and type the command "mount" I get:

//pepe/testdata mounted on /testdata type smbfs (0)    

What does that (0) , by the way it's a "(zero)", means?


0
 

Author Comment

by:moose25
Comment Utility
I think I managed to get a working configuration, pending of doing some thourough testing.

I would like to have your opinions.

I am running RH 8 with Samba 3.0.5

1) No samba shared mounted on Linux (this way I avoid smbfs)

2) Parameters in smb.conf for the share:
            -locking = yes
            -veto oplock files = *.dat/*.k*/*.hdr    (in my case)
            -strict locking = no


That last parameter seems to be the one that avoided writing new records to a file by the windows program while that same file was open by the Linux program.

0
 
LVL 20

Accepted Solution

by:
Gns earned 500 total points
Comment Utility
"locking = yes" and "strict locking = no" are the defaults and shouldn't need specifying... Which would mean that the veto would be what makes the difference... Exempting the ISAM files from oplocks (making the client go for the real stuff everytime) is good in this case... The oplock "breaking" or "downgrading" without the client seeing it was probably what bit you.
I wonder... Ah, having kernel oplocks (for cross platform/access method synchronisity) voids the granting of level2 oplocks, which would possibly have helped you.

-- Glenn
0
 

Author Comment

by:moose25
Comment Utility
Checking the defaults with testparm for samba 3.0.5 (the one we have installed) I found "strict locking=yes"

As we were  doing tests with different setups we prefered to control the setup for the share within the options of the share so as to avoid future mess ups. As for the veto files it was tested before and it was giving the same problems as mentioned previously. The problem was defenitly in strict locking. We have been testing it (and still are)  this morning and switching strict locking =yes/no. We discarded s.l.=no and so far things seem to be running fine.

We have tried also kernel oplocks (although I must admit was probably with smbfs  turned on). As for level 2 oplocks we tried them with opplocks (discarded now with veto oplocks).

What has lost me from the beggining was the mounting of the samba share in linux. But now I considered that it was good because we learned a lot (the hard way) and made us considere some points of testing that otherwise we would ignore and that were important

Regards
0
 
LVL 20

Expert Comment

by:Gns
Comment Utility
>  Checking the defaults with testparm for samba 3.0.5 (the one we have installed) I found "strict locking=yes"
Fun, the manula says something different... At least for 3.0.1 (which it turns out I was looking at:-).

According to the same docs you'd not be able to use both kernel oplock=yes and level2 oplock=yes (kernel would bar the granting of level2 oplocks).

-- Glenn
0
 

Author Comment

by:moose25
Comment Utility
>Fun, the manula says something different... At least for 3.0.1 (which it turns out I was looking at:-).

Yes.  So it does for 2.0.x and 2.6.x

Just to check I rebooted the Linux box. Checked smb.conf for strict locking and the only one that comes out is the one we set to =no. Then run testparm and checked. As default it comes to =yes.

>According to the same docs you'd not be able to use both kernel oplock=yes and level2 oplock=yes (kernel would bar the granting of level2 oplocks).

I am sure you are correct. Before each test we run testparm and adjusted accordingly. I don't have the logs for a test made then so I can't tell you.

On the other hand, we just finished one last test with 4 programs (2 in linux, 2 in Win) accessing the same file and writing to it simultaneously. Other two programs kept that file open: one in linux and the other in Win.
We wrote and read well over 10.000 new records without problems. Locks were respected, file was not damaged, and records were all recorded. So it seems that finally we are on the right track!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now