Skip to content

Commit

Permalink
lvm: Use pvremove when removing PVs after deleting a VG
Browse files Browse the repository at this point in the history
udisks_daemon_util_lvm2_wipe_block is a huge hammer that also
tries to call vgreduce and pvscan and does other steps that are
not necessary when removing the PV signature after removing the
VG.

Fixes: #1228
  • Loading branch information
vojtechtrefny committed Jan 4, 2024
1 parent fe8c35a commit 5540299
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/lvm2/udiskslinuxvolumegroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ handle_delete (UDisksVolumeGroup *_group,
GList *objects_to_wipe = NULL;
GList *l;
VGJobData data;
const gchar *device_file = NULL;

g_variant_lookup (arg_options, "tear-down", "b", &teardown_flag);

Expand Down Expand Up @@ -354,7 +355,14 @@ handle_delete (UDisksVolumeGroup *_group,
{
UDisksBlock *block = udisks_object_peek_block (l->data);
if (block)
udisks_daemon_util_lvm2_wipe_block (daemon, block, NULL);
{
device_file = udisks_block_get_device (block);
if (!bd_lvm_pvremove (device_file, NULL, &error))
{
udisks_warning ("Failed to wipe PV %s: %s", device_file, error->message);
g_clear_error (&error);
}
}
}

udisks_volume_group_complete_delete (_group, invocation);
Expand Down
26 changes: 26 additions & 0 deletions src/tests/dbus-tests/test_20_LVM.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,32 @@ def test_01_manager_interface(self):
intro_data = manager.Introspect(self.no_options, dbus_interface='org.freedesktop.DBus.Introspectable')
self.assertIn('interface name="%s.Manager.LVM2"' % self.iface_prefix, intro_data)

def test_05_vg(self):
'''Test basic VG functionality'''

vgname = 'udisks_test_vg'

dev_obj = self.get_object('/block_devices/' + os.path.basename(self.vdevs[0]))
self.assertIsNotNone(dev_obj)
self.addCleanup(self.wipe_fs, self.vdevs[0])
vg = self._create_vg(vgname, [dev_obj])
self.addCleanup(self._remove_vg, vg, ignore_removed=True)

# remove the VG without removing the PV signatures
vg.Delete(False, self.no_options, dbus_interface=self.iface_prefix + '.VolumeGroup')

fstype = self.get_property(dev_obj, '.Block', 'IdType')
fstype.assertEqual('LVM2_member')

# create new VG
vg = self._create_vg(vgname, [dev_obj])

# remove the VG and wipe the PVs
vg.Delete(True, self.no_options, dbus_interface=self.iface_prefix + '.VolumeGroup')

fstype = self.get_property(dev_obj, '.Block', 'IdType')
fstype.assertEqual('')

def test_10_linear(self):
'''Test linear (plain) LV functionality'''

Expand Down

0 comments on commit 5540299

Please sign in to comment.