CIFS VFS: No response to cmd $n mid $m

本文针对Linux系统中使用CIFS协议进行文件传输时出现的一系列错误进行了详细分析,并提供了有效的解决方案,包括调整文件写入块大小及禁用机会锁等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近一台Linux服务器报了一堆
 CIFS VFS: Unexpected lookup error -20
 CIFS VFS: Unexpected lookup error -20
 CIFS VFS: Unexpected lookup error -20
 CIFS VFS: No response for cmd 50 mid 7244
 CIFS VFS: No response to cmd 4 mid 47810
 CIFS VFS: Send error in Close = -11
 CIFS VFS: No response for cmd 50 mid 47818
 CIFS VFS: No response for cmd 50 mid 47822
 CIFS VFS: No response to cmd 5 mid 15521
 CIFS VFS: Send error in Flush = -11
 CIFS VFS: Write2 ret -11, wrote 0
 CIFS VFS: Send error in Close = -9
 CIFS VFS: No response for cmd 50 mid 15526
 CIFS VFS: No response for cmd 50 mid 15530
错误。
没有头绪, 查了一下google, 
/sbin/modprobe cifs
/bin/echo 0 > /proc/fs/cifs/OplockEnabled
/bin/echo 0 > /proc/fs/cifs/LookupCacheEnabled


转载如下 : 

On a few systems, I've noticed CIFS mounts have a tendency to lock up the system when transferring large files, or a shitload of small ones in quick succession. When this happens, the system may or may not completely lock up, and lines like these will appear in your syslog:

Aug 1 22:58:16 dreadnought kernel: CIFS VFS: No response to cmd 46 mid 25661 
Aug 1 22:58:16 dreadnought kernel: CIFS VFS: Send error in read = -11
Aug 1 22:58:16 dreadnought kernel: CIFS VFS: No response for cmd 50 mid 25664
Aug 1 22:58:16 dreadnought kernel: CIFS VFS: No response to cmd 47 mid 25663
Aug 1 22:58:20 dreadnought kernel: CIFS VFS: No response to cmd 47 mid 25662
Aug 1 22:58:20 dreadnought kernel: CIFS VFS: Write2 ret -11, written = 0
Aug 1 22:58:20 dreadnought kernel: CIFS VFS: Send error in read = -9
Aug 1 22:58:20 dreadnought kernel: CIFS VFS: Write2 ret -9, written = 0
Aug 1 22:59:52 dreadnought kernel: CIFS VFS: No writable handles for inode
Aug 1 23:00:29 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:00:36 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:01:16 dreadnought kernel: CIFS VFS: No writable handles for inode
Aug 1 23:02:28 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:03:23 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:03:44 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:05:35 dreadnought kernel: CIFS VFS: No writable handles for inode
Aug 1 23:06:18 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:06:35 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:06:46 dreadnought kernel: CIFS VFS: No writable handles for inode
Aug 1 23:06:46 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:07:02 dreadnought kernel: CIFS VFS: close with pending writes
Aug 1 23:07:46 dreadnought kernel: CIFS VFS: server not respondingI found a workaround which involves disabling Opportunistic Locking. This will have a small performance impact, but at least the thing wont hang up and use 100% CPU for no goddamn reason. Yes, this article has an angry tone, because this issue has eaten way too much of my time today.

To disable Opportunistic Locking, you have to set the contents of the file "/proc/fs/cifs/OplockEnabled" to 0. This file only exists after the cifs module has been loaded, and will be replaced if the module is unloaded and reloaded. Thus, I configured my /etc/rc.local script (use whatever equivalent your distro has to a startup script) to both load the cifs module and set the contents of said file:

# cifs client workaround
modprobe cifs
echo 0 > /proc/fs/cifs/OplockEnabledThere you go.

回复 : 

My function use cifs protocol to transfer file and it usually occur “CIFS VFS: Send error in read = -11
” error.
I searched the cifs reference and get a ways to resovle it.

http://pserver.samba.org/samba/ftp/cifs-cvs/linux-cifs-client-guide.pdf


Performance Considerations
Server speed, server disk speed and network speed can constrain the overall performance of a cifs
mount, but in some cases, client client configuration settings can be changed to increase performance:
1) size of file write (wsize). The Linux CIFS client usually sends 56K writes (14 pages) and is
limited to 56K maximum unless mounted forcedirectio.
2) size of file read (rsize). The Linux CIFS client usually sends 16K reads (4 pages). Since CIFS
large network buffers are about 16K in size by default, increasing the rsize would have little
effect unless the setting of module load parameter CIFSMaxBufSize (via insmod) also is
increased.

I just lower the block of data what i want to write.

you can use command “modinfo cifs” to get the cifs read or write buffer size and buffersize scope.


【参考】

http://blog.dhampir.no/content/cifs-vfs-no-response-for-cmd-n-mid

http://cweiske.de/tagebuch/Timed%20permission%20problems%20on%20CIFS.htm

### 解决方案分析 当遇到 **CIFS VFS server no response reconnect after 180 seconds** 的问题时,可能的原因涉及多个方面,包括网络连接超时设置、文件锁定机制以及服务器端配置不当等问题。以下是针对该问题的具体解决方案: #### 配置 `smbd` 超时时间 如果 `smbd` 在尝试联系 CUPS(Common Unix Printing System)服务器时等待的时间过短,则可能导致连接失败。可以通过调整选项来增加等待时间,从而减少因短暂网络延迟引发的错误。 在 Samba 配置文件中(通常是 `/etc/samba/smb.conf`),可以找到并修改以下参数: ```ini printing = cups printcap name = cups cups options = timeout=300 ``` 这里将 `timeout` 设置为 300 秒(即 5 分钟)。此更改允许 `smbd` 更长时间地等待与 CUPS 服务器建立连接[^1]。 #### 启用严格锁控制 另一个潜在问题是由于文件锁定引起的访问冲突。通过启用严格的文件锁定机制 (`strict locking`) 可以确保每次读写操作都经过检查,防止并发访问导致的数据损坏或挂起现象。 同样,在 `smb.conf` 文件中添加如下行即可激活这一功能: ```ini strict locking = yes ``` 需要注意的是,虽然这种方法提高了数据安全性,但也可能会降低性能表现,特别是在高负载环境下[^2]。 #### 自动重连优化 为了改善客户端断开后的自动恢复能力,还可以考虑调整以下几个关键参数: - `socket options`: 增加 TCP 缓冲区大小有助于提高传输效率; - `deadtime`: 定义闲置会话被关闭前的最大分钟数; - `keepalive`: 设定发送 keep-alive 数据包间隔秒数; 示例配置片段如下所示: ```ini socket options = TCP_NODELAY SO_RCVBUF=65536 SO_SNDBUF=65536 deadtime = 30 keepalive = 60 ``` 以上措施综合运用能够有效缓解甚至彻底解决 “no response” 类型的问题。 ```python # 示例 Python 脚本用于验证 SMB 连接状态 import subprocess def test_smb_connection(server_ip): try: result = subprocess.run(['ping', '-c', '4', server_ip], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result.returncode == 0: print(f"SMB Server {server_ip} is reachable.") else: print(f"Failed to reach SMB Server {server_ip}.") except Exception as e: print(f"An error occurred: {e}") test_smb_connection('192.168.1.1') ```
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值