fix: add UI error handling for direct IO copy operations#3564
fix: add UI error handling for direct IO copy operations#3564deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
1. Removed redundant error message parameters from doHandleErrorAndWait calls 2. Added immediate errno saving to prevent value corruption 3. Implemented system error to job error type mapping function 4. Added UI dialog support for read/write errors during direct IO copy 5. Implemented retry mechanism for failed operations with proper file seeking Log: Fixed direct IO copy operations to show proper error dialogs instead of silently failing Influence: 1. Test direct IO copy with insufficient disk space scenarios 2. Verify permission denied errors trigger proper UI dialogs 3. Test retry functionality for transient I/O errors 4. Validate error mapping for various system error codes 5. Check file position handling during retry operations fix: 为直接IO拷贝操作添加UI错误处理 1. 从doHandleErrorAndWait调用中移除冗余的错误消息参数 2. 添加立即保存errno值以防止值被破坏 3. 实现系统错误到作业错误类型的映射函数 4. 为直接IO拷贝过程中的读写错误添加UI对话框支持 5. 实现失败操作的重试机制,包含正确的文件定位处理 Log: 修复直接IO拷贝操作,现在会显示正确的错误对话框而不是静默失败 Influence: 1. 测试磁盘空间不足场景下的直接IO拷贝 2. 验证权限拒绝错误是否正确触发UI对话框 3. 测试瞬时I/O错误的重试功能 4. 验证各种系统错误代码的错误映射 5. 检查重试操作期间的文件位置处理
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Johnson-zs 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 GuideAdds robust UI-visible error handling and retry support for direct I/O copy operations by mapping system errno values to job error types, saving errno early, and wiring read/write failures into the existing job handler dialog flow. Sequence diagram for direct IO copy error handling and retrysequenceDiagram
actor User
participant DoCopyFileWorker
participant AbstractJobHandler
participant FileSystem
User->>DoCopyFileWorker: doCopyFileWithDirectIO
DoCopyFileWorker->>FileSystem: read chunk with O_DIRECT
FileSystem-->>DoCopyFileWorker: error, sets errno
alt read_error
DoCopyFileWorker->>DoCopyFileWorker: savedErrno = errno
DoCopyFileWorker->>DoCopyFileWorker: jobError = mapSystemErrorToJobError(savedErrno, false)
DoCopyFileWorker->>AbstractJobHandler: doHandleErrorAndWait(jobError, isWriteError false)
AbstractJobHandler-->>DoCopyFileWorker: action (Retry or Skip or Cancel)
alt action is Retry
DoCopyFileWorker->>FileSystem: lseek(srcFd, copied, SEEK_SET)
FileSystem-->>DoCopyFileWorker: seek result
DoCopyFileWorker->>FileSystem: retry read chunk
FileSystem-->>DoCopyFileWorker: data or error
else action is Skip or Cancel
DoCopyFileWorker->>DoCopyFileWorker: success = false
DoCopyFileWorker-->>User: operation skipped or cancelled
end
end
alt write_error
DoCopyFileWorker->>FileSystem: write chunk with O_DIRECT
FileSystem-->>DoCopyFileWorker: error, sets errno
DoCopyFileWorker->>DoCopyFileWorker: savedErrno = errno
opt O_DIRECT_invalid
DoCopyFileWorker->>FileSystem: fcntl remove O_DIRECT
FileSystem-->>DoCopyFileWorker: flags updated
DoCopyFileWorker->>FileSystem: retry write without O_DIRECT
FileSystem-->>DoCopyFileWorker: success or error
end
DoCopyFileWorker->>DoCopyFileWorker: jobError = mapSystemErrorToJobError(savedErrno, true)
DoCopyFileWorker->>AbstractJobHandler: doHandleErrorAndWait(jobError, isWriteError true)
AbstractJobHandler-->>DoCopyFileWorker: action (Retry or Skip or Cancel)
alt action is Retry
DoCopyFileWorker->>FileSystem: lseek(writer.fd, copied + bytesWritten, SEEK_SET)
FileSystem-->>DoCopyFileWorker: seek result
DoCopyFileWorker->>FileSystem: retry write chunk
FileSystem-->>DoCopyFileWorker: success or error
else action is Skip or Cancel
DoCopyFileWorker->>DoCopyFileWorker: success = false
DoCopyFileWorker-->>User: operation skipped or cancelled
end
end
Class diagram for DoCopyFileWorker error mapping and handling changesclassDiagram
class DoCopyFileWorker {
+doCopyFileWithDirectIO(fromInfo, toInfo, skip) NextDo
-handlePauseResume(writer, dest, skip) bool
-actionToNextDo(action, size, skip) NextDo
-shouldFallbackFromCopyFileRange(errorCode) bool
-mapSystemErrorToJobError(systemErrno, isWriteError) JobErrorType
}
class AbstractJobHandler {
<<interface>> AbstractJobHandler
+doHandleErrorAndWait(fromUri, toUri, jobError, isWriteError) SupportAction
}
class JobErrorType {
<<enumeration>> JobErrorType
kOpenError
kNotEnoughSpaceError
kPermissionDeniedError
kWriteError
kReadError
kProrogramError
kNonexistenceError
}
class SupportAction {
<<enumeration>> SupportAction
kRetryAction
kSkipAction
kCancelAction
}
DoCopyFileWorker ..> AbstractJobHandler : uses
DoCopyFileWorker ..> JobErrorType : returns
DoCopyFileWorker ..> SupportAction : converts_to
AbstractJobHandler ..> JobErrorType : consumes
AbstractJobHandler ..> SupportAction : returns
AbstractJobHandler o-- JobErrorType
AbstractJobHandler o-- SupportAction
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review这份代码 diff 主要针对 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与建议
修正后的代码片段建议: AbstractJobHandler::JobErrorType DoCopyFileWorker::mapSystemErrorToJobError(int systemErrno, bool isWriteError)
{
switch (systemErrno) {
case ENOSPC: // No space left on device
return AbstractJobHandler::JobErrorType::kNotEnoughSpaceError;
case EACCES: // Permission denied
case EPERM: // Operation not permitted
return AbstractJobHandler::JobErrorType::kPermissionDeniedError;
case EIO: // I/O error
return isWriteError ? AbstractJobHandler::JobErrorType::kWriteError
: AbstractJobHandler::JobErrorType::kReadError;
case EBADF: // Bad file descriptor
case EINVAL: // Invalid argument
return AbstractJobHandler::JobErrorType::kProgramError; // 修正拼写
case ENOENT: // No such file or directory
return AbstractJobHandler::JobErrorType::kNonexistenceError;
default:
// Default to read/write error based on operation type
return isWriteError ? AbstractJobHandler::JobErrorType::kWriteError
: AbstractJobHandler::JobErrorType::kReadError;
}
} |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/plugins/common/dfmplugin-fileoperations/fileoperations/fileoperationutils/docopyfileworker.cpp:380` </location>
<code_context>
+
+ if (action == AbstractJobHandler::SupportAction::kRetryAction) {
+ // Seek to retry writing this chunk
+ if (lseek(writer.fd, copied + bytesWritten, SEEK_SET) < 0) {
+ success = false;
+ break;
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `copied + bytesWritten` for the retry seek after a write error is incorrect because `bytesWritten` is negative on error.
On error `bytesWritten` is `< 0`, so `lseek(writer.fd, copied + bytesWritten, SEEK_SET)` seeks *before* the last confirmed offset and can corrupt the destination. For a retry you should seek to the last known good offset (e.g. `copied` or `copied + totalWrittenForThisChunk`), not use the failing `bytesWritten` value. Track the intended write offset separately and use that for `lseek`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
...ugins/common/dfmplugin-fileoperations/fileoperations/fileoperationutils/docopyfileworker.cpp
Show resolved
Hide resolved
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Log: Fixed direct IO copy operations to show proper error dialogs instead of silently failing
Influence:
fix: 为直接IO拷贝操作添加UI错误处理
Log: 修复直接IO拷贝操作,现在会显示正确的错误对话框而不是静默失败
Influence:
Summary by Sourcery
Handle direct I/O copy read/write failures with proper UI error reporting and retry support.
Bug Fixes:
Enhancements: