# QNAP NAS Samba Shares Issue



## hackitfast (Apr 27, 2011)

Hey,

I've been having an issue with a QNAP NAS server for a few months now. The computers connecting to it are both Windows 10 and Windows 7 machines.

I have two hard drives set up in RAID1 on the QNAP server, which are hosting Samba shares on an internal network. The computers connected to it are on the LAN and have the shares mapped as network drives. Frequently, the user attempting to modify files on the server through these network drives ends up locking the files through oplocks, or gets strange Excel errors stating he 'cannot open multiple Excel documents at once'.

I've done everything in my power to stop this from happening, minus actually entirely wiping out the QNAP and starting from scratch, although I'm convinced that won't actually fix the issue. Knowing that these network drives are mounted upon boot or after waking from sleep, I had the idea to simply stop the computer from going to sleep or shutting down at all. Strangely, things were working great for a week or two, and now I am getting complaints that things are broken yet again.

Also to note, there are several users (including myself) that use the OpenVPN hosted on this QNAP server to access the shares outside of the network as network locations (not mapped network drives) and we have never had a single issue. It is only the user on the internal network with the mapped network drives that is having these issues: it is driving the both of us *insane*! :facepalm:

Any help would be very greatly appreciated!


----------



## Stancestans (Apr 26, 2009)

You should disable Oplocks as described here https://docs.qnap.com/nas/4.2/SMB/en/index.html?share_folders.htm


----------



## hackitfast (Apr 27, 2011)

Stancestans said:


> You should disable Oplocks as described here https://docs.qnap.com/nas/4.2/SMB/en/index.html?share_folders.htm


We have multiple users (5-6) that could be using the server at any given time, accessing any file and possibly editing the same one. I know that it's unlikely with so few people but it's somewhat mandatory it stay enabled, although it may be a solution if nothing else works.


----------



## Stancestans (Apr 26, 2009)

hackitfast said:


> We have multiple users (5-6) that could be using the server at any given time, accessing any file and possibly editing the same one. I know that it's unlikely with so few people but it's somewhat mandatory it stay enabled, although it may be a solution if nothing else works.


Here's an excerpt from the QNAP documentation I linked to (emphasis mine):



> Lock File (Oplocks): Opportunistic locking is a Windows mechanism for the client to place an opportunistic lock (oplock) on a file residing on a server in order to cache the data locally for improved performance. Oplocks is enabled by default for everyday usage and *should be disabled on networks that require multiple users concurrently accessing the same files.*


----------



## hackitfast (Apr 27, 2011)

> Lock File (Oplocks): Opportunistic locking is a Windows mechanism for the client to place an opportunistic lock (oplock) on a file residing on a server in order to cache the data locally for improved performance. Oplocks is enabled by default for everyday usage and *should be disabled on networks that require multiple users concurrently accessing the same files.*


I could have sworn Oplocks existed to lock files when they are in use, and then unlock when a user closes the file. If they're not needed then I will disable them though.


----------



## Stancestans (Apr 26, 2009)

hackitfast said:


> I could have sworn Oplocks existed to lock files when they are in use, and then unlock when a user closes the file. If they're not needed then I will disable them though.


More information from the horse's mouth here https://docs.microsoft.com/en-us/windows/desktop/fileio/opportunistic-locks

The more you know...


----------



## tristar (Aug 12, 2008)

I think the OP is thinking about a check in/check out process and incorrectly referenced that as an Oplock..


----------



## hackitfast (Apr 27, 2011)

tristar said:


> I think the OP is thinking about a check in/check out process and incorrectly referenced that as an Oplock..


Yes, you are correct.

And thank you again for your help, Stancestans.


----------



## hackitfast (Apr 27, 2011)

The issue is persisting after disabling oplocks, here is the error being received ~~[ File in Use ]~~:










Here is a relevant article in relation to this error (dating back 8 years), and their solution is to ~~[ go to "Organize" then "Layout" and uncheck the "Details pane" ]~~:

https://social.technet.microsoft.co...urrently-in-use?forum=officesetupdeploylegacy

I _think_ the error may be caused by the file preview enabled in Windows which is pre-maturely opening the file through the operating system, and then being opened again in Excel causing a lockout. This preview function is requested by the user having the issue though, so they will not disable it even if it is causing the issue.

My question is, if this might actually be causing the issue, would the fault be of the operating system or the QNAP not handling Samba Shares correctly? If it's neither of those things, what might be going on?

*EDIT:* Wow, I think I actually know what's going on (correct me if I'm wrong).
...

The QNAP server has its own domain controller with its own accounts, and the user's Windows PC has its own local user account. The file preview in Windows is opening the file with the local Windows account, and the server is then opening it again with the Domain Controller's user account under Excel.

My new question is, how do I prevent this from happening, preferably without adding the Windows machine to the domain if possible?


----------



## Stancestans (Apr 26, 2009)

hackitfast said:


> The issue is persisting after disabling oplocks, here is the error being received ~~[ File in Use ]~~:
> 
> 
> 
> ...


Is the affected Excel file a shared workbook yet? For multiple users to simultaneously work on a workbook, it has to be shared. This is a legacy feature that MS is trying to replace with another called co-authoring, but co-authoring requires an Office 365 subscription, supported versions of Excel and cloud storage on OneDrive. Co-authoring DOES NOT support files on server paths or smb paths, such as is the case with the QNAP NAS. You will find this explicitly stated here among other info regarding that error.

Find additionally helpful info via the following links:
https://support.office.com/en-us/ar...orkbooks-150fc205-990a-4763-82f1-6c259303fe05

https://www.ablebits.com/office-add...el-shared-workbook-share-file-multiple-users/


----------



## hackitfast (Apr 27, 2011)

Stancestans said:


> Is the affected Excel file a shared workbook yet? For multiple users to simultaneously work on a workbook, it has to be shared.


The issue isn't that multiple users are trying to access the same file, the issue is that the same user is not able to access his own files without other users having interacted with them. I think it's an issue with a conflict between both local and Domain accounts.


----------



## iamsapphire (Dec 9, 2011)

What about, just have the internal users, use the OpenVPN to access and give it the local IP address of the NAS to connect to.

Or.. make it simple, get a simple, HP, i3-8700 Desktop computer, with Windows 10 Pro, as this is capable of handling up-to 10 user/devices, and now you have Windows Simple interaction.

You can install OpenVPN on it too, for outside connections.

Wouldn't that be simpler?

That's what I do... same cost as a NAS, without the Linux/Samba problems.

(plus, for those that do not know, since Windows Vista, the Core of Windows today (i.e. Windows 10, is Microsoft's Server Core... this made it easier for MS to service, when you just use the same core, for all versions, it all started with Windows Home Server back in 2003)

I setup about 10-15 offices a year, and if these offices are under 10 users, I just install Windows 10 Professional as their "Server"... File Services, Remote VPN, etc... etc... all built in, and recently, I've been using Windows 10 Pro-Workstation and found I can get up-to 15 users running on it comfortably. 

Just some options...

-sapphire


----------



## hackitfast (Apr 27, 2011)

iamsapphire said:


> Or.. make it simple, get a simple, HP, i3-8700 Desktop computer, with Windows 10 Pro, as this is capable of handling up-to 10 user/devices, and now you have Windows Simple interaction.


I was thinking of building a small server and putting Windows Server on it, but the problem is I don't know if the issue will even be resolved, and then I'd have a second server with the same issues.


----------



## VividProfessional (Apr 29, 2009)

I have been recently made aware of issues with qnap devices corrupting files it thinks are open. how or why is a mystery. However this was on a QNAP that was approx. 5 years old and we replaced the disks in it and this solved the file sharing issues we where seeing.


----------



## hackitfast (Apr 27, 2011)

VividProfessional said:


> I have been recently made aware of issues with qnap devices corrupting files it thinks are open. how or why is a mystery. However this was on a QNAP that was approx. 5 years old and we replaced the disks in it and this solved the file sharing issues we where seeing.


Hmm. I mean I can attempt to back up all the files, format both drives (they're ~1 year old WD Reds), and then restore the settings, but for all that effort the chances of it paying off are probably slim. It's definitely a possible solution though.


----------



## hackitfast (Apr 27, 2011)

The issue was resolved. I still don't know exactly what the issue was, but here was the situation and how I made the problem disappear.

The user in the local network who was having file lock issues had 2 computers: one was on Windows 10, and one was on Windows 7. Each of them had access to the Samba shares from the QNAP using mapped network drives. For whatever reason, Windows 7 was causing the the file locks on the file server. By upgrading this machine to Windows 10, the issues disappeared instantaneously and have since not returned. Again, I have no idea _why_ this is, but it stopped without reason.


----------

