Skip to content

fix(storage): read UFS spec versions from DConfig instead of hardcoding - #258

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:agent/backport-ufs41-to-master
Nov 18, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:agent/backport-ufs41-to-master

Conversation

@add-uos

@add-uos add-uos commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #214 (merged into release/1071) to master.

Read UFS spec_version substrings from DConfig so new UFS versions can be added via configuration without source code changes. Also parse the hwinfo "Attached to" field via getMapInfoFromInput instead of raw output split.

从 DConfig 读取 UFS spec_version 子串列表,新增 UFS 版本时只需在配置中追加,无需修改源码;hwinfo 输出改用 getMapInfoFromInput 解析 "Attached to" 字段,避免从容量行误识别接口。

Cherry-picked from release/1071 (e4a72be) with adaptations:

  • keep master's qCDebug categorized logging and Utils::executCmd flow
  • use Dtk${DTK_VERSION_MAJOR}Core for Qt5/Qt6 dual support
  • declare new dconfig assets in REUSE.toml (master dropped .reuse/dep5)

Log: UFS版本识别改为DConfig配置驱动
PMS: BUG-372777
Influence: UFS接口识别逻辑改为配置驱动,新增UFS版本无需改源码,PGUY机型UFS 4.1存储设备接口可正确识别为UFS。

Summary by Sourcery

Make UFS interface recognition configuration-driven and reliably parse hwinfo controller information.

New Features:

  • Make UFS interface detection configurable through DConfig, allowing additional UFS specification versions without source changes.

Bug Fixes:

  • Correct hwinfo interface detection to use the explicitly reported “Attached to” field instead of potentially misidentifying capacity output.

Enhancements:

  • Add the storage DConfig schema and support required for Qt5/Qt6 builds.

Build:

  • Install the storage DConfig schema with the service and link tests against Dtk Core.

Tests:

  • Add regression tests covering UFS detection from the hwinfo “Attached to” field and ignoring capacity-only output.

Chores:

  • Declare the new DConfig assets in the project licensing metadata.

@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Load configured UFS spec-version substrings with fallback defaults and parse hwinfo's Attached to field explicitly to avoid mistaking capacity output for the interface.

  • service/diskoperation/DeviceStorage.cpp L743-757, L771-775 (+3 small edits)

Configuration

Add and install the DConfig schema containing UFS version settings, and declare the new assets in the reuse annotations.

  • REUSE.toml L55
  • service/CMakeLists.txt L22-23, L31, L94
  • service/assets/dconfig/com.deepin.diskmanager.storage.json L1-17

Tests

Link the Dtk Core dependency in the test target and add coverage for Attached to parsing and missing interface data.

  • test/CMakeLists.txt L28-32
  • test/ut_diskoperation/ut_devicestorage.cpp L1-85

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

@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 found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="service/diskoperation/DeviceStorage.cpp" line_range="772" />
<code_context>
-                if (spec_version.contains("300") || spec_version.contains("310") || spec_version.contains("400")) {
-                    interface = "UFS";
+                foreach (const QString &version, ufsSpecVersions()) {
+                    if (spec_version.contains(version)) {
+                        interface = "UFS";
+                        break;
</code_context>
<issue_to_address>
**Non-UFS boot disks appear as UFS**

When the configured `ufsSpecVersions()` list contains an empty string and a boot device has a nonempty spec version, `getDiskInfoInterface` passes the empty version to `QString::contains`, which matches every nonempty `spec_version` and sets `interface` to UFS, so callers see non-UFS boot storage reported as UFS.

Skip empty entries in the version list before matching them against `spec_version`.
</issue_to_address>

### Comment 2
<location path="service/diskoperation/DeviceStorage.cpp" line_range="751-756" />
<code_context>
+    QScopedPointer<Dtk::Core::DConfig> cfg(
+        Dtk::Core::DConfig::create("com.deepin.diskmanager", "com.deepin.diskmanager.storage"));
+    if (cfg && cfg->isValid()) {
+        QStringList versions = cfg->value("ufsSpecVersions", QVariant::fromValue(fallback)).toStringList();
+        if (!versions.isEmpty())
+            return versions;
+    }
+    return fallback;
+}
</code_context>
<issue_to_address>
**Configured versions silently ignored**

When DConfig is unavailable or invalid and a device uses a spec-version substring added only through DConfig, `ufsSpecVersions()` returns the hardcoded fallback without logging that DConfig is invalid, so versions added only through DConfig are not matched and affected devices can be reported with the wrong interface.

Log a warning when DConfig cannot be loaded or validated before using the fallback list.
</issue_to_address>

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

if (spec_version.contains("300") || spec_version.contains("310") || spec_version.contains("400")) {
interface = "UFS";
foreach (const QString &version, ufsSpecVersions()) {
if (spec_version.contains(version)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Non-UFS boot disks appear as UFS

When the configured ufsSpecVersions() list contains an empty string and a boot device has a nonempty spec version, getDiskInfoInterface passes the empty version to QString::contains, which matches every nonempty spec_version and sets interface to UFS, so callers see non-UFS boot storage reported as UFS.

Skip empty entries in the version list before matching them against spec_version.

Prompt for AI agents
In `service/diskoperation/DeviceStorage.cpp` at line 772:

**Non-UFS boot disks appear as UFS**

When the configured `ufsSpecVersions()` list contains an empty string and a boot device has a nonempty spec version, `getDiskInfoInterface` passes the empty version to `QString::contains`, which matches every nonempty `spec_version` and sets `interface` to UFS, so callers see non-UFS boot storage reported as UFS.

Skip empty entries in the version list before matching them against `spec_version`.

Comment on lines +751 to +756
QStringList versions = cfg->value("ufsSpecVersions", QVariant::fromValue(fallback)).toStringList();
if (!versions.isEmpty())
return versions;
}
return fallback;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Configured versions silently ignored

When DConfig is unavailable or invalid and a device uses a spec-version substring added only through DConfig, ufsSpecVersions() returns the hardcoded fallback without logging that DConfig is invalid, so versions added only through DConfig are not matched and affected devices can be reported with the wrong interface.

Log a warning when DConfig cannot be loaded or validated before using the fallback list.

Prompt for AI agents
In `service/diskoperation/DeviceStorage.cpp` at lines 751-756:

**Configured versions silently ignored**

When DConfig is unavailable or invalid and a device uses a spec-version substring added only through DConfig, `ufsSpecVersions()` returns the hardcoded fallback without logging that DConfig is invalid, so versions added only through DConfig are not matched and affected devices can be reported with the wrong interface.

Log a warning when DConfig cannot be loaded or validated before using the fallback list.

@deepin-bot

deepin-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.29
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #259

@add-uos
add-uos force-pushed the agent/backport-ufs41-to-master branch from a7e1973 to 1017864 Compare November 18, 2026 02:56
lzwind
lzwind previously approved these changes Nov 18, 2026
Read UFS spec_version substrings from DConfig so new UFS versions can
be added via configuration without source code changes.

从 DConfig 读取 UFS spec_version 子串列表,新增 UFS 版本时只需
在配置中追加,无需修改源码。

Log: UFS版本识别改为DConfig配置驱动
PMS: BUG-372777
Influence: UFS接口识别逻辑改为配置驱动,新增UFS版本无需改源码,提升可维护性。
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

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

1 similar comment
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

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

@add-uos

add-uos commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit d704999 into linuxdeepin:master Nov 18, 2026
19 of 20 checks passed
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.

4 participants