1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib/format_text
Peter Rajnoha c9f021de0b metadata: process_each_lv_in_vg: get the list of LVs to process first, then do the processing
This avoids a problem in which we're using selection on LV list - we
need to do the selection on initial state and not on any intermediary
state as we process LVs one by one - some of the relations among LVs
can be gone during this processing.

For example, processing one LV can cause the other LVs to lose the
relation to this LV and hence they're not selectable anymore with
the original selection criteria as it would be if we did selection
on inital state. A perfect example is with thin snapshots:

$ lvs -o lv_name,origin,layout,role vg
  LV    Origin Layout      Role
  lvol1        thin,sparse public,origin,thinorigin,multithinorigin
  lvol2 lvol1  thin,sparse public,snapshot,thinsnapshot
  lvol3 lvol1  thin,sparse public,snapshot,thinsnapshot
  pool         thin,pool   private

$ lvremove -ff -S 'lv_name=lvol1 || origin=lvol1'
  Logical volume "lvol1" successfully removed

The lvremove command above was supposed to remove lvol1 as well as
all its snapshots which have origin=lvol1. It failed to do so, because
once we removed the origin lvol1, the lvol2 and lvol3 which were
snapshots before are not snapshots anymore - the relations change
as we're processing these LVs one by one.

If we do the selection first and then execute any concrete actions on
these LVs (which is what this patch does), the behaviour is correct
then - the selection is done on the *initial state*:

$ lvremove -ff -S 'lv_name=lvol1 || origin=lvol1'
  Logical volume "lvol1" successfully removed
  Logical volume "lvol2" successfully removed
  Logical volume "lvol3" successfully removed

Similarly for all the other situations in which relations among
LVs are being changed by processing the LVs one by one.

This patch also introduces LV_REMOVED internal LV status flag
to mark removed LVs so they're not processed further when we
iterate over collected list of LVs to be processed.

Previously, when we iterated directly over vg->lvs list to
process the LVs, we relied on the fact that once the LV is removed,
it is also removed from the vg->lvs list we're iterating over.
But that was incorrect as we shouldn't remove LVs from the list
during one iteration while we're iterating over that exact list
(dm_list_iterate_items safe can handle only one removal at
one iteration anyway, so it can't be used here).
2015-03-24 08:43:07 +01:00
..
archive.c cleanup: drop unneeded included header files 2012-08-23 14:37:20 +02:00
archiver.c cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
archiver.h vgconvert: Do not call lvmetad_vg_remove (path shared with vgcfgbackup). 2013-09-18 12:53:11 +02:00
export.c comments: Use full flag names. 2015-03-09 18:53:22 +00:00
flags.c metadata: process_each_lv_in_vg: get the list of LVs to process first, then do the processing 2015-03-24 08:43:07 +01:00
format-text.c format_text: Fix precommitted segfault. 2015-03-19 11:14:47 +00:00
format-text.h report: select: refactor: move str_list to libdm 2014-06-17 16:27:20 +02:00
import_vsn1.c cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
import-export.h cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
import.c cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
layout.h cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
tags.c report: select: refactor: move str_list to libdm 2014-06-17 16:27:20 +02:00
text_export.h Move the core of the lib/config/config.c functionality into libdevmapper, 2011-08-30 14:55:15 +00:00
text_import.h cleanup: self compilable headers 2013-12-12 13:28:19 +01:00
text_label.c cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00