With the default settings on mounting CIFS I had the problem while uploading a large file (200 – 300 MB) that my system frozen for some seconds. Additionally progress bars in Midnight Commander for example filled up to 100 % in some milliseconds and then it took 5 till 10 minutes until the copy job was finished.
The reason for this was that the dirty block cache of the Linux Kernel was filled by the copy job and sometimes was also full and could only cleared slowly, because of the slow connection to the server.
You can watch the current state of the dirty_cache with:
watch -n 2 "cat /proc/meminfo | egrep -i 'dirty|write'"
Also you can adjust the dirty_background_bytes and dirty_bytes of the kernel, but these settings are system wide and not only for a mountpoint. So you need more cache for local storage to get things fast and small cache for slow remote operations. But you should check the following settings of your kernel:
- vm.dirty_background_bytes
- vm.dirty_bytes
- vm.dirty_expire_centisecs
- vm.dirty_writeback_centisecs
There are many different “best values” found on the internet, but it depends. So I will not add more here.
Sometimes I also get some errors (Error 4 and Error 5), I assume due to timeouts or thatever, after the copy job was finished. Also in kernellog the following entries was reported:
CIFS VFS: No writable handles for inode<br>CIFS VFS: cifs_invalidate_mapping: could not invalidate inode
To solve the problem with the cifs mount, one solution is to disable the cache of this mount. You can do it with the mount option cache=none
of mount.cifs
.
The upload is a little bit slower, but it is stable now.