Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lvm: Manually remove removed PVs from the LVM devices file #1257

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion modules/lvm2/jobhelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
#include <blockdev/utils.h>

#include <src/udisksthreadedjob.h>
#include <src/udiskslogging.h>

#include "jobhelpers.h"


gboolean lvcreate_job_func (UDisksThreadedJob *job,
GCancellable *cancellable,
gpointer user_data,
Expand Down Expand Up @@ -310,7 +312,18 @@ gboolean pvremove_job_func (UDisksThreadedJob *job,
GError **error)
{
VGJobData *data = user_data;
return bd_lvm_pvremove (data->pv_path, NULL /* extra_args */, error);
gboolean succ = FALSE;
succ = bd_lvm_pvremove (data->pv_path, NULL /* extra_args */, error);
if (!succ)
return FALSE;

if (bd_lvm_is_tech_avail (BD_LVM_TECH_DEVICES, 0, NULL) &&
!bd_lvm_devices_delete (data->pv_path, NULL, NULL, error))
{
udisks_warning ("Failed to remove %s from LVM devices file: %s", data->pv_path, (*error)->message);
g_clear_error (error);
}
return TRUE;
}

gboolean pvmove_job_func (UDisksThreadedJob *job,
Expand Down
6 changes: 6 additions & 0 deletions modules/lvm2/udiskslinuxvolumegroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ handle_delete (UDisksVolumeGroup *_group,
udisks_warning ("Failed to wipe PV %s: %s", device_file, error->message);
g_clear_error (&error);
}
if (bd_lvm_is_tech_avail (BD_LVM_TECH_DEVICES, 0, NULL) &&
!bd_lvm_devices_delete (device_file, NULL, NULL, &error))
{
udisks_warning ("Failed to remove %s from LVM devices file: %s", device_file, error->message);
g_clear_error (&error);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/tests/dbus-tests/test_20_LVM.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import udiskstestcase


LVM_DEVICES_FILE = "/etc/lvm/devices/system.devices"


class UDisksLVMTestBase(udiskstestcase.UdisksTestCase):

@classmethod
Expand Down Expand Up @@ -107,6 +110,11 @@ def test_05_vg(self):
fstype = self.get_property(dev_obj, '.Block', 'IdType')
fstype.assertEqual('')

# check that PV was removed from the LVM devices file
if os.path.exists(LVM_DEVICES_FILE):
devices_file = self.read_file(LVM_DEVICES_FILE)
self.assertNotIn(self.vdevs[0], devices_file)

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

Expand Down
Loading