LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-27-2006, 05:41 AM   #1
marisdembovskis
Member
 
Registered: May 2006
Posts: 37

Rep: Reputation: 15
Xp user opens file via Samba, but file is not locked after opening???


Hi, forum!

I have linux/windows network.

Problem:
When XP users edit the file, after moment I open the same file with Fedora, the file is not locked and also not read only! And I can write on Fedora this file, however XP users
are editing the file.

It shouldn't be so!


Is there solution for this, to lock the opened file?
So that other users can not write to it?
Any ideas from forum?

Thanks

Maris
 
Old 06-27-2006, 09:56 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Read the section on Locks and Oplocks:
http://www.faqs.org/docs/samba/ch08.html
 
Old 06-29-2006, 02:57 AM   #3
marisdembovskis
Member
 
Registered: May 2006
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks, jschiwal!
I read that link. And tried that all out. And my report to all is here below:


I test and play with all the lock variants
locking
strict locking
oplocks
veto oplock files
My configuration now:
oplocks = yes
level2 oplocks = Yes
strict locking = yes


And the situation is following:
I have Lin server + XP user + Lin user.

1.Xp user opens water.xls via Samba
2.Samba locks the file.
3.Lin user opens the file water.xls after 20 seconds via NFS.
4.As Samba has locked the file, Lin users see (water.xls READ ONLY)
SO far seems everything is working really FINE. Problems start when we go further on.
5.Lin users after 5 minutes tries to open water.xls to edit it, in the same time XP user is still working with it.
6.Lin user opens water.xls and it is WRITABLE. , however XP user still edits it.
7.The result is corrupted file, not saved file, information lost for XP user, time lost for XP user.
What happened?

Problem:


Samba locks the file fine, however after one Lin user try to open the file lock is broken by Lin user. So next time Lin users opens the file – file is not locked, because samba lock ir broken.
But Samba lock is made: by XP user opening file or by XP user saving file.
So for example, to ensure that file is locked Xp user needs to save file each time (it locks file again, if it was unlocked), when Lin user opens the file (unlocks it).


It is is possible to open file on Lin first time Read Only, then close it. And after a three seconds open it and now it is writable. So Lin user can hack the file just with two times opening the locked file. Not good, right? In real life it means: that file is editing Xp user, then comes Lin user first time, after a time Lin users hopes, that file is not edited any more and he opens the file, however in 30% the file is still editing by XP user. The Lin users does changes and save all, but XP user looses his job.


Thanks for help to everyone!
Are there any ideas how to solve this?

Maris

Last edited by marisdembovskis; 06-29-2006 at 05:02 AM.
 
Old 06-30-2006, 12:12 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You said that the Linux user opened the file using NFS. NFS is different from Samba. If it is a Samba server, do you need both? If you have the linux users' home pages on this server, then the answer may be yes, but you don't need to offer the same directory as both a samba share and an NFS share.

You might also want to look into some sort of revision control system is several users edit the same files.

Here is a proposal for Unified File Locking: http://samba.osmirror.nl/samba/ftp/specs/UFL_spec.pdf

It is dated, but may explain the process and point you in the right direction. I found it entering a google search for the terms "samba nfs file locking interaction". There were several other search results as well.

Last edited by jschiwal; 06-30-2006 at 12:39 AM.
 
Old 06-30-2006, 06:31 AM   #5
marisdembovskis
Member
 
Registered: May 2006
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks, jschiwal for help.
About server, Yes, I need both of them.
On the server are documents, used by Win and Lin users. Lin users access them via NFS and Win users via Samba. And usually it so, XP users edit documents with 2003 MS office and Lin users edit the same documents with Ooo 2.02. Everything is really fine, except file locking.

Because we have a lot of cases, when at the same time document is accessed by different users.

I will try to look around.
and see what can I do.
I will post if I will succeed here.
need a lot of reading and googling.

Last edited by marisdembovskis; 06-30-2006 at 06:33 AM.
 
Old 06-30-2006, 08:33 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Why couldn't Linux users access shares using samba instead of NFS? The locking problem is due to NFS. The NFS locks are advisory. I believe that the Samba locks are, or can be configured to be manditory.
 
Old 07-03-2006, 03:39 AM   #7
marisdembovskis
Member
 
Registered: May 2006
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks for help.
Actually I could make everything through Samba, but then the problem is with Ooo. Saving, Viewing.
Because of this Linux users need NFS system to access the documents.



you say, that NFS loks are stronger than Samba, is there a way how to make NFS looking and accepting Samba locks and not breaking them?

Thanks, anyway!

Last edited by marisdembovskis; 07-03-2006 at 03:46 AM.
 
Old 07-03-2006, 05:12 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
We may need to back up a bit. Here is a more recent document concerning CIFS and NFS.
http://www.redbooks.ibm.com/redpapers/pdfs/redp4176.pdf

It mentions that NFSV4 provides whole file locking, and not just byte-range locking. Which version of nfs is your system(s) using? How old is your kernel?

Take a look in your running kernel's .config file:
#
# Network File Systems
#
CONFIG_NFS_FS=m
CONFIG_NFS_V3=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_NFS_DIRECTIO=y
CONFIG_NFSD=m
CONFIG_NFSD_V2_ACL=y
CONFIG_NFSD_V3=y
CONFIG_NFSD_V3_ACL=y
CONFIG_NFSD_V4=y
CONFIG_NFSD_TCP=y
CONFIG_LOCKD=m
CONFIG_LOCKD_V4=y
CONFIG_EXPORTFS=m
CONFIG_NFS_ACL_SUPPORT=m
CONFIG_NFS_COMMON=y

Is NFS Version 4 enabled.

The manpage for lockd states that all it does is start the NFS Lock Manager (NLM) in the kernel, which most kernels start anyway, so lockd isn't needed anymore, but it doesn't hurt starting it.


The book "UNIX Filesystems--Evolution, Design, and Implementation" describes a mandatory locking hack. Mandatory locking can be enabled on a file if the set group ID bit is set, and the execute bit is cleared. Probably not too usefull, sorry. Your best bet may be to look into the features of NFS V4.
Try the sourceforge home page: http://nfs.sourceforge.net/
 
Old 07-04-2006, 03:30 AM   #9
marisdembovskis
Member
 
Registered: May 2006
Posts: 37

Original Poster
Rep: Reputation: 15
NFS works!!!

I solved the problem, with installing SFU.

Instal SFU35SEL_EN.exe (it is MIcrosoft utility for Win clients tu understand UNIX). Package was !!! 217 MB !!!

http://www.microsoft.com/technet/int...u/default.mspx
http://www.microsoft.com/windows/sfu...ds/default.asp
Installed in standart way.
So now Lin users can not break the lock if they open document couple times. File all the time is read only, except nobody is writing to it! (Specially Win users via Samba)




thanks, jschiwal!
I will also try you solution

Take a look in your running kernel's .config file:
#
# Network File Systems
#
CONFIG_NFS_FS=m
CONFIG_NFS_V3=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_NFS_DIRECTIO=y
CONFIG_NFSD=m
CONFIG_NFSD_V2_ACL=y
CONFIG_NFSD_V3=y
CONFIG_NFSD_V3_ACL=y
CONFIG_NFSD_V4=y
CONFIG_NFSD_TCP=y
CONFIG_LOCKD=m
CONFIG_LOCKD_V4=y
CONFIG_EXPORTFS=m
CONFIG_NFS_ACL_SUPPORT=m
CONFIG_NFS_COMMON=y


Thanks a lot!
I'm really !


Now I only need to create automatic backup solution (still dont know, how it will look like) but then win/lin network will be integrated. (and now it seems it took 3-5 months to make all from scratch)



Maris

Last edited by marisdembovskis; 07-04-2006 at 03:32 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
file locked by another user Dagk Linux - Newbie 6 09-14-2005 09:08 PM
opens pico but aint opening file user specifys? twirl Programming 66 09-14-2005 11:01 AM
File owner and File group locked - root deiphage Linux - Hardware 5 02-05-2005 01:30 PM
Windows XP opening Samba file as "READ ONLY"? core_sa Red Hat 0 08-28-2004 01:55 PM
what opens a .bz file? Chooco Linux - Newbie 15 06-18-2002 11:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration