btrfs: die early for broken subvolume resize
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@proxmox.com> Link: https://lore.proxmox.com/20250303092445.13873-6-f.ebner@proxmox.com
This commit is contained in:
committed by
Thomas Lamprecht
parent
0426aa3165
commit
5a73bac343
@ -233,14 +233,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) = @_;
|
||||
@ -498,10 +499,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(@_);
|
||||
|
||||
Reference in New Issue
Block a user