#647567 lvm2: lvrename fails to rename mlog mimages

Package:
lvm2
Source:
lvm2
Description:
Linux Logical Volume Manager
Submitter:
Paul LeoNerd Evans
Date:
2011-11-04 01:30:07 UTC
Severity:
normal
#647567#5
Date:
2011-11-04 00:31:28 UTC
From:
To:
Dear Maintainer,

I had a --mirrorlog mirrored LV called "home", that I renamed "backups".
lvrename failed to rename the mimage components of the mirrored mlog:

root@ina:~# lvrename vg_ina/home backups
...
root@ina:~# lvs -a
  LV                   VG     Attr   LSize   Origin Snap%  Move Log          Copy%  Convert
  backups              vg_ina mwi-a- 150.00g                    backups_mlog 100.00
  [backups_mimage_0]   vg_ina iwi-ao 150.00g
  [backups_mimage_1]   vg_ina iwi-ao 150.00g
  [backups_mlog]       vg_ina mwi-ao   4.00m                                 100.00
  [home_mlog_mimage_0] vg_ina iwi-ao   4.00m
  [home_mlog_mimage_1] vg_ina iwi-ao   4.00m

This will cause a conflict if I want to create another mirrored LV called
"home".
-----

As a workaround, the mimages can be renamed by removing and recreating them:

root@ina:~# lvconvert --mirrorlog core vg_ina/backups
root@ina:~# lvconvert --mirrorlog mirrored vg_ina/backups
root@ina:~# lvs -a
  LV                      VG     Attr   LSize   Origin Snap%  Move Log          Copy%  Convert
  backups                 vg_ina mwi-a- 150.00g                    backups_mlog 100.00
  [backups_mimage_0]      vg_ina iwi-ao 150.00g
  [backups_mimage_1]      vg_ina iwi-ao 150.00g
  [backups_mlog]          vg_ina mwi-ao   4.00m                                 100.00
  [backups_mlog_mimage_0] vg_ina iwi-ao   4.00m
  [backups_mlog_mimage_1] vg_ina iwi-ao   4.00m

#647567#10
Date:
2011-11-04 01:07:04 UTC
From:
To:
Works OK for me with upstream code.

Alasdair

#647567#15
Date:
2011-11-04 01:12:39 UTC
From:
To:
Wrong.  It fails upstream too.

Alasdair

#647567#20
Date:
2011-11-04 01:27:06 UTC
From:
To:
Not thoroughly tested, but probably fix along these lines.

I.e. some recursion is missing.

Alasdair
--- lv_manip.c 3 Nov 2011 15:46:51 -0000 1.319 +++ lv_manip.c 4 Nov 2011 01:24:26 -0000 @@ -2749,13 +2749,20 @@ struct lv_segment *seg; uint32_t s; - if (lv_is_cow(lv) && lv_is_virtual_origin(org = origin_from_cow(lv))) + if (lv_is_cow(lv) && lv_is_virtual_origin(org = origin_from_cow(lv))) { if (!fn(cmd, org, data)) return_0; + if (!for_each_sub_lv(cmd, org, fn, data)) + return_0; + } dm_list_iterate_items(seg, &lv->segments) { - if (seg->log_lv && !fn(cmd, seg->log_lv, data)) - return_0; + if (seg->log_lv) { + if (!fn(cmd, seg->log_lv, data)) + return_0; + if (!for_each_sub_lv(cmd, seg->log_lv, fn, data)) + return_0; + } if (seg->pool_metadata_lv && !fn(cmd, seg->pool_metadata_lv, data)) return_0; for (s = 0; s < seg->area_count; s++) {