[pve-devel] [PATCH container v3] Fix #2109: resize rbd volume for container failed

Alwin Antreich a.antreich at proxmox.com
Mon Mar 11 10:07:15 CET 2019


On Mon, Mar 11, 2019 at 09:44:17AM +0100, Thomas Lamprecht wrote:
> Am 3/8/19 um 3:41 PM schrieb Alwin Antreich:
> > On resizing a container's disk image the filesystem is extended and in
> > the case of RBD the returned path of the volume was not a path to a
> > mapped device.
> > 
> > This patch uses map_volume (respectively unmap_volume) to get a device
> > mapped and its path returned by the storage plugin. If a path is not
> > returned then the path method is tried. Currently only the RBD storage
> > plugin returns a path on map_volume.
> > 
> > Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
> > ---
> 
> applied, but still no changelog, neither here nor in the other v3 on the list...
Dang it. :/

> 
> also...
> 
> >  src/PVE/API2/LXC.pm | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> > index 27d26d5..26d6107 100644
> > --- a/src/PVE/API2/LXC.pm
> > +++ b/src/PVE/API2/LXC.pm
> > @@ -1602,7 +1602,7 @@ __PACKAGE__->register_method({
> >  		PVE::LXC::Config->write_config($vmid, $conf);
> >  
> >  		if ($format eq 'raw') {
> > -		    my $path = PVE::Storage::path($storage_cfg, $volid, undef);
> > +		    my $path = PVE::Storage::map_volume($storage_cfg, $volid) // PVE::Storage::path($storage_cfg, $volid);
> >  		    if ($running) {
> >  
> >  			$mp->{mp} = '/';
> > @@ -1630,6 +1630,8 @@ __PACKAGE__->register_method({
> >  			    PVE::Tools::run_command(['resize2fs', $path]);
> >  			};
> >  			warn "Failed to update the container's filesystem: $@\n" if $@;
> > +
> > +			PVE::Storage::unmap_volume($storage_cfg, $volid);
> 
> ..., why map it unconditionally before the if/else, but un-map it conditionally
> in the else branch?
> I've fixed that up and added a bit of comments..
When the CT is running, the device is already mapped and should stay.
'map_volume' then returns the path only.

On a running CT the unmap fails with the following message:

--- 8< ---
rbd: sysfs write failed
can't unmap rbd device /dev/rbd/rbd/vm-100-disk-1: rbd: sysfs write
failed
--- 8< ---

That's why I put it into the else clause, as it should be unmapped only
if the CT is not running.

> 
> >  		    }
> >  		}
> >  	    };
> > 
> 




More information about the pve-devel mailing list