Skip to content

dm: Add bd_dm_get_thin_pool_stats for generic thin pools - #1209

Open
vojtechtrefny wants to merge 1 commit into
storaged-project:masterfrom
vojtechtrefny:dm-thin-pool-stats
Open

dm: Add bd_dm_get_thin_pool_stats for generic thin pools#1209
vojtechtrefny wants to merge 1 commit into
storaged-project:masterfrom
vojtechtrefny:dm-thin-pool-stats

Conversation

@vojtechtrefny

@vojtechtrefny vojtechtrefny commented Sep 2, 2026

Copy link
Copy Markdown
Member

Adds a way to query physical space usage of a device mapper thin pool directly via libdevmapper, without requiring the pool to be managed by LVM. The new BDDMThinPoolStats struct reports used/total data and metadata block counts together with the pool status flags.

Resolves: #444

Summary by CodeRabbit

  • New Features

    • Added an API to retrieve device-mapper thin-pool statistics, including metadata and data usage, capacity, and pool status indicators.
    • Added support for copying and freeing thin-pool statistics data.
  • Documentation

    • Documented the new thin-pool statistics API and data type.
  • Tests

    • Added coverage for successful statistics retrieval and expected errors for invalid or unsupported device maps.

Adds a way to query physical space usage of a device mapper thin pool
directly via libdevmapper, without requiring the pool to be managed by
LVM. The new BDDMThinPoolStats struct reports used/total data and
metadata block counts together with the pool status flags.

Resolves: storaged-project#444

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: cf8903fe-62e0-40ad-aff0-d66909cd2289

📥 Commits

Reviewing files that changed from the base of the PR and between 7ce6c6e and b951858.

📒 Files selected for processing (5)
  • docs/libblockdev-sections.txt
  • src/lib/plugin_apis/dm.api
  • src/plugins/dm.c
  • src/plugins/dm.h
  • tests/dm_test.py

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The dm plugin adds a boxed BDDMThinPoolStats type and bd_dm_get_thin_pool_stats. The implementation queries and parses device-mapper thin-pool status. Tests cover valid statistics and invalid map types. Gtk-doc sections list the new symbols.

Changes

Thin-pool statistics

Layer / File(s) Summary
Public statistics contract
src/lib/plugin_apis/dm.api, src/plugins/dm.h
Defines BDDMThinPoolStats, boxed type helpers, copy/free functions, and the bd_dm_get_thin_pool_stats declaration.
Device-mapper status implementation
src/plugins/dm.c
Queries map status, verifies the thin-pool target, parses status values, populates statistics, and reports errors.
Validation and API documentation
tests/dm_test.py, docs/libblockdev-sections.txt
Creates test thin pools, validates statistics and error cases, and adds gtk-doc entries for the new symbols.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🟡 Moderate · up to b9518

The PR adds thin-pool statistics support, but the standalone DM header currently advertises a type helper that the standalone plugin does not provide, creating a bounded integration risk for consumers and potentially causing link failures. This should be corrected before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the device-mapper change and names the primary API, bd_dm_get_thin_pool_stats, for generic thin pools.
Linked Issues check ✅ Passed The pull request satisfies issue #444 by adding bd_dm_get_thin_pool_stats and BDDMThinPoolStats to report used and total data and metadata blocks for generic device-mapper thin pools. It also adds err…
Out of Scope Changes check ✅ Passed The changes are limited to the API declaration, implementation, public header, documentation, and tests required to retrieve and manage thin-pool statistics. No unrelated changes are present.
Full details: Linked Issues check

Explanation

The pull request satisfies issue #444 by adding bd_dm_get_thin_pool_stats and BDDMThinPoolStats to report used and total data and metadata blocks for generic device-mapper thin pools. It also adds error handling, lifecycle helpers, documentation, and tests.

Full details: Docstring Coverage

Explanation

Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

dm-thin: Retrieve physical used/free space in a dm-thin pool

2 participants