lvconvert: limit lv types for cache use
PATCH 1/1 lvconvert: limit lv types for cache use
Cache data and metadata lvs can be only linear, striped or raid. Origin lvs must be either linear, striped or raid to be converted to a cache lv.
--- lib/metadata/metadata-exported.h | 8 ++ lib/metadata/snapshot_manip.c | 5 ++ tools/lvconvert.c | 173 ++++++++++++++++++++++++++++++++------- 3 files changed, 157 insertions(+), 29 deletions(-)
lib/metadata/metadata-exported.h +8 -0
@@ -180,6 +180,13 @@#define lv_is_raid_metadata (lv) (((lv)->status & (RAID_META)) ? 1 : 0)#define lv_is_raid_type (lv) (((lv)->status & (RAID | RAID_IMAGE | RAID_META)) ? 1 : 0) +/* +* Unfortunately, raid1 and raid10 end up being reported as MIRRORED, +* so lv_is_mirror_type() is true for them... add this test until that +* can be untangled. +*/ +#define lv_is_really_mirror_type (lv) (lv_is_mirror_type((lv)) && !lv_is_raid((lv))) +#define lv_is_cache (lv) (((lv)->status & (CACHE)) ? 1 : 0)#define lv_is_cache_pool (lv) (((lv)->status & (CACHE_POOL)) ? 1 : 0)#define lv_is_cache_pool_data (lv) (((lv)->status & (CACHE_POOL_DATA)) ? 1 : 0)
@@ -927,6 +934,7 @@ int lv_is_cow_covering_origin(const struct logical_volume *lv);/* Test if given LV is visible from user's perspective */ int lv_is_visible (const struct logical_volume *lv); +int lv_is_invisible (const struct logical_volume *lv);int pv_is_in_vg (struct volume_group *vg,struct physical_volume *pv);
lib/metadata/snapshot_manip.c +5 -0
@@ -129,6 +129,11 @@ int lv_is_visible(const struct logical_volume *lv)return lv->status &VISIBLE_LV ?1 :0 ; } +int lv_is_invisible (const struct logical_volume *lv) +{ +return !lv_is_visible (lv); +} +int lv_is_virtual_origin (const struct logical_volume *lv) {return (lv->status &VIRTUAL_ORIGIN ) ?1 :0 ;
tools/lvconvert.c +144 -29
229 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 1/1 lvconvert: limit lv types for cache use
Dne 2.9.2014 v 22:56 David Teigland napsal(a):
Quoted 14 lines
Cache data and metadata lvs can be only linear, striped or raid. Origin lvs must be either linear, striped or raid to be converted to a cache lv.
--- lib/metadata/metadata-exported.h | 8 ++ lib/metadata/snapshot_manip.c | 5 ++ tools/lvconvert.c | 173 ++++++++++++++++++++++++++++++++------- 3 files changed, 157 insertions(+), 29 deletions(-)lib/metadata/metadata-exported.h +0
-0
lib/metadata/metadata-exported.h line 189
Quoted 10 lines
lib/metadata/metadata-exported.h +7
-0@@ -180,6 +180,13 @@#define lv_is_raid_metadata (lv) (((lv)->status & (RAID_META)) ? 1 : 0)#define lv_is_raid_type (lv) (((lv)->status & (RAID | RAID_IMAGE | RAID_META)) ? 1 : 0) +/* +* Unfortunately, raid1 and raid10 end up being reported as MIRRORED, +* so lv_is_mirror_type() is true for them... add this test until that +* can be untangled. +*/ +#define lv_is_really_mirror_type (lv) (lv_is_mirror_type((lv)) && !lv_is_raid((lv))) +
In fact - there should be rather fixed the problem of using mirror_type for
raids. These to targets are quite different and should not share internal
flags - since it leads to many other internal bugs where code tries to run mirror repair operations on raid devices.
So instead we should separate and fix usage of lv_is_mirror_type purely for old mirrors to avoid confusion.
lib/metadata/metadata-exported.h int lv_is_cow_covering_origin(const struct logical_volume *lv); · line 937
Quoted 3 lines
lib/metadata/metadata-exported.h +1
-0/* Test if given LV is visible from user's perspective */ int lv_is_visible (const struct logical_volume *lv); +int lv_is_invisible (const struct logical_volume *lv);
!lv_is_visible is common way for code - so I would avoid to add new func for
this.
lib/metadata/metadata-exported.h
Quoted 5 lines
lib/metadata/metadata-exported.h +5
-0+static const char *lv_is_name (struct logical_volume *lv) +{ +if (lv_is_external_origin (lv)) +return "external_origin" ; +
There is already a reporting function for this with new Petr's patches.
);
lib/metadata/metadata-exported.h
Quoted 8 lines
lib/metadata/metadata-exported.h +8
-0+ if (lv_is_external_origin(metadata_lv) || + lv_is_thin_type(metadata_lv) || + lv_is_external_origin(metadata_lv) || + lv_is_really_mirror_type(metadata_lv) || + lv_is_raid_image(metadata_lv) || + lv_is_raid_metadata(metadata_lv) || + lv_is_cache_type(metadata_lv) || + lv_is_virtual(metadata_lv) ||
Many of those types are already skipped because they are invisible. So I think this list should be much shorter.
lib/metadata/metadata-exported.h static int _lvconvert_pool(struct cmd_context *cmd, · line 2724
Quoted 10 lines
lib/metadata/metadata-exported.h +0
-6@@ -2716,12 +2824,6 @@ static int _lvconvert_pool(struct cmd_context *cmd, display_lvname(metadata_lv));return 0 ; } -if (lv_is_thin_type (metadata_lv) || -lv_is_cache_type (metadata_lv)) { -log_error ("Can't use thin or cache type LV %s for pool metadata." , -display_lvname (metadata_lv)); -return 0 ; - }
don't remove
Quoted 8 lines
lib/metadata/metadata-exported.h +0
-1if (!lv_is_pool (pool_lv)) {if (!_lvconvert_update_pool_params (pool_lv, lp))@@ -2735,17 +2837,6 @@ static int _lvconvert_pool(struct cmd_context *cmd, } } -if (!lv_is_visible (pool_lv)) {
lib/metadata/metadata-exported.h static int _lvconvert_pool(struct cmd_context *cmd, · line 2748
Quoted 10 lines
lib/metadata/metadata-exported.h +0
-10-log_error ("Can't convert internal LV %s." ,display_lvname (pool_lv)); -return 0 ; - } - -if (lv_is_mirrored (pool_lv) && !lv_is_raid_type (pool_lv)) { -log_error ("Mirror logical volumes cannot be used as pools.\n" -"Try \"raid1\" segment type instead." ); -return 0 ; - } -
Don't remove
Quoted 15 lines
lib/metadata/metadata-exported.h +4
-0if ((dm_snprintf(metadata_name, sizeof(metadata_name), "%s%s", pool_lv->name, (segtype_is_cache_pool(lp->segtype)) ?@@ -3032,6 +3123,10 @@ revert_new_lv:#endif } +/* +* convert an origin lv into a cache lv by attaching a cache pool to the origin +*/ +static int _lvconvert_cache (struct cmd_context *cmd,struct logical_volume *origin,struct lvconvert_params *lp)
lib/metadata/metadata-exported.h static int _lvconvert_cache(struct cmd_context *cmd, · line 3050
Quoted 6 lines
lib/metadata/metadata-exported.h +0
-3@@ -3045,9 +3140,29 @@ static int _lvconvert_cache(struct cmd_context *cmd,return 0 ; } -if (lv_is_pool (origin) ||lv_is_cache_type (origin)) { -log_error ("Can't cache pool or cache type volume %s." , -display_lvname (origin));
don't remove
I'll look at those func myself and improving missing cases.
Zdenek
PATCH 1/1 lvconvert: limit lv types for cache use
Quoted 10 lines · Zdenek Kabelac
Dne 2.9.2014 v 22:56 David Teigland napsal(a):
tools/lvconvert.c struct lvconvert_params { · line 80
Quoted 5 lines
tools/lvconvert.c +5
-0+static const char *lv_is_name (struct logical_volume *lv) +{ +if (lv_is_external_origin (lv)) +return "external_origin" ; +There is already a reporting function for this with new Petr's patches.
That's the lv_layout_and_role fn. However, this one produces two lists of strings, not single concatenated string (for both "layout" and "role"). It was designed for reporting lv_layout and lv_role fields originally. So this would need to be patched a little bit to produce a single string that is suitable for issuing messages.
But yes, to keep the consistency here, the same identification should be used for messages too. I'll add a patch for that.
Signature · 1 line
Peter
PATCH 1/1 lvconvert: limit lv types for cache use
In reply to Zdenek KabelacQuoted 10 lines · Zdenek Kabelac
lib/metadata/metadata-exported.h line 189
Quoted 2 lines
lib/metadata/metadata-exported.h +2
-0+#define lv_is_really_mirror_type (lv) (lv_is_mirror_type((lv)) && !lv_is_raid((lv))) +In fact - there should be rather fixed the problem of using
mirror_typefor
raids. These to targets are quite different and should not share internal
flags - since it leads to many other internal bugs where code tries to run mirror repair operations on raid devices.So instead we should separate and fix usage of
lv_is_mirror_typepurely for old mirrors to avoid confusion.
Yeah, I went down that path... until it became too big a mess to untangle right now. So this is a temporary solution.
Quoted 6 lines
Quoted 3 lines
/* Test if given LV is visible from user's perspective */ int
lv_is_visible(const struct logical_volume *lv);
+intlv_is_invisible(const struct logical_volume *lv);!lv_is_visible is common way for code - so I would avoid to add
new func for this.
Yeah, I had that... until ls_is_name had to report the inverse which was more offensive than this addition.
Quoted 7 lines
tools/lvconvert.c struct lvconvert_params { · line 80
Quoted 5 lines
tools/lvconvert.c +5
-0+static const char *lv_is_name (struct logical_volume *lv) +{ +if (lv_is_external_origin (lv)) +return "external_origin" ; +There is already a reporting function for this with new Petr's patches.
Yeah, I looked at that, but it was not evident how to use it here, or if it would really report what we needed here. I'd be happy if someone replaced this with something better.
Quoted 11 lines
tools/lvconvert.c static int _lvconvert_pool(struct cmd_context *cmd, · line 2802
Quoted 8 lines
tools/lvconvert.c +8
-0+ if (lv_is_external_origin(metadata_lv) || + lv_is_thin_type(metadata_lv) || + lv_is_external_origin(metadata_lv) || + lv_is_really_mirror_type(metadata_lv) || + lv_is_raid_image(metadata_lv) || + lv_is_raid_metadata(metadata_lv) || + lv_is_cache_type(metadata_lv) || + lv_is_virtual(metadata_lv) ||Many of those types are already skipped because they are invisible. So I think this list should be much shorter.
Probably, but redundant checks are safer than missing some.
Quoted 4 lines
Quoted 4 lines
tools/lvconvert.c +0
-0@@ -2716,12 +2824,6 @@ static int _lvconvert_pool(struct cmd_context *cmd, display_lvname(metadata_lv));return 0 ; }
Quoted 8 lines
tools/lvconvert.c static int _lvconvert_pool(struct cmd_context *cmd, · line 2724
Quoted 6 lines
tools/lvconvert.c +0
-6-if (lv_is_thin_type (metadata_lv) || -lv_is_cache_type (metadata_lv)) { -log_error ("Can't use thin or cache type LV %s for pool metadata." , -display_lvname (metadata_lv)); -return 0 ; - }don't remove
Hm, those should be included in the new combined check... will verify that.
Quoted 5 lines
Quoted 5 lines
tools/lvconvert.c +0
-5-if (!lv_is_visible (pool_lv)) { -log_error ("Can't convert internal LV %s." ,display_lvname (pool_lv)); -return 0 ; - } -
Quoted 8 lines
tools/lvconvert.c static int _lvconvert_pool(struct cmd_context *cmd, · line 2748
Quoted 6 lines
tools/lvconvert.c +0
-6-if (lv_is_mirrored (pool_lv) && !lv_is_raid_type (pool_lv)) { -log_error ("Mirror logical volumes cannot be used as pools.\n" -"Try \"raid1\" segment type instead." ); -return 0 ; - } -Don't remove
same
Quoted 5 lines
tools/lvconvert.c static int _lvconvert_cache(struct cmd_context *cmd, · line 3050
Quoted 3 lines
tools/lvconvert.c +0
-3-if (lv_is_pool (origin) ||lv_is_cache_type (origin)) { -log_error ("Can't cache pool or cache type volume %s." , -display_lvname (origin));don't remove
same