[pve-devel] [PATCH storage v2 1/2] fix #3873: btrfs: check for correct subvolume taking snapshot
Fiona Ebner
f.ebner at proxmox.com
Wed Feb 19 10:31:41 CET 2025
Am 19.02.25 um 10:24 schrieb Fiona Ebner:
> Am 18.02.25 um 17:28 schrieb Maximiliano Sandoval:
>> +# Calls `$code->($volume, $snap_name)` for each snapshot of the subvolume.
>> +my sub foreach_snapshot_of_subvol : prototype($$) {
>
> We can just rename foreach_subvol() and the $BTRFS_VOL_REGEX instead of
> adding this new wrapper. As already written in the review of v1, the
> regex requires a snapshot to be present. This means the regex is a
> misnomer and the foreach_subvol() helper already operates only on
> snapshots and can also be renamed. It'd be more concise/straightforward
> and otherwise, those remain confusing.
>
I mean, it still makes sense to have the helper only operate on the
snapshots of a given subvolume, because both the existing user in
free_image() and your new user want that.
>> + my ($subvol, $code) = @_;
>> +
>> + my $basename = basename($subvol);
>> + my $dir = dirname($subvol);
>> + foreach_subvol($dir, sub {
>> + my ($volume, $name, $snap) = @_;
>> + return if $name ne $basename;
>> + return if !defined $snap;
>> + $code->($volume, $snap);
>> + });
>> +}
>> +
>> sub free_image {
>> my ($class, $storeid, $scfg, $volname, $isBase, $_format) = @_;
>>
More information about the pve-devel
mailing list