mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
discards: skip when removing LVs on missing PVs
Don't try to issue discards to a missing PV to avoid segfault. Prevent lvremove from removing LVs that have any part missing. https://bugzilla.redhat.com/857554
This commit is contained in:
parent
2a6712ddef
commit
b737ff01e4
@ -1,5 +1,7 @@
|
||||
Version 2.02.98 -
|
||||
=================================
|
||||
Don't try to issue discards to a missing PV to avoid segfault.
|
||||
Prevent lvremove from removing LVs that have any part missing.
|
||||
Clear LV_NOSYNCED flag when a RAID1 LV is converted to a linear LV.
|
||||
Disallow RAID1 upconvert if the LV was created with --nosync.
|
||||
Depend on systemd-udev-settle in units generated by activation generator.
|
||||
|
@ -191,6 +191,7 @@ int discard_pv_segment(struct pv_segment *peg, uint32_t discard_area_reduction)
|
||||
{
|
||||
uint64_t discard_offset_sectors;
|
||||
uint64_t pe_start = peg->pv->pe_start;
|
||||
char uuid[64] __attribute__((aligned(8)));
|
||||
|
||||
if (!peg->lvseg) {
|
||||
log_error("discard_pv_segment with unallocated segment: "
|
||||
@ -203,8 +204,20 @@ int discard_pv_segment(struct pv_segment *peg, uint32_t discard_area_reduction)
|
||||
* the device and kernel (>= 2.6.35) supports discards.
|
||||
*/
|
||||
if (!find_config_tree_bool(peg->pv->fmt->cmd,
|
||||
"devices/issue_discards", DEFAULT_ISSUE_DISCARDS) ||
|
||||
!dev_discard_max_bytes(peg->pv->fmt->cmd->sysfs_dir, peg->pv->dev) ||
|
||||
"devices/issue_discards", DEFAULT_ISSUE_DISCARDS))
|
||||
return 1;
|
||||
|
||||
/* Missing PV? */
|
||||
if (is_missing_pv(peg->pv) || !peg->pv->dev) {
|
||||
if (!id_write_format(&peg->pv->id, uuid, sizeof(uuid)))
|
||||
return_0;
|
||||
|
||||
log_verbose("Skipping discard on missing device with uuid %s.", uuid);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!dev_discard_max_bytes(peg->pv->fmt->cmd->sysfs_dir, peg->pv->dev) ||
|
||||
!dev_discard_granularity(peg->pv->fmt->cmd->sysfs_dir, peg->pv->dev))
|
||||
return 1;
|
||||
|
||||
|
@ -26,6 +26,12 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
|
||||
lv = origin;
|
||||
|
||||
if (lv->status & PARTIAL_LV) {
|
||||
log_error("Not removing LV %s/%s because part or all of it is missing.",
|
||||
lv->vg->name, lv->name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!lv_remove_with_dependencies(cmd, lv, arg_count(cmd, force_ARG), 0)) {
|
||||
stack;
|
||||
return ECMD_FAILED;
|
||||
|
Loading…
Reference in New Issue
Block a user