[pve-devel] [PATCH v2 storage 5/5] btrfs: die early for broken subvolume resize
Fiona Ebner
f.ebner at proxmox.com
Mon Mar 3 10:24:45 CET 2025
In the BTRFS plugin, resize_volume() for a subovlume currently fails
with "failed to get btrfs subvolume ID from: ". This is because the
btrfs 'subvol show' command is invoked with '-q', so there is no
output.
As btrfs quotas are currently not implemented, die early with a clean
error instead and comment out the unused code for now.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
Changes in v2:
* comment out dead code, squash patches
src/PVE/Storage/BTRFSPlugin.pm | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm
index b1f7912..ce21297 100644
--- a/src/PVE/Storage/BTRFSPlugin.pm
+++ b/src/PVE/Storage/BTRFSPlugin.pm
@@ -232,14 +232,15 @@ sub btrfs_cmd {
return $msg;
}
-sub btrfs_get_subvol_id {
- my ($class, $path) = @_;
- my $info = $class->btrfs_cmd(['subvolume', 'show', '--', $path]);
- if ($info !~ /^\s*(?:Object|Subvolume) ID:\s*(\d+)$/m) {
- die "failed to get btrfs subvolume ID from: $info\n";
- }
- return $1;
-}
+# NOTE: this function is currently boken, because btrfs_cmd uses '-q' so there will be no output.
+#sub btrfs_get_subvol_id {
+# my ($class, $path) = @_;
+# my $info = $class->btrfs_cmd(['subvolume', 'show', '--', $path]);
+# if ($info !~ /^\s*(?:Object|Subvolume) ID:\s*(\d+)$/m) {
+# die "failed to get btrfs subvolume ID from: $info\n";
+# }
+# return $1;
+#}
my sub chattr : prototype($$$) {
my ($fh, $mask, $xor) = @_;
@@ -497,10 +498,13 @@ sub volume_resize {
my $format = ($class->parse_volname($volname))[6];
if ($format eq 'subvol') {
- my $path = $class->filesystem_path($scfg, $volname);
- my $id = '0/' . $class->btrfs_get_subvol_id($path);
- $class->btrfs_cmd(['qgroup', 'limit', '--', "${size}k", "0/$id", $path]);
- return undef;
+ # NOTE: `btrfs send/recv` actually drops quota information so supporting subvolumes with
+ # quotas doesn't play nice with send/recv.
+ die "cannot resize subvolume - btrfs quotas are currently not supported\n";
+ # my $path = $class->filesystem_path($scfg, $volname);
+ # my $id = '0/' . $class->btrfs_get_subvol_id($path);
+ # $class->btrfs_cmd(['qgroup', 'limit', '--', "${size}k", "0/$id", $path]);
+ # return undef;
}
return PVE::Storage::Plugin::volume_resize(@_);
--
2.39.5
More information about the pve-devel
mailing list