1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
lvm2/lib/metadata
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
..
cache_manip.c cache: Fix a segfault when passing --cachepolicy without --cachesettings. 2015-02-24 11:39:35 +01:00
lv_alloc.h thin: simplify thin volume creation 2014-10-26 18:37:13 +01:00
lv_manip.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
lv.c report: fix seg_monitor field to display monitoring status for thick snapshots and mirrors 2015-03-05 14:05:34 +01:00
lv.h cleanup: for commit 7bcb3fb02d 2015-01-21 11:29:12 +01:00
merge.c cleanup: add lv_is_error_when_full() macro 2015-01-20 14:52:06 +01:00
metadata-exported.h 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
metadata.c cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
metadata.h cache: Store metadata size and checksum. 2015-03-18 23:43:02 +00:00
mirror.c mirror: Explicit cast in region_size_max 2015-02-26 19:49:25 +00:00
pool_manip.c pool: fix typo in error message: then -> than 2014-12-04 09:18:16 +01:00
pv_alloc.h cleanup: self compilable headers 2013-12-12 13:28:19 +01:00
pv_manip.c pvremove: Avoid metadata re-reads & related error messages. 2015-01-06 14:27:30 +01:00
pv_map.c raid_manip: v2 fix multi-segment misallocation on 'lvconvert --repair' 2015-01-16 13:44:16 +01:00
pv_map.h Track unreserved space for all alloc policies and then permit NORMAL to place 2012-02-01 02:10:45 +00:00
pv.c pv_vg_name: do not expose internal orphans to lvm2 users 2014-03-19 00:57:59 +01:00
pv.h cleanup: self compilable headers 2013-12-12 13:28:19 +01:00
raid_manip.c raid: check lock holding LV 2015-01-30 14:16:27 +01:00
replicator_manip.c cleanup: constify activation usage of lv pointer 2014-09-24 10:54:47 +02:00
segtype.c clean: remove unneeded assign 2013-06-17 09:34:56 +02:00
segtype.h thin: errrorwhenfull support 2015-01-14 14:52:05 +01:00
snapshot_manip.c cleanup: fix typo and use vg mempool 2014-09-24 10:54:47 +02:00
thin_manip.c thin: add missing 64KB rounding 2014-11-26 09:29:25 +01:00
vg.c Revert "systemid: Add ACCESS_NEEDS_SYSTEM_ID VG flag." 2015-03-05 09:50:43 -06:00
vg.h system_id: make new VGs read-only for old lvm versions 2015-03-05 09:50:43 -06:00