diff options
author | Alasdair G Kergon <agk@redhat.com> | 2012-09-19 12:48:56 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-09-19 12:48:56 +0100 |
commit | b737ff01e4038d45798521448dc4ae4864d1b29a (patch) | |
tree | b42bd437fae56575cb1836684b5d990e8f0e9363 | |
parent | 2a6712ddefb6720d115d11c276223b57abf5dd94 (diff) | |
download | lvm2-b737ff01e4038d45798521448dc4ae4864d1b29a.tar.gz lvm2-b737ff01e4038d45798521448dc4ae4864d1b29a.tar.xz lvm2-b737ff01e4038d45798521448dc4ae4864d1b29a.zip |
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
-rw-r--r-- | WHATS_NEW | 2 | ||||
-rw-r--r-- | lib/metadata/pv_manip.c | 17 | ||||
-rw-r--r-- | tools/lvremove.c | 6 |
3 files changed, 23 insertions, 2 deletions
@@ -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. diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c index e85a2bc5..d04ecaba 100644 --- a/lib/metadata/pv_manip.c +++ b/lib/metadata/pv_manip.c @@ -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; diff --git a/tools/lvremove.c b/tools/lvremove.c index 02521495..2c5b317d 100644 --- a/tools/lvremove.c +++ b/tools/lvremove.c @@ -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; |