V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
yiyiwa
V2EX  ›  Linux

NFS Server Lock 相关问题

  •  
  •   yiyiwa · 2016-12-27 15:48:06 +08:00 · 3806 次点击
    这是一个创建于 2893 天前的主题,其中的信息可能已经有所发展或是发生改变。

    因为要使用 Docker ,考虑兼容性相关, 安装的是 Ubuntu 16.04. 然后在此服务器上安装了 NFS server, 在用其它的 Centos 5 访问此服务器时, 运行脚本提示相关错误如下:

    INFO: Failed to obtain system lock on host with error code ENOLCK. Too many segment locks open, system lock table is full, or a remote locking protocol failed (e.g., locking over NFS).

    INFO: Could not lock library for write. Trying again in 15 second(s).

    如果是 Centos 5 却没有这个问题.

    查询了 Cento5 的 NFS 相关参数如下:(参数来自 cat /var/lib/nfs/etab) /home *(rw,sync,wdelay,hide,nocrossmnt,insecure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,mapping=identity)

    Ubuntu NFS 参数如下: /home *(rw,sync,wdelay,hide,nocrossmnt,insecure,root_squash,no_all_squash,no_subtree_check,secure_locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,root_squash,no_all_squash)

    上面也只有 mapping 这个参数在 ubuntu 中没有, 这个似乎也不好加上.

    在 Ubuntu 在配置 NFS,默认就 /etc/default/nfs 但这个文件似乎没什么折腾的. 之前以为是 NFS 版本问题, 后来加上了 --no-nfs-version 4 , 还是一样.

    有遇到过相关问题的朋友吗?

    5 条回复    2017-01-13 15:28:40 +08:00
    BangBang
        1
    BangBang  
       2016-12-27 16:38:45 +08:00   ❤️ 2
    建议贴一下内核版本号,必要复现脚本。

    猜测:
    ```
    BZ#923850
    Previously, the NFS Lock Manager (NLM) did not resend blocking lock requests after NFSv3 server reboot recovery. As a consequence, when an application was running on a NFSv3 mount and requested a blocking lock, the application received an "-ENOLCK" error. This patch ensures that NLM always resends blocking lock requests after the grace period has expired.

    BZ#920267
    The NFSv4 code uses byte range locks to simulate the flock() function, which is used to apply or remove an exclusive advisory lock on an open file. However, using the NFSv4 byte range locks precludes a possibility to open a file with read-only permissions and subsequently to apply an exclusive advisory lock on the file. A previous patch broke a mechanism used to verify the mode of the open file. As a consequence, the system became unresponsive and the system logs filled with a "kernel: nfs4_reclaim_open_state: Lock reclaim failed!" error message if the file was open with read-only permissions and an attempt to apply an exclusive advisory lock was made. This update modifies the NFSv4 code to check the mode of the open file before attempting to apply the exclusive advisory lock. The "-EBADF" error code is returned if the type of the lock does not match the file mode.
    ```

    可能的解决方案:
    升级内核版本。


    利益相关:前 nfs qe 实习生
    yiyiwa
        2
    yiyiwa  
    OP
       2016-12-27 17:05:59 +08:00
    @BangBang
    感谢回复!
    Ubuntu: Linux yy07 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    Centos: Linux yy08 2.6.18-398.el5 #1 SMP Tue Sep 16 20:50:52 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

    还真没想过可能是内核问题. 谢谢提醒!
    BangBang
        3
    BangBang  
       2016-12-27 17:15:16 +08:00   ❤️ 1
    @yiyiwa 因为 linux 下面 nfs server v3/v4 & client v3/v4/v4.1 都是放在内核实现的。
    yiyiwa
        4
    yiyiwa  
    OP
       2016-12-28 13:16:59 +08:00
    确定不是内核问题, 刚才升级到 4.9 了, 还是一样.
    yiyiwa
        5
    yiyiwa  
    OP
       2017-01-13 15:28:40 +08:00
    问题搞定了, 在 autofs 中加入 nolock 就可以了,
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5402 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 07:29 · PVG 15:29 · LAX 23:29 · JFK 02:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.