Does someone know i fit is possible to detect from a client if on the fileserver SMB2 is on or off?
Thanks in advance
Otto
My question is a slight variation on the question What is the best way to test whether a file exists on Windows?, with some specific caveats. Specifically, the data is located on a mapped drive, and the SMB 2.0 protocol is used. (By definition, this requires that the drive be mapped from a Vista machine to either a Vista or Server 2008 machine.)
The problem with the answers posted in reply to the above question is that SMB 2.0 caches a bunch of metadata, including filenames in a given directory. As a result, if you are testing for the existence of a file that was just created, then functions _access, access, GetFileAttributes, and CreateFile (and perhaps others) will all use cached information to answer the question "does this file exist?". If the file was very recently created by another user, the cache indicates that the file is not present, despite the fact that it does indeed exist. I've set up test environments to test this, and I can confirm that no SMB2 traffic is generated by the client for several seconds [presumably the cache expires every 5 seconds or so].
Has anyone else seen this? (If so, did you find a workaround other than adding a delay/retry?) Does anyone know of any API similar to the above that can check for file existence without using the SMB cache? Or, better yet, does anyone know of a Windows API that will simply dump the cached SMB metadata?
Why do you need to do this exactly? Why is it a problem if the cache gives the "wrong" answer? What depends on it "working"? – John Zwinck Feb 25 '09 at 1:49
Well, without going into too much detail, a user initiates a process that causes a new file to be created in the share. If that file is created by another machine, the "wrong" answer means that the user can't open the file, because SMB2 won't send the open request if the file "doesn't exist". – Jedidiah Thomet Feb 25 '09 at 18:16
I think you should go into more detail. I imagine there is some other aspect of the design that could be improved to provide a satisfactory user experience. – John Zwinck Feb 26 '09 at 4:19
While not a programmatic solution, I found an effective workaround (with the help of Microsoft support). I wanted to post the workaround here in case anyone else is as frustrated by this as I have been. Because this behavior is a "feature" of SMB2, Microsoft has provided the following registry entries to override the default metadata cache lifetime:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\FileInfoCacheLifetime HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\FileNotFoundCacheLifetime HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\DirectoryCacheLifetime Each of these are DWORD values, which can be set according to your needs. (Setting these to 0 on the SMB2 client was effective in resolving my issue.)
Please note that we will not publish any knowledge base content on the new settings until 2008R2 & Windows 7 are released; so my earlier comment was a bit premature. The information on the new settings is all that is available at this time.
Thanks for your patience!
Regards,
Bill Wesse
==============================================================================
Registry values
All listed settings are in the following registry location:
Key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanWorkStation\Parameters
Value type: REG_*
Value name: <name of value>
Default: <value if note present>
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: AllowGuestAuthWhenSigningRequired
Default: FALSE
Group Policy settings are not applied on member computers that are running Windows Server 2008 or Windows Vista SP1 when certain SMB signing policies are enabled
http://support.microsoft.com/kb/950876
When a Server Message Block (SMB) version 1 client establishes a non-guest session or a non-anonymous session with a server, the client enables security signatures for the server. Later sessions then inherit the security signature sequence that is already established.
To improve security, Windows Server 2008 and Windows Vista SP1 prevent server authenticated connections from being maliciously downgraded to a guest session or to an anonymous session. However, this improved security does not address the scenario that is described in the "Symptoms" section (Event ID: 1058).
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: FileInfoCacheLifetime
Default: 10 (seconds)
Used for increasing network file system performance.
The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: FileNotFoundCacheLifetime
Default: 5 (seconds)
Used for increasing network file system performance. The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: DirectoryCacheLifetime
Default: 10 (seconds)
Used for increasing network file system performance. The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: DisableBandwidthThrottling
Default: FALSE
Performance Tuning Guidelines for Windows Server 2008.
http://go.microsoft.com/fwlink/?LinkId=121171
The default is 0. This setting is available starting with Windows Server 2008 SP2. By default, the SMB redirector throttles throughput across high-latency network connections in some cases to avoid network-related timeouts. Setting this registry value to 1 disables this throttling, enabling higher file transfer throughput over high-latency network connections.
==============================================================================
Windows 2003, ...
Value type: REG_DWORD
Value name: DisableByteRangeLockingOnReadOnlyFiles
Default: FALSE
How To Improve Windows 2003 File Server Performance
http://support.microsoft.com/kb/555041
==============================================================================
Windows 2003, ...
Value type: REG_DWORD
Value name: ExtendedSessTimeout
Default: 1000 (seconds)
Value type: REG_MULTI_SZ
Value name: ServersWithExtendedSessTimeout
Default: <null>
May be useful in high latency networks.
Controls the time-out period that the client uses when sending requests to a server listed in ServersWithExtendedSessTimeout. The default is value is 1000 (or 16.67 minutes). You can increase this value on all Windows 2003 and later systems.
==============================================================================
Windows 2003, ...
Value type: REG_DWORD
Value name: NoDeleteOnClose
Default: FALSE
You cannot modify or delete files on an OS/2 Warp 4-based server that uses the HPFS file system
http://support.microsoft.com/kb/813586
==============================================================================
Windows 2003, ...
Value type: REG_DWORD
Value name: ScavengerTimeLimit
Default: 0 (seconds)
How To Improve Windows 2003 File Server Performance
http://support.microsoft.com/kb/555041
You may experience delays of between 10 and 60 seconds when you use UNC paths to access files that are stored on a remote SMB server on a multihomed Windows Server 2003-based computer
http://support.microsoft.com/kb/890553
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: EnableCachingOnWriteOnlyOpens
Default: FALSE
Write only files are not cacheable; note that this setting is not recommended due to possible side effects.
Use SetFilePointer(...) and SetEndOfFile(...) instead.
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: EnableDownLevelLogOff
Default: FALSE
Net3101 Error on OS/2 Server Because of SessionSetup SMB
http://support.microsoft.com/kb/323582
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: EnablePlainTextPassword
Default: FALSE
Unencrypted Passwords May Cause SP3 to Fail to Connect to SMB Servers
http://support.microsoft.com/kb/166730
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: EnableSecuritySignature
Default: TRUE
Value type: REG_DWORD
Value name: RequireSecuritySignature
Default: FALSE
Overview of Server Message Block signing
http://support.microsoft.com/kb/887429
Group Policy settings are not applied on member computers that are running Windows Server 2008 or Windows Vista SP1 when certain SMB signing policies are enabled
http://support.microsoft.com/kb/950876
Server Message Block communication between a client-side SMB component and a server-side SMB component is not completed if the SMB signing settings are mismatched in Group Policy or in the registry
http://support.microsoft.com/kb/916846
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: OffLineFileTimeoutIntervalInSeconds
Default: 1000
Maurizio wrote:Ciao Otto
http://social.msdn.microsoft.com/Forums ... 0138a4cd7c
Regards MaurizioPlease note that we will not publish any knowledge base content on the new settings until 2008R2 & Windows 7 are released; so my earlier comment was a bit premature. The information on the new settings is all that is available at this time.
Thanks for your patience!
Regards,
Bill Wesse
==============================================================================
Registry values
All listed settings are in the following registry location:
Key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanWorkStation\Parameters
Value type: REG_*
Value name: <name of value>
Default: <value if note present>
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: AllowGuestAuthWhenSigningRequired
Default: FALSE
Group Policy settings are not applied on member computers that are running Windows Server 2008 or Windows Vista SP1 when certain SMB signing policies are enabled
http://support.microsoft.com/kb/950876
When a Server Message Block (SMB) version 1 client establishes a non-guest session or a non-anonymous session with a server, the client enables security signatures for the server. Later sessions then inherit the security signature sequence that is already established.
To improve security, Windows Server 2008 and Windows Vista SP1 prevent server authenticated connections from being maliciously downgraded to a guest session or to an anonymous session. However, this improved security does not address the scenario that is described in the "Symptoms" section (Event ID: 1058).
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: FileInfoCacheLifetime
Default: 10 (seconds)
Used for increasing network file system performance.
The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: FileNotFoundCacheLifetime
Default: 5 (seconds)
Used for increasing network file system performance. The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: DirectoryCacheLifetime
Default: 10 (seconds)
Used for increasing network file system performance. The caches are consistent when changes are made by the client, but if changes are made from another client, they may not be reflected until the cache times out.
==============================================================================
Vista, 2008, ...
Value type: REG_DWORD
Value name: DisableBandwidthThrottling
Default: FALSE
Performance Tuning Guidelines for Windows Server 2008.
http://go.microsoft.com/fwlink/?LinkId=121171
The default is 0. This setting is available starting with Windows Server 2008 SP2. By default, the SMB redirector throttles throughput across high-latency network connections in some cases to avoid network-related timeouts. Setting this registry value to 1 disables this throttling, enabling higher file transfer throughput over high-latency network connections.
==============================================================================
Windows 2003, ...
Value type: REG_DWORD
Value name: DisableByteRangeLockingOnReadOnlyFiles
Default: FALSE
How To Improve Windows 2003 File Server Performance
http://support.microsoft.com/kb/555041
==============================================================================
Windows 2003, ...
Value type: REG_DWORD
Value name: ExtendedSessTimeout
Default: 1000 (seconds)
Value type: REG_MULTI_SZ
Value name: ServersWithExtendedSessTimeout
Default: <null>
May be useful in high latency networks.
Controls the time-out period that the client uses when sending requests to a server listed in ServersWithExtendedSessTimeout. The default is value is 1000 (or 16.67 minutes). You can increase this value on all Windows 2003 and later systems.
==============================================================================
Windows 2003, ...
Value type: REG_DWORD
Value name: NoDeleteOnClose
Default: FALSE
You cannot modify or delete files on an OS/2 Warp 4-based server that uses the HPFS file system
http://support.microsoft.com/kb/813586
==============================================================================
Windows 2003, ...
Value type: REG_DWORD
Value name: ScavengerTimeLimit
Default: 0 (seconds)
How To Improve Windows 2003 File Server Performance
http://support.microsoft.com/kb/555041
You may experience delays of between 10 and 60 seconds when you use UNC paths to access files that are stored on a remote SMB server on a multihomed Windows Server 2003-based computer
http://support.microsoft.com/kb/890553
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: EnableCachingOnWriteOnlyOpens
Default: FALSE
Write only files are not cacheable; note that this setting is not recommended due to possible side effects.
Use SetFilePointer(...) and SetEndOfFile(...) instead.
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: EnableDownLevelLogOff
Default: FALSE
Net3101 Error on OS/2 Server Because of SessionSetup SMB
http://support.microsoft.com/kb/323582
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: EnablePlainTextPassword
Default: FALSE
Unencrypted Passwords May Cause SP3 to Fail to Connect to SMB Servers
http://support.microsoft.com/kb/166730
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: EnableSecuritySignature
Default: TRUE
Value type: REG_DWORD
Value name: RequireSecuritySignature
Default: FALSE
Overview of Server Message Block signing
http://support.microsoft.com/kb/887429
Group Policy settings are not applied on member computers that are running Windows Server 2008 or Windows Vista SP1 when certain SMB signing policies are enabled
http://support.microsoft.com/kb/950876
Server Message Block communication between a client-side SMB component and a server-side SMB component is not completed if the SMB signing settings are mismatched in Group Policy or in the registry
http://support.microsoft.com/kb/916846
==============================================================================
Windows 2000, ...
Value type: REG_DWORD
Value name: OffLineFileTimeoutIntervalInSeconds
Default: 1000
driessen wrote:I have always disabled SMB2 on the server and on the workstations.
I never noticed that index problem again.
#include "FiveWin.Ch"
#define HKEY_LOCAL_MACHINE 2147483650
//---------------------------------------------------------------------------//
function Main()
LOCAL oReg, cName, uVar
oReg := TReg32():Create( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters" )
// Call Set with an empty string to access the default key
oReg:Set( "FileInfoCacheLifetime", 0 )
oReg:Set( "FileNotFoundCacheLifetime", 0 )
oReg:Set( "DirectoryCacheLifetime", 0 )
oReg:Close()
oReg := TReg32():Create( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\services\LanmanServer\Parameters" )
// Call Set with an empty string to access the default key
oReg:Set( "Smb2", 0 )
oReg:Close()
MsgInfo( "Windows registry updated!" )
return nil
driessen wrote:I have always disabled SMB2 on the server and on the workstations.
I never noticed that index problem again.
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 55 guests