NFS Server Lock 相关问题

2016-12-27 15:48:06 +08:00
 yiyiwa

因为要使用 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 , 还是一样.

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

3801 次点击
所在节点    Linux
5 条回复
BangBang
2016-12-27 16:38:45 +08:00
建议贴一下内核版本号,必要复现脚本。

猜测:
```
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
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
2016-12-27 17:15:16 +08:00
@yiyiwa 因为 linux 下面 nfs server v3/v4 & client v3/v4/v4.1 都是放在内核实现的。
yiyiwa
2016-12-28 13:16:59 +08:00
确定不是内核问题, 刚才升级到 4.9 了, 还是一样.
yiyiwa
2017-01-13 15:28:40 +08:00
问题搞定了, 在 autofs 中加入 nolock 就可以了,

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/330505

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX