سؤال

I am writing a streaming server for linux that reads files from CIFS mounts and sends them over a socket. Ideally, linux will cache the file in memory so that subsequent reads will be faster. Is this the case? Can I tell the kernel to cache network reads ?

Edit: there will be multiple reads, but no writes, on these files.

Thanks!

Update: I've tested this on a CIFS volume, using fadvise POSIX_FADV_WILLNEED to cache the file locally (using linux-ftools on command line). Turns out that the volume needs to be mounted in read-write mode for this to work. In read only mode, the fadvise seems to be ignored. This must have something to do with the samba oplock mechanism.

هل كانت مفيدة؟

المحلول

Subject to the usual cache coherency rules [1] in CIFS, yes, the kernel CIFS client will cache file data.

[1] Roughly, CIFS is uncached in principle, but by taking oplocks the client can cache data more aggressively. For an explanation of CIFS locking, see e.g. the Samba manual at http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/locking.html . If the client(s) open the files in read only mode, then I suspect the client will use level 2 oplocks, and as there's no conflicting access takes place, multiple clients should be able to have level 2 oplocks for the same files. Only when some client requests write access to the files, will the oplocks be broken.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top