How to disable caching in CIFS (samba) on the client side in Linux

developed an application to run with a target with the kernel 2.6.10. The shared folder on the Windows machine is installed through the command:

mount -t cifs -o username=xxx,password=xxx,forcedirectio //192.168.170.67/57 /fsRecord

As you can see from the command option forcedirectio, I want to disable client-side caching. But I can not.

The amount of free RAM on the target is 40 MB. When I copy a file about 10 MB in size, the size of free memory is reduced to 30 MB.

The kernel 2.6.10 uses cifs.1.28. I also set oplockEnabled to 0 (both in the source code and in the / proc / fs / cifs / OplockEnabled file). But that did not stop caching. How can I turn off caching on the cifs client for real?

+5
source share
1 answer

, , Arch :

/etc/modprobe.d/cifs.conf
-------------------------
# Disable caching and the CIFS oplog for stable NTFS network shares
options cifs enable_oplocks=0

install cifs /sbin/modprobe --ignore-install cifs $CMDLINE_OPTS && echo 0 > /proc/fs/cifs/LinuxExtensionsEnabled && echo 0 > /proc/fs/cifs/LookupCacheEnabled
remove cifs /sbin/modprobe -r cifs

.

# Shamelessly ripped the Kernel_Modules ArchWiki entry:
# https://wiki.archlinux.org/index.php?title=Kernel_modules&oldid=286087#Bash_function_to_list_module_parameters 

function aa_mod_parameters ()
{
    N=/dev/null;
    C=`tput op` O=$(echo -en "\n`tput setaf 2`>>> `tput op`");
    for mod in $(cat /proc/modules|cut -d" " -f1);
    do
        md=/sys/module/$mod/parameters;
        [[ ! -d $md ]] && continue;
        m=$mod;
        d=`modinfo -d $m 2>$N | tr "\n" "\t"`;
        echo -en "$O$m$C";
        [[ ${#d} -gt 0 ]] && echo -n " - $d";
        echo;
        for mc in $(cd $md; echo *);
        do
            de=`modinfo -p $mod 2>$N | grep ^$mc 2>$N|sed "s/^$mc=//" 2>$N`;
            echo -en "\t$mc=`cat $md/$mc 2>$N`";
            [[ ${#de} -gt 1 ]] && echo -en " - $de";
            echo;
        done;
    done
}

. man 5 modprobe.d modprobe.d.

, CIFS cache. mount.cifs, cache=none , - cache=strict.

+4

All Articles