Repository navigation
fix: add watchdog timer for mkfs progress stuck at 99% - #49
tianming-1996 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tianming-1996 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR prevents large-drive mkfs quick formatting from remaining stuck at 99% by adding a 5-second watchdog after simulated progress reaches its cap; it detects mkfs termination with pgrep and completes formatting through the existing success path, while leaving normal job-signal and non-mkfs flows unchanged. Sequence diagram for the mkfs progress watchdogsequenceDiagram
participant Timer as QTimer
participant Page as FormattingPage
participant Mkfs as mkfs
participant Job as DUDisksJob
participant Main as MainWindow
Timer->>Page: setProgress(progress < 1)
Timer->>Timer: start(5000) when progress reaches cap
loop Every 5 seconds
Timer->>Mkfs: pgrep mkfs
alt mkfs still running
Mkfs-->>Timer: exit code 0
else mkfs has exited
Mkfs-->>Timer: exit code 1
Timer->>Timer: stop()
Timer->>Page: setProgress(1)
Timer->>Job: disconnect()
Timer->>Main: onFormatingFinished(true)
end
end
Job-->>Main: completed()
Main->>Page: setProgress(1)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Root cause: mkfs quick format uses simulated progress timer that caps at 0.99; completion relies solely on DUDisksJob::completed signal which may not fire for large drives (1TB+ ext3) 2. Fix: after progress reaches 0.99, start a 5s watchdog timer that checks if the specific device's mkfs process is still running via pgrep -f with the device path; if exited, force-complete the flow 3. Impact: only activates when completed signal fails to arrive; normal formatting path is unaffected; watchdog has 5min max retry Log: fix format progress stuck at 99% for large drives Influence: 1. Test formatting with small USB drive (normal path) 2. Test formatting with large drive (1TB+) using ext3 3. Verify progress completes to 100% when mkfs finishes 4. Test concurrent formatting of multiple devices fix: 修复大容量磁盘格式化进度卡在99%的问题 1. 根因:mkfs快速格式化使用模拟进度计时器,上限为0.99;完成 仅依赖DUDisksJob::completed信号,大容量磁盘(1TB+)该信号可能不触发 2. 方案:进度到达0.99后启动5秒看门狗计时器,通过pgrep -f结合 设备路径检测对应mkfs进程是否退出;若已退出则强制完成格式化流程 3. 影响:仅在completed信号未到达时激活,不影响正常格式化路径; 看门狗最大重试5分钟后超时失败 Log: 修复大容量磁盘格式化进度卡在99%的问题 Influence: 1. 测试小容量U盘格式化(正常路径) 2. 测试大容量磁盘(1TB+) ext3格式化 3. 验证mkfs完成后进度能推进到100% 4. 测试多设备并发格式化场景 Bug: #291279
41b8816 to
17de267
Compare
|
CLA Assistant Lite bot: deepin seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
fix: add watchdog timer for mkfs progress stuck at 99%
Root Cause
When formatting large drives (1TB+ ext3) via
dde-device-formatter, the mkfs quick format path uses a simulated progress timer (step 0.06 / 300ms interval) that caps at 0.99 (99%). The only path to 100% is theDUDisksJob::completedsignal. For large drives,mkfs.ext3takes a very long time and the UDisks2 DBus job object may become invalid, causing thecompletedsignal to never fire — leaving the progress bar permanently stuck at 99%.Source evidence:
view/mainwindow.cpp:135—setProgress(0.99)hardcoded cap;view/mainwindow.cpp:140—DUDisksJob::completedis the only path tosetProgress(1).Fix
Added a watchdog timer inside the mkfs simulation progress lambda: when
m_simulationProgressValue >= 1(progress reached 0.99), the timer switches to a 5-second interval and checks if the mkfs process is still running viapgrep mkfs. If mkfs has exited (pgrep returns exit code 1), the timer stops, sets progress to 1, disconnects the job, and callsonFormatingFinished(true)to complete the formatting flow.The normal path (
DUDisksJob::completedsignal fires normally) is completely unaffected — the watchdog only activates when the signal fails to arrive.Change Safety
Business Impact Scope
DUDisksJob::completedsignal fails to arriveVerification Suggestion
Test small USB drive quick formatting (normal path) and large drive (1TB+) ext3 formatting (watchdog path).
根因分析
使用
dde-device-formatter格式化大容量磁盘(1TB+ ext3)时,mkfs 快速格式化使用模拟进度计时器(步长 0.06 / 300ms 间隔),上限固定为 0.99(99%)。唯一推进到 100% 的路径是DUDisksJob::completed信号。大容量磁盘mkfs.ext3耗时极长,UDisks2 DBus job 对象可能失效,导致completed信号不触发,进度条永久卡在 99%。源码证据:
view/mainwindow.cpp:135—setProgress(0.99)硬编码上限;view/mainwindow.cpp:140—DUDisksJob::completed是唯一推进到setProgress(1)的路径。修复方案
在 mkfs 模拟进度计时器 lambda 内新增看门狗逻辑:当
m_simulationProgressValue >= 1(进度到达 0.99)时,计时器切换为 5 秒间隔,通过pgrep mkfs检测 mkfs 进程是否仍在运行;若 mkfs 已退出(pgrep 返回退出码 1),则停止计时器、设置进度为 1、断开 job 连接并调用onFormatingFinished(true)完成格式化流程。正常路径(
DUDisksJob::completed信号正常触发)完全不受影响——看门狗仅在信号未到达时激活。改动安全评估
代码安全评估
业务影响范围
验证建议
测试小容量 U 盘快速格式化(正常路径)和大容量硬盘(1TB+)ext3 格式化(看门狗路径)。
Summary by Sourcery
Add watchdog handling to ensure mkfs formatting either completes or reports failure when progress reaches 99% without a completion signal.
Bug Fixes: