CIFS directory listing not always correct

Status
Not open for further replies.

incogjag

Cadet
Joined
May 8, 2014
Messages
2
I'm seeing a strange issue with regard to file listing in CIFS. It seems that if I make changes to a share outside of CIFS, it takes some amount of time for the change to actually show up via CIFS.

Here's the scenario:
Share name is called test and points to TopDirectory
TopDirectory
-- ChildDirectory
-- File1.txt


I browse the test share share using Windows 7. I correctly see ChildDirectory and File1.txt both inside TopDirectory (the root level). Next, I SSH into FreeNAS and move File1.txt into ChildDirectory. Here's the problem. Now, using the CIFS client, when I press F5 to refresh TopDirectory, I still see File1.txt. Sometimes I can change to ChildDirectory and I'll see File1.txt there correctly, then I go back to TopDirectory and I still see File1.txt (it appears to be in two locations). If I simply click on the file in the old location, then refresh, it will disappear. If I don't click it, it usually takes a couple minutes before hitting F5 will actually get it to show the proper listing. During tests I've had files simply not show up in the 'new' location as well.

If I connect with a new client, I see the file in the correct location (not in two places). If I do this same file move using a CIFS client A, on CIFS client B, everything shows correctly.

I've tried using smbclient instead of Windows 7, it doesn't appear to have this behavior. Unfortunately, packet traces of this show that smbclient is using smbv1 while Windows 7 is using smbv2 (I have the maximum level set to smbv3 on the server side, there is no minimum). In a test where I had moved files, refreshed the target directory, and they still didn't show up, a packet trace showed that the server simply wasn't returning them in the list. This leads me to believe the client isn't simply caching the listing. It seems like the server has some type of cache for each client?

This is all using FreeNAS 9.2.1.5. The behavior is the same for both ZFS and UFS volumes. This feels like some sort of bug, but I figure I'd post here first to see if there is some behavior in Samba that I'm unaware of. I did this exact same test using an Ubuntu box and did not have this problem (though, different OS and different Samba version). Many posts I've run across deal with either things not auto refreshing (where F5 does work--even that isn't working here). Another similar report didn't have a good answer (refresh=1 is not a valid setting anymore): http://forums.freenas.org/index.php...fresh-on-file-creation-delete-for-cifs.15851/

Thoughts?
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
This is normal. CIFS service does it's own caching of directory listing(and permissions). It doesn't expect you to pull the proverbial rug out from under it.

I've never tried this, but if you need those changes to be immediate you should be able to go to the CLI and as root do "service samba reload". If that doesn't work "service samba restart" will definitely work but it will cause all clients to disconnect from the server.

If you try these and they work please report back.
 

incogjag

Cadet
Joined
May 8, 2014
Messages
2
I've never tried this, but if you need those changes to be immediate you should be able to go to the CLI and as root do "service samba reload". If that doesn't work "service samba restart" will definitely work but it will cause all clients to disconnect from the server.

I tried 'service samba_server reload' and restart. Neither made the files show up. I had to wait 5-10 minutes before the changes appeared. I'll have to do more digging. I don't have this type of behavior using samba on Ubuntu, unless the client itself is behaving differently or perhaps is using a different protocol version.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Interesting. What if you do "service samba stop" and then "service samba start"?

I know the client will cache stuff. How much it caches is very much open for debate. I know I could do a very quick test on my desktop as I have a script that will force windows to dump it's cache. ;)
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Well, I just did some testing.

I shared out /mnt/tank and mounted it in Windows.

I went to M: and saw the directory listing. From an SSH session I created a folder "test". It didn't appear immediately(which is what I expected). But when I refreshed the window with F5 the file immediately appeared(which is what I expected).

Then I deleted the 'test' folder from the SSH session. The folder still appeared in the directory listing, but upon pressing F5 it disappeared again.

This is the exact kind of behavior I'd expect to see. I'm running Windows 7 x64 Ultimate and FreeNAS is using 9.2.0.

Next I did this on my FreeNAS Mini which is running FreeNAS-9.2.1.6-BETA-e8a3956-x64 and it worked the exact same way.

Then I upgraded FreeNAS to the latest nightly, FreeNAS-9.2.1.6-BETA-24f50a9-x64 and it performed the exact same way.

So I take away 3 possibilities:

1. The problem was on 9.2.1.x but has been fixed for the 9.2.1.6-betas.
2. Your client is caching improperly for whatever reason.
3. Your server has been tweaked in some way to create this behavior.

I *never* tweak Windows nor have I tweaked FreeNAS. I'm an ardent supporter that people that think tweaking is necessary usually don't have a clue how this stuff works and is jumping to false conclusions. I have multiple friends that swear by various tweaks, but they're reinstalling Windows regularly for various reasons while I've only had to do reinstalls because I had new hardware.
 

Maroko

Cadet
Joined
Jul 28, 2015
Messages
2
I know this is old thread, but I had similar problem on Windows 7 and this helped:

https://support.microsoft.com/en-us/kb/2646563
https://support.microsoft.com/en-us/kb/2778834

I installed both hotfixes and restarted my PC.

I still need to do refresh (or reopen the current folder) to see new files but it doesn't bother me at all.
(maybe refresh = 1 parameter in samba would solve it, but I didn't try)

Hope this helps if somebody else has this issue in the future.

Source:
http://serverfault.com/questions/475678/weird-issue-on-2008-2008r2-shares-using-smb2
 

katit

Contributor
Joined
Jun 16, 2015
Messages
162
If it helps - I had exactly same issue with mapped drive on Windows 7, and share was on another Windows 7, nothing to do with SAMBA/FreeNAS
 
Status
Not open for further replies.
Top