406 Star 1.5K Fork 1.4K

GVPopenEuler/kernel

 / 详情

【OLK-5.10】拔网线cifs写文件的进程stuck住无法退出

已完成
任务
创建于  
2024-07-05 10:41

【严重程度】 一般
【特性】
【重现类型】 有条件概率重现
【定位分析】


该问题的根因是CIFS在writepages 时 lock_page ,等待其cifsd 进程清理PG_writeback标记后unlock_page。但是由于cifsd 清理PG_writeback 发生reconnect,导致进入cifs_writev_requeue() 函数中,基线lock_page导致死锁。


进程1(dd) 进程2(cifsd) 进程3(cifsiod worker)
cifs_writepages
lock_page - [1]
wait_on_page_writeback - [2] 等待write标记被清理,被 [4] 阻塞
wait_on_page_bit
cifs_demultiplex_thread
cifs_read_from_socket
cifs_readv_from_socket
- 如果此时其他进程触发了reconnect
cifs_reconnect
- mid->mid_state 被更新为 MID_RETRY_NEEDED
smb2_writev_callback mid_entry->callback()
- mid_state 进而导致wdata->result = -EAGAIN
wdata->result = -EAGAIN
queue_work(cifsiod_wq, &wdata->work);
cifs_writev_complete - worker函数
- 条件满足
else if (..&& wdata->result == -EAGAIN)
cifs_writev_requeue
lock_page - [3] 被[1]阻塞
end_page_writeback - [4] 不会诶执行,被 [3]阻塞
unlock_page



这就导致了cifs_writepages 和 cifsiod 的worker 陷入循环等待中,导致死锁


主线重构修补程序d08089f649a0(“cifs:将I/O路径更改为使用迭代器而不是页列表”)在等待写回完成时解锁页,从而避免在重新连接期间由锁顺序问题导致的潜在死锁。


由于主线的大重构,补丁不能直接backport。因此,本补丁只是借鉴了主线补丁的部分思路来修复死锁。


评论 (1)

Hi zhixiuzhou, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Kernel, and any of the maintainers.

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
5329419 openeuler ci bot 1632792936
C
1
https://gitee.com/openeuler/kernel.git
git@gitee.com:openeuler/kernel.git
openeuler
kernel
kernel

搜索帮助