SVN + NFS = svn nfs cant get exclusive lock

Last night I was trying to configure SVN on a server. The setup was that the SVN Repo was on "srv2" and the frontend and code I wanted to import was on "srv1".

I created an NFS share on srv2 and mounted it on srv1 in /mnt/svnroot. The mount worked perfectly and I could touch and remove files from srv1.

So I tried to create a "sites" folder where I wanted to import a site I wanted to version control. This is where I started to have problems… The sollution was to add "nolock,bg" to the mount options on the client. Read on for more details!

NFS Configuration

[adsense:160x600:6965419571]

Before I continue, a little detail about the setup… The servers mentioned here are "psuedo" (ie not real). For the sake of the example "srv1" is 192.168.1.2 and "srv2" is 192.168.1.1. The SVN Server (srv2) has the following...

[user@srv2 ~]$ cat /etc/exports
/svnroot 192.168.1.2(rw)
[user@srv2 ~]$ cat /etc/hosts.deny
portmap: ALL
#ADDED BY NICK
lockd:ALL
mountd:ALL
rquotad:ALL
statd:ALL
[user@srv2 ~]$ cat /etc/hosts.allow
portmap: srv1
#ADDED BY NICK
lockd:   srv1
rquotad: srv1
mountd:  srv1
statd:   srv1

The above shows that the folder /svnroot is being exported as an NFS share and that access to the services portmap, lockd, mountd, rquotad & statd are denied to all, however the allow file grants access to these services for srv1 only.

One srv1, we have the following settings…

[user@srv1 ~]$ cat /etc/fstab
# srv2 - svn stuff
srv2:/svnroot  /mnt/svnroot  nfs  rw,hard,intr,nolock,bg  0 0

What does this do? Well it mounts the export /svnroot on srv2 to the local folder /mnt/svnroot using nfs with the options rw,hard,intr,nolock,bg. In all honesty - I dont know what the last 2 numbers are for!

Using this line in the fstab file I can now type (as root I believe)…

[user@srv1 ~]$ mount /mnt/svnroot

If this works then you can browse /mnt/svnroot as if it was on your local system. Now to use SVN!

[adsense:336x280:9994499560]

Configuring SVN

I checked out websvn from Tigris using the following command…

[user@srv1 ~]$ svn checkout http://websvn.tigris.org/svn/websvn/trunk websvn --username guest

Once in here, I went into the includes folder and copied distconfig.php to config.php. In config.php I made a few changes to suit my system - the main ones were adding a repository:

$config->addRepository('REPO', 'file:///mnt/svnroot/');

and teaching websvn that files ending in .module are actually PHP files:

$extEnscript['.module'] = 'php';

After that it was a simple matter of adding a VHost to bind a domain to my websvn install.

Using SVN

The problems really kicked in after all the above steps when I actually tried to USE SVN. When I tried to SVN to import a project by running this (on srv1)…

svn mkdir file:///mnt/svnroot/sites -m "Creating sites folder"

… I was presented with an interesting error claiming…

svn nfs cant get exclusive lock

After doing a little research I found an interesting post on woss.name by Byung-chul Lee about how he (or she?) fixed the same issue. The suggestion of adding "bg,nolock" to the mount options on the client fixed the locking issues! I don't know what the side effects will be though.