LVM: add logic to allow mirrored log
PATCH 1/1 LVM: add logic to allow mirrored log
Patch name: lvm-add-logic-to-allow-mirrored-log.patch
Insert the couple of lines that adds the logic necessary to create the mirrored log.
lib/metadata/mirror.c +7 -1
@@ -1592,7 +1592,7 @@ static struct logical_volume *_set_up_mistruct alloc_handle *ah, struct logical_volume *lv, uint32_t log_count, - uint32_t region_size __attribute((unused)), + uint32_t region_size, alloc_policy_t alloc, int in_sync) {
@@ -1636,6 +1636,12 @@ static struct logical_volume *_set_up_mireturn NULL ; } +if ((log_count >1 ) && + !_form_mirror (cmd, ah, log_lv, log_count-1 , region_size,1 )) { +log_error ("Failed to form mirrored log." ); +return NULL ; + } +if (!_init_mirror_log (cmd, log_lv, in_sync, &lv->tags,1 )) {log_error ("Failed to initialise mirror log." );return NULL ;
tools/lvconvert.c +61 -13
107 lines not on this page · raw message
PATCH 1/1 LVM: add logic to allow mirrored log
Quoted 5 lines · Jonathan Brassow
/*
tools/lvconvert.c +0
-0@@ -798,9 +840,15 @@ static int _lvconvert_mirrors(struct cmd return_0; lp->pvh = lp->failed_pvs = failed_pvs; log_lv =first_seg (lv)->log_lv;
tools/lvconvert.c static int _lvconvert_mirrors(struct cmd · line 851
Quoted 10 lines
tools/lvconvert.c +7
-1-if (!log_lv || log_lv->status &PARTIAL_LV ) { +if (!log_lv) { failed_log =1 ; log_count =0 ; + }else { + log_count =lv_mirror_count (log_lv); +if (log_lv->status &PARTIAL_LV ) { + failed_log =1 ; + log_count -=_failed_mirrors_count (log_lv); + }
When log is a "disk" type log and log disk failed, lvconvert --repair vg00/lv00 doesn't work. In this case, _failed_mirrors_count() returns "-1" and log_count became "2." (should be "0") I think that we need to check if its return value is negative.
if (_failed_mirrors_count(log_lv) < 0)
log_count = 0;
else
log_count -= _failed_mirrors_count(log_lv);Here is the reproduction steps.
1. create mirror volume with disk log
# lvcreate -m1 -L12m -nlv00 --mirrorlog disk vg00 Logical volume "lv00" created
2. disable log device
# echo offline > /sys/block/sde/device/state /* sde is a log device */
3. kill dmeventd
4. Write data
# dd if=/dev/zero of=/dev/vg00/lv00 bs=4096 count=1 <no response>
5. execute lvconvert command.
# lvconvert --config 'devices{ignore_suspended_devices=1}' --repair --use-policies vg00/lv00
Couldn't find device with uuid 'CAteli-tCjh-3zZ3-yEjl-mcLX-uVff-aRDh7b'.
Couldn't find device with uuid 'CAteli-tCjh-3zZ3-yEjl-mcLX-uVff-aRDh7b'.
Mirror status: 0 of 2 images failed. Adding log redundancy not supported yet.
Try converting the log to 'core' first.
Thanks,
Taka
PATCH 1/1 LVM: add logic to allow mirrored log
In reply to Jonathan BrassowQuoted 5 lines · Jonathan Brassow
static int _lv_update_log_type(struct
cmd_context*cmd,tools/lvconvert.c +0
-0@@ -657,21 +672,48 @@ static int _lv_update_log_type(struct cmstruct logical_volume *lv, int log_count) {
...
Quoted 4 lines
tools/lvconvert.c +4
-0+ log_lv =first_seg (original_lv)->log_lv; + +/* Adding redundancy to the log */ +if (old_log_count < log_count) {
tools/lvconvert.c static int _lv_update_log_type(struct cm · line 717
Quoted 10 lines
tools/lvconvert.c +7
-1+log_error ("Adding log redundancy not supported yet." ); +log_error ("Try converting the log to 'core' first." ); + return_0; } -return 1 ; + +/* Reducing redundancy of the log */ +return remove_mirror_images (log_lv, log_count, + lp->pv_count ? lp->pvh :NULL ,1U ); }
Should we pass lp->pvh even if lp->pv_count is 0?
+ return remove_mirror_images(log_lv, log_count, lp->pvh, 1U);
Looking at remove_mirror_images(), the third agrument, removable_pvs, is used to decide which mirror leg should be removed. When lp->pv_count is 0, lp->pvh has the list of PVs in the VG (see lvconvert_single()) and the PV list needs to be passed to remove_mirror_images().
This issue is found during tests. When the primary leg of the mirrored log (e.g. vg00-lv00_mlog_mimage_0) failed, lvconvert --repair vg00/lv00 didn't recover the vg00/lv00.
With the above fix, lvconvert --repair vg00/lv00 worked well when the primary leg of the mirrored log failed.
Thanks,
Taka