From f9b92564a7500bffac953ed25a3b7a5207a99c27 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 24 Aug 2011 13:41:46 +0000 Subject: [PATCH] Fix raid shared lib segtype registration (2.02.87). --- WHATS_NEW | 4 +- lib/commands/toolcontext.c | 40 ++++---------- lib/metadata/segtype.h | 14 +---- lib/raid/.exported_symbols | 2 +- lib/raid/raid.c | 106 +++++++++++++++++++++++------------- lib/replicator/replicator.c | 6 +- 6 files changed, 89 insertions(+), 83 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index e1a8e0ccd..98ee74fa3 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,9 +1,11 @@ Version 2.02.89 - ================================== + Add configure --with-thin for (unimplemented) segtypes "thin" and "thin_pool". + Fix raid shared lib segtype registration (2.02.87). Version 2.02.88 - 19th August 2011 ================================== - Remove incorrect 'Breaking' error message from allocation code (2.02.87). + Remove incorrect 'Breaking' error message from allocation code. (2.02.87) Add lvconvert --merge support for raid1 devices split with --trackchanges. Support lvconvert of -m1 raid1 devices to a higher number. Add --trackchanges support to lvconvert --splitmirrors option for raid1. diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 3cbd29d2b..520e26042 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -994,24 +994,17 @@ static int _init_segtypes(struct cmd_context *cmd) { int i; struct segment_type *segtype; - struct segtype_library seglib = { .cmd = cmd }; + struct segtype_library seglib = { .cmd = cmd, .lib = NULL }; struct segment_type *(*init_segtype_array[])(struct cmd_context *cmd) = { init_striped_segtype, init_zero_segtype, init_error_segtype, init_free_segtype, -#ifdef RAID_INTERNAL - init_raid1_segtype, - init_raid4_segtype, - init_raid5_segtype, - init_raid5_la_segtype, - init_raid5_ra_segtype, - init_raid5_ls_segtype, - init_raid5_rs_segtype, - init_raid6_segtype, - init_raid6_zr_segtype, - init_raid6_nr_segtype, - init_raid6_nc_segtype, +#ifdef SNAPSHOT_INTERNAL + init_snapshot_segtype, +#endif +#ifdef MIRRORED_INTERNAL + init_mirrored_segtype, #endif NULL }; @@ -1027,22 +1020,13 @@ static int _init_segtypes(struct cmd_context *cmd) dm_list_add(&cmd->segtypes, &segtype->list); } -#ifdef SNAPSHOT_INTERNAL - if (!(segtype = init_snapshot_segtype(cmd))) - return 0; - segtype->library = NULL; - dm_list_add(&cmd->segtypes, &segtype->list); -#endif - -#ifdef MIRRORED_INTERNAL - if (!(segtype = init_mirrored_segtype(cmd))) - return 0; - segtype->library = NULL; - dm_list_add(&cmd->segtypes, &segtype->list); -#endif - #ifdef REPLICATOR_INTERNAL - if (!init_replicator_segtype(&seglib)) + if (!init_replicator_segtype(cmd, &seglib)) + return 0; +#endif + +#ifdef RAID_INTERNAL + if (!init_raid_segtypes(cmd, &seglib)) return 0; #endif diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h index 286a2e847..24847dfe2 100644 --- a/lib/metadata/segtype.h +++ b/lib/metadata/segtype.h @@ -130,21 +130,11 @@ struct segment_type *init_free_segtype(struct cmd_context *cmd); struct segment_type *init_unknown_segtype(struct cmd_context *cmd, const char *name); #ifdef RAID_INTERNAL -struct segment_type *init_raid1_segtype(struct cmd_context *cmd); -struct segment_type *init_raid4_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_la_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_ra_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_ls_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_rs_segtype(struct cmd_context *cmd); -struct segment_type *init_raid6_segtype(struct cmd_context *cmd); -struct segment_type *init_raid6_zr_segtype(struct cmd_context *cmd); -struct segment_type *init_raid6_nr_segtype(struct cmd_context *cmd); -struct segment_type *init_raid6_nc_segtype(struct cmd_context *cmd); +int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib); #endif #ifdef REPLICATOR_INTERNAL -int init_replicator_segtype(struct segtype_library *seglib); +int init_replicator_segtype(struct cmd_context *cmd, struct segtype_library *seglib); #endif #ifdef SNAPSHOT_INTERNAL diff --git a/lib/raid/.exported_symbols b/lib/raid/.exported_symbols index 1c92c6a39..0d012d6f5 100644 --- a/lib/raid/.exported_symbols +++ b/lib/raid/.exported_symbols @@ -1 +1 @@ -init_segtype +init_multiple_segtypes diff --git a/lib/raid/raid.c b/lib/raid/raid.c index ceac1fa1a..a03f45337 100644 --- a/lib/raid/raid.c +++ b/lib/raid/raid.c @@ -331,8 +331,8 @@ static struct segtype_handler _raid_ops = { .destroy = _raid_destroy, }; -static struct segment_type *init_raid_segtype(struct cmd_context *cmd, - const char *raid_type) +static struct segment_type *_init_raid_segtype(struct cmd_context *cmd, + const char *raid_type) { struct segment_type *segtype = dm_zalloc(sizeof(*segtype)); @@ -362,25 +362,11 @@ static struct segment_type *init_raid_segtype(struct cmd_context *cmd, return segtype; } -#ifndef RAID_INTERNAL /* Shared */ -struct segment_type *init_raid1_segtype(struct cmd_context *cmd); -struct segment_type *init_raid4_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_la_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_ra_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_ls_segtype(struct cmd_context *cmd); -struct segment_type *init_raid5_rs_segtype(struct cmd_context *cmd); -struct segment_type *init_raid6_segtype(struct cmd_context *cmd); -struct segment_type *init_raid6_zr_segtype(struct cmd_context *cmd); -struct segment_type *init_raid6_nr_segtype(struct cmd_context *cmd); -struct segment_type *init_raid6_nc_segtype(struct cmd_context *cmd); -#endif - -struct segment_type *init_raid1_segtype(struct cmd_context *cmd) +static struct segment_type *_init_raid1_segtype(struct cmd_context *cmd) { struct segment_type *segtype; - segtype = init_raid_segtype(cmd, "raid1"); + segtype = _init_raid_segtype(cmd, "raid1"); if (!segtype) return NULL; @@ -389,43 +375,87 @@ struct segment_type *init_raid1_segtype(struct cmd_context *cmd) return segtype; } -struct segment_type *init_raid4_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid4_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid4"); + return _init_raid_segtype(cmd, "raid4"); } -struct segment_type *init_raid5_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid5_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid5"); + return _init_raid_segtype(cmd, "raid5"); } -struct segment_type *init_raid5_la_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid5_la_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid5_la"); + return _init_raid_segtype(cmd, "raid5_la"); } -struct segment_type *init_raid5_ra_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid5_ra_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid5_ra"); + return _init_raid_segtype(cmd, "raid5_ra"); } -struct segment_type *init_raid5_ls_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid5_ls_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid5_ls"); + return _init_raid_segtype(cmd, "raid5_ls"); } -struct segment_type *init_raid5_rs_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid5_rs_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid5_rs"); + return _init_raid_segtype(cmd, "raid5_rs"); } -struct segment_type *init_raid6_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid6_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid6"); + return _init_raid_segtype(cmd, "raid6"); } -struct segment_type *init_raid6_zr_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid6_zr_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid6_zr"); + return _init_raid_segtype(cmd, "raid6_zr"); } -struct segment_type *init_raid6_nr_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid6_nr_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid6_nr"); + return _init_raid_segtype(cmd, "raid6_nr"); } -struct segment_type *init_raid6_nc_segtype(struct cmd_context *cmd) + +static struct segment_type *_init_raid6_nc_segtype(struct cmd_context *cmd) { - return init_raid_segtype(cmd, "raid6_nc"); + return _init_raid_segtype(cmd, "raid6_nc"); +} + +#ifdef RAID_INTERNAL /* Shared */ +int init_raid_segtypes(struct cmd_context *cmd, struct segtype_library *seglib) +#else +int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *seglib); + +int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *seglib) +#endif +{ + struct segment_type *segtype; + unsigned i = 0; + struct segment_type *(*raid_segtype_fn[])(struct cmd_context *) = { + _init_raid1_segtype, + _init_raid4_segtype, + _init_raid5_segtype, + _init_raid5_la_segtype, + _init_raid5_ra_segtype, + _init_raid5_ls_segtype, + _init_raid5_rs_segtype, + _init_raid6_segtype, + _init_raid6_zr_segtype, + _init_raid6_nr_segtype, + _init_raid6_nc_segtype, + NULL, + }; + + do { + if ((segtype = raid_segtype_fn[i](cmd)) && + !lvm_register_segtype(seglib, segtype)) + return 0; + } while (raid_segtype_fn[++i]); + + return 1; } diff --git a/lib/replicator/replicator.c b/lib/replicator/replicator.c index 9bfc0a285..ef11c419c 100644 --- a/lib/replicator/replicator.c +++ b/lib/replicator/replicator.c @@ -754,10 +754,10 @@ static struct segtype_handler _replicator_dev_ops = { }; #ifdef REPLICATOR_INTERNAL -int init_replicator_segtype(struct segtype_library *seglib) +int init_replicator_segtype(struct cmd_context *cmd, struct segtype_library *seglib) #else /* Shared */ -int init_multiple_segtype(struct segtype_library *seglib); -int init_multiple_segtype(struct segtype_library *seglib) +int init_multiple_segtype(struct cmd_context *cmd, struct segtype_library *seglib); +int init_multiple_segtype(struct cmd_context *cmd, struct segtype_library *seglib) #endif { struct segment_type *segtype;