Skip to content

fix: add blank=as_needed before burn to fix CD-RW failure - #393

Open
liyigang1 wants to merge 1 commit into
linuxdeepin:masterfrom
liyigang1:agent/pms-bug-bot/a3a9067de5ce
Open

liyigang1 wants to merge 1 commit into
linuxdeepin:masterfrom
liyigang1:agent/pms-bug-bot/a3a9067de5ce

Conversation

@liyigang1

@liyigang1 liyigang1 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Root Cause Analysis

CD-RW disc burning fails on USB external optical drives while the same CD-RW burns normally on internal drives and DVD+RW burns normally on the same USB drive. The root cause is that doBurn() (file burning path) calls Xorriso_option_commit() directly without a prior blank=as_needed initialization step. Without this step, CD-RW media PMA/TOC is not properly initialized, causing the USB drive's Write(10) command to fail with DID_ERROR after a 10-second timeout, followed by a device reset.

Key evidence: dxorrisoengine.cppdoBurn() has no blank call while doWriteISO() passes blank=as_needed via cdrecord and doErase() uses Xorriso_option_blank("as_needed"); dmesg shows Write(10) hostbyte=DID_ERROR cmd_age=10s followed by device reset on the USB drive.

Fix

Added Xorriso_option_blank(xorriso, "as_needed", 0) before Xorriso_option_commit() in doBurn(), making it consistent with doWriteISO() and doErase() which already use blank=as_needed. The as_needed mode is a no-op for blank/appendable media and only initializes rewritable media that needs it, so there is no side effect on existing burn paths. Change is 7 lines in a single file.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Target code (commit section of doBurn()) was part of the initial implementation (2022-02-11) and has never been modified by any subsequent bug fix — this change does not revert any historical fix
  • blank=as_needed is an established pattern already used in doErase() (line 301) and doWriteISO() (via cdrecord); only caller DOpticalDiscManager::commit() is unaffected as the function signature is unchanged

Business Impact Scope

Affected module: optical disc file burning (DOpticalDiscManager::commit()DXorrisoEngine::doBurn()). User-facing scenario: burning files to disc via file manager. The fix adds a necessary media initialization step before burning; no visible change to user workflow. Only CD-RW media on USB drives that previously failed will now succeed; all other media types (DVD+RW, CD-R, DVD-R) are unaffected.

Verification Suggestion

Regression test priority: (1) CD-RW burning on USB external drive (original bug scenario), (2) DVD+RW burning to confirm no regression, (3) CD-R one-time burning to confirm blank=as_needed has no side effect, (4) multi-session appendable burning.


根因分析

CD-RW光盘使用USB外置光驱刻录失败,但同一CD-RW在内置光驱上刻录正常,同一USB光驱刻录DVD+RW也正常。根因是 doBurn()(文件刻录路径)直接调用 Xorriso_option_commit() 而未先执行 blank=as_needed 初始化步骤。缺少此步骤导致CD-RW光盘PMA/TOC未正确初始化,USB光驱执行Write(10)命令时10秒超时后以 DID_ERROR 失败,随后触发设备重置。

关键证据:dxorrisoengine.cppdoBurn()blank 调用,而 doWriteISO() 通过cdrecord传入 blank=as_neededdoErase() 使用 Xorriso_option_blank("as_needed");dmesg显示 Write(10) hostbyte=DID_ERROR cmd_age=10s 后USB光驱设备重置。

修复方案

doBurn()Xorriso_option_commit() 之前添加 Xorriso_option_blank(xorriso, "as_needed", 0),与 doWriteISO()doErase() 中已有的 blank=as_needed 行为一致。as_needed 模式对空白/可追加介质无操作,仅初始化需要空白化的可重写介质,对现有刻录路径无副作用。改动为单文件7行。

改动安全评估

代码安全评估

  • 风险等级: 低
  • 目标代码(doBurn() 的 commit 区段)属于初始实现(2022-02-11),此后未经历任何bug修复改动——本次改动不会撤销任何历史修复
  • blank=as_needed 是代码库中已建立的成熟模式,doErase()(第301行)和 doWriteISO()(通过cdrecord)均已使用;唯一调用者 DOpticalDiscManager::commit() 不受影响,函数签名未改变

业务影响范围

受影响模块:光盘文件刻录(DOpticalDiscManager::commit()DXorrisoEngine::doBurn())。用户场景:通过文件管理器将文件刻录到光盘。修复在刻录前添加必要的介质初始化步骤,用户操作流程无可见变化。仅CD-RW + USB光驱组合下此前失败的场景将恢复正常,其他介质类型(DVD+RW、CD-R、DVD-R)不受影响。

验证建议

回归测试优先级:(1) USB外置光驱刻录CD-RW光盘(原始bug场景),(2) DVD+RW刻录确认无回归,(3) CD-R一次性刻录确认 blank=as_needed 无副作用,(4) 多会话追加刻录场景。

PMS: BUG-318189

Summary by Sourcery

Bug Fixes:

  • Fix CD-RW burning failures on USB optical drives by initializing rewritable media as needed before committing the burn.

1. Root cause: doBurn() calls Xorriso_option_commit() without prior
   blank initialization, CD-RW media PMA/TOC not properly initialized
   causes Write(10) failure on USB optical drives
2. Fix: add Xorriso_option_blank("as_needed") before commit in doBurn(),
   consistent with doWriteISO() and doErase() which already use
   blank=as_needed
3. Impact: blank=as_needed is no-op for blank/appendable media, only
   initializes rewritable media that needs it, no regression for
   existing burn paths

Log: Fix CD-RW disc burning failure on USB optical drives

Influence:
1. Test CD-RW burning with USB external optical drive
2. Test DVD+RW burning to ensure no regression
3. Test CD-R burning to ensure blank=as_needed has no side effect
4. Test appendable burning (multi-session) scenarios

fix: 刻录前添加blank=as_needed修复CD-RW刻录失败

1. 根因:doBurn()直接调用Xorriso_option_commit()但未先执行blank
   初始化,CD-RW光盘PMA/TOC未正确初始化导致USB光驱Write(10)失败
2. 方案:在doBurn()的commit之前添加Xorriso_option_blank("as_needed"),
   与doWriteISO()和doErase()中已有的blank=as_needed行为一致
3. 影响:blank=as_needed对空白/可追加介质无操作,仅初始化需要空白化
   的可重写介质,对现有刻录路径无回归

Log: 修复USB外置光驱刻录CD-RW光盘失败的问题

Influence:
1. 测试USB外置光驱刻录CD-RW光盘
2. 测试DVD+RW刻录确认无回归
3. 测试CD-R刻录确认blank=as_needed无副作用
4. 测试多会话追加刻录场景

PMS: BUG-318189
@sourcery-ai

sourcery-ai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes CD-RW burning failures on USB optical drives by adding an as-needed blanking step before the xorriso commit operation, while preserving behavior for blank, appendable, and non-rewritable media.

Sequence diagram for CD-RW file burning initialization

sequenceDiagram
    participant DOpticalDiscManager
    participant DXorrisoEngine
    participant Xorriso
    participant OpticalDrive

    DOpticalDiscManager->>DXorrisoEngine: doBurn(files, speed, ...)
    DXorrisoEngine->>Xorriso: Xorriso_option_blank(as_needed)
    Xorriso->>OpticalDrive: Initialize rewritable media PMA/TOC
    OpticalDrive-->>Xorriso: Initialization result
    alt blanking succeeds
        DXorrisoEngine->>Xorriso: Xorriso_option_commit()
        Xorriso->>OpticalDrive: Write disc data
        OpticalDrive-->>Xorriso: Burn result
    else blanking fails
        DXorrisoEngine-->>DOpticalDiscManager: false
    end
Loading

File-Level Changes

Change Details Files
Initializes rewritable media only when needed before committing file-burning sessions.
  • Calls xorriso blank with the as_needed mode before commit.
  • Propagates blank-operation failures through the existing job error handling path.
  • Aligns doBurn with the established media-handling behavior used by other burn and erase paths.
src/dfm-burn/dfm-burn-lib/private/dxorrisoengine.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: liyigang1

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全漏洞,代码变更遵循现有模式,逻辑正确,注释清晰。本次修改在 doBurn 函数中 commit 操作之前添加 blank=as_needed 选项,用于为可重写媒体(如 CD-RW)初始化 PMA/TOC,修复 CD-RW 刻录失败问题。代码完全遵循函数中已有的 XORRISO_OPT + JOBFAILED_IF 错误处理模式,无安全风险。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 暂无代码示例

本报告由 AI 代码审查工具自动生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants