]> git.proxmox.com Git - pve-storage.git/commitdiff
fix #2046 add volume_size_info to LVMPlugin
authorStoiko Ivanov <s.ivanov@proxmox.com>
Fri, 4 Jan 2019 13:06:24 +0000 (14:06 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 15 Jan 2019 08:43:07 +0000 (09:43 +0100)
Without volume_size_info a Storage plugin falls back to the Implementation
in PVE/Storage/Plugin.pm, which relies on `qemu-img info`.

`qemu-img info` returns wrong results on a node in the case of shared volume
groups (e.g. when sharing disks via iSCSI), if a disk was resized on another
node (it lseeks to the end of the block-device, and this yields the old size).

Using lvs directly fixes the issue, since the LVM metadata gets updated when
invoking lvs.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
PVE/Storage/LVMPlugin.pm

index 79d527d6c1bbc427873301e15ad2014c9d208108..3be680b4d605a2f6364406be8b34f4e830639ef9 100644 (file)
@@ -499,6 +499,21 @@ sub volume_resize {
     return 1;
 }
 
+sub volume_size_info {
+    my ($class, $scfg, $storeid, $volname, $timeout) = @_;
+    my $path = $class->filesystem_path($scfg, $volname);
+
+    my $cmd = ['/sbin/lvs', '--separator', ':', '--noheadings', '--units', 'b',
+              '--unbuffered', '--nosuffix', '--options', 'lv_size', $path];
+
+    my $size;
+    run_command($cmd, timeout => $timeout, errmsg => "can't get size of '$path'",
+       outfunc => sub {
+           $size = int(shift);
+    });
+    return wantarray ? ($size, 'raw', 0, undef) : $size;
+}
+
 sub volume_snapshot {
     my ($class, $scfg, $storeid, $volname, $snap) = @_;