btrfs: Add bd_btrfs_delete_subvolume_recursive function#1193
Conversation
Add a new function for deleting btrfs subvolumes with an option for recursive deletion using the --recursive flag (requires btrfs-progs >= 6.12). The existing bd_btrfs_delete_subvolume now delegates to the new function with recursive=FALSE. A new BD_BTRFS_TECH_MODE_DELETE_RECURSIVE tech mode is added and checked in bd_btrfs_is_tech_avail for the SUBVOL tech. Fixes: storaged-project#1107 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis pull request adds support for recursive deletion of btrfs subvolumes by introducing a new function Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/btrfs_test.py (1)
270-280: Consider making the 6.12 gate coverage deterministic.This test covers only one branch per host version. A small
fake_utils/NOSTORAGEtest forBlockDev.btrfs_is_tech_avail(BlockDev.BtrfsTech.SUBVOL, BlockDev.BtrfsTechMode.DELETE_RECURSIVE)would catch regressions in the new tech-mode gate regardless of the CI runner’s installed btrfs-progs version.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/btrfs_test.py` around lines 270 - 280, Add a deterministic unit test that checks the tech-mode gate instead of relying on host btrfs-progs: create a small test in tests/btrfs_test.py (or new test module) that uses the fake_utils/NOSTORAGE environment to simulate storage absent and asserts BlockDev.btrfs_is_tech_avail(BlockDev.BtrfsTech.SUBVOL, BlockDev.BtrfsTechMode.DELETE_RECURSIVE) returns the expected boolean; if true, call BlockDev.btrfs_delete_subvolume_recursive(TEST_MNT, "subvol1", True, None) and assert success, otherwise assert it raises GLib.GError with the "Too low version of btrfs" message—this ensures both branches of the version gate are covered deterministically.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/plugin_apis/btrfs.api`:
- Around line 323-324: Update the gtk-doc text for the `@recursive` parameter in
the btrfs subvolume deletion docs (the gtk-doc block that mentions "@recursive"
in the btrfs API docs and the matching comment block in the btrfs plugin
implementation) to reflect upstream caveats: state that recursive deletion
requires btrfs-progs >= 6.12, is not atomic, and when run unprivileged
inaccessible child subvolumes may be skipped rather than deleted; ensure both
the documentation in the API gtk-doc block (the comment referring to `@recursive`)
and the corresponding comment in the btrfs.c plugin are changed to the new
wording so they match.
---
Nitpick comments:
In `@tests/btrfs_test.py`:
- Around line 270-280: Add a deterministic unit test that checks the tech-mode
gate instead of relying on host btrfs-progs: create a small test in
tests/btrfs_test.py (or new test module) that uses the fake_utils/NOSTORAGE
environment to simulate storage absent and asserts
BlockDev.btrfs_is_tech_avail(BlockDev.BtrfsTech.SUBVOL,
BlockDev.BtrfsTechMode.DELETE_RECURSIVE) returns the expected boolean; if true,
call BlockDev.btrfs_delete_subvolume_recursive(TEST_MNT, "subvol1", True, None)
and assert success, otherwise assert it raises GLib.GError with the "Too low
version of btrfs" message—this ensures both branches of the version gate are
covered deterministically.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8d5866ad-1884-4568-85dc-f513ccc7cec7
📒 Files selected for processing (5)
docs/libblockdev-sections.txtsrc/lib/plugin_apis/btrfs.apisrc/plugins/btrfs.csrc/plugins/btrfs.htests/btrfs_test.py
|
/packit build |
|
/packit build |
809e9b3
into
storaged-project:master
Add a new function for deleting btrfs subvolumes with an option for recursive deletion using the --recursive flag (requires btrfs-progs
A new BD_BTRFS_TECH_MODE_DELETE_RECURSIVE tech mode is added and checked in bd_btrfs_is_tech_avail for the SUBVOL tech.
Fixes: #1107
Summary by CodeRabbit
New Features
Tests