public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>,
	"Proxmox VE development discussion" <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH storage 3/3] rbd: add protect/unprotect helpers
Date: Tue, 6 May 2025 13:40:59 +0200	[thread overview]
Message-ID: <659b0765-5e31-4191-9fe1-9fb7fcbedb24@proxmox.com> (raw)
In-Reply-To: <1746529057.u4pbqlfxc3.astroid@yuna.none>

Am 06.05.25 um 13:07 schrieb Fabian Grünbichler:
>>> @@ -580,15 +593,7 @@ sub clone_image {
>>>  
>>>      warn "clone $volname: $basename snapname $snap to $name\n";
>>>  
>>> -    if (length($snapname)) {
>>> -	my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $volname, $snapname);
>>> -
>>> -	if (!$protected) {
>>> -	    my $snap_spec = get_rbd_path($scfg, $volname, $snapname);
>>> -	    my $cmd = $rbd_cmd->($scfg, $storeid, 'snap', 'protect', $snap_spec);
>>> -	    run_rbd_command($cmd, errmsg => "rbd protect '$snap_spec' error");
>>> -	}
>>> -    }
>>> +    rbd_protect_snap($scfg, $storeid, $volname, $snap) if length($snapname);
>>
>> Last argument should be $snapname
> 
> not really - this is saying "protect the snapshot $snap if it is not the
> (already protected) '__base__' snapshot". probably the whole logic
> should be adapted to make this explicit though, e.g., something like:

Oh right, it doesn't matter semantically, because there is
$snap = $snapname if length $snapname;
further above. I just compared with the old code that used $snapname as
the argument, which you don't anymore.

> diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
> index 6604bc3..5c1a8e2 100644
> --- a/src/PVE/Storage/RBDPlugin.pm
> +++ b/src/PVE/Storage/RBDPlugin.pm
> @@ -580,23 +580,26 @@ sub create_base {
>  sub clone_image {
>      my ($class, $scfg, $storeid, $volname, $vmid, $snapname) = @_;
>  
> -    my $snap = '__base__';
> -    $snap = $snapname if length $snapname;
> -
>      my ($vtype, $basename, $basevmid, undef, undef, $isBase) =
>          $class->parse_volname($volname);
>  
> -    die "$volname is not a base image and snapname is not provided\n" 
> -	if !$isBase && !length($snapname);
> +    my $snap;
> +
> +    if ($snapname) {
> +	$snap = $snapname;
> +    } elsif ($isBase) {
> +	$snap = '__base__';
> +    } else {
> +	die "$volname is not a base image and snapname is not provided\n";
> +    }
>  
>      my $name = $class->find_free_diskname($storeid, $scfg, $vmid);
>  
>      warn "clone $volname: $basename snapname $snap to $name\n";
>  
> -    rbd_protect_snap($scfg, $storeid, $volname, $snap) if length($snapname);
> +    rbd_protect_snap($scfg, $storeid, $volname, $snap) if $snap ne '__base__';
>  
> -    my $newvol = "$basename/$name";
> -    $newvol = $name if length($snapname);
> +    my $newvol = $snapname ? $name : "$basename/$name";
>  
>      my @options = (
>  	get_rbd_path($scfg, $basename, $snap),
> 

Looks fine to me at a glance.


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

  reply	other threads:[~2025-05-06 11:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23 13:59 [pve-devel] [RFC storage 0/3] rbd: use image-/snap-spec instead of --pool/ Fabian Grünbichler
2025-04-23 13:59 ` [pve-devel] [PATCH storage 1/3] rbd: extend get_rbd_(dev_)path helpers with $snap parameter Fabian Grünbichler
2025-04-23 13:59 ` [pve-devel] [PATCH storage 2/3] fix #6338: rbd: use image-/snap-spec consistently Fabian Grünbichler
2025-05-05 14:24   ` Fiona Ebner
2025-04-23 13:59 ` [pve-devel] [PATCH storage 3/3] rbd: add protect/unprotect helpers Fabian Grünbichler
2025-05-05 14:24   ` Fiona Ebner
2025-05-06 11:07     ` Fabian Grünbichler
2025-05-06 11:40       ` Fiona Ebner [this message]
2025-04-30 15:51 ` [pve-devel] [RFC storage 0/3] rbd: use image-/snap-spec instead of --pool/ Aaron Lauterer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=659b0765-5e31-4191-9fe1-9fb7fcbedb24@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=f.gruenbichler@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal