【问题标题】:how to disable caching in CIFS (samba) on client side in linux如何在 linux 的客户端禁用 CIFS (samba) 中的缓存
【发布时间】:2013-02-01 22:57:02
【问题描述】:

已经开发了一个应用程序,可以在具有 2.6.10 内核的目标上运行。 windows机器上的共享文件夹通过命令挂载:

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

从命令选项forcedirectio 可以理解,我想在客户端禁用缓存。但我做不到。

目标上的可用 RAM 量为 40 MB。当我复制一个大小约为 10MB 的文件时,可用 RAM 大小减少到 30MB。

内核 2.6.10 使用 cifs.1.28。我还将 oplockEnabled 设置为 0(在源代码和 /proc/fs/cifs/OplockEnabled 中)。但它并没有停止缓存。如何真正禁用 cifs 客户端上的缓存?

【问题讨论】:

    标签: caching embedded-linux samba cifs


    【解决方案1】:

    也许为时已晚,但在 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
    }
    

    有关 modprobe.d 语法的更多信息,请参阅man 5 modprobe.d

    此外,CIFS 挂载遵循 cache 选项。根据the mount.cifs manual,设置cache=none应该禁用缓存,而默认为cache=strict

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-18
      • 2018-06-06
      • 1970-01-01
      • 1970-01-01
      • 2010-10-26
      • 2010-11-02
      • 2019-03-22
      相关资源
      最近更新 更多