Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

NFS - The process cannot access the file because another process has locked

moosport

Junior Member
Joined
Mar 22, 2013
Messages
14
I have mapped the NFS share from Windows using the nolock option but I still get the "Error 0x80070021: The process cannot access the file because another process has locked". The workaround is to umount and mount the share again.

The -o nolock option is suppose to prevent such error but not in this case. Any idea?


mount -o nolock
 

jgreco

Resident Grinch
Moderator
Joined
May 29, 2011
Messages
15,851
Is Windows perhaps locking the file locally, and therefore a server setting to force no locks wouldn't be sufficiently effective?
 

moosport

Junior Member
Joined
Mar 22, 2013
Messages
14
I get the same error when downloading a file to the fileshare. So the file do not exist on the PC in the first place.
 

jgreco

Resident Grinch
Moderator
Joined
May 29, 2011
Messages
15,851
That wasn't the point, at all. An operating system maintains information on the state of locks, that's how locks can actually work in the first place. If a process on the Windows client locks a file, the local client OS can potentially be aware of the lock regardless of what the fileserver thinks should happen.
 

jgreco

Resident Grinch
Moderator
Joined
May 29, 2011
Messages
15,851
I'm saying there's a reasonably decent chance that the Windows OS is locking the file on behalf of a process, and if a second Windows process attempts to access the file, that you could still encounter an error.
 

neo_

Neophyte
Joined
Oct 14, 2014
Messages
11
I came across this thread while searching for a solution. If anyone else has this problem, this is how I solved it.

Unmount the NFS share from Windows.

When you mount the share, it is required to use the "-o nolock" option.

Example:

Code:
mount \\192.168.1.100\mnt\vol0\data\ N: -o nolock
 
L

L

Guest
Locking in general, as a framework, is one that I tend to respect. If something has a lock to a file, it might need the lock. I try not to just turn off locking.

You can see what systems may have something nfs mounted and maybe locking the file by

#showmount -a
 

philhu

Senior Member
Joined
May 17, 2016
Messages
258
So, I am resurrecting this thread, since I now have Win10 Enterprise and trying to do an NFS mount on it

I have done the mount using a non-priv cmd window

If I create a file on the windows box, a few things happen:
1) I get the error everyone sees above
2) The file IS created. It seems like any first operation on the file fails. I can edit it, get the annoying message and complete the edit
3) The file ownership shows some huge uid/gid, like 4867453431 for uid and gid
4) No other user can set/edit the file since the owner is set so wierd, until set to the valid values
5) Files end up at 755 protection, even though I use a mount switch to set to 777

So, to make it work, required '-o nolock'. There also seems to be a bug in MS mount program, as it does not allow multiple -o switches, but if you
comma seperate items, it is allowed, but ignored, ie:

'mount -o nolock -o casesensitive=yes' fails with a parse error
'mount -o nolock,casesensitive=yes' is allowed, but the arguments past the first seem ignored

So, after great consideration, I will do SMB mounts. If I need to turn off locking to make it work, it isn't any better than smb/nfs mounting, so
why kludge things?
 

Mirfster

Doesn't know what he's talking about
Joined
Oct 2, 2015
Messages
3,215
While I don't really use NFS for Windows Clients (except to just check a directory or two), I thought I would link this MS Article (old, but may still pertain): "Troubleshooting Client for NFS"

A file I created on an NFS shared resource is shown as having been created by nobody:nogroup or by –2:–1, or the user identifier (UID) is a very large number (2**32-2).

Cause
Your Windows user identity is not properly mapped in Active Directory or User Name Mapping.

Solution
In the Services for Network File System snap-in, ensure that the name of the correct Active Directory domain or User Name Mapping server is specified. Check with your Active Directory or User Name Mapping administrator to ensure that your Windows user identity is properly mapped to your UNIX user identity.

From the Comments Section:
Undocumented registry entry to control NFS locking globally
If you're having trouble with the NFS locking mechanism, and you would like to use the "NET USE" command, or the [WNetAddConnection] function to mount a NFS share without locking, there's an undocumented registry entry hidden in the NFSNP.DLL:

"HKLM\Software\Microsoft\Client for NFS\CurrentVersion\Users\Default\Mount" REG_DWORD "Locking"
If the value is "0x0" then locking will be disabled globally.
If the value is "0x1" then locking will ben enabled globally.

pbarrette

If it were me, I would focus on a fix that did still permit locking (when needed) since I do think there is value in that, especially for Office Documents, etc.
 

philhu

Senior Member
Joined
May 17, 2016
Messages
258
yes, this does explain the uid/gid problem. I cannot get around the lock problem in win10, So I samba/cifs mount the drive on my one windows client
 

Mirfster

Doesn't know what he's talking about
Joined
Oct 2, 2015
Messages
3,215
yes, this does explain the uid/gid problem. I cannot get around the lock problem in win10, So I samba/cifs mount the drive on my one windows client
Old thread, but try using the "-o nolock" at the end instead...

Example:
mount \\%IP_Address%\mnt\%Folder% N: -o nolock
 

lamb1133

Neophyte
Joined
Jan 31, 2019
Messages
9
Hello All,

I was having the same issue as the OP. Been banging my head against the wall for a few weeks. Then decided to search the forum. Found this post. Tried adding -o nolock at the end. And boom! I could use windows to create a new file & copy files to my freeNAS server! Then I kept reading and it sounds like this might not be the best option to have enabled. But it does not appear to reach the "best option". Any suggestions for 2019? -o nolock fine or is there something better? I have tons of questions but trying to stay on topic and need to continue research.

Thanks.
 

drcrow

Newbie
Joined
Sep 27, 2016
Messages
2
@lamb1133 Any update on finding away to get NFS to work on Windows 10 with locking enabled? Like you mentioned adding nolock parameter to the mount command works but disabling locking is not the best idea.

@jgreco Any troubleshooting methods you suggest? I am running Freenas 11.2 and Windows 10. If you want to see my NFS service config let me know.
 

lamb1133

Neophyte
Joined
Jan 31, 2019
Messages
9
@lamb1133 Any update on finding away to get NFS to work on Windows 10 with locking enabled? Like you mentioned adding nolock parameter to the mount command works but disabling locking is not the best idea.

I ended up just creating a windows share. The main reason I was looking to make the NFS share work was it appeared to be "Faster". Stuff I read was NFS is faster than windows share. To me (forgive my ignorance) faster was transfer speed. When I was messing around (trial and error method), I was getting signficatnly faster (100 MB/sec) file transfer speed than I was on the windows share (20 MB/sec). Just for clarity I was transfering the same file over the same hardware. So I assumed the difference was the "faster" NFS. But later I was able to achieve 100 MB/sec with the windows share when I used a much newer laptop to push the file to the sever. To this day I do not know why the old laptop had such a transfer speed difference between the two type of shares. But went with windows share as it is pretty much recommended and I got it to work with out much fuss. So I still dont know how NFS is measured faster than windows share, but I havent had any issues with performance with my server. Which mostly use for plex and backing up files. Hope that helps some. I suggest keep fiddling with it and determine if you really need the hassle of NFS or not.
 

XStylus

Junior Member
Joined
Nov 22, 2017
Messages
16
@lamb1133 Any update on finding away to get NFS to work on Windows 10 with locking enabled? Like you mentioned adding nolock parameter to the mount command works but disabling locking is not the best idea.

I know this is a mega necropost, but I've posted a bug report for this longstanding issue which seems to still be a problem on TrueNAS 12-MASTER. If you're interested in seeing this fixed, maybe add your voice to the cause.

 

WillysMD

Neophyte
Joined
Dec 15, 2020
Messages
4
Hello everyone,

I'm also stuck on the same issue, I might try to bring @XStylus ticket to the dev's attention.
Anyone has a solution other than disabling locking or moving to SMB ?
 

luxo75

Newbie
Joined
May 6, 2021
Messages
1
Hi everyone,

I'm hitting this one also.
Has anyone tried the suggestion on the ticket https://jira.ixsystems.com/browse/NAS-108237 of using TrueNAS SCALE (i.e via Linux, not FreeBSD)?

I've only just got my first ever TrueNAS Core box going for our critical home/work data so I wasn't feeling brave enough to try SCALE until it has had a good year or so in the wild and any major bugs had been ironed out.

Would love to know if this issue goes away via Linux though?
 

JoHapp

Member
Joined
Jul 29, 2021
Messages
27
I tried the nolock, but the write speed was about 10-30 MB/s (that's a 10% of my SMB speed).

I am wondering if it might be connected with an earlier SMB sharing access to the same pool? I only created a new Filesystem inside my pool, mainly, because all discs are bound to the existing pool, so that I can't create a further. But all SMB services and shares are off now.
 

JoHapp

Member
Joined
Jul 29, 2021
Messages
27
Hi again, i just retried to solve the issue with a complete new pool and directly only starting NFS sharing with that one.
Same result - no writing access by windows machine and with nolock, very slow speeds.

Is that a general bug which occurs to all truenas installations with win10 or do only some users experience that?
 
Top