NFS - concurrent write to same file normal ?


 
Thread Tools Search this Thread
Operating Systems Solaris NFS - concurrent write to same file normal ?
# 1  
Old 02-23-2016
NFS - concurrent write to same file normal ?

Hi all,

Sorry if I sound like a novice , I have always thought that for network file system which can be shared, there will be some access restriction in which

when user A is writing/editing fileA, user B is able to view the same fileA but cannot write/edit it until user A has completed and saved the fileA.

======================

Today, while in Solaris10, I encounter the following

Code:
 
 ServerA:/shareddrive
 ServerB -> mount -F nfs serverA:/shareddrive /shareddrive
 ServerC -> mount -F nfs serverA:/shareddrive /shareddrive
  
 -- shuser user has the same UID across all the 3 servers.
 In Server A -> mkdir sharedfolder; chown shuser:shuser sharedfolder;
 In Server B -> touch filea; vi filea;  insert 'abcd' -- leaving the file open
 In Server C -> vi filea; insert '1234'  
  
 In server B -> :wq!
 In server C -> :wq!
  
 Result filea = 1234

====================

Is this behaviour perfectly normal under NFS ?
Able to edit the same file at the same time, with 1 write overwriting another ? SmilieSmilieSmilie

Regards,
Noob
# 2  
Old 02-23-2016
Hi javanoob,

That would be correct, if the share is set rw then you have to live with it I'm afraid. Options for getting round it are limited, you could try using NLM there are some documents here.

Regards

Gull04

Last edited by gull04; 02-23-2016 at 09:27 AM.. Reason: Additional information.
These 2 Users Gave Thanks to gull04 For This Post:
# 3  
Old 02-23-2016
I always avoid NFS where I can for this sort of reason. It gets more complicated for every extra client that uses it. It can seem like overkill, but reading through NFS and writing back with an FTP/SFTP process seems to help, but there is still a risk of who gets the last write - although that is present when using local files anyway.


Robin
This User Gave Thanks to rbatte1 For This Post:
# 4  
Old 02-23-2016
Hi Javanoob,

There are much more robust solutions, consequentially they are more complex. If you are serious about needing the access and the file level locking spread across multiple servers or shares. I would suggest that you use GFS, I have used it very successfully in the past - with upwards of 15 systems accessing the same disk areas.

However although the systems all functioned as expected, there was an issue where when the utilization of the filesystem got above 80% performance fell away dramatically. These file systems were pretty big (almost 10Tb), so if there was an issue that required an "fsck" the file system was unavailable for a long time (60 hours in one case).

So you have to weigh up the requirements, it may be worth considering something like CVS or similar - where the file has to be checked out and then back in by one user at a time.

Regards

Gull04
This User Gave Thanks to gull04 For This Post:
# 5  
Old 02-23-2016
Quote:
Originally Posted by javanoob
Is this behaviour perfectly normal under NFS ?
Able to edit the same file at the same time, with 1 write overwriting another ? SmilieSmilieSmilie
This behavior is actually perfectly normal whether NFS is used or not.

It is simply a consequence of the editor you use, here the legacy BSD vi, not doing any concurrent edition avoidance.

Should you have used vim, the editor would have prevented or at least warned you about the situation regardless of whether the file system is local or remote, and supports file locking or not. vim tries to create a temporary file (.swp) when you open a file in read/write mode. Should this file already exists, it ask you about the issue and wait for your decision.
This User Gave Thanks to jlliagre For This Post:
# 6  
Old 02-25-2016
Quote:
Originally Posted by jlliagre
This behavior is actually perfectly normal whether NFS is used or not.

It is simply a consequence of the editor you use, here the legacy BSD vi, not doing any concurrent edition avoidance.

Should you have used vim, the editor would have prevented or at least warned you about the situation regardless of whether the file system is local or remote, and supports file locking or not. vim tries to create a temporary file (.swp) when you open a file in read/write mode. Should this file already exists, it ask you about the issue and wait for your decision.
Hi Jilliagre and all,

Thanks for your reply.

I have assume NFS would have built some auto-lock mechanism beneath the application layer (irregardless of the application used), so that concurrent access are restricted.
But guess i am wrong.

Regards,
Noob
# 7  
Old 02-26-2016
Unix file systems do allow concurrent file access. This is a POSIX requirement. Forbidding such accesses with NFS would have prevented many applications to run properly.

Moreover, up to NFSv3, NFS is stateless, i.e. the NFS server doesn't store the fact a file is open by a remote client so file locking requires extra services to be supported.

NFSv4 is stateful so allows mandatory locking but this must be a client decision that "vi" never makes anyway.
These 2 Users Gave Thanks to jlliagre For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

NFS write error on host xyz: Stale NFS file handle - Solaris 10

Oct 13 12:19:15 xyz nfs: NFS write error on host xyz: Stale NFS file handle. Oct 13 12:19:15 xyz nfs: (file handle: 68000000 1bc5492e 20000000 377c5e 1ce9395c 720a6203 40000000 bdfb0400) Oct 13 12:19:15 xyz nfs: NFS write error on host zyz: Stale NFS file handle. Oct 13 12:19:15 xyz nfs: ... (5 Replies)
Discussion started by: psychocandy
5 Replies

2. AIX

NFS multiple write error.

Hi, We are taking the mksysb backup to NIM server's NFS mount point (/backup). We have mounted /backup to all the clients /backup and full permission. When multiple mksysb backup starting simultaneously to the NIM server's shared NFS mount point then only one backup is running and all others... (3 Replies)
Discussion started by: sunnybee
3 Replies

3. AIX

Difference between concurrent and enhanced concurrent VG

Hi, What are the differences between concurrent and enhanced concurrent VGs.? Any advantages of enhanced concurrent VG over normal concurrent vg Regards, Siva (2 Replies)
Discussion started by: ksgnathan
2 Replies

4. UNIX for Dummies Questions & Answers

Unable to write to a mounted NFS share

Hi All, I created a nfs share in the server(Solaris 10) with the following command and also updated the dfstab file share -F nfs -o rw=server_name2,anon=0 /to_share And then in the client(solaris 10) added the following command to mount the share mount -F nfs server_name1:/to_share... (4 Replies)
Discussion started by: Rossdba
4 Replies

5. AIX

Normal VG to Enhanced Concurrent VG

Hi All, I am going to perform some activity in 2Node HA Server(Active/Passive). For that i have to do some pre-requsite (ie., Resource Group VG's should be Enhanced-Concurrent) In my setup, we have two volume groups in one RG. In that one VG is Normal and another is Enhance Concurrent. ... (2 Replies)
Discussion started by: Thala
2 Replies

6. AIX

Write once on NFS file system

Hello Guru's We are trying to save some data for 10 -15 yrs. so we created a NFS share file system and mounted on AIX 5.3 servers, keeping in mind that we might need to replace the expired disk/bad disk every 2 yrs or 4 yrs. Now we are trying to solve. How to protect it from getting deleted... (6 Replies)
Discussion started by: Beginner123
6 Replies

7. Red Hat

NFS mount read and write

Dear all, I have a server A and Client B. I am mounting a folder which is Server A using read and write options in client B. I have put entries in /etc/exports file as /mnt1/load *(rw,sync) In the client i cannot create any new file or delete any file eventhough it is read... (3 Replies)
Discussion started by: jegaraman
3 Replies

8. Solaris

Write problem in NFS

Hi Gurus, I am trying to share certain file with NFS. Requirement is to give access to root of another host to some file system which is shared through NFS. Step1. I entered the below line in /etc/dfs/dfstab share -F nfs -o root=sun2 /usr/src ... (3 Replies)
Discussion started by: kumarmani
3 Replies

9. Solaris

NFS write error on host : Stale NFS file handle

:confused:Hi all When i see in the /var/adm/messages, i saw the following error unix: NFS write error on host : Stale NFS file handle. unix: (file handle: 45ca415 3e7 a0000 2c7f6 3ebfc25f a0000 2 3e49) It is using sunOS 5.7. Is anybody know what is this error? Is is related to any network... (2 Replies)
Discussion started by: AirWalker83
2 Replies

10. IP Networking

Write permisson in NFS mounting

Hi all i have done set up for nfs. at server <dir> <client IP>/<netmask>(rw,sync) at client mount -o rw -nfs <server IP>:<dir1><dir2> with this i am successful in mounting the directory with write permission. But the write permission is not activate in client machine for the file which... (5 Replies)
Discussion started by: bhakti
5 Replies
Login or Register to Ask a Question