none
Disabling oplock/SMB2 vs FileInfoCacheLifetime

    Question

  • A few years ago we had a situation where users accessing shared ISAM database files located on a server are experiencing frequent file locks and data corruption. The server can be windows 2000 and up. The clients could be running windows 2000 and up.

    To solve this we disabled oplocking and SMB2 which has been working fine so far.

    It has now come to our attention that we can leave SMB2 enabled and instead disable the following on the client side:

    FileInfoCacheLifetime

    FileNotFoundCacheLifetime

    DirectoryCacheLifetime

    Can anyone point out the pros and cons of disabling SMB2 or leaving SBM2 enabled and only disabling the the above mentioned keys? Users can either read/write the files from their own client computer or directly on the server via terminal services.

    Thanks

    Friday, November 25, 2011 12:17 AM

Answers

  • Looks like you didnt get a chance to go through:

    SMB2 Client Redirector Caches Explained http://technet.microsoft.com/en-us/library/ff686200(WS.10).aspx

     

    When you use SMB and oplocks, the client caches the data that is locked to speed up the accessed to frequently accessed file info.

    This is the client side setting that controls the caches life time, if we stop caching then we are reading from the server directly and there is no chance for cached data getting stale and causing corruption.

     

    Hope that helps.

     

     


    Sumesh P - Microsoft Online Community Support
    Friday, December 2, 2011 12:09 PM
    Moderator

All replies

  • http://social.technet.microsoft.com/Forums/en-US/winserverfiles/thread/67baa9fd-5eaf-438e-9cc4-dc1a531b9e19


    Here's what you'll miss out if you were to disable SMB 2.0

    What's New in SMB http://technet.microsoft.com/en-us/library/ff625695(WS.10).aspx


    As for the SMB cache, the following link details its usage and is self explanatory:

    SMB2 Client Redirector Caches Explained http://technet.microsoft.com/en-us/library/ff686200(WS.10).aspx


    Per the link,

    Recommendations

    If you suspect metadata caching in the redirector as cause for misbehaving applications, disable the caches in the following order to determine which of these caches is affecting the application. Disabling the File information cache can have significant effect on client performance and show an increase in the number of metadata requests that are sent to the server.

    1. Directory cache, by setting DirectoryCacheLifetime to ZERO.
    2. File Not Found cache, by setting FileNotFoundCacheLifetime to ZERO.
    3. File information cache, by setting FileInfoCacheLifetime to ZERO.

     


    Sumesh P - Microsoft Online Community Support
    Friday, November 25, 2011 10:00 AM
    Moderator
  • I assume that disabling SMB2 affects network performance more than just disabling the SMB2 caches?

    We had a site that lost all of their networked driver paths(mapped drives) when SMB2 was disabled.  Disabling only the file caches should not cause this to happen?

    Is there away to disable the SMB2 caches on the server side as instead of each clients? as we need to be sure that all clients connecting to the database are not caching files and any new clients introduced later on also need the file caching disabled before connecting to the database. 

     

    Sunday, November 27, 2011 8:28 PM
  • Yes

    This should not have happed.

    There are no server side settings.

    Once a server returns data to a client there’s nothing the server can do to prevent the client from caching that data. Even if the server could somehow mark the data as non-cacheable, there’s no way for the server to enforce this.

    If the machines are part of a domain you can use one of the methods described in this article to configure them centrally: http://blogs.technet.com/b/askds/archive/2007/08/14/deploying-custom-registry-changes-through-group-policy.aspx


    Sumesh P - Microsoft Online Community Support
    Tuesday, November 29, 2011 2:33 AM
    Moderator
  • However you should look at fixing the corruption issue. There are a few known issues that has hotfix.

    What is your SP level?

    The one below deals with a corruption issue and the workaround is also on the same lines as you are doing but is for Win7 RTM.

    2028965 Data corruption when multiple users perform read and write operations to a shared file in the SMB2 environment

    2618096 Data corruption when one user on a computer that is running Windows 7 or Windows Server 2008 R2 updates a shared file that is open on multiple computers by using SMB Version 2


    Sumesh P - Microsoft Online Community Support
    Tuesday, November 29, 2011 2:36 AM
    Moderator
  • We have been trying to test the effects of oplocking on our ISAM database but so far it seems to not be causing an issue.  However we know that in the past our clients have had to disable oplocking to prevent data corruption.

    Can anyone suggest a simple test/setup that will show oplocking in action or the issues that oplocking can cause.  As far as I know if I get a lock on a file or a region of a file and then another user tries to get a lock, then my lock will be released to the other user. Is that how it is supposed to work? We have so far not been able to get this to happen

    Wednesday, November 30, 2011 8:14 PM
  •  

    With Exclusive Oplock, if a file is opened in a non-exclusive (deny none) mode, the redirector requests an opportunistic lock of the entire file. As long as no other process has the file open, the server will grant this oplock, giving the redirector exclusive access to the specified file. This will allow the redirector to perform read-ahead, write-behind, and lock caching, as long as no other process tries to open the file.

    When a second process attempts to open the file, the original owner will be asked to Break Oplock or Break to Level II Oplock. At that point, the redirector must invalidate cached data, flush writes and locks, and release the oplock, or close the file.

    Opportunistic Locking level II, provides a method for granting read access to a file by more than one workstation, and these workstations can cache read data locally (read-ahead). As long as no station writes to the file, multiple stations can have the file open with level II oplock.

     

    http://support.microsoft.com/kb/129202

     

     

    By default, opportunistic locking is enabled for server message block (SMB) clients. Opportunistic locking lets clients lock files and locally cache information without the risk of another user changing the file. This increases performance for many file operations but may decrease performance in other operations because the server that grants the opportunistic lock must manage the breaking of that lock when another user requests access to the file.

    Notes for Windows Vista and later Operating Systems (i.e. Windows 7)

     

    The opportunistic locking registry keys are valid only for traditional SMB (SMB1). You cannot turn off opportunistic locking for SMB2. SMB2 was introduced in Windows Vista to enable faster communication between computer that are running Windows Vista and Windows Server 2008 or Windows Server 2008 R2.

     

    If you disable opportunistic locking, the offline files feature in Windows Vista or Windows 7 fails.

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;296264


    Sumesh P - Microsoft Online Community Support
    Thursday, December 1, 2011 3:28 AM
    Moderator
  • Thats great.  but i dont see how disabling the following reg keys would resolve the issues caused by oplocking:

    FileInfoCacheLifetime

    FileNotFoundCacheLifetime

    DirectoryCacheLifetime


    The microsoft website says FileInfoCacheLifetime deals with the caching of file attributes whereas the other two only cache that the file was not found and the directory enumeration.  How does this resolve oplocking issues?

    Thursday, December 1, 2011 4:13 AM
  • ????

    What are you referring to?

    I thought you said that disabling those fixed the issue in your environment.

    Am I missing something?


    Sumesh P - Microsoft Online Community Support
    Thursday, December 1, 2011 4:18 AM
    Moderator
  • Sorry I meant disabling SMB1 and SMB2 fixed the issue but we have recently been told that disabling the following keys can fix the issue without disabling SMB2. However these key don't seem to refer to oplocking so I dont see how its possible thats why I'm asking here.

    FileInfoCacheLifetime

    FileNotFoundCacheLifetime

    DirectoryCacheLifetime

    Thursday, December 1, 2011 8:45 PM
  • Looks like you didnt get a chance to go through:

    SMB2 Client Redirector Caches Explained http://technet.microsoft.com/en-us/library/ff686200(WS.10).aspx

     

    When you use SMB and oplocks, the client caches the data that is locked to speed up the accessed to frequently accessed file info.

    This is the client side setting that controls the caches life time, if we stop caching then we are reading from the server directly and there is no chance for cached data getting stale and causing corruption.

     

    Hope that helps.

     

     


    Sumesh P - Microsoft Online Community Support
    Friday, December 2, 2011 12:09 PM
    Moderator