From zkabelac@sourceware.org Thu Sep 1 10:16:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 01 Sep 2011 10:16:00 -0000 Subject: LVM2/lib/thin thin.c Message-ID: <20110901101633.11218.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-01 10:16:33 Modified files: lib/thin : thin.c Log message: Reflect dm_config API update Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/lib/thin/thin.c 2011/08/30 14:55:18 1.6 +++ LVM2/lib/thin/thin.c 2011/09/01 10:16:32 1.7 @@ -46,28 +46,24 @@ static int _thin_pool_text_import(struct lv_segment *seg, const struct dm_config_node *sn, struct dm_hash_table *pv_hash __attribute__((unused))) { - const struct dm_config_node *cn; + const char *lv_name; - if (!(cn = dm_config_find_node(sn, "data")) || - !cn->v || cn->v->type != DM_CFG_STRING) + if (!dm_config_get_str(sn, "data", &lv_name)) return SEG_LOG_ERROR("Thin pool data must be a string in"); - if (!(seg->data_lv = find_lv(seg->lv->vg, cn->v->v.str))) - return SEG_LOG_ERROR("Unknown pool data %s in", - cn->v->v.str); + if (!(seg->data_lv = find_lv(seg->lv->vg, lv_name))) + return SEG_LOG_ERROR("Unknown pool data %s in", lv_name); - if (!(cn = dm_config_find_node(sn, "metadata")) || - !cn->v || cn->v->type != DM_CFG_STRING) + if (!dm_config_get_str(sn, "metadata", &lv_name)) return SEG_LOG_ERROR("Thin pool metadata must be a string in"); - if (!(seg->metadata_lv = find_lv(seg->lv->vg, cn->v->v.str))) - return SEG_LOG_ERROR("Unknown pool metadata %s in", - cn->v->v.str); + if (!(seg->metadata_lv = find_lv(seg->lv->vg, lv_name))) + return SEG_LOG_ERROR("Unknown pool metadata %s in", lv_name); if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id)) return SEG_LOG_ERROR("Could not read transaction_id for"); - if (dm_config_find_node(sn, "zero_new_blocks") && + if (dm_config_has_node(sn, "zero_new_blocks") && !dm_config_get_uint32(sn, "zero_new_blocks", &seg->zero_new_blocks)) return SEG_LOG_ERROR("Could not read zero_new_blocks for"); @@ -93,23 +89,20 @@ static int _thin_text_import(struct lv_segment *seg, const struct dm_config_node *sn, struct dm_hash_table *pv_hash __attribute__((unused))) { - const struct dm_config_node *cn; + const char *lv_name; - if (!(cn = dm_config_find_node(sn, "thin_pool")) || - !cn->v || cn->v->type != DM_CFG_STRING) + if (!dm_config_get_str(sn, "thin_pool", &lv_name)) return SEG_LOG_ERROR("Thin pool must be a string in"); - if (!(seg->thin_pool_lv = find_lv(seg->lv->vg, cn->v->v.str))) - return SEG_LOG_ERROR("Unknown thin pool %s in", - cn->v->v.str); + if (!(seg->thin_pool_lv = find_lv(seg->lv->vg, lv_name))) + return SEG_LOG_ERROR("Unknown thin pool %s in", lv_name); - if ((cn = dm_config_find_node(sn, "origin"))) { - if (!cn->v || cn->v->type != DM_CFG_STRING) + if (dm_config_has_node(sn, "origin")) { + if (!dm_config_get_str(sn, "origin", &lv_name)) return SEG_LOG_ERROR("Thin pool origin must be a string in"); - if (!(seg->origin = find_lv(seg->lv->vg, cn->v->v.str))) - return SEG_LOG_ERROR("Unknown origin %s in", - cn->v->v.str); + if (!(seg->origin = find_lv(seg->lv->vg, lv_name))) + return SEG_LOG_ERROR("Unknown origin %s in", lv_name); } if (!dm_config_get_uint64(sn, "device_id", &seg->device_id)) From zkabelac@sourceware.org Thu Sep 1 10:19:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 01 Sep 2011 10:19:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/mm/pool.c Message-ID: <20110901101901.11955.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-01 10:19:01 Modified files: . : WHATS_NEW_DM libdm/mm : pool.c Log message: Mark unreleased memory pools as internal error Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.495&r2=1.496 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/mm/pool.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9 --- LVM2/WHATS_NEW_DM 2011/08/19 19:42:39 1.495 +++ LVM2/WHATS_NEW_DM 2011/09/01 10:19:01 1.496 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Mark unreleased memory pools as internal error. Version 1.02.67 - 19th August 2011 ================================== --- LVM2/libdm/mm/pool.c 2011/08/11 17:29:05 1.8 +++ LVM2/libdm/mm/pool.c 2011/09/01 10:19:01 1.9 @@ -94,6 +94,7 @@ log_error(" [%p] %s", p, p->name); #endif } + log_error(INTERNAL_ERROR "Unreleased memory pool(s) found."); } /** From zkabelac@sourceware.org Thu Sep 1 10:25:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 01 Sep 2011 10:25:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/form ... Message-ID: <20110901102523.14028.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-01 10:25:23 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lib/format_text: export.c import-export.h lib/metadata : metadata.h Log message: Use size_t return type Since these function returns buffer size - use size_t type for them. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2087&r2=1.2088 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.27&r2=1.28 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.250&r2=1.251 --- LVM2/WHATS_NEW 2011/08/31 12:47:59 1.2087 +++ LVM2/WHATS_NEW 2011/09/01 10:25:22 1.2088 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Use size_t return type for text_vg_export_raw() and export_vg_to_buffer(). Add configure --enable-lvmetad for building the (experimental) LVMetaD. Fix resource leak when strdup fails in _get_device_status() (2.02.85). Directly allocate buffer memory in a pvck scan instead of using a mempool. --- LVM2/lib/cache/lvmcache.c 2011/08/30 14:55:16 1.117 +++ LVM2/lib/cache/lvmcache.c 2011/09/01 10:25:22 1.118 @@ -102,7 +102,7 @@ char uuid[64] __attribute__((aligned(8))); struct lvmcache_vginfo *vginfo; char *data; - int size; + size_t size; if (!(vginfo = vginfo_from_vgid((const char *)&vg->id))) { stack; @@ -132,7 +132,7 @@ return; } - log_debug("Metadata cache: VG %s (%s) stored (%d bytes%s).", + log_debug("Metadata cache: VG %s (%s) stored (%" PRIsize_t " bytes%s).", vginfo->vgname, uuid, size, precommitted ? ", precommitted" : ""); } --- LVM2/lib/format_text/export.c 2011/08/30 14:55:17 1.83 +++ LVM2/lib/format_text/export.c 2011/09/01 10:25:22 1.84 @@ -775,10 +775,10 @@ } /* Returns amount of buffer used incl. terminating NUL */ -int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf) +size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf) { struct formatter *f; - int r = 0; + size_t r = 0; _init(); @@ -809,7 +809,7 @@ return r; } -int export_vg_to_buffer(struct volume_group *vg, char **buf) +size_t export_vg_to_buffer(struct volume_group *vg, char **buf) { return text_vg_export_raw(vg, "", buf); } --- LVM2/lib/format_text/import-export.h 2011/08/30 14:55:17 1.27 +++ LVM2/lib/format_text/import-export.h 2011/09/01 10:25:22 1.28 @@ -65,7 +65,7 @@ int read_tags(struct dm_pool *mem, struct dm_list *tags, const struct dm_config_value *cv); int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp); -int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf); +size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf); struct volume_group *text_vg_import_file(struct format_instance *fid, const char *file, time_t *when, char **desc); --- LVM2/lib/metadata/metadata.h 2011/08/30 14:55:17 1.250 +++ LVM2/lib/metadata/metadata.h 2011/09/01 10:25:22 1.251 @@ -454,7 +454,7 @@ /* * For internal metadata caching. */ -int export_vg_to_buffer(struct volume_group *vg, char **buf); +size_t export_vg_to_buffer(struct volume_group *vg, char **buf); int export_vg_to_config_tree(struct volume_group *vg, struct dm_config_tree **cft); struct volume_group *import_vg_from_buffer(const char *buf, struct format_instance *fid); From zkabelac@sourceware.org Thu Sep 1 13:25:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 01 Sep 2011 13:25:00 -0000 Subject: LVM2 daemons/common/daemon-server.h lib/comman ... Message-ID: <20110901132550.4200.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-01 13:25:50 Modified files: daemons/common : daemon-server.h lib/commands : toolcontext.c Log message: Keep the old-style prototypes Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.h.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.131&r2=1.132 --- LVM2/daemons/common/daemon-server.h 2011/08/31 12:39:58 1.11 +++ LVM2/daemons/common/daemon-server.h 2011/09/01 13:25:50 1.12 @@ -114,6 +114,6 @@ daemon_reply daemon_takeover(daemon_info i, daemon_request r); /* Call this to request a clean shutdown of the daemon. Async safe. */ -void daemon_stop(); +void daemon_stop(void); #endif --- LVM2/lib/commands/toolcontext.c 2011/08/30 14:55:16 1.131 +++ LVM2/lib/commands/toolcontext.c 2011/09/01 13:25:50 1.132 @@ -206,7 +206,7 @@ * 856a6f1dbd8940e72755af145ebcd806408ecedd * some operations could not be performed by udev, requiring our fallback code. */ -static int _dm_driver_has_stable_udev_support() +static int _dm_driver_has_stable_udev_support(void) { char vsn[80]; unsigned maj, min, patchlevel; From zkabelac@sourceware.org Thu Sep 1 13:30:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 01 Sep 2011 13:30:00 -0000 Subject: LVM2/lib/misc lvm-globals.c Message-ID: <20110901133012.5878.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-01 13:30:11 Modified files: lib/misc : lvm-globals.c Log message: Match the prototype old-style declaration Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14 --- LVM2/lib/misc/lvm-globals.c 2011/08/11 17:46:14 1.13 +++ LVM2/lib/misc/lvm-globals.c 2011/09/01 13:30:11 1.14 @@ -207,7 +207,7 @@ return _full_scan_done; } -int obtain_device_list_from_udev() +int obtain_device_list_from_udev(void) { return _obtain_device_list_from_udev; } From zkabelac@sourceware.org Thu Sep 1 14:02:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 01 Sep 2011 14:02:00 -0000 Subject: LVM2/libdm libdm-config.c Message-ID: <20110901140208.7987.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-01 14:02:07 Modified files: libdm : libdm-config.c Log message: Use const casting when it's needed Keep the lookup operation const and use const casting at the dm_ function level. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/libdm/libdm-config.c 2011/08/31 15:19:20 1.3 +++ LVM2/libdm/libdm-config.c 2011/09/01 14:02:05 1.4 @@ -809,8 +809,8 @@ /* * utility functions */ -static struct dm_config_node *_find_config_node(const void *start, - const char *path) +static const struct dm_config_node *_find_config_node(const void *start, + const char *path) { const char *e; const struct dm_config_node *cn = start; @@ -848,15 +848,15 @@ path = e; } - return (struct dm_config_node *) cn_found; + return cn_found; } -typedef struct dm_config_node *_node_lookup_fn(const void *start, const char *path); +typedef const struct dm_config_node *_node_lookup_fn(const void *start, const char *path); -static struct dm_config_node *_find_first_config_node(const void *start, const char *path) +static const struct dm_config_node *_find_first_config_node(const void *start, const char *path) { const struct dm_config_tree *cft = start; - struct dm_config_node *cn = NULL; + const struct dm_config_node *cn = NULL; while (cft) { if ((cn = _find_config_node(cft->root, path))) @@ -976,7 +976,7 @@ struct dm_config_node *dm_config_find_node(struct dm_config_node *cn, const char *path) { - return _find_config_node(cn, path); + return (struct dm_config_node *) _find_config_node(cn, path); } int dm_config_find_int(const struct dm_config_node *cn, const char *path, int fail) From agk@sourceware.org Thu Sep 1 17:56:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 01 Sep 2011 17:56:00 -0000 Subject: LVM2/daemons Makefile.in Message-ID: <20110901175654.15784.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-01 17:56:53 Modified files: daemons : Makefile.in Log message: Only build libdaemon.a when we need it at the moment. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/Makefile.in.diff?cvsroot=lvm2&r1=1.17&r2=1.18 --- LVM2/daemons/Makefile.in 2011/08/31 11:31:58 1.17 +++ LVM2/daemons/Makefile.in 2011/09/01 17:56:53 1.18 @@ -15,8 +15,10 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ +ifeq ("@BUILD_LVMETAD@", "yes") LIB_STATIC=libdaemon.a SOURCES = common/daemon-shared.c common/daemon-server.c common/daemon-client.c +endif .PHONY: dmeventd clvmd cmirrord lvmetad @@ -30,6 +32,7 @@ ifeq ("@BUILD_LVMETAD@", "yes") SUBDIRS += lvmetad +device-mapper: libdaemon.a endif ifeq ("@BUILD_DMEVENTD@", "yes") @@ -48,5 +51,3 @@ ifeq ("@BUILD_DMEVENTD@", "yes") device-mapper: dmeventd.device-mapper endif - -device-mapper: libdaemon.a From agk@sourceware.org Thu Sep 1 17:58:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 01 Sep 2011 17:58:00 -0000 Subject: LVM2/libdm libdm-string.c Message-ID: <20110901175827.15982.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-01 17:58:27 Modified files: libdm : libdm-string.c Log message: Add comments & remove always-included header. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-string.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16 --- LVM2/libdm/libdm-string.c 2011/08/30 14:55:16 1.15 +++ LVM2/libdm/libdm-string.c 2011/09/01 17:58:27 1.16 @@ -13,7 +13,6 @@ */ #include "dmlib.h" -#include "libdevmapper.h" #include @@ -179,6 +178,12 @@ (*count)++; } +/* + * Count occurrences of 'c' in 'str' of length 'size'. + * + * Returns: + * Number of occurrences of 'c' + */ unsigned dm_count_chars(const char *str, size_t len, const int c) { size_t i; @@ -191,6 +196,9 @@ return count; } +/* + * Length of string after escaping double quotes and backslashes. + */ size_t dm_escaped_len(const char *str) { size_t len = 1; @@ -289,6 +297,9 @@ _quote_characters(out, src, '-', '-', 0); } +/* + * -- or if !layer just -. + */ char *dm_build_dm_name(struct dm_pool *mem, const char *vgname, const char *lvname, const char *layer) { @@ -328,7 +339,7 @@ return r; } -char *dm_build_dm_uuid(struct dm_pool *mem, const char *prefix, const char *lvid, const char *layer) +char *dm_build_dm_uuid(struct dm_pool *mem, const char *uuid_prefix, const char *lvid, const char *layer) { char *dmuuid; size_t len; @@ -336,7 +347,7 @@ if (!layer) layer = ""; - len = strlen(prefix) + strlen(lvid) + strlen(layer) + 1; + len = strlen(uuid_prefix) + strlen(lvid) + strlen(layer) + 1; if (!(dmuuid = dm_pool_alloc(mem, len))) { log_error("build_dm_name: Allocation failed for %" PRIsize_t @@ -344,7 +355,7 @@ return NULL; } - sprintf(dmuuid, "%s%s%s%s", prefix, lvid, (*layer) ? "-" : "", layer); + sprintf(dmuuid, "%s%s%s%s", uuid_prefix, lvid, (*layer) ? "-" : "", layer); return dmuuid; } @@ -362,11 +373,20 @@ return out; } +/* + * Undo quoting in situ. + */ void dm_unescape_double_quotes(char *src) { _unquote_one_character(src, '\"', '\\'); } +/* + * Unescape colons and "at" signs in situ and save the substrings + * starting at the position of the first unescaped colon and the + * first unescaped "at" sign. This is normally used to unescape + * device names used as PVs. + */ void dm_unescape_colons_and_at_signs(char *src, char **substr_first_unquoted_colon, char **substr_first_unquoted_at_sign) From jbrassow@sourceware.org Thu Sep 1 19:22:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Thu, 01 Sep 2011 19:22:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/mirror.c Message-ID: <20110901192212.29121.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-01 19:22:11 Modified files: . : WHATS_NEW lib/metadata : mirror.c Log message: Fix for bug 732142: Unsafe table load during mirror image split There was a bad sequence: *) Make changes to LV layout to split images (e.g. 4-way -> 2-way/2-way) 1) vg_write, suspend_lv(original_mirror), vg_commit 2) activate_lv(newly_split_lv) 3) resume_lv(original_mirror) Step #2 is not allowed. However, without it, the resume of the original mirror will also resume its former sub-LVs - making it impossible to activate the newly split LV due to the changes in layering, pointers, and names that had already been made. Additionally, the resume or the original brings the sub-lv's online with names that differ from the metadata on disk - also a no-no. Thus, the split must be done in stages such that the active LVs always reflect what is in the committed LVM metadata. First, alter the original mirror by releasing the images. The images are made visible and independent as an intermediate stage. (This way, we can have consistency between LVM metadata and active LVs.) The second stage collects the recently split LVs, deactivates them, forms them into a mirror if necessary, and then activates them. It is a bit of a circuitous method, but it is the only way to split a mirror from a mirror and obey these general rules: 1) Never [de]activate sub-lvs when the top-level LV is suspended 2) Avoid having active LVs that differ from the description in the LVM metadata Signed-off-by: Jonathan Brassow Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2088&r2=1.2089 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.159&r2=1.160 --- LVM2/WHATS_NEW 2011/09/01 10:25:22 1.2088 +++ LVM2/WHATS_NEW 2011/09/01 19:22:11 1.2089 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix unsafe table load when splitting off smaller mirror from a larger one. Use size_t return type for text_vg_export_raw() and export_vg_to_buffer(). Add configure --enable-lvmetad for building the (experimental) LVMetaD. Fix resource leak when strdup fails in _get_device_status() (2.02.85). --- LVM2/lib/metadata/mirror.c 2011/08/30 14:55:17 1.159 +++ LVM2/lib/metadata/mirror.c 2011/09/01 19:22:11 1.160 @@ -585,7 +585,8 @@ struct logical_volume *detached_log_lv = NULL; struct lv_segment *mirrored_seg = first_seg(lv); struct dm_list split_images; - struct lv_list *lvl; + struct lv_list *lvl, *new_lvl; + struct cmd_context *cmd = lv->vg->cmd; if (!(lv->status & MIRRORED)) { log_error("Unable to split non-mirrored LV, %s", @@ -594,7 +595,7 @@ } if (!split_count) { - log_error("split_count is zero!"); + log_error(INTERNAL_ERROR "split_count is zero!"); return 0; } @@ -614,6 +615,12 @@ return 0; } + /* + * Step 1: + * Remove the images from the mirror. + * Make them visible, independent LVs (don't change names yet). + * Track them in a list for later instantiation. + */ dm_list_init(&split_images); for (i = 0; i < split_count; i++) { mirrored_seg->area_count--; @@ -626,31 +633,114 @@ log_very_verbose("%s assigned to be split", sub_lv->name); + lvl = dm_pool_alloc(lv->vg->vgmem, sizeof(*lvl)); + if (!lvl) { + log_error("lv_list alloc failed"); + return 0; + } + lvl->lv = sub_lv; + dm_list_add(&split_images, &lvl->list); + } + sub_lv = NULL; + + /* + * If no more mirrors, remove mirror layer. + * The sub_lv is removed entirely later - leaving + * only the top-level (now linear) LV. + */ + if (mirrored_seg->area_count == 1) { + sub_lv = seg_lv(mirrored_seg, 0); + sub_lv->status &= ~MIRROR_IMAGE; + lv_set_visible(sub_lv); + detached_log_lv = detach_mirror_log(mirrored_seg); + if (!remove_layer_from_lv(lv, sub_lv)) + return_0; + lv->status &= ~MIRRORED; + lv->status &= ~LV_NOTSYNCED; + } + + if (!vg_write(mirrored_seg->lv->vg)) { + log_error("Intermediate VG metadata write failed."); + return 0; + } + + /* + * Suspend the mirror - this includes all the sub-LVs and + * soon-to-be-split sub-LVs + */ + if (!suspend_lv(cmd, mirrored_seg->lv)) { + log_error("Failed to lock %s", mirrored_seg->lv->name); + vg_revert(mirrored_seg->lv->vg); + return 0; + } + + if (!vg_commit(mirrored_seg->lv->vg)) { + resume_lv(cmd, mirrored_seg->lv); + return 0; + } + + log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name); + + /* + * Resume the mirror - this also activates the visible, independent + * soon-to-be-split sub-LVs + */ + if (!resume_lv(cmd, mirrored_seg->lv)) { + log_error("Problem resuming %s", mirrored_seg->lv->name); + return 0; + } + + /* Remove original mirror layer if it has been converted to linear */ + if (sub_lv && !_delete_lv(lv, sub_lv)) + return_0; + + /* Remove the log if it has been converted to linear */ + if (detached_log_lv && !_delete_lv(lv, detached_log_lv)) + return_0; + + /* + * Step 2: + * The original mirror has been changed and we now have visible, + * independent, not-yet-renamed, active sub-LVs. We must: + * - deactivate the split sub-LVs + * - rename them + * - form new mirror if necessary + * - commit VG changes + * - activate the new LV + */ + new_lv = NULL; + dm_list_iterate_items(lvl, &split_images) { if (!new_lv) { - new_lv = sub_lv; - new_lv->name = dm_pool_strdup(lv->vg->cmd->mem, - split_name); - if (!new_lv->name) { - log_error("Unable to rename newly split LV"); - return 0; - } - } else { - lvl = dm_pool_alloc(lv->vg->cmd->mem, sizeof(*lvl)); - if (!lvl) { - log_error("lv_list alloc failed"); - return 0; - } - lvl->lv = sub_lv; - dm_list_add(&split_images, &lvl->list); + /* Grab 1st sub-LV for later */ + new_lvl = lvl; + new_lv = lvl->lv; + } + + sub_lv = lvl->lv; + if (!deactivate_lv(cmd, sub_lv)) { + log_error("Failed to deactivate former mirror image, %s", + sub_lv->name); + return 0; } } + dm_list_del(&new_lvl->list); + new_lv->name = dm_pool_strdup(lv->vg->vgmem, split_name); + if (!new_lv->name) { + log_error("Unable to rename newly split LV"); + return 0; + } + if (!dm_list_empty(&split_images)) { size_t len = strlen(new_lv->name) + 32; char *layer_name, format[len]; - if (!insert_layer_for_lv(lv->vg->cmd, new_lv, - 0, "_mimage_%d")) { + /* + * A number of images have been split and + * a new mirror layer must be formed + */ + + if (!insert_layer_for_lv(cmd, new_lv, 0, "_mimage_%d")) { log_error("Failed to build new mirror, %s", new_lv->name); return 0; @@ -664,7 +754,7 @@ dm_snprintf(format, len, "%s_mimage_%%d", new_lv->name); - layer_name = dm_pool_alloc(lv->vg->cmd->mem, len); + layer_name = dm_pool_alloc(lv->vg->vgmem, len); if (!layer_name) { log_error("Unable to allocate memory"); return 0; @@ -691,63 +781,17 @@ init_mirror_in_sync(1); } - sub_lv = NULL; - - /* - * If no more mirrors, remove mirror layer. - * The sub_lv is removed entirely later - leaving - * only the top-level (now linear) LV. - */ - if (mirrored_seg->area_count == 1) { - sub_lv = seg_lv(mirrored_seg, 0); - sub_lv->status &= ~MIRROR_IMAGE; - lv_set_visible(sub_lv); - detached_log_lv = detach_mirror_log(mirrored_seg); - if (!remove_layer_from_lv(lv, sub_lv)) - return_0; - lv->status &= ~MIRRORED; - lv->status &= ~LV_NOTSYNCED; - } - - if (!vg_write(mirrored_seg->lv->vg)) { - log_error("Intermediate VG metadata write failed."); - return 0; - } - - /* - * Suspend the original device and all its sub devices - */ - if (!suspend_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) { - log_error("Failed to lock %s", mirrored_seg->lv->name); - vg_revert(mirrored_seg->lv->vg); - return 0; - } - - if (!vg_commit(mirrored_seg->lv->vg)) { - resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv); - return 0; - } + if (!vg_write(mirrored_seg->lv->vg) || + !vg_commit(mirrored_seg->lv->vg)) + return_0; /* Bring newly split-off LV into existence */ - if (!activate_lv(lv->vg->cmd, new_lv)) { + if (!activate_lv(cmd, new_lv)) { log_error("Failed to activate newly split LV, %s", new_lv->name); return 0; } - /* Resume altered original LV */ - log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name); - if (!resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) { - log_error("Problem reactivating %s", mirrored_seg->lv->name); - return 0; - } - - if (sub_lv && !_delete_lv(lv, sub_lv)) - return_0; - - if (detached_log_lv && !_delete_lv(lv, detached_log_lv)) - return_0; - log_very_verbose("%" PRIu32 " image(s) detached from %s", split_count, lv->name); From jbrassow@sourceware.org Thu Sep 1 21:01:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Thu, 01 Sep 2011 21:01:00 -0000 Subject: LVM2/scripts gdbinit Message-ID: <20110901210112.8299.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-01 21:01:12 Modified files: scripts : gdbinit Log message: Updates to gdbinit file 1) Add more status flags for printing 2) Fix bug in lv_status_r processing for mirror segment type Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.7&r2=1.8 --- LVM2/scripts/gdbinit 2011/07/01 16:15:25 1.7 +++ LVM2/scripts/gdbinit 2011/09/01 21:01:12 1.8 @@ -27,8 +27,8 @@ printf "Use 'help ' for more info\n" printf "\n\n" printf "Popular breakpoints:\n" -printf "break lv_raid_change_image_count\n" -printf "run -m1 vg/lv\n" +printf "break _split_mirror_images\n" +printf "run --splitmirrors 2 -n new vg/lv\n" printf "\n\n" set follow-fork-mode child @@ -114,7 +114,7 @@ set $_SMI_seg = (struct lv_segment *)$arg1 set $_SMI_index= $arg2 - if ($_SMI_index < $_SMI_seg->area_count) + if (($_SMI_index < $_SMI_seg->area_count) && $_SMI_seg->meta_areas) set $_SMI_area = $_SMI_seg->meta_areas[$_SMI_index] set $_SMI_type = $_SMI_area.type @@ -174,6 +174,21 @@ # Constants defined in metadata-exported.h +# if ($_s_status & RAID) + if ($_s_status & 0x00000001U) + set $_s_status = $_s_status & ~0x00000001U + printf " RAID" + end +# if ($_s_status & RAID_META) + if ($_s_status & 0x00000002U) + set $_s_status = $_s_status & ~0x00000002U + printf " RAID_META" + end +# if ($_s_status & RAID_IMAGE) + if ($_s_status & 0x00000004U) + set $_s_status = $_s_status & ~0x00000004U + printf " RAID_IMAGE" + end # if ($_s_status & VISIBLE_LV) if ($_s_status & 0x00000040U) printf " VISIBLE_LV" @@ -186,6 +201,16 @@ set $_s_status = $_s_status & ~0x00000080U printf " FIXED_MINOR" end +# if ($_s_status & LVM_READ) + if ($_s_status & 0x00000100U) + set $_s_status = $_s_status & ~0x00000100U + printf " LVM_READ" + end +# if ($_s_status & LVM_WRITE) + if ($_s_status & 0x00000200U) + set $_s_status = $_s_status & ~0x00000200U + printf " LVM_WRITE" + end # if ($_s_status & SNAPSHOT) if ($_s_status & 0x00001000U) set $_s_status = $_s_status & ~0x00001000U @@ -216,21 +241,6 @@ set $_s_status = $_s_status & ~0x00040000U printf " MIRROR_IMAGE" end -# if ($_s_status & RAID) - if ($_s_status & 0x00000001U) - set $_s_status = $_s_status & ~0x00000001U - printf " RAID" - end -# if ($_s_status & RAID_META) - if ($_s_status & 0x00000002U) - set $_s_status = $_s_status & ~0x00000002U - printf " RAID_META" - end -# if ($_s_status & RAID_IMAGE) - if ($_s_status & 0x00000004U) - set $_s_status = $_s_status & ~0x00000004U - printf " RAID_IMAGE" - end # if ($_s_status & LV_NOTSYNCED) if ($_s_status & 0x00080000U) set $_s_status = $_s_status & ~0x00080000U @@ -241,15 +251,10 @@ set $_s_status = $_s_status & ~0x00400000U printf " CONVERTING" end -# if ($_s_status & LVM_READ) - if ($_s_status & 0x00000100U) - set $_s_status = $_s_status & ~0x00000100U - printf " LVM_READ" - end -# if ($_s_status & LVM_WRITE) - if ($_s_status & 0x00000200U) - set $_s_status = $_s_status & ~0x00000200U - printf " LVM_WRITE" +# if ($_s_status & MERGING) + if ($_s_status & 0x10000000U) + set $_s_status = $_s_status & ~0x10000000U + printf " MERGING" end if ($_s_status) @@ -417,7 +422,9 @@ # __lv_status_r # Decend tree, printing LV and seg status as we go. This # performs a depth first approach (but can't come up) +# # or +# # __lv_status_r # Try continuing decent of tree by first shifting to the # next 'area' in the seg ($arg1). If no more areas, then @@ -464,7 +471,6 @@ if (!$_area_index) seg_status $_seg $indent end - __seg_type $_type $_seg $_area_index if ($_type == AREA_LV) set $indent++ From agk@sourceware.org Thu Sep 1 21:04:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 01 Sep 2011 21:04:00 -0000 Subject: LVM2 ./WHATS_NEW_DM lib/config/config.c libdm/ ... Message-ID: <20110901210415.8884.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-01 21:04:15 Modified files: . : WHATS_NEW_DM lib/config : config.c libdm : libdevmapper.h libdm-config.c Log message: Comments, FIXMEs, name changes. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.496&r2=1.497 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.147&r2=1.148 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 --- LVM2/WHATS_NEW_DM 2011/09/01 10:19:01 1.496 +++ LVM2/WHATS_NEW_DM 2011/09/01 21:04:14 1.497 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Add dm_config and string character escaping functions to libdevmapper. Mark unreleased memory pools as internal error. Version 1.02.67 - 19th August 2011 --- LVM2/lib/config/config.c 2011/08/31 15:19:19 1.103 +++ LVM2/lib/config/config.c 2011/09/01 21:04:14 1.104 @@ -120,7 +120,7 @@ int r; if (!dm_config_check_file(cft, &filename, &info)) - return 0; + return_0; if (!dev) { if (!(dev = dev_create_file(filename, NULL, NULL, 1))) @@ -142,16 +142,17 @@ return r; } +// FIXME AGK Move to override_config_tree_from_string before next release static struct dm_config_tree *_setup_context_tree(struct cmd_context *cmd) { - struct dm_config_tree *r = cmd->cft_override; + struct dm_config_tree *cft = cmd->cft_override; - if (r) - r->cascade = cmd->cft; + if (cft) + cft->cascade = cmd->cft; else - r = cmd->cft; + cft = cmd->cft; - return r; + return cft; } const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd, --- LVM2/libdm/libdevmapper.h 2011/08/31 15:19:20 1.147 +++ LVM2/libdm/libdevmapper.h 2011/09/01 21:04:14 1.148 @@ -1016,10 +1016,7 @@ const char *dm_basename(const char *path); /* - * Count occurences of 'c' in 'str' of length 'size'. - * - * Returns: - * Number of occurrences of 'c' + * Returns number of occurrences of 'c' in 'str' of length 'size'. */ unsigned dm_count_chars(const char *str, size_t len, const int c); @@ -1223,9 +1220,10 @@ const void *sortvalue); -/********************************* - * config file parse/prettyprint - *********************************/ +/************************* + * config file parse/print + *************************/ +// FIXME AGK Review this interface before inclusion in a release. enum { DM_CFG_STRING, DM_CFG_FLOAT, @@ -1237,10 +1235,11 @@ int type; union { int64_t i; - float r; + float f; + double d; /* For completeness. (Unused.) */ const char *str; } v; - struct dm_config_value *next; /* for arrays */ + struct dm_config_value *next; /* For arrays */ }; struct dm_config_node { @@ -1281,8 +1280,7 @@ int dm_config_find_int(const struct dm_config_node *cn, const char *path, int fail); float dm_config_find_float(const struct dm_config_node *cn, const char *path, float fail); -const struct dm_config_node *dm_config_tree_find_node( - const struct dm_config_tree *cft, const char *path); +const struct dm_config_node *dm_config_tree_find_node(const struct dm_config_tree *cft, const char *path); const char *dm_config_tree_find_str(const struct dm_config_tree *cft, const char *path, const char *fail); int dm_config_tree_find_int(const struct dm_config_tree *cft, --- LVM2/libdm/libdm-config.c 2011/09/01 14:02:05 1.4 +++ LVM2/libdm/libdm-config.c 2011/09/01 21:04:14 1.5 @@ -57,7 +57,7 @@ off_t st_size; char *filename; int exists; - int keep_open; + int keep_open; // FIXME AGK Remove this before release void *custom; /* LVM uses this for a device pointer */ }; @@ -135,18 +135,21 @@ void dm_config_set_custom(struct dm_config_tree *cft, void *custom) { struct cs *c = (struct cs *) cft; + c->custom = custom; } void *dm_config_get_custom(struct dm_config_tree *cft) { struct cs *c = (struct cs *) cft; + return c->custom; } int dm_config_keep_open(struct dm_config_tree *cft) { struct cs *c = (struct cs *) cft; + return c->keep_open; } @@ -228,6 +231,7 @@ time_t dm_config_timestamp(struct dm_config_tree *cft) { struct cs *c = (struct cs *) cft; + return c->timestamp; } @@ -345,7 +349,7 @@ break; case DM_CFG_FLOAT: - line_append("%f", v->v.r); + line_append("%f", v->v.f); break; case DM_CFG_INT: @@ -442,6 +446,7 @@ outline.fp = NULL; outline.putline = NULL; +// FIXME AGK remove the fopen from libdm before release if (!file) file = "stdout"; else if (!(outline.fp = fopen(file, "w"))) { @@ -593,7 +598,7 @@ case TOK_FLOAT: v->type = DM_CFG_FLOAT; - v->v.r = strtod(p->tb, NULL); /* FIXME: check error */ + v->v.f = strtod(p->tb, NULL); /* FIXME: check error */ match(TOK_FLOAT); break; @@ -807,8 +812,19 @@ } /* - * utility functions + * Utility functions + */ + +/* + * node_lookup_fn is either: + * _find_config_node to perform a lookup starting from a given config_node + * in a config_tree; + * or + * _find_first_config_node to find the first config_node in a set of + * cascaded trees. */ +typedef const struct dm_config_node *node_lookup_fn(const void *start, const char *path); + static const struct dm_config_node *_find_config_node(const void *start, const char *path) { @@ -851,8 +867,6 @@ return cn_found; } -typedef const struct dm_config_node *_node_lookup_fn(const void *start, const char *path); - static const struct dm_config_node *_find_first_config_node(const void *start, const char *path) { const struct dm_config_tree *cft = start; @@ -867,10 +881,10 @@ return NULL; } -static const char *_find_config_str(const void *start, _node_lookup_fn find, +static const char *_find_config_str(const void *start, node_lookup_fn find_fn, const char *path, const char *fail) { - const struct dm_config_node *n = find(start, path); + const struct dm_config_node *n = find_fn(start, path); /* Empty strings are ignored */ if ((n && n->v && n->v->type == DM_CFG_STRING) && (*n->v->v.str)) { @@ -890,7 +904,7 @@ return _find_config_str(cn, _find_config_node, path, fail); } -static int64_t _find_config_int64(const void *start, _node_lookup_fn find, +static int64_t _find_config_int64(const void *start, node_lookup_fn find, const char *path, int64_t fail) { const struct dm_config_node *n = find(start, path); @@ -905,14 +919,14 @@ return fail; } -static float _find_config_float(const void *start, _node_lookup_fn find, +static float _find_config_float(const void *start, node_lookup_fn find, const char *path, float fail) { const struct dm_config_node *n = find(start, path); if (n && n->v && n->v->type == DM_CFG_FLOAT) { - log_very_verbose("Setting %s to %f", path, n->v->v.r); - return n->v->v.r; + log_very_verbose("Setting %s to %f", path, n->v->v.f); + return n->v->v.f; } log_very_verbose("%s not found in config: defaulting to %f", @@ -947,7 +961,7 @@ return fail; } -static int _find_config_bool(const void *start, _node_lookup_fn find, +static int _find_config_bool(const void *start, node_lookup_fn find, const char *path, int fail) { const struct dm_config_node *n = find(start, path); From agk@sourceware.org Fri Sep 2 01:32:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 02 Sep 2011 01:32:00 -0000 Subject: LVM2 tools/lvmcmdline.c lib/commands/toolconte ... Message-ID: <20110902013211.28181.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-02 01:32:09 Modified files: tools : lvmcmdline.c lib/commands : toolcontext.c toolcontext.h lib/config : config.c config.h libdm : libdevmapper.h libdm-config.c Log message: Move cascade inside libdm etc. Makes dumpconfig whole-section output wrong in a different way from before, but we should be able to merge cft_cmdline properly into cmd->cft now and remove cascade. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.146&r2=1.147 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.h.diff?cvsroot=lvm2&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.148&r2=1.149 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/tools/lvmcmdline.c 2011/08/04 14:54:48 1.146 +++ LVM2/tools/lvmcmdline.c 2011/09/02 01:32:08 1.147 @@ -996,6 +996,7 @@ { int ret = 0; int locking_type; + struct dm_config_tree *old_cft; init_error_message_produced(0); @@ -1020,8 +1021,7 @@ set_cmd_name(cmd->command->name); if (arg_count(cmd, config_ARG)) - if (override_config_tree_from_string(cmd, - arg_str_value(cmd, config_ARG, ""))) { + if (override_config_tree_from_string(cmd, arg_str_value(cmd, config_ARG, ""))) { ret = EINVALID_CMD_LINE; goto_out; } @@ -1029,10 +1029,9 @@ if (arg_count(cmd, config_ARG) || !cmd->config_valid || config_files_changed(cmd)) { /* Reinitialise various settings inc. logging, filters */ if (!refresh_toolcontext(cmd)) { - if (cmd->cft_override) { - destroy_config_tree(cmd->cft_override); - cmd->cft_override = NULL; - } + old_cft = remove_overridden_config_tree(cmd); + if (old_cft) + dm_config_destroy(old_cft); log_error("Updated config file invalid. Aborting."); return ECMD_FAILED; } @@ -1081,9 +1080,8 @@ lvmcache_destroy(cmd, 1); } - if (cmd->cft_override) { - destroy_config_tree(cmd->cft_override); - cmd->cft_override = NULL; + if ((old_cft = remove_overridden_config_tree(cmd))) { + dm_config_destroy(old_cft); /* Move this? */ if (!refresh_toolcontext(cmd)) stack; --- LVM2/lib/commands/toolcontext.c 2011/09/01 13:25:50 1.132 +++ LVM2/lib/commands/toolcontext.c 2011/09/02 01:32:09 1.133 @@ -558,13 +558,13 @@ return 1; } -static int _merge_config_files(struct cmd_context *cmd) +struct dm_config_tree *_merge_config_files(struct cmd_context *cmd, struct dm_config_tree *cft) { struct config_tree_list *cfl; /* Replace temporary duplicate copy of lvm.conf */ - if (cmd->cft->root) { - if (!(cmd->cft = dm_config_create(NULL, 0))) { + if (cft->root) { + if (!(cft = dm_config_create(NULL, 0))) { log_error("Failed to create config tree"); return 0; } @@ -572,11 +572,11 @@ dm_list_iterate_items(cfl, &cmd->config_files) { /* Merge all config trees into cmd->cft using merge/tag rules */ - if (!merge_config_tree(cmd, cmd->cft, cfl->cft)) + if (!merge_config_tree(cmd, cft, cfl->cft)) return_0; } - return 1; + return cft; } static void _destroy_tags(struct cmd_context *cmd) @@ -600,9 +600,19 @@ return 0; } -static void _destroy_tag_configs(struct cmd_context *cmd) +/* + * Returns cmdline config_tree that overrides all others, if present. + */ +static struct dm_config_tree *_destroy_tag_configs(struct cmd_context *cmd) { struct config_tree_list *cfl; + struct dm_config_tree *cft_cmdline = NULL, *cft; + + cft = dm_config_remove_cascaded_tree(cmd->cft); + if (cft) { + cft_cmdline = cmd->cft; + cmd->cft = cft; + } dm_list_iterate_items(cfl, &cmd->config_files) { if (cfl->cft == cmd->cft) @@ -616,6 +626,8 @@ } dm_list_init(&cmd->config_files); + + return cft_cmdline; } static int _init_dev_cache(struct cmd_context *cmd) @@ -1285,7 +1297,7 @@ if (!_init_tag_configs(cmd)) goto_out; - if (!_merge_config_files(cmd)) + if (!(cmd->cft = _merge_config_files(cmd, cmd->cft))) goto_out; if (!_process_config(cmd)) @@ -1397,6 +1409,8 @@ int refresh_toolcontext(struct cmd_context *cmd) { + struct dm_config_tree *cft_cmdline, *cft_tmp; + log_verbose("Reloading config files"); /* @@ -1415,7 +1429,7 @@ } dev_cache_exit(); _destroy_tags(cmd); - _destroy_tag_configs(cmd); + cft_cmdline = _destroy_tag_configs(cmd); cmd->config_valid = 0; @@ -1424,17 +1438,31 @@ if (!_init_lvm_conf(cmd)) return 0; + /* Temporary duplicate cft pointer holding lvm.conf - replaced later */ + cft_tmp = cmd->cft; + if (cft_cmdline) + cmd->cft = dm_config_insert_cascaded_tree(cft_cmdline, cft_tmp); + + /* Uses cmd->cft i.e. cft_cmdline + lvm.conf */ _init_logging(cmd); - if (!_init_tags(cmd, cmd->cft)) + /* Init tags from lvm.conf. */ + if (!_init_tags(cmd, cft_tmp)) return 0; + /* Doesn't change cmd->cft */ if (!_init_tag_configs(cmd)) return 0; - if (!_merge_config_files(cmd)) + /* Merge all the tag config files with lvm.conf, returning a + * fresh cft pointer in place of cft_tmp. */ + if (!(cmd->cft = _merge_config_files(cmd, cft_tmp))) return 0; + /* Finally we can make the proper, fully-merged, cmd->cft */ + if (cft_cmdline) + cmd->cft = dm_config_insert_cascaded_tree(cft_cmdline, cmd->cft); + if (!_process_config(cmd)) return 0; @@ -1464,6 +1492,8 @@ void destroy_toolcontext(struct cmd_context *cmd) { + struct dm_config_tree *cft_cmdline; + if (cmd->dump_filter) persistent_filter_dump(cmd->filter, 1); @@ -1479,7 +1509,8 @@ dm_pool_destroy(cmd->mem); dev_cache_exit(); _destroy_tags(cmd); - _destroy_tag_configs(cmd); + if ((cft_cmdline = _destroy_tag_configs(cmd))) + dm_config_destroy(cft_cmdline); if (cmd->libmem) dm_pool_destroy(cmd->libmem); --- LVM2/lib/commands/toolcontext.h 2011/08/30 14:55:16 1.45 +++ LVM2/lib/commands/toolcontext.h 2011/09/02 01:32:09 1.46 @@ -93,7 +93,6 @@ struct dm_list config_files; int config_valid; struct dm_config_tree *cft; - struct dm_config_tree *cft_override; struct config_info default_settings; struct config_info current_settings; --- LVM2/lib/config/config.c 2011/09/01 21:04:14 1.104 +++ LVM2/lib/config/config.c 2011/09/02 01:32:09 1.105 @@ -40,14 +40,34 @@ dm_config_destroy(cft); } +/* + * Returns config tree if it was removed. + */ +struct dm_config_tree *remove_overridden_config_tree(struct cmd_context *cmd) +{ + struct dm_config_tree *old_cft = cmd->cft; + struct dm_config_tree *cft = dm_config_remove_cascaded_tree(cmd->cft); + + if (!cft) + return NULL; + + cmd->cft = cft; + + return old_cft; +} + int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings) { - if (!(cmd->cft_override = dm_config_from_string(config_settings))) { + struct dm_config_tree *cft_new; + + if (!(cft_new = dm_config_from_string(config_settings))) { log_error("Failed to set overridden configuration entries."); return 1; } + cmd->cft = dm_config_insert_cascaded_tree(cft_new, cmd->cft); + return 0; } @@ -114,7 +134,7 @@ int read_config_file(struct dm_config_tree *cft) { - const char *filename; + const char *filename = NULL; struct device *dev = dm_config_get_custom(cft); struct stat info; int r; @@ -122,6 +142,10 @@ if (!dm_config_check_file(cft, &filename, &info)) return_0; + /* Nothing to do. E.g. empty file. */ + if (!filename) + return 1; + if (!dev) { if (!(dev = dev_create_file(filename, NULL, NULL, 1))) return_0; @@ -142,51 +166,38 @@ return r; } -// FIXME AGK Move to override_config_tree_from_string before next release -static struct dm_config_tree *_setup_context_tree(struct cmd_context *cmd) -{ - struct dm_config_tree *cft = cmd->cft_override; - - if (cft) - cft->cascade = cmd->cft; - else - cft = cmd->cft; - - return cft; -} - const struct dm_config_node *find_config_tree_node(struct cmd_context *cmd, const char *path) { - return dm_config_tree_find_node(_setup_context_tree(cmd), path); + return dm_config_tree_find_node(cmd->cft, path); } const char *find_config_tree_str(struct cmd_context *cmd, const char *path, const char *fail) { - return dm_config_tree_find_str(_setup_context_tree(cmd), path, fail); + return dm_config_tree_find_str(cmd->cft, path, fail); } int find_config_tree_int(struct cmd_context *cmd, const char *path, int fail) { - return dm_config_tree_find_int(_setup_context_tree(cmd), path, fail); + return dm_config_tree_find_int(cmd->cft, path, fail); } int64_t find_config_tree_int64(struct cmd_context *cmd, const char *path, int64_t fail) { - return dm_config_tree_find_int64(_setup_context_tree(cmd), path, fail); + return dm_config_tree_find_int64(cmd->cft, path, fail); } float find_config_tree_float(struct cmd_context *cmd, const char *path, float fail) { - return dm_config_tree_find_float(_setup_context_tree(cmd), path, fail); + return dm_config_tree_find_float(cmd->cft, path, fail); } int find_config_tree_bool(struct cmd_context *cmd, const char *path, int fail) { - return dm_config_tree_find_bool(_setup_context_tree(cmd), path, fail); + return dm_config_tree_find_bool(cmd->cft, path, fail); } /* Insert cn2 after cn1 */ --- LVM2/lib/config/config.h 2011/08/30 14:55:16 1.36 +++ LVM2/lib/config/config.h 2011/09/02 01:32:09 1.37 @@ -24,6 +24,7 @@ int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings); void destroy_config_tree(struct dm_config_tree *cft); +struct dm_config_tree *remove_overridden_config_tree(struct cmd_context *cmd); typedef uint32_t (*checksum_fn_t) (uint32_t initial, const uint8_t *buf, uint32_t size); --- LVM2/libdm/libdevmapper.h 2011/09/01 21:04:14 1.148 +++ LVM2/libdm/libdevmapper.h 2011/09/02 01:32:09 1.149 @@ -1248,6 +1248,7 @@ struct dm_config_value *v; }; +/* FIXME Move cascade to dm_config_node and remove this struct */ struct dm_config_tree { struct dm_config_node *root; struct dm_config_tree *cascade; @@ -1263,6 +1264,17 @@ void dm_config_set_custom(struct dm_config_tree *cft, void *custom); +/* + * If there's a cascaded dm_config_tree, remove the top layer + * and return the layer below. Otherwise return NULL. + */ +struct dm_config_tree *dm_config_remove_cascaded_tree(struct dm_config_tree *cft); + +/* + * When searching, first_cft is checked before second_cft. + */ +struct dm_config_tree *dm_config_insert_cascaded_tree(struct dm_config_tree *first_cft, struct dm_config_tree *second_cft); + void dm_config_destroy(struct dm_config_tree *cft); int dm_config_write(struct dm_config_tree *cft, const char *file, --- LVM2/libdm/libdm-config.c 2011/09/01 21:04:14 1.5 +++ LVM2/libdm/libdm-config.c 2011/09/02 01:32:09 1.6 @@ -159,6 +159,29 @@ dm_pool_destroy(c->mem); } +/* + * If there's a cascaded dm_config_tree, remove and return it, otherwise + * return NULL. + */ +struct dm_config_tree *dm_config_remove_cascaded_tree(struct dm_config_tree *cft) +{ + struct dm_config_tree *second_cft = cft->cascade; + + cft->cascade = NULL; + + return second_cft; +} + +/* + * When searching, first_cft is checked before second_cft. + */ +struct dm_config_tree *dm_config_insert_cascaded_tree(struct dm_config_tree *first_cft, struct dm_config_tree *second_cft) +{ + first_cft->cascade = second_cft; + + return first_cft; +} + int dm_config_parse(struct dm_config_tree *cft, const char *start, const char *end) { /* TODO? if (start == end) return 1; */ @@ -196,14 +219,16 @@ return cft; } +/* + * Doesn't populate filename if the file is empty. + */ int dm_config_check_file(struct dm_config_tree *cft, const char **filename, struct stat *info) { struct cs *c = (struct cs *) cft; struct stat _info; + if (!info) info = &_info; - if (filename) - *filename = c->filename; if (stat(c->filename, info)) { log_sys_error("stat", c->filename); @@ -218,12 +243,13 @@ } c->exists = 1; + c->timestamp = info->st_ctime; + c->st_size = info->st_size; if (info->st_size == 0) log_verbose("%s is empty", c->filename); - - c->timestamp = info->st_ctime; - c->st_size = info->st_size; + else if (filename) + *filename = c->filename; return 1; } From agk@sourceware.org Fri Sep 2 01:59:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 02 Sep 2011 01:59:00 -0000 Subject: LVM2/lib commands/toolcontext.c config/config.c Message-ID: <20110902015908.30814.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-02 01:59:08 Modified files: lib/commands : toolcontext.c lib/config : config.c Log message: temp notes on dealing with cascade Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106 --- LVM2/lib/commands/toolcontext.c 2011/09/02 01:32:09 1.133 +++ LVM2/lib/commands/toolcontext.c 2011/09/02 01:59:07 1.134 @@ -608,6 +608,7 @@ struct config_tree_list *cfl; struct dm_config_tree *cft_cmdline = NULL, *cft; +// FIXME No need for this - only one config tree now cft = dm_config_remove_cascaded_tree(cmd->cft); if (cft) { cft_cmdline = cmd->cft; @@ -1429,6 +1430,7 @@ } dev_cache_exit(); _destroy_tags(cmd); +// FIXME Use cmd->cft_cmdline instead here. cft_cmdline = _destroy_tag_configs(cmd); cmd->config_valid = 0; @@ -1441,6 +1443,7 @@ /* Temporary duplicate cft pointer holding lvm.conf - replaced later */ cft_tmp = cmd->cft; if (cft_cmdline) +// FIXME Use cmd->cft_cmdline (convert string to cft again?) and merge instead cmd->cft = dm_config_insert_cascaded_tree(cft_cmdline, cft_tmp); /* Uses cmd->cft i.e. cft_cmdline + lvm.conf */ @@ -1454,11 +1457,15 @@ if (!_init_tag_configs(cmd)) return 0; +// FIXME Will need to use a fresh copy of the lvm.conf cft as the original +// FIXME got destroyed when cft_cmdline was merged into it /* Merge all the tag config files with lvm.conf, returning a * fresh cft pointer in place of cft_tmp. */ if (!(cmd->cft = _merge_config_files(cmd, cft_tmp))) return 0; +// FIXME Merge instead - but keep a clean copy of cmd->cft at this point +// FIXME so we can easily 'remove' the effect of cft_cmdline after each cmd /* Finally we can make the proper, fully-merged, cmd->cft */ if (cft_cmdline) cmd->cft = dm_config_insert_cascaded_tree(cft_cmdline, cmd->cft); @@ -1509,6 +1516,8 @@ dm_pool_destroy(cmd->mem); dev_cache_exit(); _destroy_tags(cmd); + +// FIXME destroy_tag_configs handles this itself again if ((cft_cmdline = _destroy_tag_configs(cmd))) dm_config_destroy(cft_cmdline); if (cmd->libmem) --- LVM2/lib/config/config.c 2011/09/02 01:32:09 1.105 +++ LVM2/lib/config/config.c 2011/09/02 01:59:07 1.106 @@ -45,6 +45,7 @@ */ struct dm_config_tree *remove_overridden_config_tree(struct cmd_context *cmd) { +// FIXME Replace cmd->cft with clean copy of merged lvm*.conf tree struct dm_config_tree *old_cft = cmd->cft; struct dm_config_tree *cft = dm_config_remove_cascaded_tree(cmd->cft); @@ -56,6 +57,8 @@ return old_cft; } +// FIXME Retain a copy of the string (or tree?) in cmd->cft_cmdline +// FIXME and merge into cmd->cft int override_config_tree_from_string(struct cmd_context *cmd, const char *config_settings) { From zkabelac@sourceware.org Fri Sep 2 11:04:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 02 Sep 2011 11:04:00 -0000 Subject: LVM2/daemons/lvmetad lvmetad-core.c Message-ID: <20110902110412.30761.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-02 11:04:12 Modified files: daemons/lvmetad: lvmetad-core.c Log message: Compile fix Reflecting change in dm_config_value float r -> float f. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25 --- LVM2/daemons/lvmetad/lvmetad-core.c 2011/08/31 12:39:58 1.24 +++ LVM2/daemons/lvmetad/lvmetad-core.c 2011/09/02 11:04:12 1.25 @@ -192,7 +192,7 @@ switch (a->type) { case DM_CFG_STRING: r = strcmp(a->v.str, b->v.str); - case DM_CFG_FLOAT: r = (a->v.r == b->v.r); + case DM_CFG_FLOAT: r = (a->v.f == b->v.f); case DM_CFG_INT: r = (a->v.i == b->v.i); case DM_CFG_EMPTY_ARRAY: return 0; } From zkabelac@sourceware.org Fri Sep 2 12:38:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 02 Sep 2011 12:38:00 -0000 Subject: LVM2/lib/commands toolcontext.c Message-ID: <20110902123844.4257.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-02 12:38:44 Modified files: lib/commands : toolcontext.c Log message: Add missing 'static' for local function Avoid missing prototype warning. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135 --- LVM2/lib/commands/toolcontext.c 2011/09/02 01:59:07 1.134 +++ LVM2/lib/commands/toolcontext.c 2011/09/02 12:38:43 1.135 @@ -558,7 +558,7 @@ return 1; } -struct dm_config_tree *_merge_config_files(struct cmd_context *cmd, struct dm_config_tree *cft) +static struct dm_config_tree *_merge_config_files(struct cmd_context *cmd, struct dm_config_tree *cft) { struct config_tree_list *cfl; From zkabelac@sourceware.org Fri Sep 2 14:49:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 02 Sep 2011 14:49:00 -0000 Subject: LVM2/daemons Makefile.in Message-ID: <20110902144901.21671.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-02 14:49:00 Modified files: daemons : Makefile.in Log message: Hack for build rules of lvmetad FIXME Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/Makefile.in.diff?cvsroot=lvm2&r1=1.18&r2=1.19 --- LVM2/daemons/Makefile.in 2011/09/01 17:56:53 1.18 +++ LVM2/daemons/Makefile.in 2011/09/02 14:49:00 1.19 @@ -32,7 +32,8 @@ ifeq ("@BUILD_LVMETAD@", "yes") SUBDIRS += lvmetad -device-mapper: libdaemon.a +# FIXME: build dependency order needs rule fixing, using hack +all: libdaemon.a endif ifeq ("@BUILD_DMEVENTD@", "yes") From agk@sourceware.org Mon Sep 5 12:54:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 05 Sep 2011 12:54:00 -0000 Subject: LVM2 ./WHATS_NEW tools/lvchange.c Message-ID: <20110905125430.23508.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-05 12:54:30 Modified files: . : WHATS_NEW tools : lvchange.c Log message: Remove incorrect requirement for -j or -m from lvchange error message. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2089&r2=1.2090 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.129&r2=1.130 --- LVM2/WHATS_NEW 2011/09/01 19:22:11 1.2089 +++ LVM2/WHATS_NEW 2011/09/05 12:54:29 1.2090 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Remove incorrect requirement for -j or -m from lvchange error message. Fix unsafe table load when splitting off smaller mirror from a larger one. Use size_t return type for text_vg_export_raw() and export_vg_to_buffer(). Add configure --enable-lvmetad for building the (experimental) LVMetaD. --- LVM2/tools/lvchange.c 2011/03/29 12:51:58 1.129 +++ LVM2/tools/lvchange.c 2011/09/05 12:54:29 1.130 @@ -715,10 +715,8 @@ if (!update && !arg_count(cmd, available_ARG) && !arg_count(cmd, refresh_ARG) && - !arg_count(cmd, monitor_ARG) && !arg_count(cmd, poll_ARG) && - /* for persistent_ARG */ - !arg_count(cmd, minor_ARG) && !arg_count(cmd, major_ARG)) { - log_error("Need 1 or more of -a, -C, -j, -m, -M, -p, -r, " + !arg_count(cmd, monitor_ARG) && !arg_count(cmd, poll_ARG)) { + log_error("Need 1 or more of -a, -C, -M, -p, -r, " "--resync, --refresh, --alloc, --addtag, --deltag, " "--monitor or --poll"); return EINVALID_CMD_LINE; From agk@sourceware.org Tue Sep 6 00:26:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 06 Sep 2011 00:26:00 -0000 Subject: LVM2 lib/format1/import-extents.c lib/format_p ... Message-ID: <20110906002645.18489.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-06 00:26:44 Modified files: lib/format1 : import-extents.c lib/format_pool: import_export.c lib/format_text: import_vsn1.c lib/metadata : lv_alloc.h lv_manip.c merge.c metadata-exported.h lib/misc : lvm-string.c lib/thin : thin.c man : lvcreate.8.in tools : args.h commands.h lvcreate.c lvresize.c Log message: lvcreate parsing for thin provisioning. The rest is incomplete so this isn't usable yet. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-extents.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/import_export.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_alloc.h.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.277&r2=1.278 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.203&r2=1.204 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-string.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvcreate.8.in.diff?cvsroot=lvm2&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/args.h.diff?cvsroot=lvm2&r1=1.83&r2=1.84 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.161&r2=1.162 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.234&r2=1.235 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135 --- LVM2/lib/format1/import-extents.c 2011/03/30 12:30:39 1.40 +++ LVM2/lib/format1/import-extents.c 2011/09/06 00:26:42 1.41 @@ -223,7 +223,7 @@ len = _area_length(lvm, le); if (!(seg = alloc_lv_segment(cmd->mem, segtype, lvm->lv, le, - len, 0, 0, NULL, 1, len, 0, 0, 0, NULL))) { + len, 0, 0, NULL, NULL, 1, len, 0, 0, 0, NULL))) { log_error("Failed to allocate linear segment."); return 0; } @@ -295,7 +295,7 @@ if (!(seg = alloc_lv_segment(cmd->mem, segtype, lvm->lv, lvm->stripes * first_area_le, lvm->stripes * area_len, - 0, lvm->stripe_size, NULL, + 0, lvm->stripe_size, NULL, NULL, lvm->stripes, area_len, 0, 0, 0, NULL))) { log_error("Failed to allocate striped segment."); --- LVM2/lib/format_pool/import_export.c 2010/12/01 13:05:07 1.33 +++ LVM2/lib/format_pool/import_export.c 2011/09/06 00:26:42 1.34 @@ -195,7 +195,7 @@ if (!(seg = alloc_lv_segment(mem, segtype, lv, *le_cur, area_len * usp->num_devs, 0, - usp->striping, NULL, usp->num_devs, + usp->striping, NULL, NULL, usp->num_devs, area_len, 0, 0, 0, NULL))) { log_error("Unable to allocate striped lv_segment structure"); return 0; @@ -235,7 +235,7 @@ if (!(seg = alloc_lv_segment(mem, segtype, lv, *le_cur, area_len, 0, usp->striping, - NULL, 1, area_len, + NULL, NULL, 1, area_len, POOL_PE_SIZE, 0, 0, NULL))) { log_error("Unable to allocate linear lv_segment " "structure"); --- LVM2/lib/format_text/import_vsn1.c 2011/08/31 15:19:19 1.92 +++ LVM2/lib/format_text/import_vsn1.c 2011/09/06 00:26:43 1.93 @@ -329,7 +329,7 @@ return_0; if (!(seg = alloc_lv_segment(mem, segtype, lv, start_extent, - extent_count, 0, 0, NULL, area_count, + extent_count, 0, 0, NULL, NULL, area_count, extent_count, 0, 0, 0, NULL))) { log_error("Segment allocation failed"); return 0; --- LVM2/lib/metadata/lv_alloc.h 2011/07/19 16:37:42 1.29 +++ LVM2/lib/metadata/lv_alloc.h 2011/09/06 00:26:43 1.30 @@ -22,6 +22,7 @@ uint64_t status, uint32_t stripe_size, struct logical_volume *log_lv, + struct logical_volume *thin_pool_lv, uint32_t area_count, uint32_t area_len, uint32_t chunk_size, @@ -72,7 +73,9 @@ int lv_add_log_segment(struct alloc_handle *ah, uint32_t first_area, struct logical_volume *log_lv, uint64_t status); int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status, - uint32_t extents, const struct segment_type *segtype); + uint32_t extents, + const struct segment_type *segtype, + const char *thin_pool_name); void alloc_destroy(struct alloc_handle *ah); --- LVM2/lib/metadata/lv_manip.c 2011/08/30 14:55:17 1.277 +++ LVM2/lib/metadata/lv_manip.c 2011/09/06 00:26:43 1.278 @@ -198,6 +198,22 @@ return i; } +static int _attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata) +{ + // FIXME Housekeeping needed here (cf attach_mirror_log) + seg->metadata_lv = thin_pool_metadata; + + return 1; +} + +static int _attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv) +{ + // FIXME Housekeeping needed here (cf attach_mirror_log) + seg->thin_pool_lv = thin_pool_lv; + + return 1; +} + /* * All lv_segments get created here. */ @@ -208,6 +224,7 @@ uint64_t status, uint32_t stripe_size, struct logical_volume *log_lv, + struct logical_volume *thin_pool_lv, uint32_t area_count, uint32_t area_len, uint32_t chunk_size, @@ -248,13 +265,20 @@ seg->chunk_size = chunk_size; seg->region_size = region_size; seg->extents_copied = extents_copied; - seg->log_lv = log_lv; seg->pvmove_source_seg = pvmove_source_seg; dm_list_init(&seg->tags); - if (log_lv && !attach_mirror_log(seg, log_lv)) + if (thin_pool_lv && !_attach_pool_lv(seg, thin_pool_lv)) return_NULL; + if (log_lv) { + if (thin_pool_lv) { + if (!_attach_pool_metadata(seg, log_lv)) + return_NULL; + } else if (!attach_mirror_log(seg, log_lv)) + return_NULL; + } + return seg; } @@ -272,7 +296,7 @@ if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv, old_le_count, lv->le_count - old_le_count, status, 0, - NULL, 0, lv->le_count - old_le_count, + NULL, NULL, 0, lv->le_count - old_le_count, 0, 0, 0, NULL))) { log_error("Couldn't allocate new snapshot segment."); return NULL; @@ -559,9 +583,7 @@ /* FIXME: Should we bug if we find a log_lv attached? */ - if (!lv_add_virtual_segment(lv, 0, len, - get_segtype_from_string(lv->vg->cmd, - "error"))) + if (!lv_add_virtual_segment(lv, 0, len, get_segtype_from_string(lv->vg->cmd, "error"), NULL)) return_0; return 1; @@ -917,7 +939,7 @@ if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv, lv->le_count, aa[0].len * area_multiple, - status, stripe_size, NULL, + status, stripe_size, NULL, NULL, area_count, aa[0].len, 0u, region_size, 0u, NULL))) { log_error("Couldn't allocate new LV segment."); @@ -1987,13 +2009,25 @@ } int lv_add_virtual_segment(struct logical_volume *lv, uint64_t status, - uint32_t extents, const struct segment_type *segtype) + uint32_t extents, const struct segment_type *segtype, + const char *thin_pool_name) { struct lv_segment *seg; + struct logical_volume *thin_pool_lv = NULL; + struct lv_list *lvl; + + if (thin_pool_name) { + if (!(lvl = find_lv_in_vg(lv->vg, thin_pool_name))) { + log_error("Unable to find existing pool LV %s in VG %s.", + thin_pool_name, lv->vg->name); + return 0; + } + thin_pool_lv = lvl->lv; + } if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, segtype, lv, lv->le_count, extents, status, 0, - NULL, 0, extents, 0, 0, 0, NULL))) { + NULL, thin_pool_lv, 0, extents, 0, 0, 0, NULL))) { log_error("Couldn't allocate new zero segment."); return 0; } @@ -2129,7 +2163,7 @@ get_segtype_from_string(seg->lv->vg->cmd, "mirror"), seg->lv, seg->le, seg->len, seg->status, seg->stripe_size, - log_lv, + log_lv, NULL, seg->area_count, seg->area_len, seg->chunk_size, region_size, seg->extents_copied, NULL))) { @@ -2316,14 +2350,18 @@ lv->status |= MIRRORED; status = MIRROR_IMAGE; layer_name = "mimage"; - } else + } else if (segtype_is_thin_pool(segtype)) { + // lv->status |= THIN_POOL; + // status = THIN_IMAGE; + layer_name = "tdata"; + } return_0; /* * First, create our top-level segment for our top-level LV */ if (!(mapseg = alloc_lv_segment(lv->vg->cmd->mem, segtype, - lv, 0, 0, lv->status, stripe_size, NULL, + lv, 0, 0, lv->status, stripe_size, NULL, NULL, devices, 0, 0, region_size, 0, NULL))) { log_error("Failed to create mapping segment for %s", lv->name); return 0; @@ -2363,6 +2401,8 @@ } dm_list_add(&lv->segments, &mapseg->list); +// FIXME If thin pool, create one "log_lv" as tmeta here lv->metadata_lv + return 1; } @@ -2481,7 +2521,7 @@ const struct segment_type *segtype, uint32_t stripes, uint32_t stripe_size, uint32_t mirrors, uint32_t region_size, - uint32_t extents, + uint32_t extents, const char *thin_pool_name, struct dm_list *allocatable_pvs, alloc_policy_t alloc) { int r = 1; @@ -2492,17 +2532,19 @@ log_very_verbose("Extending segment type, %s", segtype->name); if (segtype_is_virtual(segtype)) - return lv_add_virtual_segment(lv, 0u, extents, segtype); + return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name); if (segtype_is_raid(segtype) && !lv->le_count) raid_logs = mirrors * stripes; +// For thin pool, ensure space for "log_lv" ->metadata_lv is allocated simultaneously here + if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors, raid_logs, region_size, extents, allocatable_pvs, alloc, NULL))) return_0; - if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype)) + if (!segtype_is_mirrored(segtype) && !segtype_is_raid(segtype) && !segtype_is_thin_pool(segtype)) r = lv_add_segment(ah, 0, ah->area_count, lv, segtype, stripe_size, 0u, 0); else { @@ -2524,6 +2566,7 @@ return 0; } +// For thin_pool, populate tmeta here too r = _lv_extend_layered_lv(ah, lv, extents, 0, stripes, stripe_size); } @@ -3372,7 +3415,7 @@ /* Replace the empty layer with error segment */ segtype = get_segtype_from_string(lv->vg->cmd, "error"); - if (!lv_add_virtual_segment(layer_lv, 0, parent->le_count, segtype)) + if (!lv_add_virtual_segment(layer_lv, 0, parent->le_count, segtype, NULL)) return_0; return 1; @@ -3425,7 +3468,7 @@ segtype = get_segtype_from_string(cmd, "error"); - if (!lv_add_virtual_segment(layer_lv, 0, lv_where->le_count, segtype)) { + if (!lv_add_virtual_segment(layer_lv, 0, lv_where->le_count, segtype, NULL)) { log_error("Creation of transient LV %s for mirror conversion in VG %s failed.", name, lv_where->vg->name); return NULL; } @@ -3466,7 +3509,7 @@ /* allocate a new linear segment */ if (!(mapseg = alloc_lv_segment(cmd->mem, segtype, lv_where, 0, layer_lv->le_count, - status, 0, NULL, 1, layer_lv->le_count, + status, 0, NULL, NULL, 1, layer_lv->le_count, 0, 0, 0, NULL))) return_NULL; @@ -3510,7 +3553,7 @@ if (!(mapseg = alloc_lv_segment(layer_lv->vg->cmd->mem, segtype, layer_lv, layer_lv->le_count, seg->area_len, status, 0, - NULL, 1, seg->area_len, 0, 0, 0, seg))) + NULL, NULL, 1, seg->area_len, 0, 0, 0, seg))) return_0; /* map the new segment to the original underlying are */ @@ -3737,7 +3780,6 @@ return 1; } - static struct logical_volume *_create_virtual_origin(struct cmd_context *cmd, struct volume_group *vg, const char *lv_name, @@ -3766,7 +3808,7 @@ return_NULL; if (!lv_extend(lv, segtype, 1, 0, 1, 0, voriginextents, - NULL, ALLOC_INHERIT)) + NULL, NULL, ALLOC_INHERIT)) return_NULL; /* store vg on disk(s) */ @@ -3778,8 +3820,14 @@ return lv; } -int lv_create_single(struct volume_group *vg, - struct lvcreate_params *lp) +/* Thin notes: + * If lp->thin OR lp->activate is AY*, activate the pool if not already active. + * If lp->thin, create thin LV within the pool - as a snapshot if lp->snapshot. + * If lp->activate is AY*, activate it. + * If lp->activate was AN* and the pool was originally inactive, deactivate it. + */ +static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct lvcreate_params *lp, + const char *new_lv_name) { struct cmd_context *cmd = vg->cmd; uint32_t size_rest; @@ -3788,24 +3836,24 @@ int origin_active = 0; struct lvinfo info; - if (lp->lv_name && find_lv_in_vg(vg, lp->lv_name)) { + if (new_lv_name && find_lv_in_vg(vg, new_lv_name)) { log_error("Logical volume \"%s\" already exists in " - "volume group \"%s\"", lp->lv_name, lp->vg_name); - return 0; + "volume group \"%s\"", new_lv_name, lp->vg_name); + return NULL; } if (vg_max_lv_reached(vg)) { log_error("Maximum number of logical volumes (%u) reached " "in volume group %s", vg->max_lv, vg->name); - return 0; + return NULL; } if ((segtype_is_mirrored(lp->segtype) || - segtype_is_raid(lp->segtype)) && + segtype_is_raid(lp->segtype) || segtype_is_thin(lp->segtype)) && !(vg->fid->fmt->features & FMT_SEGMENTS)) { - log_error("Metadata does not support %s.", - segtype_is_raid(lp->segtype) ? "RAID" : "mirroring"); - return 0; + log_error("Metadata does not support %s segments.", + lp->segtype->name); + return NULL; } if (lp->read_ahead != DM_READ_AHEAD_AUTO && @@ -3813,7 +3861,7 @@ (vg->fid->fmt->features & FMT_RESTRICTED_READAHEAD) && (lp->read_ahead < 2 || lp->read_ahead > 120)) { log_error("Metadata only supports readahead values between 2 and 120."); - return 0; + return NULL; } if (lp->stripe_size > vg->extent_size) { @@ -3830,7 +3878,7 @@ (lp->stripe_size > STRIPE_SIZE_MAX)) { log_error("Stripe size may not exceed %s", display_size(cmd, (uint64_t) STRIPE_SIZE_MAX)); - return 0; + return NULL; } if ((size_rest = lp->extents % lp->stripes)) { @@ -3840,19 +3888,20 @@ lp->extents = lp->extents - size_rest + lp->stripes; } - if (lp->zero && !activation()) { + if (lp->zero && !segtype_is_thin(lp->segtype) && !activation()) { log_error("Can't wipe start of new LV without using " "device-mapper kernel driver"); - return 0; + return NULL; } status |= lp->permission | VISIBLE_LV; + /* FIXME Thin snapshots are different */ if (lp->snapshot) { if (!activation()) { log_error("Can't create snapshot without using " "device-mapper kernel driver"); - return 0; + return NULL; } /* Must zero cow */ @@ -3865,27 +3914,27 @@ if (!(org = find_lv(vg, lp->origin))) { log_error("Couldn't find origin volume '%s'.", lp->origin); - return 0; + return NULL; } if (lv_is_virtual_origin(org)) { log_error("Can't share virtual origins. " "Use --virtualsize."); - return 0; + return NULL; } if (lv_is_cow(org)) { log_error("Snapshots of snapshots are not " "supported yet."); - return 0; + return NULL; } if (org->status & LOCKED) { log_error("Snapshots of locked devices are not " "supported yet"); - return 0; + return NULL; } if (lv_is_merging_origin(org)) { log_error("Snapshots of an origin that has a " "merging snapshot is not supported"); - return 0; + return NULL; } if ((org->status & MIRROR_IMAGE) || (org->status & MIRROR_LOG)) { @@ -3893,13 +3942,13 @@ "are not supported", (org->status & MIRROR_LOG) ? "log" : "image"); - return 0; + return NULL; } if (!lv_info(cmd, org, 0, &info, 0, 0)) { log_error("Check for existence of snapshot " "origin '%s' failed.", org->name); - return 0; + return NULL; } origin_active = info.exists; @@ -3907,19 +3956,19 @@ !lv_is_active_exclusive_locally(org)) { log_error("%s must be active exclusively to" " create snapshot", org->name); - return 0; + return NULL; } } } - if (!lp->extents) { + if (!lp->thin && !lp->extents) { log_error("Unable to create new logical volume with no extents"); - return 0; + return NULL; } if (lp->snapshot && (lp->extents * vg->extent_size < 2 * lp->chunk_size)) { log_error("Unable to create a snapshot smaller than 2 chunks."); - return 0; + return NULL; } if (!seg_is_virtual(lp) && @@ -3927,38 +3976,38 @@ log_error("Volume group \"%s\" has insufficient free space " "(%u extents): %u required.", vg->name, vg->free_count, lp->extents); - return 0; + return NULL; } if (lp->stripes > dm_list_size(lp->pvh) && lp->alloc != ALLOC_ANYWHERE) { log_error("Number of stripes (%u) must not exceed " "number of physical volumes (%d)", lp->stripes, dm_list_size(lp->pvh)); - return 0; + return NULL; } if ((segtype_is_mirrored(lp->segtype) || - segtype_is_raid(lp->segtype)) && !activation()) { + segtype_is_raid(lp->segtype) || seg_is_thin_volume(lp)) && !activation()) { log_error("Can't create %s without using " "device-mapper kernel driver.", segtype_is_raid(lp->segtype) ? lp->segtype->name : "mirror"); - return 0; + return NULL; } /* The snapshot segment gets created later */ if (lp->snapshot && !(lp->segtype = get_segtype_from_string(cmd, "striped"))) - return_0; + return_NULL; if (!archive(vg)) - return 0; + return_NULL; if (!dm_list_empty(&lp->tags)) { if (!(vg->fid->fmt->features & FMT_TAGS)) { log_error("Volume group %s does not support tags", vg->name); - return 0; + return NULL; } } @@ -3973,16 +4022,16 @@ } } - if (!(lv = lv_create_empty(lp->lv_name ? lp->lv_name : "lvol%d", NULL, + if (!(lv = lv_create_empty(new_lv_name ? : "lvol%d", NULL, status, lp->alloc, vg))) - return_0; + return_NULL; if (lp->read_ahead != lv->read_ahead) { log_verbose("Setting read ahead sectors"); lv->read_ahead = lp->read_ahead; } - if (lp->minor >= 0) { + if (!seg_is_thin_pool(lp) && lp->minor >= 0) { lv->major = lp->major; lv->minor = lp->minor; lv->status |= FIXED_MINOR; @@ -4000,8 +4049,12 @@ if (!lv_extend(lv, lp->segtype, lp->stripes, lp->stripe_size, lp->mirrors, lp->region_size, - lp->extents, lp->pvh, lp->alloc)) - return_0; + seg_is_thin_volume(lp) ? lp->voriginextents : lp->extents, + seg_is_thin_volume(lp) ? lp->pool : NULL, lp->pvh, lp->alloc)) + return_NULL; + + if (seg_is_thin_pool(lp) && lp->zero) + first_seg(lv)->zero_new_blocks = 1; if (lp->log_count && !seg_is_raid(first_seg(lv)) && seg_is_mirrored(first_seg(lv))) { @@ -4015,7 +4068,7 @@ /* store vg on disk(s) */ if (!vg_write(vg) || !vg_commit(vg)) - return_0; + return_NULL; backup(vg); @@ -4038,12 +4091,12 @@ log_error("Failed to activate new LV."); if (lp->zero) goto deactivate_and_revert_new_lv; - return 0; + return NULL; } - if (!lp->zero && !lp->snapshot) + if (!seg_is_thin(lp) && !lp->zero && !lp->snapshot) log_warn("WARNING: \"%s\" not zeroed", lv->name); - else if (!set_lv(cmd, lv, UINT64_C(0), 0)) { + else if (!seg_is_thin(lp) && !set_lv(cmd, lv, UINT64_C(0), 0)) { log_error("Aborting. Failed to wipe %s.", lp->snapshot ? "snapshot exception store" : "start of new LV"); @@ -4059,7 +4112,7 @@ if (!origin_active && !deactivate_lv(cmd, lv)) { log_error("Aborting. Couldn't deactivate snapshot " "COW area. Manual intervention required."); - return 0; + return NULL; } /* A virtual origin must be activated explicitly. */ @@ -4085,40 +4138,33 @@ /* store vg on disk(s) */ if (!vg_write(vg)) - return_0; + return_NULL; if (!suspend_lv(cmd, org)) { log_error("Failed to suspend origin %s", org->name); vg_revert(vg); - return 0; + return NULL; } if (!vg_commit(vg)) - return_0; + return_NULL; if (!resume_lv(cmd, org)) { log_error("Problem reactivating origin %s", org->name); - return 0; + return NULL; } } /* FIXME out of sequence */ backup(vg); out: - log_print("Logical volume \"%s\" created", lv->name); - - /* - * FIXME: as a sanity check we could try reading the - * last block of the device ? - */ - - return 1; + return lv; deactivate_and_revert_new_lv: if (!deactivate_lv(cmd, lv)) { log_error("Unable to deactivate failed new LV. " "Manual intervention required."); - return 0; + return NULL; } revert_new_lv: @@ -4129,6 +4175,37 @@ else backup(vg); - return 0; + return NULL; } +int lv_create_single(struct volume_group *vg, + struct lvcreate_params *lp) +{ + struct logical_volume *lv; + + /* Create thin pool first if necessary */ + if (lp->create_thin_pool) { + if (!seg_is_thin_pool(lp) && + !(lp->segtype = get_segtype_from_string(vg->cmd, "thin_pool"))) + return_0; + + if (!(lv = _lv_create_an_lv(vg, lp, lp->pool))) + return_0; + + if (!lp->thin) + goto out; + + lp->pool = lv->name; + + if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin"))) + return_0; + } + + if (!(lv = _lv_create_an_lv(vg, lp, lp->lv_name))) + return_0; + +out: + log_print("Logical volume \"%s\" created", lv->name); + + return 1; +} --- LVM2/lib/metadata/merge.c 2011/08/02 22:07:22 1.45 +++ LVM2/lib/metadata/merge.c 2011/09/06 00:26:43 1.46 @@ -313,7 +313,7 @@ if (!(split_seg = alloc_lv_segment(lv->vg->vgmem, seg->segtype, seg->lv, seg->le, seg->len, seg->status, seg->stripe_size, - seg->log_lv, + seg->log_lv, seg->thin_pool_lv, seg->area_count, seg->area_len, seg->chunk_size, seg->region_size, seg->extents_copied, seg->pvmove_source_seg))) { --- LVM2/lib/metadata/metadata-exported.h 2011/08/26 17:40:53 1.203 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/06 00:26:43 1.204 @@ -513,7 +513,7 @@ const struct segment_type *segtype, uint32_t stripes, uint32_t stripe_size, uint32_t mirrors, uint32_t region_size, - uint32_t extents, + uint32_t extents, const char *thin_pool_name, struct dm_list *allocatable_pvs, alloc_policy_t alloc); /* lv must be part of lv->vg->lvs */ @@ -556,8 +556,8 @@ int activation_monitoring; /* all */ activation_change_t activate; /* non-snapshot, non-mirror */ - char *origin; /* snap */ - char *pool; /* thin */ + const char *origin; /* snap */ + const char *pool; /* thin */ const char *vg_name; /* all */ const char *lv_name; /* all */ --- LVM2/lib/misc/lvm-string.c 2011/08/30 14:55:18 1.29 +++ LVM2/lib/misc/lvm-string.c 2011/09/06 00:26:43 1.30 @@ -137,6 +137,18 @@ return 0; } + if (strstr(name, "_tdata")) { + log_error("Names including \"_tpool\" are reserved. " + "Please choose a different LV name."); + return 0; + } + + if (strstr(name, "_tmeta")) { + log_error("Names including \"_tpool\" are reserved. " + "Please choose a different LV name."); + return 0; + } + return 1; } --- LVM2/lib/thin/thin.c 2011/09/01 10:16:32 1.7 +++ LVM2/lib/thin/thin.c 2011/09/06 00:26:43 1.8 @@ -201,7 +201,8 @@ uint32_t flags; } reg_segtypes[] = { { &_thin_pool_ops, "thin_pool", SEG_THIN_POOL }, - { &_thin_ops, "thin", SEG_THIN_VOLUME } + /* FIXME Maybe use SEG_THIN_VOLUME instead of SEG_VIRTUAL */ + { &_thin_ops, "thin", SEG_THIN_VOLUME | SEG_VIRTUAL } }; struct segment_type *segtype; --- LVM2/man/lvcreate.8.in 2011/08/17 15:15:37 1.21 +++ LVM2/man/lvcreate.8.in 2011/09/06 00:26:43 1.22 @@ -32,11 +32,13 @@ [\-\-noudevsync] [\-\-ignoremonitoring] [\-\-monitor {y|n}] -\-n|\-\-name SnapshotLogicalVolumeName +[--thinpool ThinPoolLogicalVolumeName] +[\-n|\-\-name SnapshotLogicalVolumeName] {{\-s|\-\-snapshot} OriginalLogicalVolumePath | [\-s|\-\-snapshot] -VolumeGroupName \-V|\-\-virtualsize VirtualSize} +VolumeGroupName \-V|\-\-virtualsize VirtualSize | +-T VolumeGroupName[/ThinPoolLogicalVolumeName] \-V|\-\-virtualsize VirtualSize} .SH DESCRIPTION lvcreate creates a new logical volume in a volume group ( see .B vgcreate(8), vgchange(8) --- LVM2/tools/args.h 2011/08/18 19:38:27 1.83 +++ LVM2/tools/args.h 2011/09/06 00:26:43 1.84 @@ -71,6 +71,7 @@ arg(poll_ARG, '\0', "poll", yes_no_arg, 0) arg(stripes_long_ARG, '\0', "stripes", int_arg, 0) arg(sysinit_ARG, '\0', "sysinit", NULL, 0) +arg(thinpool_ARG, '\0', "thinpool", string_arg, 0) /* Allow some variations */ arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0) @@ -133,6 +134,7 @@ arg(stdin_ARG, 's', "stdin", NULL, 0) arg(snapshot_ARG, 's', "snapshot", NULL, 0) arg(short_ARG, 's', "short", NULL, 0) +arg(thin_ARG, 'T', "thin", NULL, 0) arg(test_ARG, 't', "test", NULL, 0) arg(uuid_ARG, 'u', "uuid", NULL, 0) arg(uuidstr_ARG, 'u', "uuid", string_arg, 0) --- LVM2/tools/commands.h 2011/08/18 19:38:27 1.161 +++ LVM2/tools/commands.h 2011/09/06 00:26:43 1.162 @@ -177,6 +177,8 @@ "lvcreate \n" "\t{ {-s|--snapshot} OriginalLogicalVolume[Path] |\n" "\t [-s|--snapshot] VolumeGroupName[Path] -V|--virtualsize VirtualSize}\n" + "\t {-T|--thin} VolumeGroupName[Path][/PoolLogicalVolume] \n" + "\t -V|--virtualsize VirtualSize}\n" "\t[-c|--chunksize]\n" "\t[-A|--autobackup {y|n}]\n" "\t[--addtag Tag]\n" @@ -195,6 +197,7 @@ "\t[-p|--permission {r|rw}]\n" "\t[-r|--readahead ReadAheadSectors|auto|none]\n" "\t[-t|--test]\n" + "\t[--thinpool] PoolLogicalVolume\n" "\t[-v|--verbose]\n" "\t[--version]\n" @@ -205,7 +208,8 @@ minor_ARG, mirrorlog_ARG, mirrors_ARG, monitor_ARG, name_ARG, nosync_ARG, noudevsync_ARG, permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG, size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG, - test_ARG, type_ARG, virtualoriginsize_ARG, virtualsize_ARG, zero_ARG) + test_ARG, thin_ARG, thinpool_ARG, type_ARG, virtualoriginsize_ARG, + virtualsize_ARG, zero_ARG) xx(lvdisplay, "Display information about a logical volume", --- LVM2/tools/lvcreate.c 2011/08/12 02:16:46 1.234 +++ LVM2/tools/lvcreate.c 2011/09/06 00:26:43 1.235 @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -25,6 +25,24 @@ int pv_count; }; +static int _set_vg_name(struct lvcreate_params *lp, const char *vg_name) +{ + /* Can't do anything */ + if (!vg_name) + return 1; + + /* If VG name already known, ensure this 2nd copy is identical */ + if (lp->vg_name && strcmp(lp->vg_name, vg_name)) { + log_error("Inconsistent volume group names " + "given: \"%s\" and \"%s\"", + lp->vg_name, vg_name); + return 0; + } + lp->vg_name = vg_name; + + return 1; +} + static int _lvcreate_name_params(struct lvcreate_params *lp, struct cmd_context *cmd, int *pargc, char ***pargv) @@ -33,38 +51,88 @@ char **argv = *pargv, *ptr; const char *vg_name; + lp->pool = arg_str_value(cmd, thinpool_ARG, NULL); + + /* If --thinpool contains VG name, extract it. */ + if (lp->pool && strchr(lp->pool, '/')) { + if (!(lp->vg_name = extract_vgname(cmd, lp->pool))) + return 0; + /* Strip VG from pool */ + if ((ptr = strrchr(lp->pool, (int) '/'))) + lp->pool = ptr + 1; + } + lp->lv_name = arg_str_value(cmd, name_ARG, NULL); + /* If --name contains VG name, extract it. */ + if (lp->lv_name && strchr(lp->lv_name, '/')) { + if (!_set_vg_name(lp, extract_vgname(cmd, lp->lv_name))) + return_0; + + /* Strip VG from lv_name */ + if ((ptr = strrchr(lp->lv_name, (int) '/'))) + lp->lv_name = ptr + 1; + } + + /* Need an origin? */ if (lp->snapshot && !arg_count(cmd, virtualsize_ARG)) { + /* argv[0] might be origin or vg/origin */ if (!argc) { log_error("Please specify a logical volume to act as " "the snapshot origin."); return 0; } - lp->origin = argv[0]; - (*pargv)++, (*pargc)--; - if (!(lp->vg_name = extract_vgname(cmd, lp->origin))) { + lp->origin = skip_dev_dir(cmd, argv[0], NULL); + if (strrchr(lp->origin, '/')) { + if (!_set_vg_name(lp, extract_vgname(cmd, lp->origin))) + return_0; + + /* Strip the volume group from the origin */ + if ((ptr = strrchr(lp->origin, (int) '/'))) + lp->origin = ptr + 1; + } + + if (!lp->vg_name) { log_error("The origin name should include the " "volume group."); return 0; } - /* Strip the volume group from the origin */ - if ((ptr = strrchr(lp->origin, (int) '/'))) - lp->origin = ptr + 1; + (*pargv)++, (*pargc)--; + } else if (seg_is_thin(lp) && !lp->pool && argc) { + /* argv[0] might be vg or vg/Pool */ + + vg_name = skip_dev_dir(cmd, argv[0], NULL); + if (!strrchr(vg_name, '/')) { + if (!_set_vg_name(lp, vg_name)) + return_0; + } else { + lp->pool = vg_name; + if (!_set_vg_name(lp, extract_vgname(cmd, lp->pool))) + return_0; + + if (!lp->vg_name) { + log_error("The pool name should include the " + "volume group."); + return 0; + } + + /* Strip the volume group */ + if ((ptr = strrchr(lp->pool, (int) '/'))) + lp->pool = ptr + 1; + } + (*pargv)++, (*pargc)--; } else { /* - * If VG not on command line, try -n arg and then - * environment. + * If VG not on command line, try environment default. */ if (!argc) { - if (!(lp->vg_name = extract_vgname(cmd, lp->lv_name))) { + if (!lp->vg_name && !(lp->vg_name = extract_vgname(cmd, NULL))) { log_error("Please provide a volume group name"); return 0; } - } else { vg_name = skip_dev_dir(cmd, argv[0], NULL); if (strrchr(vg_name, '/')) { @@ -73,25 +141,9 @@ return 0; } - /* - * Ensure lv_name doesn't contain a - * different VG. - */ - if (lp->lv_name && strchr(lp->lv_name, '/')) { - if (!(lp->vg_name = - extract_vgname(cmd, lp->lv_name))) - return 0; - - if (strcmp(lp->vg_name, vg_name)) { - log_error("Inconsistent volume group " - "names " - "given: \"%s\" and \"%s\"", - lp->vg_name, vg_name); - return 0; - } - } + if (!_set_vg_name(lp, vg_name)) + return_0; - lp->vg_name = vg_name; (*pargv)++, (*pargc)--; } } @@ -103,9 +155,6 @@ } if (lp->lv_name) { - if ((ptr = strrchr(lp->lv_name, '/'))) - lp->lv_name = ptr + 1; - if (!apply_lvname_restrictions(lp->lv_name)) return_0; @@ -116,6 +165,54 @@ } } + if (lp->pool) { + if (!apply_lvname_restrictions(lp->pool)) + return_0; + + if (!validate_name(lp->pool)) { + log_error("Logical volume name \"%s\" is invalid", + lp->pool); + return 0; + } + + if (lp->lv_name && !strcmp(lp->lv_name, lp->pool)) { + log_error("Logical volume name %s and pool name %s must be different.", + lp->lv_name, lp->pool); + return 0; + } + } + + return 1; +} + +/* + * Normal snapshot or thinly-provisioned snapshot? + */ +static int _determine_snapshot_type(struct volume_group *vg, + struct lvcreate_params *lp) +{ + struct lv_list *lvl; + struct lv_segment *seg; + + if (!(lvl = find_lv_in_vg(vg, lp->origin))) { + log_error("Snapshot origin LV %s not found in Volume group %s.", lp->origin, vg->name); + return 0; + } + + /* FIXME Replace with lv_is_thin_volume() once more flags are added */ + if (seg_is_thin_volume(seg = first_seg(lvl->lv))) { + lp->thin = 1; + if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin"))) + return_0; + + lp->pool = seg->thin_pool_lv->name; + } + + if (!lp->thin && !arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) { + log_error("Please specify either size or extents with snapshots."); + return 0; + } + return 1; } @@ -195,11 +292,16 @@ struct lvcreate_cmdline_params *lcp, struct cmd_context *cmd) { - if (arg_count(cmd, extents_ARG) + arg_count(cmd, size_ARG) != 1) { + if (arg_count(cmd, extents_ARG) && arg_count(cmd, size_ARG)) { log_error("Please specify either size or extents (not both)"); return 0; } + if (!lp->thin && !lp->snapshot && !arg_count(cmd, extents_ARG) && !arg_count(cmd, size_ARG)) { + log_error("Please specify either size or extents"); + return 0; + } + if (arg_count(cmd, extents_ARG)) { if (arg_sign_value(cmd, extents_ARG, 0) == SIGN_MINUS) { log_error("Negative number of extents is invalid"); @@ -219,8 +321,16 @@ lcp->percent = PERCENT_NONE; } + /* If size/extents given with thin, then we are creating a thin pool */ + if (lp->thin && (arg_count(cmd, size_ARG) || arg_count(cmd, extents_ARG))) + lp->create_thin_pool = 1; + /* Size returned in kilobyte units; held in sectors */ if (arg_count(cmd, virtualsize_ARG)) { + if (seg_is_thin_pool(lp)) { + log_error("Virtual size in incompatible with thin_pool segment type."); + return 0; + } if (arg_sign_value(cmd, virtualsize_ARG, 0) == SIGN_MINUS) { log_error("Negative virtual origin size is invalid"); return 0; @@ -231,6 +341,12 @@ log_error("Virtual origin size may not be zero"); return 0; } + } else { + /* No virtual size given, so no thin LV to create. */ + if (!seg_is_thin_pool(lp) && !(lp->segtype = get_segtype_from_string(cmd, "thin_pool"))) + return_0; + + lp->thin = 0; } return 1; @@ -357,7 +473,87 @@ * that by checking and warning if they aren't set. */ if (!lp->region_size) { - log_error("Programmer error: lp->region_size not set."); + log_error(INTERNAL_ERROR "region_size not set."); + return 0; + } + + return 1; +} + +static int _read_activation_params(struct lvcreate_params *lp, struct cmd_context *cmd) +{ + unsigned pagesize; + + lp->activate = arg_uint_value(cmd, available_ARG, CHANGE_AY); + + if (lp->activate == CHANGE_AN || lp->activate == CHANGE_ALN) { + if (lp->zero && !seg_is_thin(lp)) { + log_error("--available n requires --zero n"); + return 0; + } + } + + /* + * Read ahead. + */ + lp->read_ahead = arg_uint_value(cmd, readahead_ARG, + cmd->default_settings.read_ahead); + pagesize = lvm_getpagesize() >> SECTOR_SHIFT; + if (lp->read_ahead != DM_READ_AHEAD_AUTO && + lp->read_ahead != DM_READ_AHEAD_NONE && + lp->read_ahead % pagesize) { + if (lp->read_ahead < pagesize) + lp->read_ahead = pagesize; + else + lp->read_ahead = (lp->read_ahead / pagesize) * pagesize; + log_warn("WARNING: Overriding readahead to %u sectors, a multiple " + "of %uK page size.", lp->read_ahead, pagesize >> 1); + } + + /* + * Permissions. + */ + lp->permission = arg_uint_value(cmd, permission_ARG, + LVM_READ | LVM_WRITE); + + if (lp->thin && !(lp->permission & LVM_WRITE)) { + log_error("Read-only thin volumes are not currently supported."); + return 0; + } + + /* Must not zero read only volume */ + if (!(lp->permission & LVM_WRITE)) + lp->zero = 0; + + lp->minor = arg_int_value(cmd, minor_ARG, -1); + lp->major = arg_int_value(cmd, major_ARG, -1); + + /* Persistent minor */ + if (arg_count(cmd, persistent_ARG)) { + if (lp->create_thin_pool && !lp->thin) { + log_error("--persistent is not permitted when creating a thin pool device."); + return 0; + } + if (!strcmp(arg_str_value(cmd, persistent_ARG, "n"), "y")) { + if (lp->minor == -1) { + log_error("Please specify minor number with " + "--minor when using -My"); + return 0; + } + if (lp->major == -1) { + log_error("Please specify major number with " + "--major when using -My"); + return 0; + } + } else { + if ((lp->minor != -1) || (lp->major != -1)) { + log_error("--major and --minor incompatible " + "with -Mn"); + return 0; + } + } + } else if (arg_count(cmd, minor_ARG) || arg_count(cmd, major_ARG)) { + log_error("--major and --minor require -My"); return 0; } @@ -370,7 +566,6 @@ int argc, char **argv) { int contiguous; - unsigned pagesize; struct arg_value_group_list *current_group; const char *segtype_str; const char *tag; @@ -382,16 +577,36 @@ /* * Check selected options are compatible and determine segtype */ - segtype_str = "striped"; + if (arg_count(cmd, thin_ARG) && arg_count(cmd,mirrors_ARG)) { + log_error("--thin and --mirrors are incompatible."); + return 0; + } + + /* Set default segtype */ if (arg_count(cmd, mirrors_ARG)) segtype_str = find_config_tree_str(cmd, "global/mirror_segtype_default", DEFAULT_MIRROR_SEGTYPE); + else if (arg_count(cmd, thin_ARG) || arg_count(cmd, thinpool_ARG)) + segtype_str = "thin"; + else + segtype_str = "striped"; lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, segtype_str)); if (arg_count(cmd, snapshot_ARG) || seg_is_snapshot(lp) || - arg_count(cmd, virtualsize_ARG)) + (!seg_is_thin(lp) && arg_count(cmd, virtualsize_ARG))) lp->snapshot = 1; + if (seg_is_thin_pool(lp)) { + if (lp->snapshot) { + log_error("Snapshots are incompatible with thin_pool segment_type."); + return 0; + } + lp->create_thin_pool = 1; + } + + if (seg_is_thin_volume(lp)) + lp->thin = 1; + lp->mirrors = 1; /* Default to 2 mirrored areas if '--type mirror|raid1' */ @@ -408,31 +623,9 @@ } } - if (lp->snapshot) { - if (arg_count(cmd, zero_ARG)) { - log_error("-Z is incompatible with snapshots"); - return 0; - } - if (arg_sign_value(cmd, chunksize_ARG, 0) == SIGN_MINUS) { - log_error("Negative chunk size is invalid"); - return 0; - } - lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8); - if (lp->chunk_size < 8 || lp->chunk_size > 1024 || - (lp->chunk_size & (lp->chunk_size - 1))) { - log_error("Chunk size must be a power of 2 in the " - "range 4K to 512K"); - return 0; - } - log_verbose("Setting chunksize to %d sectors.", lp->chunk_size); - - if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot"))) - return_0; - } else { - if (arg_count(cmd, chunksize_ARG)) { - log_error("-c is only available with snapshots"); - return 0; - } + if (lp->snapshot && arg_count(cmd, zero_ARG)) { + log_error("-Z is incompatible with snapshots"); + return 0; } if (segtype_is_mirrored(lp->segtype) || segtype_is_raid(lp->segtype)) { @@ -476,34 +669,39 @@ !_read_raid_params(lp, cmd)) return_0; - lp->activate = arg_uint_value(cmd, available_ARG, CHANGE_AY); - - /* - * Should we zero the lv. - */ - lp->zero = strcmp(arg_str_value(cmd, zero_ARG, - (lp->segtype->flags & SEG_CANNOT_BE_ZEROED) ? "n" : "y"), "n"); + if (lp->snapshot && lp->thin && arg_count(cmd, chunksize_ARG)) + log_warn("WARNING: Ignoring --chunksize with thin snapshots."); + else if (lp->thin && !lp->create_thin_pool) { + if (arg_count(cmd, chunksize_ARG)) + log_warn("WARNING: Ignoring --chunksize when using an existing pool."); + } else if (lp->snapshot || lp->create_thin_pool) { + if (arg_sign_value(cmd, chunksize_ARG, 0) == SIGN_MINUS) { + log_error("Negative chunk size is invalid"); + return 0; + } + lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8); + if (lp->chunk_size < 8 || lp->chunk_size > 1024 || + (lp->chunk_size & (lp->chunk_size - 1))) { + log_error("Chunk size must be a power of 2 in the " + "range 4K to 512K"); + return 0; + } + log_verbose("Setting chunksize to %d sectors.", lp->chunk_size); - if (lp->activate == CHANGE_AN || lp->activate == CHANGE_ALN) { - if (lp->zero) { - log_error("--available n requires --zero n"); + if (!lp->thin && lp->snapshot && !(lp->segtype = get_segtype_from_string(cmd, "snapshot"))) + return_0; + } else { + if (arg_count(cmd, chunksize_ARG)) { + log_error("-c is only available with snapshots and thin pools"); return 0; } } /* - * Alloc policy + * Should we zero the lv. */ - contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n"); - - lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT; - - lp->alloc = arg_uint_value(cmd, alloc_ARG, lp->alloc); - - if (contiguous && (lp->alloc != ALLOC_CONTIGUOUS)) { - log_error("Conflicting contiguous and alloc arguments"); - return 0; - } + lp->zero = strcmp(arg_str_value(cmd, zero_ARG, + (lp->segtype->flags & SEG_CANNOT_BE_ZEROED) ? "n" : "y"), "n"); if (lp->mirrors > DEFAULT_MIRROR_MAX_IMAGES) { log_error("Only up to %d images in mirror supported currently.", @@ -511,58 +709,20 @@ return 0; } - /* - * Read ahead. - */ - lp->read_ahead = arg_uint_value(cmd, readahead_ARG, - cmd->default_settings.read_ahead); - pagesize = lvm_getpagesize() >> SECTOR_SHIFT; - if (lp->read_ahead != DM_READ_AHEAD_AUTO && - lp->read_ahead != DM_READ_AHEAD_NONE && - lp->read_ahead % pagesize) { - if (lp->read_ahead < pagesize) - lp->read_ahead = pagesize; - else - lp->read_ahead = (lp->read_ahead / pagesize) * pagesize; - log_warn("WARNING: Overriding readahead to %u sectors, a multiple " - "of %uK page size.", lp->read_ahead, pagesize >> 1); - } + if (!_read_activation_params(lp, cmd)) + return_0; /* - * Permissions. + * Allocation parameters */ - lp->permission = arg_uint_value(cmd, permission_ARG, - LVM_READ | LVM_WRITE); + contiguous = strcmp(arg_str_value(cmd, contiguous_ARG, "n"), "n"); - /* Must not zero read only volume */ - if (!(lp->permission & LVM_WRITE)) - lp->zero = 0; + lp->alloc = contiguous ? ALLOC_CONTIGUOUS : ALLOC_INHERIT; - lp->minor = arg_int_value(cmd, minor_ARG, -1); - lp->major = arg_int_value(cmd, major_ARG, -1); + lp->alloc = arg_uint_value(cmd, alloc_ARG, lp->alloc); - /* Persistent minor */ - if (arg_count(cmd, persistent_ARG)) { - if (!strcmp(arg_str_value(cmd, persistent_ARG, "n"), "y")) { - if (lp->minor == -1) { - log_error("Please specify minor number with " - "--minor when using -My"); - return 0; - } - if (lp->major == -1) { - log_error("Please specify major number with " - "--major when using -My"); - return 0; - } - } else { - if ((lp->minor != -1) || (lp->major != -1)) { - log_error("--major and --minor incompatible " - "with -Mn"); - return 0; - } - } - } else if (arg_count(cmd, minor_ARG) || arg_count(cmd, major_ARG)) { - log_error("--major and --minor require -My"); + if (contiguous && (lp->alloc != ALLOC_CONTIGUOUS)) { + log_error("Conflicting contiguous and alloc arguments"); return 0; } @@ -576,10 +736,10 @@ } if (!str_list_add(cmd->mem, &lp->tags, tag)) { - log_error("Unable to allocate memory for tag %s", tag); + log_error("Unable to allocate memory for tag %s", tag); return 0; } - } + } lcp->pv_count = argc; lcp->pvs = argv; @@ -587,6 +747,140 @@ return 1; } +static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_params *lp, + struct lvcreate_cmdline_params *lcp) +{ + struct lv_list *lvl; + + if (!lp->thin && !lp->create_thin_pool) { + log_error("Please specify device size(s)."); + return 0; + } + + if (lp->thin && !lp->create_thin_pool) { + if (arg_count(vg->cmd, chunksize_ARG)) { + log_error("Only specify --chunksize when originally creating the thin pool."); + return 0; + } + + if (lcp->pv_count) { + log_error("Only specify Physical volumes when allocating the thin pool."); + return 0; + } + + if (arg_count(vg->cmd, alloc_ARG)) { + log_error("--alloc may only be specified when allocating the thin pool."); + return 0; + } + + if (arg_count(vg->cmd, stripesize_ARG)) { + log_error("--stripesize may only be specified when allocating the thin pool."); + return 0; + } + + if (arg_count(vg->cmd, stripes_ARG)) { + log_error("--stripes may only be specified when allocating the thin pool."); + return 0; + } + + if (arg_count(vg->cmd, contiguous_ARG)) { + log_error("--contiguous may only be specified when allocating the thin pool."); + return 0; + } + + if (arg_count(vg->cmd, zero_ARG)) { + log_error("--zero may only be specified when allocating the thin pool."); + return 0; + } + } + + if (lp->create_thin_pool && lp->pool) { + if (find_lv_in_vg(vg, lp->pool)) { + log_error("Pool %s already exists in Volume group %s.", lp->pool, vg->name); + return 0; + } + } else if (lp->pool) { + if (!(lvl = find_lv_in_vg(vg, lp->pool))) { + log_error("Pool %s not found in Volume group %s.", lp->pool, vg->name); + return 0; + } + /* FIXME Use lv_is_thin_pool() */ + if (!seg_is_thin_pool(first_seg(lvl->lv))) { + log_error("Logical volume %s is not a thin pool.", lp->pool); + return 0; + } + } else if (!lp->create_thin_pool) { + log_error("Please specify name of existing pool."); + return 0; + } + + if (!lp->thin && lp->lv_name) { + log_error("--name may only be given when creating a new thin Logical volume or snapshot."); + return 0; + } + + if (!lp->thin) { + if (arg_count(vg->cmd, readahead_ARG)) { + log_error("--readhead may only be given when creating a new thin Logical volume or snapshot."); + return 0; + } + if (arg_count(vg->cmd, permission_ARG)) { + log_error("--permission may only be given when creating a new thin Logical volume or snapshot."); + return 0; + } + if (arg_count(vg->cmd, persistent_ARG)) { + log_error("--persistent may only be given when creating a new thin Logical volume or snapshot."); + return 0; + } + } + + return 1; +} + +/* + * Ensure the set of thin parameters extracted from the command line is consistent. + */ +static int _validate_internal_thin_processing(const struct lvcreate_params *lp) +{ + int r = 1; + + /* + The final state should be one of: + thin create_thin_pool snapshot origin pool + 1 1 0 0 y/n - create new pool and a thin LV in it + 1 0 0 0 y - create new thin LV in existing pool + 0 1 0 0 y/n - create new pool only + 1 0 1 1 y - create thin snapshot of existing thin LV + */ + + if (!lp->create_thin_pool && !lp->pool) { + log_error(INTERNAL_ERROR "--thinpool not identified."); + r = 0; + } + + if ((lp->snapshot && !lp->origin) || (!lp->snapshot && lp->origin)) { + log_error(INTERNAL_ERROR "Inconsistent snapshot and origin parameters identified."); + r = 0; + } + + if (lp->snapshot && (lp->create_thin_pool || !lp->thin)) { + log_error(INTERNAL_ERROR "Inconsistent thin and snapshot parameters identified."); + r = 0; + } + + if (!lp->thin && !lp->create_thin_pool) { + log_error(INTERNAL_ERROR "Failed to identify what type of thin target to use."); + r = 0; + } + + if (seg_is_thin_pool(lp) && lp->thin) { + log_error(INTERNAL_ERROR "Thin volume cannot be created with thin pool segment type."); + r = 0; + } + + return r; +} + int lvcreate(struct cmd_context *cmd, int argc, char **argv) { int r = ECMD_PROCESSED; @@ -605,11 +899,43 @@ return ECMD_FAILED; } + if (lp.snapshot && !_determine_snapshot_type(vg, &lp)) { + r = ECMD_FAILED; + goto_out; + } + + if (seg_is_thin(&lp) && !_check_thin_parameters(vg, &lp, &lcp)) { + r = ECMD_FAILED; + goto_out; + } + if (!_update_extents_params(vg, &lp, &lcp)) { r = ECMD_FAILED; goto_out; } + if (seg_is_thin(&lp) && !_validate_internal_thin_processing(&lp)) { + r = ECMD_FAILED; + goto_out; + } + + if (lp.create_thin_pool) + log_verbose("Making thin pool %s in VG %s using segtype %s", + lp.pool ? : "with generated name", lp.vg_name, lp.segtype->name); + + if (lp.thin) + log_verbose("Making thin LV %s in pool %s in VG %s%s%s using segtype %s", + lp.lv_name ? : "with generated name", + lp.pool, lp.vg_name, lp.snapshot ? " as snapshot of " : "", + lp.snapshot ? lp.origin : "", lp.segtype->name); + + /* FIXME Remove when thin snapshots are supported. */ + if (lp.thin && lp.snapshot) { + log_error("Thin snapshots are not yet supported."); + r = ECMD_FAILED; + goto_out; + } + if (!lv_create_single(vg, &lp)) { stack; r = ECMD_FAILED; --- LVM2/tools/lvresize.c 2011/08/10 20:25:31 1.134 +++ LVM2/tools/lvresize.c 2011/09/06 00:26:43 1.135 @@ -707,7 +707,7 @@ !lv_extend(lv, lp->segtype, lp->stripes, lp->stripe_size, lp->mirrors, first_seg(lv)->region_size, - lp->extents - lv->le_count, + lp->extents - lv->le_count, NULL, pvh, alloc)) { stack; return ECMD_FAILED; From agk@sourceware.org Tue Sep 6 15:35:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 06 Sep 2011 15:35:00 -0000 Subject: LVM2/tools lvcreate.c Message-ID: <20110906153512.15498.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-06 15:35:11 Modified files: tools : lvcreate.c Log message: only thin volumes need converting Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.235&r2=1.236 --- LVM2/tools/lvcreate.c 2011/09/06 00:26:43 1.235 +++ LVM2/tools/lvcreate.c 2011/09/06 15:35:11 1.236 @@ -343,7 +343,7 @@ } } else { /* No virtual size given, so no thin LV to create. */ - if (!seg_is_thin_pool(lp) && !(lp->segtype = get_segtype_from_string(cmd, "thin_pool"))) + if (seg_is_thin_volume(lp) && !(lp->segtype = get_segtype_from_string(cmd, "thin_pool"))) return_0; lp->thin = 0; From agk@sourceware.org Tue Sep 6 15:38:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 06 Sep 2011 15:38:00 -0000 Subject: LVM2/lib/misc lvm-string.c Message-ID: <20110906153846.8780.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-06 15:38:45 Modified files: lib/misc : lvm-string.c Log message: tdata->tpool Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-string.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31 --- LVM2/lib/misc/lvm-string.c 2011/09/06 00:26:43 1.30 +++ LVM2/lib/misc/lvm-string.c 2011/09/06 15:38:44 1.31 @@ -95,58 +95,40 @@ int apply_lvname_restrictions(const char *name) { - if (!strncmp(name, "snapshot", 8)) { - log_error("Names starting \"snapshot\" are reserved. " - "Please choose a different LV name."); - return 0; - } - - if (!strncmp(name, "pvmove", 6)) { - log_error("Names starting \"pvmove\" are reserved. " - "Please choose a different LV name."); - return 0; - } - - if (strstr(name, "_mlog")) { - log_error("Names including \"_mlog\" are reserved. " - "Please choose a different LV name."); - return 0; - } - - if (strstr(name, "_mimage")) { - log_error("Names including \"_mimage\" are reserved. " - "Please choose a different LV name."); - return 0; - } - - if (strstr(name, "_rimage")) { - log_error("Names including \"_rimage\" are reserved. " - "Please choose a different LV name."); - return 0; - } - - if (strstr(name, "_rmeta")) { - log_error("Names including \"_rmeta\" are reserved. " - "Please choose a different LV name."); - return 0; - } - - if (strstr(name, "_vorigin")) { - log_error("Names including \"_vorigin\" are reserved. " - "Please choose a different LV name."); - return 0; - } - - if (strstr(name, "_tdata")) { - log_error("Names including \"_tpool\" are reserved. " - "Please choose a different LV name."); - return 0; - } - - if (strstr(name, "_tmeta")) { - log_error("Names including \"_tpool\" are reserved. " - "Please choose a different LV name."); - return 0; + const char *reserved_prefixes[] = { + "snapshot", + "pvmove", + NULL + }; + + const char *reserved_strings[] = { + "_mlog", + "_mimage", + "_rimage", + "_rmeta", + "_vorigin", + "_tpool", + "_tmeta", + NULL + }; + + unsigned i; + const char *s; + + for (i = 0; (s = reserved_prefixes[i]); i++) { + if (!strncmp(name, s, strlen(s))) { + log_error("Names starting \"%s\" are reserved. " + "Please choose a different LV name.", s); + return 0; + } + } + + for (i = 0; (s = reserved_strings[i]); i++) { + if (strstr(name, s)) { + log_error("Names including \"%s\" are reserved. " + "Please choose a different LV name.", s); + return 0; + } } return 1; From agk@sourceware.org Tue Sep 6 15:39:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 06 Sep 2011 15:39:00 -0000 Subject: LVM2/lib/metadata lv_manip.c Message-ID: <20110906153947.13869.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-06 15:39:47 Modified files: lib/metadata : lv_manip.c Log message: else Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.278&r2=1.279 --- LVM2/lib/metadata/lv_manip.c 2011/09/06 00:26:43 1.278 +++ LVM2/lib/metadata/lv_manip.c 2011/09/06 15:39:46 1.279 @@ -2354,7 +2354,7 @@ // lv->status |= THIN_POOL; // status = THIN_IMAGE; layer_name = "tdata"; - } + } else return_0; /* From zkabelac@sourceware.org Tue Sep 6 18:11:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 06 Sep 2011 18:11:00 -0000 Subject: LVM2 daemons/cmirrord/clogd.c ./WHATS_NEW Message-ID: <20110906181122.6298.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-06 18:11:21 Modified files: daemons/cmirrord: clogd.c . : WHATS_NEW Log message: Log unlink() error Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/clogd.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2090&r2=1.2091 --- LVM2/daemons/cmirrord/clogd.c 2010/12/13 10:43:57 1.13 +++ LVM2/daemons/cmirrord/clogd.c 2011/09/06 18:11:21 1.14 @@ -121,7 +121,8 @@ static void remove_lockfile(void) { - unlink(CMIRRORD_PIDFILE); + if (unlink(CMIRRORD_PIDFILE)) + LOG_ERROR("Unable to remove \"" CMIRRORD_PIDFILE "\" %s", strerror(errno)); } /* --- LVM2/WHATS_NEW 2011/09/05 12:54:29 1.2090 +++ LVM2/WHATS_NEW 2011/09/06 18:11:21 1.2091 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Log unlink() error in cmirrord remove_lockfile(). Remove incorrect requirement for -j or -m from lvchange error message. Fix unsafe table load when splitting off smaller mirror from a larger one. Use size_t return type for text_vg_export_raw() and export_vg_to_buffer(). From zkabelac@sourceware.org Tue Sep 6 18:15:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 06 Sep 2011 18:15:00 -0000 Subject: LVM2 daemons/cmirrord/cluster.c ./WHATS_NEW Message-ID: <20110906181543.7215.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-06 18:15:43 Modified files: daemons/cmirrord: cluster.c . : WHATS_NEW Log message: Fix memory leak of allocated bitmap in error path Found by static analyzer. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/cluster.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2091&r2=1.2092 --- LVM2/daemons/cmirrord/cluster.c 2010/10/25 12:59:24 1.16 +++ LVM2/daemons/cmirrord/cluster.c 2011/09/06 18:15:43 1.17 @@ -619,6 +619,7 @@ if (rv != SA_AIS_OK) { LOG_ERROR("[%s] Failed to open checkpoint: %s", SHORT_UUID(entry->name.value), str_ais_error(rv)); + free(bitmap); return -EIO; /* FIXME: better error */ } @@ -647,6 +648,7 @@ if (rv != SA_AIS_OK) { LOG_ERROR("[%s] Sync checkpoint section creation failed: %s", SHORT_UUID(entry->name.value), str_ais_error(rv)); + free(bitmap); return -EIO; /* FIXME: better error */ } --- LVM2/WHATS_NEW 2011/09/06 18:11:21 1.2091 +++ LVM2/WHATS_NEW 2011/09/06 18:15:43 1.2092 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix error path bitmap leak in cmirrord import_checkpoint(). Log unlink() error in cmirrord remove_lockfile(). Remove incorrect requirement for -j or -m from lvchange error message. Fix unsafe table load when splitting off smaller mirror from a larger one. From zkabelac@sourceware.org Tue Sep 6 18:24:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 06 Sep 2011 18:24:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/cmirrord/functions.c Message-ID: <20110906182427.11342.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-06 18:24:27 Modified files: . : WHATS_NEW daemons/cmirrord: functions.c Log message: Detect sscanf recovering_region input error Missing check for sscanf found by static analyzer. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2092&r2=1.2093 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28 --- LVM2/WHATS_NEW 2011/09/06 18:15:43 1.2092 +++ LVM2/WHATS_NEW 2011/09/06 18:24:27 1.2093 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Detect sscanf recovering_region input error in cmirrord pull_state(). Fix error path bitmap leak in cmirrord import_checkpoint(). Log unlink() error in cmirrord remove_lockfile(). Remove incorrect requirement for -j or -m from lvchange error message. --- LVM2/daemons/cmirrord/functions.c 2010/12/20 13:58:38 1.27 +++ LVM2/daemons/cmirrord/functions.c 2011/09/06 18:24:27 1.28 @@ -1817,8 +1817,11 @@ } if (!strncmp(which, "recovering_region", 17)) { - sscanf(buf, "%llu %u", (unsigned long long *)&lc->recovering_region, - &lc->recoverer); + if (sscanf(buf, "%llu %u", (unsigned long long *)&lc->recovering_region, + &lc->recoverer) != 2) { + LOG_ERROR("cannot parse recovering region from: %s", buf); + return -EINVAL; + } LOG_SPRINT(lc, "CKPT INIT - SEQ#=X, UUID=%s, nodeid = X:: " "recovering_region=%llu, recoverer=%u", SHORT_UUID(lc->uuid), From agk@sourceware.org Tue Sep 6 18:49:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 06 Sep 2011 18:49:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c lib/m ... Message-ID: <20110906184935.10709.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-06 18:49:33 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c metadata-exported.h metadata.h mirror.c raid_manip.c tools : lvconvert.c polldaemon.c polldaemon.h Log message: Start using 64-bit status flags - most of the code already handles them. tdata -> tpool remove commented out definitions from metadata.h formatting clean-ups Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2093&r2=1.2094 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.279&r2=1.280 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.204&r2=1.205 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.251&r2=1.252 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.160&r2=1.161 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/raid_manip.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.171&r2=1.172 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.h.diff?cvsroot=lvm2&r1=1.11&r2=1.12 --- LVM2/WHATS_NEW 2011/09/06 18:24:27 1.2093 +++ LVM2/WHATS_NEW 2011/09/06 18:49:31 1.2094 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Begin using 64-bit status field flags. Detect sscanf recovering_region input error in cmirrord pull_state(). Fix error path bitmap leak in cmirrord import_checkpoint(). Log unlink() error in cmirrord remove_lockfile(). --- LVM2/lib/metadata/lv_manip.c 2011/09/06 15:39:46 1.279 +++ LVM2/lib/metadata/lv_manip.c 2011/09/06 18:49:32 1.280 @@ -1675,7 +1675,7 @@ if (alloc_state->areas[s].pva && alloc_state->areas[s].pva->map->pv == pvm->pv) goto next_pv; /* On a second pass, avoid PVs already used in an uncommitted area */ - } else if (iteration_count) + } else if (iteration_count) for (s = 0; s < devices_needed; s++) if (alloc_state->areas[s].pva && alloc_state->areas[s].pva->map->pv == pvm->pv) goto next_pv; @@ -1907,8 +1907,8 @@ return 1; } - if (ah->area_multiple > 1 && - (ah->new_extents - alloc_state.allocated) % ah->area_count) { + if (ah->area_multiple > 1 && + (ah->new_extents - alloc_state.allocated) % ah->area_count) { log_error("Number of extents requested (%d) needs to be divisible by %d.", ah->new_extents - alloc_state.allocated, ah->area_count); return 0; @@ -2306,7 +2306,7 @@ * If we used AREA_PVs under the mirror layer of a log, we could * assemble it all at once by calling 'lv_add_segment' with the * appropriate segtype (mirror/stripe), like this: - * lv_add_segment(ah, ah->area_count, ah->log_area_count, + * lv_add_segment(ah, ah->area_count, ah->log_area_count, * log_lv, segtype, 0, MIRROR_LOG, 0); * * For now, we use the same mechanism to build a mirrored log as we @@ -2353,7 +2353,7 @@ } else if (segtype_is_thin_pool(segtype)) { // lv->status |= THIN_POOL; // status = THIN_IMAGE; - layer_name = "tdata"; + layer_name = "tpool"; } else return_0; @@ -3775,7 +3775,7 @@ dev_flush(dev); if (!dev_close_immediate(dev)) - stack; + stack; return 1; } @@ -4198,7 +4198,7 @@ lp->pool = lv->name; if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin"))) - return_0; + return_0; } if (!(lv = _lv_create_an_lv(vg, lp, lp->lv_name))) --- LVM2/lib/metadata/metadata-exported.h 2011/09/06 00:26:43 1.204 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/06 18:49:32 1.205 @@ -42,55 +42,55 @@ /* Various flags */ /* Note that the bits no longer necessarily correspond to LVM1 disk format */ -#define PARTIAL_VG 0x00000001U /* VG */ -#define EXPORTED_VG 0x00000002U /* VG PV */ -#define RESIZEABLE_VG 0x00000004U /* VG */ - -/* - * Since the RAID flags are LV (and seg) only and the above three - * are VG/PV only, these flags are reused. - */ -#define RAID 0x00000001U /* LV */ -#define RAID_META 0x00000002U /* LV */ -#define RAID_IMAGE 0x00000004U /* LV */ +#define PARTIAL_VG UINT64_C(0x00000001) /* VG */ +#define EXPORTED_VG UINT64_C(0x00000002) /* VG PV */ +#define RESIZEABLE_VG UINT64_C(0x00000004) /* VG */ /* May any free extents on this PV be used or must they be left free? */ -#define ALLOCATABLE_PV 0x00000008U /* PV */ +#define ALLOCATABLE_PV UINT64_C(0x00000008) /* PV */ -//#define SPINDOWN_LV 0x00000010U /* LV */ -//#define BADBLOCK_ON 0x00000020U /* LV */ -#define VISIBLE_LV 0x00000040U /* LV */ -#define FIXED_MINOR 0x00000080U /* LV */ +//#define SPINDOWN_LV UINT64_C(0x00000010) /* LV */ +//#define BADBLOCK_ON UINT64_C(0x00000020) /* LV */ +#define VISIBLE_LV UINT64_C(0x00000040) /* LV */ +#define FIXED_MINOR UINT64_C(0x00000080) /* LV */ /* FIXME Remove when metadata restructuring is completed */ -#define SNAPSHOT 0x00001000U /* LV - internal use only */ -#define PVMOVE 0x00002000U /* VG LV SEG */ -#define LOCKED 0x00004000U /* LV */ -#define MIRRORED 0x00008000U /* LV - internal use only */ -//#define VIRTUAL 0x00010000U /* LV - internal use only */ -#define MIRROR_LOG 0x00020000U /* LV */ -#define MIRROR_IMAGE 0x00040000U /* LV */ -#define LV_NOTSYNCED 0x00080000U /* LV */ -//#define PRECOMMITTED 0x00200000U /* VG - internal use only */ -#define CONVERTING 0x00400000U /* LV */ - -#define MISSING_PV 0x00800000U /* PV */ -#define PARTIAL_LV 0x01000000U /* LV - derived flag, not - written out in metadata*/ - -//#define POSTORDER_FLAG 0x02000000U /* Not real flags, reserved for -//#define POSTORDER_OPEN_FLAG 0x04000000U temporary use inside vg_read_internal. */ -//#define VIRTUAL_ORIGIN 0x08000000U /* LV - internal use only */ - -#define MERGING 0x10000000U /* LV SEG */ - -#define REPLICATOR 0x20000000U /* LV -internal use only for replicator */ -#define REPLICATOR_LOG 0x40000000U /* LV -internal use only for replicator-dev */ -#define UNLABELLED_PV 0x80000000U /* PV -this PV had no label written yet */ - -#define LVM_READ 0x00000100U /* LV VG */ -#define LVM_WRITE 0x00000200U /* LV VG */ -#define CLUSTERED 0x00000400U /* VG */ -//#define SHARED 0x00000800U /* VG */ +#define SNAPSHOT UINT64_C(0x00001000) /* LV - internal use only */ +#define PVMOVE UINT64_C(0x00002000) /* VG LV SEG */ +#define LOCKED UINT64_C(0x00004000) /* LV */ +#define MIRRORED UINT64_C(0x00008000) /* LV - internal use only */ +//#define VIRTUAL UINT64_C(0x00010000) /* LV - internal use only */ +#define MIRROR_LOG UINT64_C(0x00020000) /* LV */ +#define MIRROR_IMAGE UINT64_C(0x00040000) /* LV */ +#define LV_NOTSYNCED UINT64_C(0x00080000) /* LV */ +//#define PRECOMMITTED UINT64_C(0x00200000) /* VG - internal use only */ +#define CONVERTING UINT64_C(0x00400000) /* LV */ + +#define MISSING_PV UINT64_C(0x00800000) /* PV */ +#define PARTIAL_LV UINT64_C(0x01000000) /* LV - derived flag, not + written out in metadata*/ + +//#define POSTORDER_FLAG UINT64_C(0x02000000) /* Not real flags, reserved for +//#define POSTORDER_OPEN_FLAG UINT64_C(0x04000000) temporary use inside vg_read_internal. */ +//#define VIRTUAL_ORIGIN UINT64_C(0x08000000) /* LV - internal use only */ + +#define MERGING UINT64_C(0x10000000) /* LV SEG */ + +#define REPLICATOR UINT64_C(0x20000000) /* LV -internal use only for replicator */ +#define REPLICATOR_LOG UINT64_C(0x40000000) /* LV -internal use only for replicator-dev */ +#define UNLABELLED_PV UINT64_C(0x80000000) /* PV -this PV had no label written yet */ + +#define RAID UINT64_C(0x0000000100000000) /* LV */ +#define RAID_META UINT64_C(0x0000000200000000) /* LV */ +#define RAID_IMAGE UINT64_C(0x0000000400000000) /* LV */ + +#define THIN_VOLUME UINT64_C(0x0000001000000000) /* LV */ +#define THIN_POOL UINT64_C(0x0000002000000000) /* LV */ + +#define LVM_READ 0x00000100U /* LV VG 32-bit */ +#define LVM_WRITE 0x00000200U /* LV VG 32-bit */ + +#define CLUSTERED UINT64_C(0x00000400) /* VG */ +//#define SHARED UINT64_C(0x00000800) /* VG */ /* Format features flags */ #define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */ @@ -112,10 +112,10 @@ /* vg_read and vg_read_for_update flags */ #define READ_ALLOW_INCONSISTENT 0x00010000U #define READ_ALLOW_EXPORTED 0x00020000U -#define READ_WITHOUT_LOCK 0x00040000U +#define READ_WITHOUT_LOCK 0x00040000U /* A meta-flag, useful with toollib for_each_* functions. */ -#define READ_FOR_UPDATE 0x00100000U +#define READ_FOR_UPDATE 0x00100000U /* vg's "read_status" field */ #define FAILED_INCONSISTENT 0x00000001U @@ -189,19 +189,19 @@ */ /* PV-based format instance */ -#define FMT_INSTANCE_PV 0x00000000U +#define FMT_INSTANCE_PV 0x00000000U /* VG-based format instance */ -#define FMT_INSTANCE_VG 0x00000001U +#define FMT_INSTANCE_VG 0x00000001U /* Include any existing PV mdas during format_instance initialisation */ -#define FMT_INSTANCE_MDAS 0x00000002U +#define FMT_INSTANCE_MDAS 0x00000002U /* Include any auxiliary mdas during format_instance intialisation */ -#define FMT_INSTANCE_AUX_MDAS 0x00000004U +#define FMT_INSTANCE_AUX_MDAS 0x00000004U /* Include any other format-specific mdas during format_instance initialisation */ -#define FMT_INSTANCE_PRIVATE_MDAS 0x00000008U +#define FMT_INSTANCE_PRIVATE_MDAS 0x00000008U struct format_instance { unsigned ref_count; /* Refs to this fid from VG and PV structs */ @@ -265,9 +265,9 @@ struct logical_volume *replicator; /* Reference to replicator */ - const char *name; /* Site name */ + const char *name; /* Site name */ const char *vg_name; /* VG name */ - struct volume_group *vg; /* resolved vg (activate/deactive) */ + struct volume_group *vg; /* resolved vg (activate/deactive) */ unsigned site_index; replicator_state_t state; /* Active or pasive state of site */ dm_replicator_mode_t op_mode; /* Operation mode sync or async fail|warn|drop|stall */ @@ -301,7 +301,7 @@ uint64_t status; /* FIXME Fields depend on segment type */ - uint32_t stripe_size; /* For stripe and RAID - in sectors */ + uint32_t stripe_size; /* For stripe and RAID - in sectors */ uint32_t area_count; uint32_t area_len; uint32_t chunk_size; /* For snapshots - in sectors */ @@ -388,7 +388,7 @@ int vg_commit(struct volume_group *vg); int vg_revert(struct volume_group *vg); struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name, - const char *vgid, int warnings, int *consistent); + const char *vgid, int warnings, int *consistent); struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name, int warnings, int scan_label_only); @@ -425,9 +425,9 @@ * Return a handle to VG metadata. */ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, - const char *vgid, uint32_t flags); + const char *vgid, uint32_t flags); struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_name, - const char *vgid, uint32_t flags); + const char *vgid, uint32_t flags); /* * Test validity of a VG handle. @@ -450,7 +450,7 @@ uint64_t pvmetadatasize, unsigned metadataignore); int pv_resize(struct physical_volume *pv, struct volume_group *vg, - uint64_t size); + uint64_t size); int pv_analyze(struct cmd_context *cmd, const char *pv_name, uint64_t label_sector); @@ -495,7 +495,7 @@ /* Write out LV contents */ int set_lv(struct cmd_context *cmd, struct logical_volume *lv, - uint64_t sectors, int value); + uint64_t sectors, int value); int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag); @@ -699,7 +699,7 @@ int lv_is_mirrored(const struct logical_volume *lv); uint32_t lv_mirror_count(const struct logical_volume *lv); uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents, - uint32_t region_size); + uint32_t region_size); int remove_mirrors_from_segments(struct logical_volume *lv, uint32_t new_mirrors, uint64_t status_mask); int add_mirrors_to_segments(struct cmd_context *cmd, struct logical_volume *lv, @@ -773,12 +773,12 @@ void lv_release_replicator_vgs(struct logical_volume *lv); struct logical_volume *find_pvmove_lv(struct volume_group *vg, - struct device *dev, uint32_t lv_type); + struct device *dev, uint64_t lv_type); struct logical_volume *find_pvmove_lv_from_pvname(struct cmd_context *cmd, struct volume_group *vg, const char *name, const char *uuid, - uint32_t lv_type); + uint64_t lv_type); struct logical_volume *find_pvmove_lv_in_lv(struct logical_volume *lv); const char *get_pvmove_pvname_from_lv(struct logical_volume *lv); const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr); --- LVM2/lib/metadata/metadata.h 2011/09/01 10:25:22 1.251 +++ LVM2/lib/metadata/metadata.h 2011/09/06 18:49:32 1.252 @@ -49,54 +49,23 @@ /* Various flags */ +/* See metadata-exported.h for the complete list. */ /* Note that the bits no longer necessarily correspond to LVM1 disk format */ -//#define PARTIAL_VG 0x00000001U /* VG */ -//#define EXPORTED_VG 0x00000002U /* VG PV */ -//#define RESIZEABLE_VG 0x00000004U /* VG */ - /* May any free extents on this PV be used or must they be left free? */ -//#define ALLOCATABLE_PV 0x00000008U /* PV */ -#define SPINDOWN_LV 0x00000010U /* LV */ -#define BADBLOCK_ON 0x00000020U /* LV */ -//#define VISIBLE_LV 0x00000040U /* LV */ -//#define FIXED_MINOR 0x00000080U /* LV */ -/* FIXME Remove when metadata restructuring is completed */ -//#define SNAPSHOT 0x00001000U /* LV - internal use only */ -//#define PVMOVE 0x00002000U /* VG LV SEG */ -//#define LOCKED 0x00004000U /* LV */ -//#define MIRRORED 0x00008000U /* LV - internal use only */ -#define VIRTUAL 0x00010000U /* LV - internal use only */ -//#define MIRROR_LOG 0x00020000U /* LV */ -//#define MIRROR_IMAGE 0x00040000U /* LV */ -//#define MIRROR_NOTSYNCED 0x00080000U /* LV */ -#define PRECOMMITTED 0x00200000U /* VG - internal use only */ -//#define CONVERTING 0x00400000U /* LV */ - -//#define MISSING_PV 0x00800000U /* PV */ -//#define PARTIAL_LV 0x01000000U /* LV - derived flag, not -// written out in metadata*/ - -#define POSTORDER_FLAG 0x02000000U /* Not real flags, reserved for */ -#define POSTORDER_OPEN_FLAG 0x04000000U /* temporary use inside vg_read_internal. */ -#define VIRTUAL_ORIGIN 0x08000000U /* LV - internal use only */ - -//#define LVM_READ 0x00000100U /* LV VG */ -//#define LVM_WRITE 0x00000200U /* LV VG */ -//#define CLUSTERED 0x00000400U /* VG */ -#define SHARED 0x00000800U /* VG */ +#define SPINDOWN_LV UINT64_C(0x00000010) /* LV */ +#define BADBLOCK_ON UINT64_C(0x00000020) /* LV */ +#define VIRTUAL UINT64_C(0x00010000) /* LV - internal use only */ +#define PRECOMMITTED UINT64_C(0x00200000) /* VG - internal use only */ +#define POSTORDER_FLAG UINT64_C(0x02000000) /* Not real flags, reserved for */ +#define POSTORDER_OPEN_FLAG UINT64_C(0x04000000) /* temporary use inside vg_read_internal. */ +#define VIRTUAL_ORIGIN UINT64_C(0x08000000) /* LV - internal use only */ + +#define SHARED UINT64_C(0x00000800) /* VG */ /* Format features flags */ -//#define FMT_SEGMENTS 0x00000001U /* Arbitrary segment params? */ -//#define FMT_MDAS 0x00000002U /* Proper metadata areas? */ -//#define FMT_TAGS 0x00000004U /* Tagging? */ -//#define FMT_UNLIMITED_VOLS 0x00000008U /* Unlimited PVs/LVs? */ -//#define FMT_RESTRICTED_LVIDS 0x00000010U /* LVID <= 255 */ -//#define FMT_ORPHAN_ALLOCATABLE 0x00000020U /* Orphan PV allocatable? */ #define FMT_PRECOMMIT 0x00000040U /* Supports pre-commit? */ -//#define FMT_RESIZE_PV 0x00000080U /* Supports pvresize? */ -//#define FMT_UNLIMITED_STRIPESIZE 0x00000100U /* Unlimited stripe size? */ struct dm_config_tree; struct metadata_area; --- LVM2/lib/metadata/mirror.c 2011/09/01 19:22:11 1.160 +++ LVM2/lib/metadata/mirror.c 2011/09/06 18:49:32 1.161 @@ -1528,7 +1528,7 @@ struct logical_volume *find_pvmove_lv(struct volume_group *vg, struct device *dev, - uint32_t lv_type) + uint64_t lv_type) { struct lv_list *lvl; struct logical_volume *lv; @@ -1558,7 +1558,7 @@ struct volume_group *vg, const char *name, const char *uuid __attribute__((unused)), - uint32_t lv_type) + uint64_t lv_type) { struct physical_volume *pv; struct logical_volume *lv; --- LVM2/lib/metadata/raid_manip.c 2011/08/19 19:35:50 1.11 +++ LVM2/lib/metadata/raid_manip.c 2011/09/06 18:49:32 1.12 @@ -359,7 +359,7 @@ */ static int _alloc_image_component(struct logical_volume *lv, struct alloc_handle *ah, uint32_t first_area, - uint32_t type, struct logical_volume **new_lv) + uint64_t type, struct logical_volume **new_lv) { uint64_t status; size_t len = strlen(lv->name) + 32; --- LVM2/tools/lvconvert.c 2011/08/18 19:43:09 1.171 +++ LVM2/tools/lvconvert.c 2011/09/06 18:49:32 1.172 @@ -342,7 +342,7 @@ struct volume_group *vg, const char *name, const char *uuid, - uint32_t lv_type __attribute__((unused))) + uint64_t lv_type __attribute__((unused))) { struct logical_volume *lv = find_lv(vg, name); --- LVM2/tools/polldaemon.c 2011/08/10 20:25:31 1.45 +++ LVM2/tools/polldaemon.c 2011/09/06 18:49:32 1.46 @@ -283,7 +283,7 @@ */ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid, unsigned background, - uint32_t lv_type, struct poll_functions *poll_fns, + uint64_t lv_type, struct poll_functions *poll_fns, const char *progress_title) { struct daemon_parms parms; --- LVM2/tools/polldaemon.h 2010/01/22 21:59:43 1.11 +++ LVM2/tools/polldaemon.h 2011/09/06 18:49:32 1.12 @@ -36,7 +36,7 @@ struct volume_group *vg, const char *name, const char *uuid, - uint32_t lv_type); + uint64_t lv_type); progress_t (*poll_progress)(struct cmd_context *cmd, struct logical_volume *lv, const char *name, @@ -59,13 +59,13 @@ unsigned outstanding_count; unsigned progress_display; const char *progress_title; - uint32_t lv_type; + uint64_t lv_type; struct poll_functions *poll_fns; }; int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid, unsigned background, - uint32_t lv_type, struct poll_functions *poll_fns, + uint64_t lv_type, struct poll_functions *poll_fns, const char *progress_title); progress_t poll_mirror_progress(struct cmd_context *cmd, From agk@sourceware.org Tue Sep 6 19:25:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 06 Sep 2011 19:25:00 -0000 Subject: LVM2 tools/lvcreate.c lib/Makefile.in lib/meta ... Message-ID: <20110906192545.20690.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-06 19:25:44 Modified files: tools : lvcreate.c lib : Makefile.in lib/metadata : lv_manip.c metadata-exported.h metadata.h mirror.c replicator_manip.c lib/thin : thin.c Added files: lib/metadata : thin_manip.c Log message: add thin_manip.c like the other manip files move basic lv_is_* to macros data_lv -> pool_lv - we decided to call it 'pool' everywhere now Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.236&r2=1.237 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/Makefile.in.diff?cvsroot=lvm2&r1=1.112&r2=1.113 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/thin_manip.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.280&r2=1.281 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.205&r2=1.206 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.252&r2=1.253 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.161&r2=1.162 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9 --- LVM2/tools/lvcreate.c 2011/09/06 15:35:11 1.236 +++ LVM2/tools/lvcreate.c 2011/09/06 19:25:42 1.237 @@ -192,7 +192,6 @@ struct lvcreate_params *lp) { struct lv_list *lvl; - struct lv_segment *seg; if (!(lvl = find_lv_in_vg(vg, lp->origin))) { log_error("Snapshot origin LV %s not found in Volume group %s.", lp->origin, vg->name); @@ -200,12 +199,12 @@ } /* FIXME Replace with lv_is_thin_volume() once more flags are added */ - if (seg_is_thin_volume(seg = first_seg(lvl->lv))) { + if (lv_is_thin_volume(lvl->lv)) { lp->thin = 1; if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin"))) return_0; - lp->pool = seg->thin_pool_lv->name; + lp->pool = first_seg(lvl->lv)->thin_pool_lv->name; } if (!lp->thin && !arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) { @@ -804,8 +803,7 @@ log_error("Pool %s not found in Volume group %s.", lp->pool, vg->name); return 0; } - /* FIXME Use lv_is_thin_pool() */ - if (!seg_is_thin_pool(first_seg(lvl->lv))) { + if (!lv_is_thin_pool(lvl->lv)) { log_error("Logical volume %s is not a thin pool.", lp->pool); return 0; } --- LVM2/lib/Makefile.in 2011/08/24 08:27:50 1.112 +++ LVM2/lib/Makefile.in 2011/09/06 19:25:43 1.113 @@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -93,6 +93,7 @@ metadata/replicator_manip.c \ metadata/segtype.c \ metadata/snapshot_manip.c \ + metadata/thin_manip.c \ metadata/vg.c \ misc/crc.c \ misc/lvm-exec.c \ /cvs/lvm2/LVM2/lib/metadata/thin_manip.c,v --> standard output revision 1.1 --- LVM2/lib/metadata/thin_manip.c +++ - 2011-09-06 19:25:44.583371000 +0000 @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "lib.h" +#include "metadata.h" + +int attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata) +{ + // FIXME Housekeeping needed here (cf attach_mirror_log) + seg->metadata_lv = thin_pool_metadata; + + return 1; +} + +int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv) +{ + // FIXME Housekeeping needed here (cf attach_mirror_log) + seg->thin_pool_lv = thin_pool_lv; + + return 1; +} + --- LVM2/lib/metadata/lv_manip.c 2011/09/06 18:49:32 1.280 +++ LVM2/lib/metadata/lv_manip.c 2011/09/06 19:25:43 1.281 @@ -198,22 +198,6 @@ return i; } -static int _attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata) -{ - // FIXME Housekeeping needed here (cf attach_mirror_log) - seg->metadata_lv = thin_pool_metadata; - - return 1; -} - -static int _attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv) -{ - // FIXME Housekeeping needed here (cf attach_mirror_log) - seg->thin_pool_lv = thin_pool_lv; - - return 1; -} - /* * All lv_segments get created here. */ @@ -268,12 +252,12 @@ seg->pvmove_source_seg = pvmove_source_seg; dm_list_init(&seg->tags); - if (thin_pool_lv && !_attach_pool_lv(seg, thin_pool_lv)) + if (thin_pool_lv && !attach_pool_lv(seg, thin_pool_lv)) return_NULL; if (log_lv) { if (thin_pool_lv) { - if (!_attach_pool_metadata(seg, log_lv)) + if (!attach_pool_metadata(seg, log_lv)) return_NULL; } else if (!attach_mirror_log(seg, log_lv)) return_NULL; --- LVM2/lib/metadata/metadata-exported.h 2011/09/06 18:49:32 1.205 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/06 19:25:43 1.206 @@ -132,6 +132,11 @@ #define VGMETADATACOPIES_ALL UINT32_MAX #define VGMETADATACOPIES_UNMANAGED 0 +#define lv_is_thin_volume(lv) ((lv)->status & THIN_VOLUME ? 1 : 0) +#define lv_is_thin_pool(lv) ((lv)->status & THIN_POOL ? 1 : 0) +#define lv_is_mirrored(lv) ((lv)->status & MIRRORED ? 1 : 0) +#define lv_is_rlog(lv) ((lv)->status & REPLICATOR_LOG ? 1 : 0) + /* Ordered list - see lv_manip.c */ typedef enum { AREA_UNASSIGNED, @@ -318,7 +323,7 @@ struct lv_segment_area *areas; struct lv_segment_area *meta_areas; /* For RAID */ - struct logical_volume *data_lv; /* For thin_pool */ + struct logical_volume *pool_lv; /* For thin_pool */ struct logical_volume *metadata_lv; /* For thin_pool */ uint64_t transaction_id; /* For thin_pool */ uint32_t zero_new_blocks; /* For thin_pool */ @@ -696,7 +701,6 @@ int is_temporary_mirror_layer(const struct logical_volume *lv); struct logical_volume * find_temporary_mirror(const struct logical_volume *lv); -int lv_is_mirrored(const struct logical_volume *lv); uint32_t lv_mirror_count(const struct logical_volume *lv); uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents, uint32_t region_size); @@ -742,7 +746,6 @@ int lv_is_replicator(const struct logical_volume *lv); int lv_is_replicator_dev(const struct logical_volume *lv); int lv_is_rimage(const struct logical_volume *lv); -int lv_is_rlog(const struct logical_volume *lv); int lv_is_slog(const struct logical_volume *lv); struct logical_volume *first_replicator_dev(const struct logical_volume *lv); /* -- metadata/replicator_manip.c */ --- LVM2/lib/metadata/metadata.h 2011/09/06 18:49:32 1.252 +++ LVM2/lib/metadata/metadata.h 2011/09/06 19:25:43 1.253 @@ -440,6 +440,13 @@ int fixup_imported_mirrors(struct volume_group *vg); /* + * From thin_manip.c + */ +int attach_pool_metadata(struct lv_segment *seg, + struct logical_volume *thin_pool_metadata); +int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv); + +/* * Begin skeleton for external LVM library */ struct id pv_id(const struct physical_volume *pv); --- LVM2/lib/metadata/mirror.c 2011/09/06 18:49:32 1.161 +++ LVM2/lib/metadata/mirror.c 2011/09/06 19:25:43 1.162 @@ -72,14 +72,6 @@ return NULL; } -int lv_is_mirrored(const struct logical_volume *lv) -{ - if (lv->status & MIRRORED) - return 1; - - return 0; -} - /* * cluster_mirror_is_available * --- LVM2/lib/metadata/replicator_manip.c 2011/08/10 20:25:30 1.8 +++ LVM2/lib/metadata/replicator_manip.c 2011/09/06 19:25:43 1.9 @@ -446,14 +446,6 @@ } /** - * Is this LV rlog - */ -int lv_is_rlog(const struct logical_volume *lv) -{ - return (lv->status & REPLICATOR_LOG); -} - -/** * Is this LV sync log */ int lv_is_slog(const struct logical_volume *lv) --- LVM2/lib/thin/thin.c 2011/09/06 00:26:43 1.8 +++ LVM2/lib/thin/thin.c 2011/09/06 19:25:44 1.9 @@ -51,12 +51,14 @@ if (!dm_config_get_str(sn, "data", &lv_name)) return SEG_LOG_ERROR("Thin pool data must be a string in"); - if (!(seg->data_lv = find_lv(seg->lv->vg, lv_name))) +// Use attach_pool_lv + if (!(seg->pool_lv = find_lv(seg->lv->vg, lv_name))) return SEG_LOG_ERROR("Unknown pool data %s in", lv_name); if (!dm_config_get_str(sn, "metadata", &lv_name)) return SEG_LOG_ERROR("Thin pool metadata must be a string in"); +// Use attach_pool_metadata() if (!(seg->metadata_lv = find_lv(seg->lv->vg, lv_name))) return SEG_LOG_ERROR("Unknown pool metadata %s in", lv_name); @@ -72,7 +74,7 @@ static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter *f) { - outf(f, "data = \"%s\"", seg->data_lv->name); + outf(f, "data = \"%s\"", seg->pool_lv->name); outf(f, "metadata = \"%s\"", seg->metadata_lv->name); outf(f, "transaction_id = %" PRIu64, seg->transaction_id); if (seg->zero_new_blocks) From zkabelac@sourceware.org Tue Sep 6 22:35:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 06 Sep 2011 22:35:00 -0000 Subject: LVM2/lib/thin thin.c Message-ID: <20110906223545.14191.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-06 22:35:45 Modified files: lib/thin : thin.c Log message: Convert data->pool Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10 --- LVM2/lib/thin/thin.c 2011/09/06 19:25:44 1.9 +++ LVM2/lib/thin/thin.c 2011/09/06 22:35:44 1.10 @@ -48,19 +48,19 @@ { const char *lv_name; - if (!dm_config_get_str(sn, "data", &lv_name)) - return SEG_LOG_ERROR("Thin pool data must be a string in"); + if (!dm_config_get_str(sn, "pool", &lv_name)) + return SEG_LOG_ERROR("Pool must be a string in"); // Use attach_pool_lv if (!(seg->pool_lv = find_lv(seg->lv->vg, lv_name))) - return SEG_LOG_ERROR("Unknown pool data %s in", lv_name); + return SEG_LOG_ERROR("Unknown pool %s in", lv_name); if (!dm_config_get_str(sn, "metadata", &lv_name)) - return SEG_LOG_ERROR("Thin pool metadata must be a string in"); + return SEG_LOG_ERROR("Metadata must be a string in"); // Use attach_pool_metadata() if (!(seg->metadata_lv = find_lv(seg->lv->vg, lv_name))) - return SEG_LOG_ERROR("Unknown pool metadata %s in", lv_name); + return SEG_LOG_ERROR("Unknown metadata %s in", lv_name); if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id)) return SEG_LOG_ERROR("Could not read transaction_id for"); @@ -74,7 +74,7 @@ static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter *f) { - outf(f, "data = \"%s\"", seg->pool_lv->name); + outf(f, "pool = \"%s\"", seg->pool_lv->name); outf(f, "metadata = \"%s\"", seg->metadata_lv->name); outf(f, "transaction_id = %" PRIu64, seg->transaction_id); if (seg->zero_new_blocks) @@ -101,7 +101,7 @@ if (dm_config_has_node(sn, "origin")) { if (!dm_config_get_str(sn, "origin", &lv_name)) - return SEG_LOG_ERROR("Thin pool origin must be a string in"); + return SEG_LOG_ERROR("Origin must be a string in"); if (!(seg->origin = find_lv(seg->lv->vg, lv_name))) return SEG_LOG_ERROR("Unknown origin %s in", lv_name); From agk@sourceware.org Tue Sep 6 22:44:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 06 Sep 2011 22:44:00 -0000 Subject: LVM2 lib/metadata/lv_manip.c lib/metadata/merg ... Message-ID: <20110906224359.24695.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-06 22:43:58 Modified files: lib/metadata : lv_manip.c merge.c metadata-exported.h metadata.h thin_manip.c lib/thin : thin.c tools : lvcreate.c Log message: pool attach fns & more field renaming Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.281&r2=1.282 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.206&r2=1.207 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.253&r2=1.254 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/thin_manip.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.237&r2=1.238 --- LVM2/lib/metadata/lv_manip.c 2011/09/06 19:25:43 1.281 +++ LVM2/lib/metadata/lv_manip.c 2011/09/06 22:43:56 1.282 @@ -257,7 +257,7 @@ if (log_lv) { if (thin_pool_lv) { - if (!attach_pool_metadata(seg, log_lv)) + if (!attach_pool_metadata_lv(seg, log_lv)) return_NULL; } else if (!attach_mirror_log(seg, log_lv)) return_NULL; --- LVM2/lib/metadata/merge.c 2011/09/06 00:26:43 1.46 +++ LVM2/lib/metadata/merge.c 2011/09/06 22:43:57 1.47 @@ -313,7 +313,7 @@ if (!(split_seg = alloc_lv_segment(lv->vg->vgmem, seg->segtype, seg->lv, seg->le, seg->len, seg->status, seg->stripe_size, - seg->log_lv, seg->thin_pool_lv, + seg->log_lv, seg->pool_lv, seg->area_count, seg->area_len, seg->chunk_size, seg->region_size, seg->extents_copied, seg->pvmove_source_seg))) { --- LVM2/lib/metadata/metadata-exported.h 2011/09/06 19:25:43 1.206 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/06 22:43:57 1.207 @@ -85,6 +85,8 @@ #define THIN_VOLUME UINT64_C(0x0000001000000000) /* LV */ #define THIN_POOL UINT64_C(0x0000002000000000) /* LV */ +#define THIN_POOL_DATA UINT64_C(0x0000002000000000) /* LV */ +#define THIN_POOL_METADATA UINT64_C(0x0000004000000000) /* LV */ #define LVM_READ 0x00000100U /* LV VG 32-bit */ #define LVM_WRITE 0x00000200U /* LV VG 32-bit */ @@ -134,6 +136,8 @@ #define lv_is_thin_volume(lv) ((lv)->status & THIN_VOLUME ? 1 : 0) #define lv_is_thin_pool(lv) ((lv)->status & THIN_POOL ? 1 : 0) +#define lv_is_thin_pool_data(lv) ((lv)->status & THIN_POOL_DATA ? 1 : 0) +#define lv_is_thin_pool_metadata(lv) ((lv)->status & THIN_POOL_METADATA ? 1 : 0) #define lv_is_mirrored(lv) ((lv)->status & MIRRORED ? 1 : 0) #define lv_is_rlog(lv) ((lv)->status & REPLICATOR_LOG ? 1 : 0) @@ -322,12 +326,12 @@ struct dm_list tags; struct lv_segment_area *areas; - struct lv_segment_area *meta_areas; /* For RAID */ - struct logical_volume *pool_lv; /* For thin_pool */ - struct logical_volume *metadata_lv; /* For thin_pool */ + struct lv_segment_area *meta_areas; /* For RAID */ + struct logical_volume *pool_data_lv; /* For thin_pool */ + struct logical_volume *pool_metadata_lv;/* For thin_pool */ uint64_t transaction_id; /* For thin_pool */ uint32_t zero_new_blocks; /* For thin_pool */ - struct logical_volume *thin_pool_lv; /* For thin */ + struct logical_volume *pool_lv; /* For thin */ uint64_t device_id; /* For thin */ struct logical_volume *replicator;/* For replicator-devs - link to replicator LV */ --- LVM2/lib/metadata/metadata.h 2011/09/06 19:25:43 1.253 +++ LVM2/lib/metadata/metadata.h 2011/09/06 22:43:57 1.254 @@ -442,9 +442,11 @@ /* * From thin_manip.c */ -int attach_pool_metadata(struct lv_segment *seg, - struct logical_volume *thin_pool_metadata); -int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv); +int attach_pool_metadata_lv(struct lv_segment *seg, + struct logical_volume *pool_metadata_lv); +int attach_pool_data_lv(struct lv_segment *seg, + struct logical_volume *pool_data_lv); +int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv); /* * Begin skeleton for external LVM library --- LVM2/lib/metadata/thin_manip.c 2011/09/06 19:25:43 1.1 +++ LVM2/lib/metadata/thin_manip.c 2011/09/06 22:43:57 1.2 @@ -15,19 +15,28 @@ #include "lib.h" #include "metadata.h" -int attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata) +int attach_pool_metadata_lv(struct lv_segment *seg, struct logical_volume *pool_metadata_lv) { - // FIXME Housekeeping needed here (cf attach_mirror_log) - seg->metadata_lv = thin_pool_metadata; + seg->pool_metadata_lv = pool_metadata_lv; + pool_metadata_lv->status |= THIN_POOL_METADATA; + lv_set_hidden(pool_metadata_lv); - return 1; + return add_seg_to_segs_using_this_lv(pool_metadata_lv, seg); } -int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv) +int attach_pool_data_lv(struct lv_segment *seg, struct logical_volume *pool_data_lv) { - // FIXME Housekeeping needed here (cf attach_mirror_log) - seg->thin_pool_lv = thin_pool_lv; + seg->pool_data_lv = pool_data_lv; + pool_data_lv->status |= THIN_POOL_DATA; + lv_set_hidden(pool_data_lv); - return 1; + return add_seg_to_segs_using_this_lv(pool_data_lv, seg); } +int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv) +{ + seg->pool_lv = pool_lv; + pool_lv->status |= THIN_POOL; + + return add_seg_to_segs_using_this_lv(pool_lv, seg); +} --- LVM2/lib/thin/thin.c 2011/09/06 22:35:44 1.10 +++ LVM2/lib/thin/thin.c 2011/09/06 22:43:57 1.11 @@ -47,21 +47,26 @@ struct dm_hash_table *pv_hash __attribute__((unused))) { const char *lv_name; + struct logical_volume *pool_data_lv, *pool_metadata_lv; if (!dm_config_get_str(sn, "pool", &lv_name)) return SEG_LOG_ERROR("Pool must be a string in"); -// Use attach_pool_lv - if (!(seg->pool_lv = find_lv(seg->lv->vg, lv_name))) + if (!(pool_data_lv = find_lv(seg->lv->vg, lv_name))) return SEG_LOG_ERROR("Unknown pool %s in", lv_name); if (!dm_config_get_str(sn, "metadata", &lv_name)) return SEG_LOG_ERROR("Metadata must be a string in"); -// Use attach_pool_metadata() - if (!(seg->metadata_lv = find_lv(seg->lv->vg, lv_name))) + if (!(pool_metadata_lv = find_lv(seg->lv->vg, lv_name))) return SEG_LOG_ERROR("Unknown metadata %s in", lv_name); + if (!attach_pool_metadata_lv(seg, pool_metadata_lv)) + return_0; + + if (!attach_pool_data_lv(seg, pool_data_lv)) + return_0; + if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id)) return SEG_LOG_ERROR("Could not read transaction_id for"); @@ -74,8 +79,8 @@ static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter *f) { - outf(f, "pool = \"%s\"", seg->pool_lv->name); - outf(f, "metadata = \"%s\"", seg->metadata_lv->name); + outf(f, "pool = \"%s\"", seg->pool_data_lv->name); + outf(f, "metadata = \"%s\"", seg->pool_metadata_lv->name); outf(f, "transaction_id = %" PRIu64, seg->transaction_id); if (seg->zero_new_blocks) outf(f, "zero_new_blocks = 1"); @@ -92,13 +97,17 @@ struct dm_hash_table *pv_hash __attribute__((unused))) { const char *lv_name; + struct logical_volume *pool_lv; if (!dm_config_get_str(sn, "thin_pool", &lv_name)) return SEG_LOG_ERROR("Thin pool must be a string in"); - if (!(seg->thin_pool_lv = find_lv(seg->lv->vg, lv_name))) + if (!(pool_lv = find_lv(seg->lv->vg, lv_name))) return SEG_LOG_ERROR("Unknown thin pool %s in", lv_name); + if (!attach_pool_lv(seg, pool_lv)) + return_0; + if (dm_config_has_node(sn, "origin")) { if (!dm_config_get_str(sn, "origin", &lv_name)) return SEG_LOG_ERROR("Origin must be a string in"); @@ -115,7 +124,7 @@ static int _thin_text_export(const struct lv_segment *seg, struct formatter *f) { - outf(f, "thin_pool = \"%s\"", seg->thin_pool_lv->name); + outf(f, "thin_pool = \"%s\"", seg->pool_lv->name); outf(f, "device_id = %" PRIu64, seg->device_id); if (seg->origin) --- LVM2/tools/lvcreate.c 2011/09/06 19:25:42 1.237 +++ LVM2/tools/lvcreate.c 2011/09/06 22:43:58 1.238 @@ -198,13 +198,12 @@ return 0; } - /* FIXME Replace with lv_is_thin_volume() once more flags are added */ if (lv_is_thin_volume(lvl->lv)) { lp->thin = 1; if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin"))) return_0; - lp->pool = first_seg(lvl->lv)->thin_pool_lv->name; + lp->pool = first_seg(lvl->lv)->pool_lv->name; } if (!lp->thin && !arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) { From zkabelac@sourceware.org Wed Sep 7 08:31:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 07 Sep 2011 08:31:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/vgimportclone.sh test ... Message-ID: <20110907083119.16078.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-07 08:31:17 Modified files: . : WHATS_NEW scripts : vgimportclone.sh test : t-vgimportclone.sh Log message: Replace char class :space: with explicit chars Some major distributions are still using 'mawk' and they are not using the latest version - we end here with hidden dependency on the latest version of mawk (1.3.4) while i.e. Debian Lenny seems to stay with 1.3.3. So we end with completely broken vgimportclone script on such system. We would need to check for proper support of :space: and abort build if it doesn't work or simplier replace [:space:] with [ \t] which seems sufficient to make it work (as can be seen in this patch) A better fix would be to use command line parameter override - leaving as FIXME comment. This patch makes t-vgimportclone.sh test passing on Lenny. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2094&r2=1.2095 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/vgimportclone.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgimportclone.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/WHATS_NEW 2011/09/06 18:49:31 1.2094 +++ LVM2/WHATS_NEW 2011/09/07 08:31:16 1.2095 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Replace :space: with [\t ] for awk in vgimportclone (not widely supported). Begin using 64-bit status field flags. Detect sscanf recovering_region input error in cmirrord pull_state(). Fix error path bitmap leak in cmirrord import_checkpoint(). --- LVM2/scripts/vgimportclone.sh 2010/05/14 11:33:21 1.3 +++ LVM2/scripts/vgimportclone.sh 2011/09/07 08:31:17 1.4 @@ -242,13 +242,14 @@ LVMCONF=${TMP_LVM_SYSTEM_DIR}/lvm.conf +# FIXME convert to cmdline override "$LVM" dumpconfig ${LVM_OPTS} | \ "$AWK" -v DEV=${TMP_LVM_SYSTEM_DIR} -v CACHE=${TMP_LVM_SYSTEM_DIR}/.cache \ -v CACHE_DIR=${TMP_LVM_SYSTEM_DIR}/cache \ - '/^[[:space:]]*filter[[:space:]]*=/{print ENVIRON["FILTER"];next} \ - /^[[:space:]]*scan[[:space:]]*=/{print "scan = [ \"" DEV "\" ]";next} \ - /^[[:space:]]*cache[[:space:]]*=/{print "cache = \"" CACHE "\"";next} \ - /^[[:space:]]*cache_dir[[:space:]]*=/{print "cache_dir = \"" CACHE_DIR "\"";next} \ + '/^[ \t]*filter[ \t]*=/{print ENVIRON["FILTER"];next} \ + /^[ \t]*scan[ \t]*=/{print "scan = [ \"" DEV "\" ]";next} \ + /^[ \t]*cache[ \t]*=/{print "cache = \"" CACHE "\"";next} \ + /^[ \t]*cache_dir[ \t]*=/{print "cache_dir = \"" CACHE_DIR "\"";next} \ {print $0}' > ${LVMCONF} checkvalue $? "Failed to generate ${LVMCONF}" @@ -282,7 +283,7 @@ # output VG info so each line looks like: name:exported?:disk1,disk2,... VGINFO=`echo "${PVINFO}" | \ - "$AWK" -F : '{{sub(/^[[:space:]]*/,"")} \ + "$AWK" -F : '{{sub(/^[ \t]*/,"")} \ {sub(/unknown device/,"unknown_device")} \ {vg[$2]=$1","vg[$2]} if($3 ~ /^..x/){x[$2]="x"}} \ END{for(k in vg){printf("%s:%s:%s\n", k, x[k], vg[k])}}'` --- LVM2/test/t-vgimportclone.sh 2011/04/21 19:06:00 1.2 +++ LVM2/test/t-vgimportclone.sh 2011/09/07 08:31:17 1.3 @@ -1,4 +1,4 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -12,25 +12,19 @@ aux prepare_devs 2 -pvcreate $dev1 $dev2 -vgcreate $vg1 $dev1 +vgcreate -c n --metadatasize 128k $vg1 $dev1 lvcreate -l100%FREE -n $lv1 $vg1 # Clone the LUN -dd if=$dev1 of=$dev2 +dd if=$dev1 of=$dev2 bs=256K count=1 # Verify pvs works on each device to give us vgname -pvs --noheadings -o vg_name $dev1 1>err -grep $vg1 err -pvs --noheadings -o vg_name $dev2 1>err -grep $vg1 err +check pv_field $dev1 vg_name $vg1 +check pv_field $dev2 vg_name $vg1 # Import the cloned PV to a new VG -# FIXME: this fails on lenny buildslave, I think we need proper wrapper -# vgimportclone --basevgname $vg2 $dev2 +vgimportclone --basevgname $vg2 $dev2 # Verify we can activate / deactivate the LV from both VGs -# lvchange -ay $vg1/$lv1 -# lvchange -ay $vg2/$lv1 -# vgchange -an $vg1 -# vgchange -an $vg2 +lvchange -ay $vg1/$lv1 $vg2/$lv1 +vgchange -an $vg1 $vg2 From zkabelac@sourceware.org Wed Sep 7 08:34:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 07 Sep 2011 08:34:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ... Message-ID: <20110907083423.20624.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-07 08:34:22 Modified files: . : WHATS_NEW lib/metadata : metadata-exported.h metadata.c Log message: Minor change for pv_create api Switch int to unsigned type. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2095&r2=1.2096 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.207&r2=1.208 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.466&r2=1.467 --- LVM2/WHATS_NEW 2011/09/07 08:31:16 1.2095 +++ LVM2/WHATS_NEW 2011/09/07 08:34:21 1.2096 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Switch int to unsigned type for pvmetadatacopies for pv_create(). Replace :space: with [\t ] for awk in vgimportclone (not widely supported). Begin using 64-bit status field flags. Detect sscanf recovering_region input error in cmirrord pull_state(). --- LVM2/lib/metadata/metadata-exported.h 2011/09/06 22:43:57 1.207 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/07 08:34:22 1.208 @@ -455,7 +455,7 @@ uint32_t existing_extent_count, uint32_t existing_extent_size, uint64_t label_sector, - int pvmetadatacopies, + unsigned pvmetadatacopies, uint64_t pvmetadatasize, unsigned metadataignore); int pv_resize(struct physical_volume *pv, struct volume_group *vg, --- LVM2/lib/metadata/metadata.c 2011/08/30 14:55:17 1.466 +++ LVM2/lib/metadata/metadata.c 2011/09/07 08:34:22 1.467 @@ -1621,7 +1621,7 @@ uint32_t existing_extent_count, uint32_t existing_extent_size, uint64_t label_sector, - int pvmetadatacopies, + unsigned pvmetadatacopies, uint64_t pvmetadatasize, unsigned metadataignore) { From zkabelac@sourceware.org Wed Sep 7 08:37:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 07 Sep 2011 08:37:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdm-deptree.c Message-ID: <20110907083749.25465.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-07 08:37:48 Modified files: . : WHATS_NEW_DM libdm : libdm-deptree.c Log message: Remove unused passed parameters Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.497&r2=1.498 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.108&r2=1.109 --- LVM2/WHATS_NEW_DM 2011/09/01 21:04:14 1.497 +++ LVM2/WHATS_NEW_DM 2011/09/07 08:37:48 1.498 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Remove unused passed parameters for _mirror_emit_segment_line(). Add dm_config and string character escaping functions to libdevmapper. Mark unreleased memory pools as internal error. --- LVM2/libdm/libdm-deptree.c 2011/08/19 17:02:48 1.108 +++ LVM2/libdm/libdm-deptree.c 2011/09/07 08:37:48 1.109 @@ -1594,10 +1594,8 @@ /* * Returns: 1 on success, 0 on failure */ -static int _mirror_emit_segment_line(struct dm_task *dmt, uint32_t major, - uint32_t minor, struct load_segment *seg, - uint64_t *seg_start, char *params, - size_t paramsize) +static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *seg, + char *params, size_t paramsize) { int block_on_error = 0; int handle_errors = 0; @@ -1784,8 +1782,7 @@ break; case SEG_MIRRORED: /* Mirrors are pretty complicated - now in separate function */ - r = _mirror_emit_segment_line(dmt, major, minor, seg, seg_start, - params, paramsize); + r = _mirror_emit_segment_line(dmt, seg, params, paramsize); if (!r) return_0; break; From zkabelac@sourceware.org Wed Sep 7 08:41:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 07 Sep 2011 08:41:00 -0000 Subject: LVM2 ./WHATS_NEW tools/toollib.c tools/vgchange.c Message-ID: <20110907084149.13250.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-07 08:41:48 Modified files: . : WHATS_NEW tools : toollib.c vgchange.c Log message: Support break for vgchange and vgrefresh operation Allow to break some lengthy vgchange and vgrefresh operation. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2096&r2=1.2097 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.229&r2=1.230 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122 --- LVM2/WHATS_NEW 2011/09/07 08:34:21 1.2096 +++ LVM2/WHATS_NEW 2011/09/07 08:41:47 1.2097 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Support break for vgchange and vgrefresh operation. Switch int to unsigned type for pvmetadatacopies for pv_create(). Replace :space: with [\t ] for awk in vgimportclone (not widely supported). Begin using 64-bit status field flags. --- LVM2/tools/toollib.c 2011/08/30 14:55:19 1.229 +++ LVM2/tools/toollib.c 2011/09/07 08:41:48 1.230 @@ -1323,10 +1323,17 @@ struct lv_list *lvl; int r = 1; - dm_list_iterate_items(lvl, &vg->lvs) + sigint_allow(); + dm_list_iterate_items(lvl, &vg->lvs) { + if (sigint_caught()) + return_0; + if (lv_is_visible(lvl->lv)) if (!lv_refresh(cmd, lvl->lv)) r = 0; + } + + sigint_restore(); return r; } --- LVM2/tools/vgchange.c 2011/06/11 00:03:08 1.121 +++ LVM2/tools/vgchange.c 2011/09/07 08:41:48 1.122 @@ -90,7 +90,11 @@ struct logical_volume *lv; int count = 0, expected_count = 0; + sigint_allow(); dm_list_iterate_items(lvl, &vg->lvs) { + if (sigint_caught()) + return_0; + lv = lvl->lv; if (!lv_is_visible(lv)) @@ -160,6 +164,8 @@ count++; } + sigint_restore(); + if (expected_count) log_verbose("%s %d logical volumes in volume group %s", (activate == CHANGE_AN || activate == CHANGE_ALN)? From zkabelac@sourceware.org Wed Sep 7 08:50:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 07 Sep 2011 08:50:00 -0000 Subject: LVM2 ./WHATS_NEW man/fsadm.8.in man/lvreduce.8 ... Message-ID: <20110907085037.15123.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-07 08:50:36 Modified files: . : WHATS_NEW man : fsadm.8.in lvreduce.8.in lvremove.8.in lvrename.8.in lvresize.8.in Log message: Improve man page style Only reformat man pages. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2097&r2=1.2098 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/fsadm.8.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvreduce.8.in.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvremove.8.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvrename.8.in.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvresize.8.in.diff?cvsroot=lvm2&r1=1.9&r2=1.10 --- LVM2/WHATS_NEW 2011/09/07 08:41:47 1.2097 +++ LVM2/WHATS_NEW 2011/09/07 08:50:35 1.2098 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Improve man page style for fsadm, lvreduce, lvremove, lvrename, lvresize. Support break for vgchange and vgrefresh operation. Switch int to unsigned type for pvmetadatacopies for pv_create(). Replace :space: with [\t ] for awk in vgimportclone (not widely supported). --- LVM2/man/fsadm.8.in 2010/11/01 14:10:46 1.4 +++ LVM2/man/fsadm.8.in 2011/09/07 08:50:35 1.5 @@ -1,64 +1,74 @@ .TH "FSADM" "8" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\"" .SH "NAME" fsadm \- utility to resize or check filesystem on a device -.SH "SYNOPSIS" +.SH SYNOPSIS .B fsadm -.RI [options]\ check\ device - +.RI [ options ] +.B check +.I device +.sp .B fsadm -.RI [options]\ resize\ device\ [new_size[BKMGTEP]] - -.SH "DESCRIPTION" -\fBfsadm\fR utility resizes or checks the filesystem on a device. -It tries to use the same API for \fBext2/ext3/ext4\fR, -\fBReiserFS\fR and \fBXFS\fR filesystem. -.SH "OPTIONS" +.RI [ options ] +.B resize +.I device +.RI [ new_size [ BKMGTEP ]] +.sp +.SH DESCRIPTION +.B fsadm +utility checks or resizes the filesystem on a device. +It tries to use the same API for +.IR ext2 , ext3 , ext4 , ReiserFS +and \fIXFS\fP filesystem. +.SH OPTIONS .TP -\fB\-h \-\-help\fR -\(em print help message +.BR \-h ", " \-\-help +Display the help text. .TP -\fB\-v \-\-verbose\fR -\(em be more verbose +.BR \-v ", " \-\-verbose +Be more verbose. .TP -\fB\-e \-\-ext\-offline\fR -\(em unmount ext2/ext3/ext4 filesystem before doing resize +.BR \-e ", " \-\-ext\-offline +Unmount ext2/ext3/ext4 filesystem before doing resize. .TP -\fB\-f \-\-force\fR -\(em bypass some sanity checks +.BR \-f ", " \-\-force +Bypass some sanity checks. .TP -\fB\-n \-\-dry\-run\fR -\(em print commands without running them +.BR \-n ", " \-\-dry\-run +Print commands without running them. .TP -\fB\-y \-\-yes\fR -\(em answer "yes" at any prompts +.BR \-y ", " \-\-yes +Answer "yes" at any prompts. .TP -\fBnew_size\fR -\(em Absolute number of filesystem blocks to be in the filesystem, +.I new_size +Absolute number of filesystem blocks to be in the filesystem, or an absolute size using a suffix (in powers of 1024). If new_size is not supplied, the whole device is used. -.SH "DIAGNOSTICS" +.SH DIAGNOSTICS On successful completion, the status code is 0. A status code of 2 indicates the operation was interrupted by the user. A status code of 3 indicates the requested check operation could not be performed -because the filesystem is mounted and does not support an online fsck. +because the filesystem is mounted and does not support an online +.BR fsck (8). A status code of 1 is used for other failures. -.SH "EXAMPLES" -"fsadm \-e \-y resize /dev/vg/test 1000M" tries to resize the filesystem -on logical volume /dev/vg/test. If /dev/vg/test contains ext2/ext3/ext4 +.SH EXAMPLES +Resize the filesystem on logical volume /dev/vg/test to 1000 megabytes. +If /dev/vg/test contains ext2/ext3/ext4 filesystem it will be unmounted prior the resize. All [y|n] questions will be answered 'y'. -.SH "ENVIRONMENT VARIABLES" +.sp +.B fsadm \-e \-y resize /dev/vg/test 1000M +.SH ENVIRONMENT VARIABLES .TP -\fBTMPDIR\fP -Where the temporary directory should be created. -.TP -.BR -.SH "SEE ALSO" +.B TMPDIR +The temporary directory name for mount points. Defaults to "/tmp". + +.SH SEE ALSO .BR lvm (8), .BR lvresize (8), .BR lvm.conf (5), +.BR fsck (8), .BR tune2fs (8), .BR resize2fs (8), .BR reiserfstune (8), --- LVM2/man/lvreduce.8.in 2010/06/21 15:56:59 1.8 +++ LVM2/man/lvreduce.8.in 2011/09/07 08:50:35 1.9 @@ -3,15 +3,22 @@ lvreduce \- reduce the size of a logical volume .SH SYNOPSIS .B lvreduce -[\-A|\-\-autobackup y|n] [\-d|\-\-debug] [\-f|\-\-force] -[\-h|\-?|\-\-help] -[\-\-noudevsync] -{\-l|\-\-extents [\-]LogicalExtentsNumber[%{VG|LV|FREE|ORIGIN}] | -\-L|\-\-size [\-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]} -[\-n|\-\-nofsck] -[\-r|\-\-resizefs] -[\-t|\-\-test] -[\-v|\-\-verbose] LogicalVolume[Path] +.RB [ \-A | \-\-autobackup +.RI { y | n }] +.RB [ \-d | \-\-debug ] +.RB [ \-h | \-\-help ] +.RB [ \-t | \-\-test ] +.RB [ \-v | \-\-verbose ] +.RB [ \-\-version ] +.RB [ \-f | \-\-force ] +.RB [ \-\-noudevsync ] +.RB { \-l | \-\-extents +.RI [ \- ] LogicalExtentsNumber [ % { VG | LV | FREE | ORIGIN "}] |" +.RB [ \-L | \-\-size +.RI [ \- ] LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]} +.RB [ \-n | \-\-nofsck ] +.RB [ \-r | \-\-resizefs ] +.IR LogicalVolume { Name | Path } .SH DESCRIPTION lvreduce allows you to reduce the size of a logical volume. Be careful when reducing a logical volume's size, because data in the @@ -23,61 +30,64 @@ running lvreduce so that the extents that are to be removed are not in use. .br Shrinking snapshot logical volumes (see -.B lvcreate(8) +.BR lvcreate (8) for information to create snapshots) is supported as well. But to change the number of copies in a mirrored logical volume use -.B lvconvert (8). +.BR lvconvert (8). .br Sizes will be rounded if necessary - for example, the volume size must be an exact number of extents and the size of a striped segment must be a multiple of the number of stripes. .br .SH OPTIONS -See \fBlvm\fP for common options. +See +.BR lvm (8) +for common options. .TP -.I \-f, \-\-force +.BR \-f ", " \-\-force Force size reduction without prompting even when it may cause data loss. .TP -.I \-\-noudevsync +.BR \-\-noudevsync Disable udev synchronisation. The process will not wait for notification from udev. It will continue irrespective of any possible udev processing in the background. You should only use this if udev is not running or has rules that ignore the devices LVM2 creates. .TP -.I \-l, \-\-extents [\-]LogicalExtentsNumber[%{VG|LV|FREE|ORIGIN}] +.IR \fB\-l ", " \fB\-\-extents " [" \- ] LogicalExtentsNumber [ % { VG | LV | FREE | ORIGIN }] Reduce or set the logical volume size in units of logical extents. -With the - sign the value will be subtracted from +With the \fI-\fP sign the value will be subtracted from the logical volume's actual size and without it the value will be taken as an absolute size. The number can also be expressed as a percentage of the total space -in the Volume Group with the suffix %VG, relative to the existing -size of the Logical Volume with the suffix %LV, as a percentage of the -remaining free space in the Volume Group with the suffix %FREE, or (for +in the Volume Group with the suffix \fI%VG\fP, relative to the existing +size of the Logical Volume with the suffix \fI%LV\fP, as a percentage of the +remaining free space in the Volume Group with the suffix \fI%FREE\fP, or (for a snapshot) as a percentage of the total space in the Origin Logical -Volume with the suffix %ORIGIN. +Volume with the suffix \fI%ORIGIN\fP. .TP -.I \-L, \-\-size [\-]LogicalVolumeSize[bBsSkKmMgGtTpPeE] +.IR \fB\-L ", " \fB\-\-size " [" \- ] LogicalVolumeSize [ bBsSkKmMgGtTpPeE ] Reduce or set the logical volume size in units of megabytes. -A size suffix of k for kilobyte, m for megabyte, -g for gigabytes, t for terabytes, p for petabytes -or e for exabytes is optional. -With the - sign the value will be subtracted from +A size suffix of \fIk\fP for kilobyte, \fIm\fP for megabyte, +\fIg\fP for gigabytes, \fIt\fP for terabytes, \fIp\fP for petabytes +or \fIe\fP for exabytes is optional. +With the \fI-\fP sign the value will be subtracted from the logical volume's actual size and without it it will be taken as an absolute size. .TP -.I \-n, \-\-nofsck +.BR \-n ", " \-\-nofsck Do not perform fsck before resizing filesystem when filesystem requires it. You may need to use \fB--force\fR to proceed with this option. .TP -.I \-r, \-\-resizefs +.BR \-r ", " \-\-resizefs Resize underlying filesystem together with the logical volume using -\fBfsadm\fR(8). -.SH Example -"lvreduce -l -3 vg00/lvol1" reduces the size of logical volume lvol1 -in volume group vg00 by 3 logical extents. +.BR fsadm (8). +.SH EXAMPLES +Reduce the size of logical volume lvol1 in volume group vg00 by 3 logical extents: +.sp +.B lvreduce -l -3 vg00/lvol1 .SH SEE ALSO .BR fsadm (8), .BR lvchange (8), --- LVM2/man/lvremove.8.in 2009/08/04 08:09:52 1.4 +++ LVM2/man/lvremove.8.in 2011/09/07 08:50:35 1.5 @@ -3,11 +3,17 @@ lvremove \- remove a logical volume .SH SYNOPSIS .B lvremove -[\-A|\-\-autobackup y|n] [\-d|\-\-debug] [\-f|\-\-force] -[\-h|\-?|\-\-help] -[\-\-noudevsync] -[\-t|\-\-test] -[\-v|\-\-verbose] LogicalVolumePath [LogicalVolumePath...] +.RB [ \-A | \-\-autobackup +.RI { y | n }] +.RB [ \-d | \-\-debug ] +.RB [ \-h | \-\-help ] +.RB [ \-t | \-\-test ] +.RB [ \-v | \-\-verbose ] +.RB [ \-\-version ] +.RB [ \-f | \-\-force ] +.RB [ \-\-noudevsync ] +.IR LogicalVolume { Name | Path } +.RI [ LogicalVolume { Name | Path }...] .SH DESCRIPTION \fBlvremove\fP removes one or more logical volumes. Confirmation will be requested before deactivating any active logical @@ -21,10 +27,10 @@ .SH OPTIONS See \fBlvm\fP(8) for common options. .TP -.I \-f, \-\-force +.BR \-f ", " \-\-force Remove active logical volumes without confirmation. .TP -.I \-\-noudevsync +.B \-\-noudevsync Disable udev synchronisation. The process will not wait for notification from udev. It will continue irrespective of any possible udev processing @@ -34,11 +40,11 @@ Remove the active logical volume lvol1 in volume group vg00 without asking for confirmation: .sp -\ \fBlvremove -f vg00/lvol1\fP +.B lvremove -f vg00/lvol1 .sp Remove all logical volumes in volume group vg00: .sp -\ \fBlvremove vg00\fP +.B lvremove vg00 .SH SEE ALSO .BR lvcreate (8), .BR lvdisplay (8), --- LVM2/man/lvrename.8.in 2011/08/04 10:14:42 1.3 +++ LVM2/man/lvrename.8.in 2011/09/07 08:50:35 1.4 @@ -3,17 +3,20 @@ lvrename \- rename a logical volume .SH SYNOPSIS .B lvrename -.RB [ \-A | \-\-autobackup " {" y | n }] +.RB [ \-A | \-\-autobackup +.RI { y | n }] .RB [ \-d | \-\-debug ] .RB [ \-h | \-\-help ] -.RB [ \-\-noudevsync ] .RB [ \-t | \-\-test ] .RB [ \-v | \-\-verbose ] .RB [ \-\-version ] -.TP -.IR "OldLogicalVolumePath NewLogicalVolume" { Path | Name } -.TP +.RB [ \-f | \-\-force ] +.RB [ \-\-noudevsync ] +.RI { OldLogicalVolume { Name | Path } +.IR NewLogicalVolume { Name | Path } +| .I VolumeGroupName OldLogicalVolumeName NewLogicalVolumeName +} .SH DESCRIPTION .B lvrename renames an existing logical volume from @@ -21,7 +24,7 @@ to .IR NewLogicalVolume { Name | Path }. .SH OPTIONS -See \fBlvm\fP for common options. +See \fBlvm\fP(8) for common options. .TP .BR \-\-noudevsync Disable udev synchronisation. The @@ -30,23 +33,14 @@ in the background. You should only use this if udev is not running or has rules that ignore the devices LVM2 creates. .SH EXAMPLE -To rename -.B lvold -in volume group -.B vg02 -to -.BR lvnew : -.nf - -\ lvrename /dev/vg02/lvold /dev/vg02/lvnew - -.fi -An alternate syntax to rename this logical volume is -.nf - -\ lvrename vg02 lvold lvnew - -.fi +To rename lvold in volume group vg02 to lvnew: +.sp +.B lvrename /dev/vg02/lvold vg02/lvnew +.sp +An alternate syntax to rename this logical volume is: +.sp +.B lvrename vg02 lvold lvnew +.sp .SH SEE ALSO .BR lvm (8), .BR lvchange (8), --- LVM2/man/lvresize.8.in 2010/06/21 15:56:59 1.9 +++ LVM2/man/lvresize.8.in 2011/09/07 08:50:35 1.10 @@ -3,17 +3,19 @@ lvresize \- resize a logical volume .SH SYNOPSIS .B lvresize -[\-\-alloc AllocationPolicy] -[\-A|\-\-autobackup y|n] [\-d|\-\-debug] [\-h|\-?|\-\-help] -[\-\-noudevsync] -[\-i|\-\-stripes Stripes [\-I|\-\-stripesize StripeSize]] -{\-l|\-\-extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] | -\-L|\-\-size [+]LogicalVolumeSize[bBsSkKmMgGtTpPeE]} -[\-f|\-\-force] -[\-n|\-\-nofsck] -[\-r|\-\-resizefs] -[\-t|\-\-test] -[\-v|\-\-verbose] LogicalVolumePath [PhysicalVolumePath[:PE[-PE]]...] +.RB [ \-\-alloc " " \fIAllocationPolicy ] +.RB [ \-\-noudevsync ] +.RB [ \-i | \-\-stripes " " \fIStripes +.RB [ \-I | \-\-stripesize " " \fIStripeSize ]] +.RB {[ \-l | \-\-extents +.RI [ + | \- ] LogicalExtentsNumber [ % { VG | LV | PVS | FREE | ORIGIN "}] |" +.RB [ \-L | \-\-size +.RI [ + | \- ] LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]} +.RB [ \-f | \-\-force ] +.RB [ \-n | \-\-nofsck ] +.RB [ \-r | \-\-resizefs ] +.IR LogicalVolume { Name | Path } +.RI [ PhysicalVolumePath [ :PE [ -PE ]]...] .SH DESCRIPTION lvresize allows you to resize a logical volume. Be careful when reducing a logical volume's size, because data in the reduced @@ -21,74 +23,73 @@ You should therefore ensure that any filesystem on the volume is shrunk first so that the extents that are to be removed are not in use. Resizing snapshot logical volumes (see -.B lvcreate(8) +.BR lvcreate (8) for information about creating snapshots) is supported as well. But to change the number of copies in a mirrored logical volume use .BR lvconvert (8). .SH OPTIONS -See \fBlvm\fP for common options. +See \fBlvm\fP(8) for common options. .TP -.I \-f, \-\-force +.BR \-f ", " \-\-force Force resize without prompting even when it may cause data loss. .TP -.I \-l, \-\-extents [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE|ORIGIN}] -Change or set the logical volume size in units of logical extents. -With the + or - sign the value is added to or subtracted from the actual size -of the logical volume and without it, the value is taken as an absolute one. -The number can also be expressed as a percentage of the total space -in the Volume Group with the suffix %VG, relative to the existing -size of the Logical Volume with the suffix %LV, as a percentage of -the remaining free space of the PhysicalVolumes on the command line with the -suffix %PVS, as a percentage of the remaining free space in the -Volume Group with the suffix %FREE, or (for a snapshot) as a percentage -of the total space in the Origin Logical Volume with the suffix %ORIGIN. -.TP -.I \-n, \-\-nofsck +.BR \-n ", " \-\-nofsck Do not perform fsck before resizing filesystem when filesystem requires it. You may need to use \fB--force\fR to proceed with this option. .TP -.I \-\-noudevsync -Disable udev synchronisation. The -process will not wait for notification from udev. -It will continue irrespective of any possible udev processing -in the background. You should only use this if udev is not running -or has rules that ignore the devices LVM2 creates. -.TP -.I \-r, \-\-resizefs +.BR \-r ", " \-\-resizefs Resize underlying filesystem together with the logical volume using \fBfsadm\fR(8). .TP -.I \-L, \-\-size [+|-]LogicalVolumeSize[bBsSkKmMgGtTpPeE] +.IR \fB\-l ", " \fB\-\-extents " [" + | - ] LogicalExtentsNumber [ % { VG | LV | PVS | FREE | ORIGIN }] +Change or set the logical volume size in units of logical extents. +With the \fI+\fP or \fI-\fP sign the value is added to or subtracted from the actual size +of the logical volume and without it, the value is taken as an absolute one. +The number can also be expressed as a percentage of the total space +in the Volume Group with the suffix \fI%VG\fP, relative to the existing +size of the Logical Volume with the suffix \fI%LV\fP, as a percentage of +the remaining free space of the PhysicalVolumes on the command line with the +suffix \fI%PVS\fP, as a percentage of the remaining free space in the +Volume Group with the suffix \fI%FREE\fP, or (for a snapshot) as a percentage +of the total space in the Origin Logical Volume with the suffix \fI%ORIGIN\fP. +.TP +.IR \fB\-L ", " \fB\-\-size " [" + | - ] LogicalVolumeSize [ bBsSkKmMgGtTpPeE ] Change or set the logical volume size in units of megabytes. -A size suffix of M for megabytes, -G for gigabytes, T for terabytes, P for petabytes -or E for exabytes is optional. -With the + or - sign the value is added to or subtracted from +A size suffix of \fIM\fP for megabytes, +\fIG\fP for gigabytes, \fIT\fP for terabytes, \fIP\fP for petabytes +or \fIE\fP for exabytes is optional. +With the \fI+\fP or \fI-\fP sign the value is added to or subtracted from the actual size of the logical volume and without it, the value is taken as an absolute one. .TP -.I \-i, \-\-stripes Stripes +.BR \-i ", " \-\-stripes " " \fIStripes Gives the number of stripes to use when extending a Logical Volume. Defaults to whatever the last segment of the Logical Volume uses. Not applicable to LVs using the original metadata LVM format, which must use a single value throughout. .TP -.I \-I, \-\-stripesize StripeSize +.BR \-I ", " \-\-stripesize " " \fIStripeSize Gives the number of kilobytes for the granularity of the stripes. Defaults to whatever the last segment of the Logical Volume uses. Not applicable to LVs using the original metadata LVM format, which must use a single value throughout. .br -StripeSize must be 2^n (n = 2 to 9) -.SH Examples -.br -"lvresize -L+16M vg1/lv1 /dev/sda:0-1 /dev/sdb:0-1" +StripeSize must be 2^n (n = 2 to 9). +.TP +.B \-\-noudevsync +Disable udev synchronisation. The +process will not wait for notification from udev. +It will continue irrespective of any possible udev processing +in the background. You should only use this if udev is not running +or has rules that ignore the devices LVM2 creates. +.SH EXAMPLES .br -tries to extend a logical volume "vg1/lv1" by 16MB using physical extents -/dev/sda:0-1 and /dev/sdb:0-1 for allocation of extents. - +Extend a logical volume vg1/lv1 by 16MB using physical extents +/dev/sda:0-1 and /dev/sdb:0-1 for allocation of extents: +.sp +.B lvresize -L+16M vg1/lv1 /dev/sda:0-1 /dev/sdb:0-1 .SH SEE ALSO .BR fsadm (8), .BR lvm (8), From zkabelac@sourceware.org Wed Sep 7 09:25:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 07 Sep 2011 09:25:00 -0000 Subject: LVM2/tools lvcreate.c Message-ID: <20110907092552.25686.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-07 09:25:51 Modified files: tools : lvcreate.c Log message: Check if lp.origin exists Currently needed for _determine_snapshot_type(). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.238&r2=1.239 --- LVM2/tools/lvcreate.c 2011/09/06 22:43:58 1.238 +++ LVM2/tools/lvcreate.c 2011/09/07 09:25:51 1.239 @@ -896,7 +896,7 @@ return ECMD_FAILED; } - if (lp.snapshot && !_determine_snapshot_type(vg, &lp)) { + if (lp.snapshot && lp.origin && !_determine_snapshot_type(vg, &lp)) { r = ECMD_FAILED; goto_out; } From zkabelac@sourceware.org Wed Sep 7 09:48:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 07 Sep 2011 09:48:00 -0000 Subject: LVM2 ./WHATS_NEW man/pvcreate.8.in Message-ID: <20110907094852.27759.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-07 09:48:51 Modified files: . : WHATS_NEW man : pvcreate.8.in Log message: Fix typo Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2098&r2=1.2099 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/pvcreate.8.in.diff?cvsroot=lvm2&r1=1.11&r2=1.12 --- LVM2/WHATS_NEW 2011/09/07 08:50:35 1.2098 +++ LVM2/WHATS_NEW 2011/09/07 09:48:49 1.2099 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix 'not not' typo in pvcreate man page. Improve man page style for fsadm, lvreduce, lvremove, lvrename, lvresize. Support break for vgchange and vgrefresh operation. Switch int to unsigned type for pvmetadatacopies for pv_create(). --- LVM2/man/pvcreate.8.in 2011/02/04 21:19:03 1.11 +++ LVM2/man/pvcreate.8.in 2011/09/07 09:48:50 1.12 @@ -125,7 +125,7 @@ Ignore or un-ignore metadata areas on this physical volume. The default is "n". This setting can be changed with \fBpvchange\fP. If metadata areas on a physical volume are ignored, LVM will -not not store metadata in the metadata areas present on this Physical +not store metadata in the metadata areas present on this Physical Volume. Metadata areas cannot be created or extended after Logical Volumes have been allocated on the device. If you do not want to store metadata on this device, it is still wise always to allocate a metadata From agk@sourceware.org Wed Sep 7 13:42:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 07 Sep 2011 13:42:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/pv.c Message-ID: <20110907134201.14968.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-07 13:42:00 Modified files: . : WHATS_NEW lib/metadata : pv.c Log message: Terminate pv_attr field correctly. (2.02.86) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2099&r2=1.2100 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/pv.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11 --- LVM2/WHATS_NEW 2011/09/07 09:48:49 1.2099 +++ LVM2/WHATS_NEW 2011/09/07 13:42:00 1.2100 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Terminate pv_attr field correctly. (2.02.86) Fix 'not not' typo in pvcreate man page. Improve man page style for fsadm, lvreduce, lvremove, lvrename, lvresize. Support break for vgchange and vgrefresh operation. --- LVM2/lib/metadata/pv.c 2011/06/29 14:56:33 1.10 +++ LVM2/lib/metadata/pv.c 2011/09/07 13:42:00 1.11 @@ -190,7 +190,7 @@ { char *repstr; - if (!(repstr = dm_pool_zalloc(mem, 3))) { + if (!(repstr = dm_pool_zalloc(mem, 4))) { log_error("dm_pool_alloc failed"); return NULL; } @@ -198,6 +198,7 @@ repstr[0] = (pv->status & ALLOCATABLE_PV) ? 'a' : '-'; repstr[1] = (pv->status & EXPORTED_VG) ? 'x' : '-'; repstr[2] = (pv->status & MISSING_PV) ? 'm' : '-'; + return repstr; } From agk@sourceware.org Thu Sep 8 16:41:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 08 Sep 2011 16:41:00 -0000 Subject: LVM2 lib/format_text/flags.c lib/metadata/lv_m ... Message-ID: <20110908164123.17665.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-08 16:41:20 Modified files: lib/format_text: flags.c lib/metadata : lv_manip.c merge.c metadata-exported.h metadata.h thin_manip.c lib/thin : thin.c tools : lvcreate.c Log message: lvcreate/remove thin_pool and thin volumes (--driverloaded n only) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.282&r2=1.283 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.208&r2=1.209 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.254&r2=1.255 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/thin_manip.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.239&r2=1.240 --- LVM2/lib/format_text/flags.c 2011/08/30 14:55:17 1.47 +++ LVM2/lib/format_text/flags.c 2011/09/08 16:41:18 1.48 @@ -71,6 +71,10 @@ {VIRTUAL_ORIGIN, NULL, 0}, {REPLICATOR, NULL, 0}, {REPLICATOR_LOG, NULL, 0}, + {THIN_VOLUME, NULL, 0}, + {THIN_POOL, NULL, 0}, + {THIN_POOL_DATA, NULL, 0}, + {THIN_POOL_METADATA, NULL, 0}, {0, NULL, 0} }; --- LVM2/lib/metadata/lv_manip.c 2011/09/06 22:43:56 1.282 +++ LVM2/lib/metadata/lv_manip.c 2011/09/08 16:41:18 1.283 @@ -255,13 +255,8 @@ if (thin_pool_lv && !attach_pool_lv(seg, thin_pool_lv)) return_NULL; - if (log_lv) { - if (thin_pool_lv) { - if (!attach_pool_metadata_lv(seg, log_lv)) - return_NULL; - } else if (!attach_mirror_log(seg, log_lv)) - return_NULL; - } + if (log_lv && !attach_mirror_log(seg, log_lv)) + return_NULL; return seg; } @@ -310,6 +305,11 @@ return; } + if (seg_lv(seg, s)->status & THIN_POOL_DATA) { + lv_reduce(seg_lv(seg, s), area_reduction); + return; + } + if (seg_lv(seg, s)->status & RAID_IMAGE) { /* * FIXME: Use lv_reduce not lv_remove @@ -510,6 +510,12 @@ /* FIXME Check this is safe */ if (seg->log_lv && !lv_remove(seg->log_lv)) return_0; + if (seg->pool_metadata_lv && !lv_remove(seg->pool_metadata_lv)) + return_0; + + if (seg->pool_lv && !detach_pool_lv(seg)) + return_0; + dm_list_del(&seg->list); reduction = seg->len; } else @@ -770,7 +776,14 @@ * RAID device's metadata_area */ ah->new_extents += (ah->log_len * ah->area_multiple); + } else { + ah->log_area_count = 0; + ah->log_len = 0; } + } else if (segtype_is_thin_pool(segtype)) { + ah->log_area_count = metadata_area_count; +// FIXME Calculate thin metadata area size + ah->log_len = 1; } else { ah->log_area_count = metadata_area_count; ah->log_len = !metadata_area_count ? 0 : @@ -2314,7 +2327,7 @@ { struct logical_volume *sub_lv; uint32_t i; - uint64_t status = 0; + uint64_t sub_lv_status = 0; const char *layer_name; size_t len = strlen(lv->name) + 32; char img_name[len]; @@ -2328,15 +2341,14 @@ if (segtype_is_raid(segtype)) { lv->status |= RAID; - status = RAID_IMAGE; + sub_lv_status = RAID_IMAGE; layer_name = "rimage"; } else if (segtype_is_mirrored(segtype)) { lv->status |= MIRRORED; - status = MIRROR_IMAGE; + sub_lv_status = MIRROR_IMAGE; layer_name = "mimage"; } else if (segtype_is_thin_pool(segtype)) { - // lv->status |= THIN_POOL; - // status = THIN_IMAGE; + lv->status |= THIN_POOL; layer_name = "tpool"; } else return_0; @@ -2356,37 +2368,52 @@ */ for (i = 0; i < devices; i++) { /* Data LVs */ - if (dm_snprintf(img_name, len, "%s_%s_%u", - lv->name, layer_name, i) < 0) - return_0; - - sub_lv = lv_create_empty(img_name, NULL, - LVM_READ | LVM_WRITE | status, - lv->alloc, lv->vg); + if (devices > 1) { + if (dm_snprintf(img_name, len, "%s_%s_%u", + lv->name, layer_name, i) < 0) + return_0; + } else { + if (dm_snprintf(img_name, len, "%s_%s", + lv->name, layer_name) < 0) + return_0; + } - if (!sub_lv) + /* FIXME Should use ALLOC_INHERIT here and inherit from parent LV */ + if (!(sub_lv = lv_create_empty(img_name, NULL, + LVM_READ | LVM_WRITE, + lv->alloc, lv->vg))) return_0; - if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, status)) + + if (segtype_is_thin_pool(segtype)) { + if (!attach_pool_data_lv(mapseg, sub_lv)) + return_0; + } else if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, sub_lv_status)) return_0; - if (!segtype_is_raid(segtype)) + + /* Metadata LVs for raid or thin pool */ + if (segtype_is_raid(segtype)) { + if (dm_snprintf(img_name, len, "%s_rmeta_%u", lv->name, i) < 0) + return_0; + } else if (segtype_is_thin_pool(segtype)) { + if (dm_snprintf(img_name, len, "%s_tmeta", lv->name) < 0) + return_0; + } else continue; - /* RAID meta LVs */ - if (dm_snprintf(img_name, len, "%s_rmeta_%u", lv->name, i) < 0) + /* FIXME Should use ALLOC_INHERIT here and inherit from parent LV */ + if (!(sub_lv = lv_create_empty(img_name, NULL, + LVM_READ | LVM_WRITE, + lv->alloc, lv->vg))) return_0; - sub_lv = lv_create_empty(img_name, NULL, - LVM_READ | LVM_WRITE | RAID_META, - lv->alloc, lv->vg); - if (!sub_lv) - return_0; - if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META)) - return_0; + if (segtype_is_thin_pool(segtype)) { + if (!attach_pool_metadata_lv(mapseg, sub_lv)) + return_0; + } else if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META)) + return_0; } dm_list_add(&lv->segments, &mapseg->list); -// FIXME If thin pool, create one "log_lv" as tmeta here lv->metadata_lv - return 1; } @@ -2509,9 +2536,22 @@ struct dm_list *allocatable_pvs, alloc_policy_t alloc) { int r = 1; - int raid_logs = 0; + int log_count = 0; struct alloc_handle *ah; - uint32_t dev_count = mirrors * stripes + segtype->parity_devs; + uint32_t sub_lv_count; + + /* + * For RAID, all the devices are AREA_LV. + * However, for 'mirror on stripe' using non-RAID targets, + * the mirror legs are AREA_LV while the stripes underneath + * are AREA_PV. + */ + if (segtype_is_raid(segtype)) + sub_lv_count = mirrors * stripes + segtype->parity_devs; + else if (segtype_is_thin_pool(segtype)) + sub_lv_count = 1; + else + sub_lv_count = mirrors; log_very_verbose("Extending segment type, %s", segtype->name); @@ -2519,12 +2559,14 @@ return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name); if (segtype_is_raid(segtype) && !lv->le_count) - raid_logs = mirrors * stripes; + log_count = mirrors * stripes; -// For thin pool, ensure space for "log_lv" ->metadata_lv is allocated simultaneously here + if (segtype_is_thin_pool(segtype)) + log_count = 1; + /* Thin pool allocation treats its metadata device like a mirror log. */ if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors, - raid_logs, region_size, extents, + log_count, region_size, extents, allocatable_pvs, alloc, NULL))) return_0; @@ -2532,27 +2574,20 @@ r = lv_add_segment(ah, 0, ah->area_count, lv, segtype, stripe_size, 0u, 0); else { - /* - * For RAID, all the devices are AREA_LV. - * However, for 'mirror on stripe' using non-RAID targets, - * the mirror legs are AREA_LV while the stripes underneath - * are AREA_PV. So if this is not RAID, reset dev_count to - * just 'mirrors' - the necessary sub_lv count. - */ - if (!segtype_is_raid(segtype)) - dev_count = mirrors; - if (!lv->le_count && !_lv_insert_empty_sublvs(lv, segtype, stripe_size, - region_size, dev_count)) { + region_size, sub_lv_count)) { log_error("Failed to insert layer for %s", lv->name); alloc_destroy(ah); return 0; } -// For thin_pool, populate tmeta here too r = _lv_extend_layered_lv(ah, lv, extents, 0, stripes, stripe_size); + + if (r && segtype_is_thin_pool(segtype)) + r = lv_add_segment(ah, ah->area_count, 1, first_seg(lv)->pool_metadata_lv, + get_segtype_from_string(lv->vg->cmd, "striped"), 0, 0, 0); } alloc_destroy(ah); return r; @@ -3872,6 +3907,7 @@ lp->extents = lp->extents - size_rest + lp->stripes; } + /* Does LV need to be zeroed? Thin handles this as a per-pool in-kernel setting. */ if (lp->zero && !segtype_is_thin(lp->segtype) && !activation()) { log_error("Can't wipe start of new LV without using " "device-mapper kernel driver"); @@ -3945,7 +3981,7 @@ } } - if (!lp->thin && !lp->extents) { + if (!seg_is_thin_volume(lp) && !lp->extents) { log_error("Unable to create new logical volume with no extents"); return NULL; } @@ -3975,7 +4011,8 @@ log_error("Can't create %s without using " "device-mapper kernel driver.", segtype_is_raid(lp->segtype) ? lp->segtype->name : - "mirror"); + segtype_is_mirrored(lp->segtype) ? "mirror" : + "thin volume"); return NULL; } @@ -4073,7 +4110,7 @@ (lp->activate == CHANGE_AE && !activate_lv_excl(cmd, lv)) || (lp->activate == CHANGE_ALY && !activate_lv_local(cmd, lv))) { log_error("Failed to activate new LV."); - if (lp->zero) + if (lp->zero && !seg_is_thin(lp)) goto deactivate_and_revert_new_lv; return NULL; } --- LVM2/lib/metadata/merge.c 2011/09/06 22:43:57 1.47 +++ LVM2/lib/metadata/merge.c 2011/09/08 16:41:18 1.48 @@ -75,6 +75,40 @@ struct replicator_site *rsite; struct replicator_device *rdev; + /* Check LV flags match first segment type */ + if (complete_vg) { + if (lv_is_thin_volume(lv) && + (!(seg2 = first_seg(lv)) || !seg_is_thin_volume(seg2))) { + log_error("LV %s is thin volume without first thin volume segment", + lv->name); + inc_error_count; + } + + if (lv_is_thin_pool(lv) && + (!(seg2 = first_seg(lv)) || !seg_is_thin_pool(seg2))) { + log_error("LV %s is thin pool without first thin pool segment", + lv->name); + inc_error_count; + } + + if (lv_is_thin_pool_data(lv) && + (!(seg2 = first_seg(lv)) || !(seg2 = find_pool_seg(seg2)) || + seg2->area_count != 1 || seg_type(seg2, 0) != AREA_LV || + seg_lv(seg2, 0) != lv)) { + log_error("LV %s: segment 1 pool data LV does not point back to same LV", + lv->name); + inc_error_count; + } + + if (lv_is_thin_pool_metadata(lv) && + (!(seg2 = first_seg(lv)) || !(seg2 = find_pool_seg(seg2)) || + seg2->pool_metadata_lv != lv)) { + log_error("LV %s: segment 1 pool metadata LV does not point back to same LV", + lv->name); + inc_error_count; + } + } + dm_list_iterate_items(seg, &lv->segments) { seg_count++; if (seg->le != le) { @@ -132,6 +166,80 @@ } } + /* Check the various thin segment types */ + if (complete_vg) { + if (seg_is_thin_pool(seg)) { + if (!lv_is_thin_pool(lv)) { + log_error("LV %s is missing thin pool flag for segment %u", + lv->name, seg_count); + inc_error_count; + } + + if (lv_is_thin_volume(lv)) { + log_error("LV %s is a thin volume that must not contain thin pool segment %u", + lv->name, seg_count); + inc_error_count; + } + + if (seg->area_count != 1 || seg_type(seg, 0) != AREA_LV) { + log_error("LV %s: thin pool segment %u is missing a pool data LV", + lv->name, seg_count); + inc_error_count; + } else if (!(seg2 = first_seg(seg_lv(seg, 0))) || find_pool_seg(seg2) != seg) { + log_error("LV %s: thin pool segment %u data LV does not refer back to pool LV", + lv->name, seg_count); + inc_error_count; + } + + if (!seg->pool_metadata_lv) { + log_error("LV %s: thin pool segment %u is missing a pool metadata LV", + lv->name, seg_count); + inc_error_count; + } else if (!(seg2 = first_seg(seg->pool_metadata_lv)) || + find_pool_seg(seg2) != seg) { + log_error("LV %s: thin pool segment %u metadata LV does not refer back to pool LV", + lv->name, seg_count); + inc_error_count; + } + } else { + if (seg->pool_metadata_lv) { + log_error("LV %s: segment %u must not have thin pool metadata LV set", + lv->name, seg_count); + inc_error_count; + } + } + + if (seg_is_thin_volume(seg)) { + if (!lv_is_thin_volume(lv)) { + log_error("LV %s is missing thin volume flag for segment %u", + lv->name, seg_count); + inc_error_count; + } + + if (lv_is_thin_pool(lv)) { + log_error("LV %s is a thin pool that must not contain thin volume segment %u", + lv->name, seg_count); + inc_error_count; + } + + if (!seg->pool_lv) { + log_error("LV %s: segment %u is missing thin pool LV", + lv->name, seg_count); + inc_error_count; + } else if (!lv_is_thin_pool(seg->pool_lv)) { + log_error("LV %s: thin volume segment %u pool LV is not flagged as a pool LV", + lv->name, seg_count); + inc_error_count; + } + } else { + if (seg->pool_lv) { + log_error("LV %s: segment %u must not have thin pool LV set", + lv->name, seg_count); + inc_error_count; + } + } + } + if (seg_is_snapshot(seg)) { if (seg->cow && seg->cow == seg->origin) { log_error("LV %s: segment %u has same LV %s for " @@ -250,6 +358,8 @@ seg_found++; if (seg->log_lv == lv) seg_found++; + if (seg->pool_metadata_lv == lv || seg->pool_lv == lv) + seg_found++; if (!seg_found) { log_error("LV %s is used by LV %s:%" PRIu32 "-%" PRIu32 ", but missing ptr from %s to %s", --- LVM2/lib/metadata/metadata-exported.h 2011/09/07 08:34:22 1.208 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/08 16:41:18 1.209 @@ -85,8 +85,8 @@ #define THIN_VOLUME UINT64_C(0x0000001000000000) /* LV */ #define THIN_POOL UINT64_C(0x0000002000000000) /* LV */ -#define THIN_POOL_DATA UINT64_C(0x0000002000000000) /* LV */ -#define THIN_POOL_METADATA UINT64_C(0x0000004000000000) /* LV */ +#define THIN_POOL_DATA UINT64_C(0x0000004000000000) /* LV */ +#define THIN_POOL_METADATA UINT64_C(0x0000008000000000) /* LV */ #define LVM_READ 0x00000100U /* LV VG 32-bit */ #define LVM_WRITE 0x00000200U /* LV VG 32-bit */ @@ -327,7 +327,6 @@ struct lv_segment_area *areas; struct lv_segment_area *meta_areas; /* For RAID */ - struct logical_volume *pool_data_lv; /* For thin_pool */ struct logical_volume *pool_metadata_lv;/* For thin_pool */ uint64_t transaction_id; /* For thin_pool */ uint32_t zero_new_blocks; /* For thin_pool */ --- LVM2/lib/metadata/metadata.h 2011/09/06 22:43:57 1.254 +++ LVM2/lib/metadata/metadata.h 2011/09/08 16:41:19 1.255 @@ -371,6 +371,9 @@ /* Find LV segment containing given LE */ struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le); +/* Find pool LV segment given a thin pool data or metadata segment. */ +struct lv_segment *find_pool_seg(struct lv_segment *seg); + /* * Remove a dev_dir if present. */ @@ -447,6 +450,7 @@ int attach_pool_data_lv(struct lv_segment *seg, struct logical_volume *pool_data_lv); int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv); +int detach_pool_lv(struct lv_segment *seg); /* * Begin skeleton for external LVM library --- LVM2/lib/metadata/thin_manip.c 2011/09/06 22:43:57 1.2 +++ LVM2/lib/metadata/thin_manip.c 2011/09/08 16:41:19 1.3 @@ -14,6 +14,8 @@ #include "lib.h" #include "metadata.h" +#include "segtype.h" +#include "lv_alloc.h" int attach_pool_metadata_lv(struct lv_segment *seg, struct logical_volume *pool_metadata_lv) { @@ -26,17 +28,55 @@ int attach_pool_data_lv(struct lv_segment *seg, struct logical_volume *pool_data_lv) { - seg->pool_data_lv = pool_data_lv; - pool_data_lv->status |= THIN_POOL_DATA; + if (!set_lv_segment_area_lv(seg, 0, pool_data_lv, 0, THIN_POOL_DATA)) + return_0; + lv_set_hidden(pool_data_lv); - return add_seg_to_segs_using_this_lv(pool_data_lv, seg); + return 1; } int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv) { + if (!lv_is_thin_pool(pool_lv)) { + log_error(INTERNAL_ERROR "LV %s is not a thin pool", + pool_lv->name); + return 0; + } + seg->pool_lv = pool_lv; - pool_lv->status |= THIN_POOL; + seg->lv->status |= THIN_VOLUME; return add_seg_to_segs_using_this_lv(pool_lv, seg); } + +int detach_pool_lv(struct lv_segment *seg) +{ + if (!lv_is_thin_pool(seg->pool_lv)) { + log_error(INTERNAL_ERROR "LV %s is not a thin pool", + seg->pool_lv->name); + return 0; + } + + return remove_seg_from_segs_using_this_lv(seg->pool_lv, seg); +} + +struct lv_segment *find_pool_seg(struct lv_segment *seg) +{ + struct lv_segment *pool_seg; + + pool_seg = get_only_segment_using_this_lv(seg->lv); + + if (!pool_seg) { + log_error("Failed to find pool_seg for %s", seg->lv->name); + return NULL; + } + + if (!seg_is_thin_pool(pool_seg)) { + log_error("%s on %s is not a pool segment", + pool_seg->lv->name, seg->lv->name); + return NULL; + } + + return pool_seg; +} --- LVM2/lib/thin/thin.c 2011/09/06 22:43:57 1.11 +++ LVM2/lib/thin/thin.c 2011/09/08 16:41:19 1.12 @@ -61,10 +61,10 @@ if (!(pool_metadata_lv = find_lv(seg->lv->vg, lv_name))) return SEG_LOG_ERROR("Unknown metadata %s in", lv_name); - if (!attach_pool_metadata_lv(seg, pool_metadata_lv)) + if (!attach_pool_data_lv(seg, pool_data_lv)) return_0; - if (!attach_pool_data_lv(seg, pool_data_lv)) + if (!attach_pool_metadata_lv(seg, pool_metadata_lv)) return_0; if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id)) @@ -74,12 +74,22 @@ !dm_config_get_uint32(sn, "zero_new_blocks", &seg->zero_new_blocks)) return SEG_LOG_ERROR("Could not read zero_new_blocks for"); + seg->lv->status |= THIN_POOL; + + return 1; +} + +static int _thin_pool_text_import_area_count(const struct dm_config_node *sn, + uint32_t *area_count) +{ + *area_count = 1; + return 1; } static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter *f) { - outf(f, "pool = \"%s\"", seg->pool_data_lv->name); + outf(f, "pool = \"%s\"", seg_lv(seg, 0)->name); outf(f, "metadata = \"%s\"", seg->pool_metadata_lv->name); outf(f, "transaction_id = %" PRIu64, seg->transaction_id); if (seg->zero_new_blocks) @@ -182,6 +192,7 @@ static struct segtype_handler _thin_pool_ops = { .name = _thin_pool_name, .text_import = _thin_pool_text_import, + .text_import_area_count = _thin_pool_text_import_area_count, .text_export = _thin_pool_text_export, .modules_needed = _thin_modules_needed, .destroy = _thin_destroy, --- LVM2/tools/lvcreate.c 2011/09/07 09:25:51 1.239 +++ LVM2/tools/lvcreate.c 2011/09/08 16:41:19 1.240 @@ -590,6 +590,11 @@ lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, segtype_str)); + if (seg_unknown(lp)) { + log_error("Unable to create LV with unknown segment type %s.", arg_str_value(cmd, type_ARG, segtype_str)); + return 0; + } + if (arg_count(cmd, snapshot_ARG) || seg_is_snapshot(lp) || (!seg_is_thin(lp) && arg_count(cmd, virtualsize_ARG))) lp->snapshot = 1; From agk@sourceware.org Thu Sep 8 20:55:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 08 Sep 2011 20:55:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv.c lib/metadat ... Message-ID: <20110908205540.1705.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-08 20:55:39 Modified files: . : WHATS_NEW lib/metadata : lv.c metadata-exported.h man : lvs.8.in Log message: Add 7th lv_attr char to show the related kernel target. Add thin volume types to lv_attr. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2100&r2=1.2101 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.209&r2=1.210 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvs.8.in.diff?cvsroot=lvm2&r1=1.13&r2=1.14 --- LVM2/WHATS_NEW 2011/09/07 13:42:00 1.2100 +++ LVM2/WHATS_NEW 2011/09/08 20:55:39 1.2101 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add 7th lv_attr char to show the related kernel target. Terminate pv_attr field correctly. (2.02.86) Fix 'not not' typo in pvcreate man page. Improve man page style for fsadm, lvreduce, lvremove, lvrename, lvresize. --- LVM2/lib/metadata/lv.c 2011/04/12 12:24:29 1.24 +++ LVM2/lib/metadata/lv.c 2011/09/08 20:55:39 1.25 @@ -298,7 +298,7 @@ struct lvinfo info; char *repstr; - if (!(repstr = dm_pool_zalloc(mem, 7))) { + if (!(repstr = dm_pool_zalloc(mem, 8))) { log_error("dm_pool_alloc failed"); return 0; } @@ -311,15 +311,22 @@ repstr[0] = 'p'; else if (lv->status & CONVERTING) repstr[0] = 'c'; - else if (lv->status & VIRTUAL) - repstr[0] = 'v'; - /* Origin takes precedence over Mirror */ - else if (lv_is_origin(lv)) { + /* Origin takes precedence over mirror and thin volume */ + else if (lv_is_origin(lv)) repstr[0] = (lv_is_merging_origin(lv)) ? 'O' : 'o'; - } - else if (lv->status & MIRRORED) { + else if (lv->status & MIRRORED) repstr[0] = (lv->status & LV_NOTSYNCED) ? 'M' : 'm'; - }else if (lv->status & MIRROR_IMAGE) + else if (lv_is_thin_volume(lv)) + repstr[0] = 'V'; + else if (lv->status & VIRTUAL) + repstr[0] = 'v'; + else if (lv_is_thin_pool(lv)) + repstr[0] = 't'; + else if (lv_is_thin_pool_data(lv)) + repstr[0] = 'T'; + else if (lv_is_thin_pool_metadata(lv) || (lv->status & RAID_META)) + repstr[0] = 'e'; + else if (lv->status & MIRROR_IMAGE) repstr[0] = (_lv_mimage_in_sync(lv)) ? 'i' : 'I'; else if (lv->status & MIRROR_LOG) repstr[0] = 'l'; @@ -370,6 +377,22 @@ repstr[4] = '-'; repstr[5] = '-'; } + + if (lv_is_thin_type(lv)) + repstr[6] = 't'; + else if (lv_is_mirror_type(lv)) + repstr[6] = 'm'; + else if (lv_is_raid_type(lv)) + repstr[6] = 'r'; + else if (lv_is_cow(lv) || lv_is_origin(lv)) + repstr[6] = 's'; + else if (lv_has_unknown_segments(lv)) + repstr[6] = 'u'; + else if (lv_is_virtual(lv)) + repstr[6] = 'v'; + else + repstr[6] = '-'; + out: return repstr; } --- LVM2/lib/metadata/metadata-exported.h 2011/09/08 16:41:18 1.209 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/08 20:55:39 1.210 @@ -141,6 +141,12 @@ #define lv_is_mirrored(lv) ((lv)->status & MIRRORED ? 1 : 0) #define lv_is_rlog(lv) ((lv)->status & REPLICATOR_LOG ? 1 : 0) +#define lv_is_thin_type(lv) ((lv)->status & (THIN_POOL | THIN_VOLUME | THIN_POOL_DATA | THIN_POOL_METADATA) ? 1 : 0) +#define lv_is_mirror_type(lv) ((lv)->status & (MIRROR_LOG | MIRROR_IMAGE | MIRRORED | PVMOVE) ? 1 : 0) +#define lv_is_raid_type(lv) ((lv)->status & (RAID | RAID_IMAGE | RAID_META)) + +#define lv_is_virtual(lv) ((lv)->status & VIRTUAL) + /* Ordered list - see lv_manip.c */ typedef enum { AREA_UNASSIGNED, --- LVM2/man/lvs.8.in 2010/06/23 12:32:08 1.13 +++ LVM2/man/lvs.8.in 2011/09/08 20:55:39 1.14 @@ -70,7 +70,9 @@ .IP 1 3 Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (O)rigin with merging snapshot, (s)napshot, merging (S)napshot, (p)vmove, -(v)irtual, mirror (i)mage, mirror (I)mage out-of-sync, under (c)onversion +(v)irtual, mirror (i)mage, mirror (I)mage out-of-sync, mirror (l)og device, +under (c)onversion, thin (V)olume, (t)hin pool, (T)hin pool data, thin pool +m(e)tadata .IP 2 3 Permissions: (w)riteable, (r)ead-only .IP 3 3 @@ -84,6 +86,14 @@ mapped (d)evice present without tables, mapped device present with (i)nactive table .IP 6 3 device (o)pen +.IP 7 3 +Target type: (m)irror, (r)aid, (s)napshot, (t)hin, (u)nknown, (v)irtual. +This groups logical volumes related to the same kernel target together. So, +for example, mirror images, mirror logs as well as mirrors themselves appear as +(m) if they use the original device-mapper mirror kernel driver; whereas the raid +equivalents using the md raid kernel driver all appear as (r). +Snapshots using the original device-mapper driver appear as (s); whereas +snapshots of thin volumes using the new thin provisioning driver appear as (t). .RE .TP .I \-\-segments From jbrassow@sourceware.org Thu Sep 8 22:19:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Thu, 08 Sep 2011 22:19:00 -0000 Subject: LVM2/scripts gdbinit Message-ID: <20110908221945.21769.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-08 22:19:45 Modified files: scripts : gdbinit Log message: Adjust gdbinit script to new RAID status flag values. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.8&r2=1.9 --- LVM2/scripts/gdbinit 2011/09/01 21:01:12 1.8 +++ LVM2/scripts/gdbinit 2011/09/08 22:19:45 1.9 @@ -27,8 +27,8 @@ printf "Use 'help ' for more info\n" printf "\n\n" printf "Popular breakpoints:\n" -printf "break _split_mirror_images\n" -printf "run --splitmirrors 2 -n new vg/lv\n" +printf "break _raid_add_images\n" +printf "run --type raid1 -m 1 vg/lv\n" printf "\n\n" set follow-fork-mode child @@ -175,18 +175,18 @@ # Constants defined in metadata-exported.h # if ($_s_status & RAID) - if ($_s_status & 0x00000001U) - set $_s_status = $_s_status & ~0x00000001U + if ($_s_status & 0x0000000100000000LU) + set $_s_status = $_s_status & ~0x0000000100000000LU printf " RAID" end # if ($_s_status & RAID_META) - if ($_s_status & 0x00000002U) - set $_s_status = $_s_status & ~0x00000002U + if ($_s_status & 0x0000000200000000LU) + set $_s_status = $_s_status & ~0x0000000200000000LU printf " RAID_META" end # if ($_s_status & RAID_IMAGE) - if ($_s_status & 0x00000004U) - set $_s_status = $_s_status & ~0x00000004U + if ($_s_status & 0x0000000400000000LU) + set $_s_status = $_s_status & ~0x0000000400000000LU printf " RAID_IMAGE" end # if ($_s_status & VISIBLE_LV) From agk@sourceware.org Fri Sep 9 00:54:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 09 Sep 2011 00:54:00 -0000 Subject: LVM2 lib/config/defaults.h lib/metadata/lv.c l ... Message-ID: <20110909005451.9436.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-09 00:54:50 Modified files: lib/config : defaults.h lib/metadata : lv.c lv.h lib/report : columns.h properties.c report.c man : lvs.8.in Log message: Add a new 'thin_pool' output field to 'lvs. A gentle reminder that anyone relying on the output of reporting commands like lvs in scripts must use -o to guarantee they get the fields they expect. The default sequence of fields can change from release to release. Equally, the 'attr' fields can have new values introduced and/or characters appended to them. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.82&r2=1.83 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.h.diff?cvsroot=lvm2&r1=1.20&r2=1.21 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/columns.h.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/properties.c.diff?cvsroot=lvm2&r1=1.31&r2=1.32 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.145&r2=1.146 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvs.8.in.diff?cvsroot=lvm2&r1=1.14&r2=1.15 --- LVM2/lib/config/defaults.h 2011/08/11 17:46:14 1.82 +++ LVM2/lib/config/defaults.h 2011/09/09 00:54:49 1.83 @@ -139,13 +139,13 @@ #define DEFAULT_REP_QUOTED 1 #define DEFAULT_REP_SEPARATOR " " -#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,origin,snap_percent,move_pv,mirror_log,copy_percent,convert_lv" +#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,thin_pool,origin,snap_percent,move_pv,mirror_log,copy_percent,convert_lv" #define DEFAULT_VGS_COLS "vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free" #define DEFAULT_PVS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free" #define DEFAULT_SEGS_COLS "lv_name,vg_name,lv_attr,stripes,segtype,seg_size" #define DEFAULT_PVSEGS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pvseg_start,pvseg_size" -#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_major,lv_minor,lv_kernel_major,lv_kernel_minor,origin,snap_percent,move_pv,copy_percent,mirror_log,convert_lv,lv_uuid" +#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_major,lv_minor,lv_kernel_major,lv_kernel_minor,thin_pool,origin,snap_percent,move_pv,copy_percent,mirror_log,convert_lv,lv_uuid" #define DEFAULT_VGS_COLS_VERB "vg_name,vg_attr,vg_extent_size,pv_count,lv_count,snap_count,vg_size,vg_free,vg_uuid" #define DEFAULT_PVS_COLS_VERB "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,dev_size,pv_uuid" #define DEFAULT_SEGS_COLS_VERB "lv_name,vg_name,lv_attr,seg_start,seg_size,stripes,segtype,stripesize,chunksize" --- LVM2/lib/metadata/lv.c 2011/09/08 20:55:39 1.25 +++ LVM2/lib/metadata/lv.c 2011/09/09 00:54:49 1.26 @@ -185,6 +185,18 @@ return NULL; } +char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv) +{ + struct lv_segment *seg; + + dm_list_iterate_items(seg, &lv->segments) { + if (!seg_is_thin_volume(seg) || !seg->pool_lv) + continue; + return dm_pool_strdup(mem, seg->pool_lv->name); + } + return NULL; +} + int lv_kernel_minor(const struct logical_volume *lv) { struct lvinfo info; --- LVM2/lib/metadata/lv.h 2011/04/12 12:24:29 1.20 +++ LVM2/lib/metadata/lv.h 2011/09/09 00:54:49 1.21 @@ -59,6 +59,7 @@ int lv_kernel_major(const struct logical_volume *lv); int lv_kernel_minor(const struct logical_volume *lv); char *lv_mirror_log_dup(struct dm_pool *mem, const struct logical_volume *lv); +char *lv_pool_lv_dup(struct dm_pool *mem, const struct logical_volume *lv); char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv); char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv); char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv); --- LVM2/lib/report/columns.h 2010/11/17 19:15:10 1.46 +++ LVM2/lib/report/columns.h 2011/09/09 00:54:49 1.47 @@ -80,6 +80,7 @@ FIELD(LVS, lv, STR, "Convert", lvid, 7, convertlv, convert_lv, "For lvconvert, Name of temporary LV created by lvconvert.", 0) FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, lv_tags, "Tags, if any.", 0) FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, mirror_log, "For mirrors, the LV holding the synchronisation log.", 0) +FIELD(LVS, lv, STR, "Pool", lvid, 3, poollv, thin_pool, "For thinly-provisioned devices, the pool LV holding the data.", 0) FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, modules, "Kernel device-mapper modules required for this LV.", 0) FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, pv_fmt, "Type of metadata.", 0) --- LVM2/lib/report/properties.c 2011/04/12 12:24:29 1.31 +++ LVM2/lib/report/properties.c 2011/09/09 00:54:49 1.32 @@ -175,6 +175,8 @@ #define _lv_tags_set _not_implemented_set GET_LV_STR_PROPERTY_FN(mirror_log, lv_mirror_log_dup(lv->vg->vgmem, lv)) #define _mirror_log_set _not_implemented_set +GET_LV_STR_PROPERTY_FN(thin_pool, lv_pool_lv_dup(lv->vg->vgmem, lv)) +#define _thin_pool_set _not_implemented_set GET_LV_STR_PROPERTY_FN(modules, lv_modules_dup(lv->vg->vgmem, lv)) #define _modules_set _not_implemented_set --- LVM2/lib/report/report.c 2011/08/04 14:30:52 1.145 +++ LVM2/lib/report/report.c 2011/09/09 00:54:49 1.146 @@ -240,6 +240,19 @@ return 1; } +static int _poollv_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)), + struct dm_report_field *field, + const void *data, void *private __attribute__((unused))) +{ + const struct logical_volume *lv = (const struct logical_volume *) data; + const char *name; + + if ((name = lv_pool_lv_dup(mem, lv))) + return dm_report_field_string(rh, field, &name); + + dm_report_field_set_value(field, "", NULL); + return 1; +} static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private __attribute__((unused))) --- LVM2/man/lvs.8.in 2011/09/08 20:55:39 1.14 +++ LVM2/man/lvs.8.in 2011/09/09 00:54:49 1.15 @@ -57,7 +57,7 @@ Column names include: lv_uuid, lv_name, lv_path, lv_attr, lv_major, lv_minor, lv_read_ahead, lv_kernel_major, lv_kernel_minor, lv_kernel_read_ahead, lv_size, seg_count, origin, origin_size, -snap_percent, copy_percent, move_pv, convert_lv, lv_tags, mirror_log, modules, +snap_percent, copy_percent, move_pv, convert_lv, lv_tags, mirror_log, thin_pool, modules, segtype, stripes, stripesize, regionsize, chunksize, seg_start, seg_start_pe, seg_size, seg_tags, seg_pe_ranges, devices. .IP From agk@sourceware.org Fri Sep 9 01:15:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 09 Sep 2011 01:15:00 -0000 Subject: LVM2 lib/metadata/lv.c lib/metadata/metadata.h ... Message-ID: <20110909011520.6664.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-09 01:15:18 Modified files: lib/metadata : lv.c metadata.h thin_manip.c man : lvs.8.in Log message: Append z to lv_attr if new blocks will be zeroed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.255&r2=1.256 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/thin_manip.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvs.8.in.diff?cvsroot=lvm2&r1=1.15&r2=1.16 --- LVM2/lib/metadata/lv.c 2011/09/09 00:54:49 1.26 +++ LVM2/lib/metadata/lv.c 2011/09/09 01:15:18 1.27 @@ -308,9 +308,10 @@ { percent_t snap_percent; struct lvinfo info; + struct lv_segment *seg; char *repstr; - if (!(repstr = dm_pool_zalloc(mem, 8))) { + if (!(repstr = dm_pool_zalloc(mem, 9))) { log_error("dm_pool_alloc failed"); return 0; } @@ -405,6 +406,13 @@ else repstr[6] = '-'; + if ((lv_is_thin_volume(lv) && (seg = first_seg(lv)) && seg->pool_lv && (seg = first_seg(seg->pool_lv))) || + (lv_is_thin_pool(lv) && (seg = first_seg(lv))) && + seg->zero_new_blocks) + repstr[7] = 'z'; + else + repstr[7] = '-'; + out: return repstr; } --- LVM2/lib/metadata/metadata.h 2011/09/08 16:41:19 1.255 +++ LVM2/lib/metadata/metadata.h 2011/09/09 01:15:18 1.256 @@ -372,7 +372,7 @@ struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le); /* Find pool LV segment given a thin pool data or metadata segment. */ -struct lv_segment *find_pool_seg(struct lv_segment *seg); +struct lv_segment *find_pool_seg(const struct lv_segment *seg); /* * Remove a dev_dir if present. --- LVM2/lib/metadata/thin_manip.c 2011/09/08 16:41:19 1.3 +++ LVM2/lib/metadata/thin_manip.c 2011/09/09 01:15:18 1.4 @@ -61,7 +61,7 @@ return remove_seg_from_segs_using_this_lv(seg->pool_lv, seg); } -struct lv_segment *find_pool_seg(struct lv_segment *seg) +struct lv_segment *find_pool_seg(const struct lv_segment *seg) { struct lv_segment *pool_seg; --- LVM2/man/lvs.8.in 2011/09/09 00:54:49 1.15 +++ LVM2/man/lvs.8.in 2011/09/09 01:15:18 1.16 @@ -94,6 +94,8 @@ equivalents using the md raid kernel driver all appear as (r). Snapshots using the original device-mapper driver appear as (s); whereas snapshots of thin volumes using the new thin provisioning driver appear as (t). +.IP 8 3 +Newly-allocated data blocks are overwritten with blocks of (z)eroes before use. .RE .TP .I \-\-segments From zkabelac@sourceware.org Fri Sep 9 13:19:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 09 Sep 2011 13:19:00 -0000 Subject: LVM2/test/lib check.sh Message-ID: <20110909131920.32556.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-09 13:19:20 Modified files: test/lib : check.sh Log message: Updated testing script Since attrs were extended by 2 new fields update check functions. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/check.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/test/lib/check.sh 2011/04/12 12:39:24 1.5 +++ LVM2/test/lib/check.sh 2011/09/09 13:19:19 1.6 @@ -139,8 +139,8 @@ mirror_nonredundant() { lv="$1/$2" - lvs -oattr "$lv" | grep "^ *m.....$" >/dev/null || { - if lvs -oattr "$lv" | grep "^ *o.....$" >/dev/null && + lvs -oattr "$lv" | grep "^ *m.......$" >/dev/null || { + if lvs -oattr "$lv" | grep "^ *o.......$" >/dev/null && lvs -a | fgrep "[${2}_mimage" >/dev/null; then echo "TEST WARNING: $lv is a snapshot origin and looks like a mirror," echo "assuming it is actually a mirror" @@ -183,7 +183,7 @@ active() { lv="$1/$2" - lvl -oattr "$lv" 2> /dev/null | grep "^ *....a.$" >/dev/null || { + lvl -oattr "$lv" 2> /dev/null | grep "^ *....a...$" >/dev/null || { echo "$lv expected active, but lvs says it's not:" lvl "$lv" -o+devices 2>/dev/null exit 1 @@ -197,7 +197,7 @@ inactive() { lv="$1/$2" - lvl -oattr "$lv" 2> /dev/null | grep '^ *....[-isd].$' >/dev/null || { + lvl -oattr "$lv" 2> /dev/null | grep '^ *....[-isd]...$' >/dev/null || { echo "$lv expected inactive, but lvs says it's not:" lvl "$lv" -o+devices 2>/dev/null exit 1 From jbrassow@sourceware.org Tue Sep 13 13:57:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Tue, 13 Sep 2011 13:57:00 -0000 Subject: LVM2/scripts gdbinit Message-ID: <20110913135703.4342.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-13 13:57:02 Modified files: scripts : gdbinit Log message: reorder some status flag printing in gdbinit file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.9&r2=1.10 --- LVM2/scripts/gdbinit 2011/09/08 22:19:45 1.9 +++ LVM2/scripts/gdbinit 2011/09/13 13:57:02 1.10 @@ -189,6 +189,21 @@ set $_s_status = $_s_status & ~0x0000000400000000LU printf " RAID_IMAGE" end +# if ($_s_status & MIRRORED) + if ($_s_status & 0x00008000U) + set $_s_status = $_s_status & ~0x00008000U + printf " MIRRORED" + end +# if ($_s_status & MIRROR_LOG) + if ($_s_status & 0x00020000U) + set $_s_status = $_s_status & ~0x00020000U + printf " MIRROR_LOG" + end +# if ($_s_status & MIRROR_IMAGE) + if ($_s_status & 0x00040000U) + set $_s_status = $_s_status & ~0x00040000U + printf " MIRROR_IMAGE" + end # if ($_s_status & VISIBLE_LV) if ($_s_status & 0x00000040U) printf " VISIBLE_LV" @@ -226,21 +241,6 @@ set $_s_status = $_s_status & ~0x00004000U printf " LOCKED" end -# if ($_s_status & MIRRORED) - if ($_s_status & 0x00008000U) - set $_s_status = $_s_status & ~0x00008000U - printf " MIRRORED" - end -# if ($_s_status & MIRROR_LOG) - if ($_s_status & 0x00020000U) - set $_s_status = $_s_status & ~0x00020000U - printf " MIRROR_LOG" - end -# if ($_s_status & MIRROR_IMAGE) - if ($_s_status & 0x00040000U) - set $_s_status = $_s_status & ~0x00040000U - printf " MIRROR_IMAGE" - end # if ($_s_status & LV_NOTSYNCED) if ($_s_status & 0x00080000U) set $_s_status = $_s_status & ~0x00080000U From jbrassow@sourceware.org Tue Sep 13 13:59:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Tue, 13 Sep 2011 13:59:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/mirror.c Message-ID: <20110913135920.4871.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-13 13:59:19 Modified files: . : WHATS_NEW lib/metadata : mirror.c Log message: Fix for bug 733114. When an image is split from a 2-way mirror, the original mirror is converted to a linear device. To do this, the top "layer" must be removed. The segments are transferred from the sub-lv to the top-level LV and the link is severed. The former sub-lv - having its segments transferred - now contains a temporary error target. When the original LV is resumed, the old sub-lv that now contains an error segment is activated and scanned. This is what causes the I/O error messages. There are three ways to fix this problem: 1) Do not set the sub-lv which contains the error target as "visible" before suspending the original LV. This way, when the original is resumed, the sub-lv device node is not created and it is not scanned - avoiding the error messages. The problem with this approach is that if the machine crashes after the resume, it leaves the *hidden* LV in place and the user has a more difficult time noticing that it needs to be cleaned up. Thus, this type of processing is frowned upon. 2) Do like _remove_mirror_images does and suspend the original, then suspend the sub-lv (the error target), then resume the sub-lv, and finally resume the original LV. This seems like extra pointless operations to me, but it does not produce the error message (although, I'm not sure why) and it allows us to leave the visible flag in place. 3) Flag the sub-lv (error target) with a "do not scan" flag. This seems like the cleanest approach, but I have been unable to find the method for doing this. LVs get tagged in such a way by _get_udev_flags, but in this case the resume of the original LV also resumes the error target LV without running it through _get_udev_flags (likely because they are no longer linked). Could there be something wrong in resume_lv? Option #2 was chosen to fix this bug, but it seems like more of a workaround for now. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2101&r2=1.2102 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.162&r2=1.163 --- LVM2/WHATS_NEW 2011/09/08 20:55:39 1.2101 +++ LVM2/WHATS_NEW 2011/09/13 13:59:19 1.2102 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Work around resume_lv causing error LV scanning during splitmirror operation. Add 7th lv_attr char to show the related kernel target. Terminate pv_attr field correctly. (2.02.86) Fix 'not not' typo in pvcreate man page. --- LVM2/lib/metadata/mirror.c 2011/09/06 19:25:43 1.162 +++ LVM2/lib/metadata/mirror.c 2011/09/13 13:59:19 1.163 @@ -666,6 +666,10 @@ return 0; } + /* Suspend temporary error target (see FIXME for resume below) */ + if (sub_lv && !suspend_lv(sub_lv->vg->cmd, sub_lv)) + return_0; + if (!vg_commit(mirrored_seg->lv->vg)) { resume_lv(cmd, mirrored_seg->lv); return 0; @@ -674,6 +678,42 @@ log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name); /* + * FIXME: +When an image is split from a 2-way mirror, the original mirror is converted to +a linear device. To do this, the top "layer" must be removed. The segments +are transferred from the sub-lv to the top-level LV and the link is severed. +The former sub-lv - having its segments transferred - now contains a temporary +error target. + +When the original LV is resumed, the old sub-lv that now contains an error +segment is activated and scanned. This causes I/O error messages. There are +three ways to fix this problem: + +1) Do not set the sub-lv which contains the error target as "visible" before +suspending the original LV. This way, when the original is resumed, the sub-lv +device node is not created and it is not scanned - avoiding the error messages. + The problem with this approach is that if the machine crashes after the +resume, it leaves the *hidden* LV in place and the user has a more difficult +time noticing that it needs to be cleaned up. Thus, this type of processing is +frowned upon. + +2) Do like _remove_mirror_images does and suspend the original, then suspend +the sub-lv (the error target), then resume the sub-lv, and finally resume the +original LV. This seems like extra pointless operations to me, but it does not +produce the error message (although, I'm not sure why) and it allows us to +leave the visible flag in place. ** THIS IS THE CHOSEN SOLUTION HERE ** + +3) Flag the sub-lv (error target) with a "do not scan" flag. This seems like +the cleanest approach, but I have been unable to find the method for doing +this. LVs get tagged in such a way by _get_udev_flags, but in this case the +resume of the original LV also resumes the error target LV without running it +through _get_udev_flags (likely because they are no longer linked). Could +there be something wrong in resume_lv? + */ + if (sub_lv && !resume_lv(sub_lv->vg->cmd, sub_lv)) + return_0; + + /* * Resume the mirror - this also activates the visible, independent * soon-to-be-split sub-LVs */ From jbrassow@sourceware.org Tue Sep 13 14:37:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Tue, 13 Sep 2011 14:37:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/mirror.c Message-ID: <20110913143749.9114.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-13 14:37:49 Modified files: . : WHATS_NEW lib/metadata : mirror.c Log message: Fix for bug 737125 - unable to create mirror on 1K extent size VG _alloc_init calculates the number of necessary log extents via 'mirror_log_extents'. 'mirror_log_extents' takes 3 arguments: region_size, pe_size, and size of the mirror LV. Unfortunately, _alloc_init is guessing at the mirror size by using 'ah->new_extents / ah->area_multiple' - the number of extents that the mirror images have. However, this is /always/ wrong when allocating the log separately. Further, the log is always allocated separately unless we are up-converting the mirror at the same time. It was by luck alone that a default value of '1' reflects what we want in most cases. In order to get a decent value computed, we need to pass in the 'lv' argument to allocate_extents. This would normally imply a desire for cling/contiguous allocation to the given LV, but since we are not allocating any parallel extents and only log extents, it works fine. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2102&r2=1.2103 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.163&r2=1.164 --- LVM2/WHATS_NEW 2011/09/13 13:59:19 1.2102 +++ LVM2/WHATS_NEW 2011/09/13 14:37:48 1.2103 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix log size calculation when only a log is being added to a mirror. Work around resume_lv causing error LV scanning during splitmirror operation. Add 7th lv_attr char to show the related kernel target. Terminate pv_attr field correctly. (2.02.86) --- LVM2/lib/metadata/mirror.c 2011/09/13 13:59:19 1.163 +++ LVM2/lib/metadata/mirror.c 2011/09/13 14:37:49 1.164 @@ -1966,7 +1966,7 @@ } /* allocate destination extents */ - ah = allocate_extents(lv->vg, NULL, segtype, + ah = allocate_extents(lv->vg, lv, segtype, 0, 0, log_count - old_log_count, region_size, 0, allocatable_pvs, alloc, parallel_areas); if (!ah) { From prajnoha@sourceware.org Tue Sep 13 15:13:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Tue, 13 Sep 2011 15:13:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c Message-ID: <20110913151342.26443.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-13 15:13:41 Modified files: . : WHATS_NEW_DM libdm/ioctl : libdm-iface.c Log message: Retry DM_DEVICE_REMOVE ioctl if device is busy. This is a workaround for long-lasting problem with using the WATCH udev rule. When trying to remove a DM device, this one can still be opened while processing the event in parallel (generated based on the WATCH udev rule). Let's use this until we have a proper solution. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.498&r2=1.499 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120 --- LVM2/WHATS_NEW_DM 2011/09/07 08:37:48 1.498 +++ LVM2/WHATS_NEW_DM 2011/09/13 15:13:41 1.499 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Retry DM_DEVICE_REMOVE ioctl if device is busy. Remove unused passed parameters for _mirror_emit_segment_line(). Add dm_config and string character escaping functions to libdevmapper. Mark unreleased memory pools as internal error. --- LVM2/libdm/ioctl/libdm-iface.c 2011/08/19 17:02:48 1.119 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/09/13 15:13:41 1.120 @@ -1539,11 +1539,14 @@ return sanitised_message; } +#define DM_REMOVE_IOCTL_RETRIES 25 + static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command, unsigned repeat_count) { struct dm_ioctl *dmi; int ioctl_with_uevent; + int retries = DM_REMOVE_IOCTL_RETRIES; dmi = _flatten(dmt, repeat_count); if (!dmi) { @@ -1627,11 +1630,23 @@ dmt->sector, _sanitise_message(dmt->message), dmi->data_size); #ifdef DM_IOCTLS +repeat_dm_ioctl: if (ioctl(_control_fd, command, dmi) < 0) { if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) || (dmt->type == DM_DEVICE_MKNODES) || (dmt->type == DM_DEVICE_STATUS))) dmi->flags &= ~DM_EXISTS_FLAG; /* FIXME */ + /* + * FIXME: This is a workaround for asynchronous events generated + * as a result of using the WATCH udev rule with which we + * have no way of synchronizing. Processing such events in + * parallel causes devices to be open. + */ + else if (errno == EBUSY && (dmt->type == DM_DEVICE_REMOVE) && retries--) { + log_debug("device-mapper: device is busy, retrying removal"); + usleep(200000); + goto repeat_dm_ioctl; + } else { if (_log_suppress) log_verbose("device-mapper: %s ioctl " From jbrassow@sourceware.org Tue Sep 13 16:33:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Tue, 13 Sep 2011 16:33:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/raid_manip.c Message-ID: <20110913163323.16570.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-13 16:33:22 Modified files: . : WHATS_NEW lib/metadata : raid_manip.c Log message: Changing RAID status flags to 64-bit broke some binary flag operations. LVM_WRITE is a 32-bit flag. Now that RAID[_IMAGE|_META] are 64-bit, and'ing a RAID LV's status against LVM_WRITE can reset the higher order flags. A similar thing will affect thinp flags if not careful. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2103&r2=1.2104 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/raid_manip.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13 --- LVM2/WHATS_NEW 2011/09/13 14:37:48 1.2103 +++ LVM2/WHATS_NEW 2011/09/13 16:33:21 1.2104 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix improper RAID 64-bit status flag reset when and'ing against 32-bit flag. Fix log size calculation when only a log is being added to a mirror. Work around resume_lv causing error LV scanning during splitmirror operation. Add 7th lv_attr char to show the related kernel target. --- LVM2/lib/metadata/raid_manip.c 2011/09/06 18:49:32 1.12 +++ LVM2/lib/metadata/raid_manip.c 2011/09/13 16:33:21 1.13 @@ -971,7 +971,11 @@ if (!_lv_is_on_pvs(seg_lv(seg, s), splittable_pvs)) continue; lv_set_visible(seg_lv(seg, s)); - seg_lv(seg, s)->status &= ~LVM_WRITE; + /* + * LVM_WRITE is 32-bit, if we don't '|' it with + * UINT64_C(0) it will remove all higher order flags + */ + seg_lv(seg, s)->status &= ~(UINT64_C(0) | LVM_WRITE); break; } From jbrassow@sourceware.org Tue Sep 13 18:11:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Tue, 13 Sep 2011 18:11:00 -0000 Subject: LVM2/lib/metadata mirror.c Message-ID: <20110913181139.8073.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-13 18:11:38 Modified files: lib/metadata : mirror.c Log message: Better fix for bug 737125 - unable to create mirror on 1K extent size VG WHATS_NEW entry: Fix log size calculation when only a log is being added to a mirror. The original fix pass the mirror LV to allocate_extents (rather than passing NULL) so that _alloc_init could correctly determine the necessary size of the mirror log. In the previous check-in, I noted: In order to get a decent value computed, we need to pass in the 'lv' argument to allocate_extents. This would normally imply a desire for cling/contiguous allocation to the given LV, but since we are not allocating any parallel extents and only log extents, it works fine. However, passing in the LV did have unintended consequences on the placement of the log. The better solution is to pass in the number of extext that are in the mirror LV instead of the LV itself. This will not cause the allocator to reserve that number of extents, because 'stripes' and 'mirrors' are specified as 0. Thus, 'extents' is used to calculate the size of the log, but won't affect how much is allocated. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165 --- LVM2/lib/metadata/mirror.c 2011/09/13 14:37:49 1.164 +++ LVM2/lib/metadata/mirror.c 2011/09/13 18:11:38 1.165 @@ -1966,9 +1966,10 @@ } /* allocate destination extents */ - ah = allocate_extents(lv->vg, lv, segtype, - 0, 0, log_count - old_log_count, region_size, 0, - allocatable_pvs, alloc, parallel_areas); + ah = allocate_extents(lv->vg, NULL, segtype, + 0, 0, log_count - old_log_count, region_size, + lv->le_count, allocatable_pvs, + alloc, parallel_areas); if (!ah) { log_error("Unable to allocate extents for mirror log."); return 0; From jbrassow@sourceware.org Tue Sep 13 18:43:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Tue, 13 Sep 2011 18:43:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c Message-ID: <20110913184300.12758.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-13 18:42:59 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c Log message: Fix for bug 737200 - Can't create mirrored-log mirror on a VG with small extents Kernel requires a mirror to be at least 1 region large. So, if our mirror log is itself a mirror, it must be at least 1 region large. This restriction may not be necessary for non-mirrored logs, but we apply the rule anyway. (The other option is to make the region size of the log mirror smaller than the mirror it is acting as a log for, but that really complicates things. It's much easier to keep the region_size the same for both.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2104&r2=1.2105 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.283&r2=1.284 --- LVM2/WHATS_NEW 2011/09/13 16:33:21 1.2104 +++ LVM2/WHATS_NEW 2011/09/13 18:42:57 1.2105 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix mirrored log creation when PE size is small - force log_size >= region_size Fix improper RAID 64-bit status flag reset when and'ing against 32-bit flag. Fix log size calculation when only a log is being added to a mirror. Work around resume_lv causing error LV scanning during splitmirror operation. --- LVM2/lib/metadata/lv_manip.c 2011/09/08 16:41:18 1.283 +++ LVM2/lib/metadata/lv_manip.c 2011/09/13 18:42:58 1.284 @@ -687,8 +687,21 @@ /* Log device holds both header and bitset. */ log_size = dm_round_up((MIRROR_LOG_OFFSET << SECTOR_SHIFT) + bitset_size, 1 << SECTOR_SHIFT); log_size >>= SECTOR_SHIFT; + log_size = dm_div_up(log_size, pe_size); - return dm_div_up(log_size, pe_size); + /* + * Kernel requires a mirror to be at least 1 region large. So, + * if our mirror log is itself a mirror, it must be at least + * 1 region large. This restriction may not be necessary for + * non-mirrored logs, but we apply the rule anyway. + * + * (The other option is to make the region size of the log + * mirror smaller than the mirror it is acting as a log for, + * but that really complicates things. It's much easier to + * keep the region_size the same for both.) + */ + return (log_size > (region_size / pe_size)) ? log_size : + (region_size / pe_size); } /* From jbrassow@sourceware.org Tue Sep 13 21:13:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Tue, 13 Sep 2011 21:13:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/mirror.c Message-ID: <20110913211334.9661.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-13 21:13:33 Modified files: . : WHATS_NEW lib/metadata : mirror.c Log message: Fix bug 733400 - Mirror down conversion when specifying the secondary leg is broke The operation of deactivating the residual error target LV after removing a mirror layer can cause a "device in-use" conflict with udev. Giving udev a poke before calling deactivate_lv eliminates the conflict. The stick used to poke udev is 'sync_local_dev_names'. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2105&r2=1.2106 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.165&r2=1.166 --- LVM2/WHATS_NEW 2011/09/13 18:42:57 1.2105 +++ LVM2/WHATS_NEW 2011/09/13 21:13:33 1.2106 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix failure to down-convert a mirror to linear due to udev "dev open" conflict Fix mirrored log creation when PE size is small - force log_size >= region_size Fix improper RAID 64-bit status flag reset when and'ing against 32-bit flag. Fix log size calculation when only a log is being added to a mirror. --- LVM2/lib/metadata/mirror.c 2011/09/13 18:11:38 1.165 +++ LVM2/lib/metadata/mirror.c 2011/09/13 21:13:33 1.166 @@ -419,6 +419,7 @@ return_0; } + sync_local_dev_names(lv->vg->cmd); if (!deactivate_lv(cmd, lv)) return_0; From jbrassow@sourceware.org Wed Sep 14 02:45:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Wed, 14 Sep 2011 02:45:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/mirror.c Message-ID: <20110914024538.3362.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-14 02:45:37 Modified files: . : WHATS_NEW lib/metadata : mirror.c Log message: Fix for bug 734252 - problem up converting striped mirror after image failure lv_mirror_count was not able to handle mirrors of stripes properly. When a failed device is removed, the MIRRORED status flag is removed from the LV conditionally based on the results of lv_mirror_count. However, lv_mirror_count trusted the MIRRORED flag - thinking any such LV must be mirrored. It would happily assign first_seg(lv)->area_count as the number of mirrors, but when a mirrored striped LV was reduced to a simple striped LV area_count would be the number of /stripes/ not the number of /mirrors/. A result higher than 1 would be returned from lv_mirror_count, the MIRRORED flag would not be cleared, and the LV would fail to be up-converted properly in lvconvert_mirrors_aux because of it. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2106&r2=1.2107 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.166&r2=1.167 --- LVM2/WHATS_NEW 2011/09/13 21:13:33 1.2106 +++ LVM2/WHATS_NEW 2011/09/14 02:45:36 1.2107 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix lv_mirror_count to handle mirrored stripes properly. Fix failure to down-convert a mirror to linear due to udev "dev open" conflict Fix mirrored log creation when PE size is small - force log_size >= region_size Fix improper RAID 64-bit status flag reset when and'ing against 32-bit flag. --- LVM2/lib/metadata/mirror.c 2011/09/13 21:13:33 1.166 +++ LVM2/lib/metadata/mirror.c 2011/09/14 02:45:37 1.167 @@ -114,16 +114,18 @@ return 1; seg = first_seg(lv); - mirrors = seg->area_count; + mirrors = 0; for (s = 0; s < seg->area_count; s++) { if (seg_type(seg, s) != AREA_LV) continue; if (is_temporary_mirror_layer(seg_lv(seg, s))) mirrors += lv_mirror_count(seg_lv(seg, s)) - 1; + else + mirrors++; } - return mirrors; + return mirrors ? mirrors : 1; } struct lv_segment *find_mirror_seg(struct lv_segment *seg) From jbrassow@sourceware.org Wed Sep 14 04:10:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Wed, 14 Sep 2011 04:10:00 -0000 Subject: LVM2/lib/metadata mirror.c Message-ID: <20110914041027.18733.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-14 04:10:27 Modified files: lib/metadata : mirror.c Log message: Additional fixes for lv_mirror_count. Changing lv_mirror_count to only count the AREA_LVs made the function stop working for PVMOVE mirrors. A conditional has been added to fix that problem. Additionally, when counting the images in a mirror stack, we don't need to subtract 1 from the count we get back from the lv_mirror_count call on the temporary mirror layer. (This is because we are no falsely counting the top layer of the temporary mirror.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.167&r2=1.168 --- LVM2/lib/metadata/mirror.c 2011/09/14 02:45:37 1.167 +++ LVM2/lib/metadata/mirror.c 2011/09/14 04:10:26 1.168 @@ -114,13 +114,17 @@ return 1; seg = first_seg(lv); + + if (lv->status & PVMOVE) + return seg->area_count; + mirrors = 0; for (s = 0; s < seg->area_count; s++) { if (seg_type(seg, s) != AREA_LV) continue; if (is_temporary_mirror_layer(seg_lv(seg, s))) - mirrors += lv_mirror_count(seg_lv(seg, s)) - 1; + mirrors += lv_mirror_count(seg_lv(seg, s)); else mirrors++; } From zkabelac@sourceware.org Wed Sep 14 09:53:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 14 Sep 2011 09:53:00 -0000 Subject: LVM2/daemons/dmeventd dmeventd.c Message-ID: <20110914095332.1425.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-14 09:53:32 Modified files: daemons/dmeventd: dmeventd.c Log message: Keep the old-style function definition Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84 --- LVM2/daemons/dmeventd/dmeventd.c 2011/08/31 08:23:05 1.83 +++ LVM2/daemons/dmeventd/dmeventd.c 2011/09/14 09:53:32 1.84 @@ -1632,7 +1632,7 @@ /* * Protection against OOM killer if kernel supports it */ -static int _protect_against_oom_killer() +static int _protect_against_oom_killer(void) { struct stat st; From zkabelac@sourceware.org Wed Sep 14 09:54:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 14 Sep 2011 09:54:00 -0000 Subject: LVM2/lib/metadata mirror.c Message-ID: <20110914095421.1606.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-14 09:54:21 Modified files: lib/metadata : mirror.c Log message: Add missing underscores to local static functions Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.168&r2=1.169 --- LVM2/lib/metadata/mirror.c 2011/09/14 04:10:26 1.168 +++ LVM2/lib/metadata/mirror.c 2011/09/14 09:54:21 1.169 @@ -81,7 +81,7 @@ * * Returns: 1 if available, 0 otherwise */ -static int cluster_mirror_is_available(struct logical_volume *lv) +static int _cluster_mirror_is_available(struct logical_volume *lv) { unsigned attr = 0; struct cmd_context *cmd = lv->vg->cmd; @@ -1256,7 +1256,7 @@ return 1; } -static int get_mirror_fault_policy(struct cmd_context *cmd __attribute__((unused)), +static int _get_mirror_fault_policy(struct cmd_context *cmd __attribute__((unused)), int log_policy) { const char *policy; @@ -1287,14 +1287,14 @@ return MIRROR_REMOVE; } -static int get_mirror_log_fault_policy(struct cmd_context *cmd) +static int _get_mirror_log_fault_policy(struct cmd_context *cmd) { - return get_mirror_fault_policy(cmd, 1); + return _get_mirror_fault_policy(cmd, 1); } -static int get_mirror_device_fault_policy(struct cmd_context *cmd) +static int _get_mirror_device_fault_policy(struct cmd_context *cmd) { - return get_mirror_fault_policy(cmd, 0); + return _get_mirror_fault_policy(cmd, 0); } /* @@ -1310,7 +1310,7 @@ * * Returns: 0 on failure, 1 on reconfig, -1 if no reconfig done */ -static int replace_mirror_images(struct lv_segment *mirrored_seg, +static int _replace_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirrors, int log_policy, int in_sync) { @@ -1381,10 +1381,10 @@ log_warn("WARNING: Bad device removed from mirror volume, %s/%s", mirrored_seg->lv->vg->name, mirrored_seg->lv->name); - log_policy = get_mirror_log_fault_policy(mirrored_seg->lv->vg->cmd); - dev_policy = get_mirror_device_fault_policy(mirrored_seg->lv->vg->cmd); + log_policy = _get_mirror_log_fault_policy(mirrored_seg->lv->vg->cmd); + dev_policy = _get_mirror_device_fault_policy(mirrored_seg->lv->vg->cmd); - r = replace_mirror_images(mirrored_seg, + r = _replace_mirror_images(mirrored_seg, (dev_policy != MIRROR_REMOVE) ? old_num_mirrors : num_mirrors, log_policy, in_sync); @@ -2103,7 +2103,7 @@ if (vg_is_clustered(lv->vg)) { /* FIXME: review check of lv_is_active_remotely */ - if (!cluster_mirror_is_available(lv)) { + if (!_cluster_mirror_is_available(lv)) { log_error("Shared cluster mirrors are not available."); return 0; } From zkabelac@sourceware.org Wed Sep 14 09:57:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 14 Sep 2011 09:57:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ... Message-ID: <20110914095736.2732.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-14 09:57:36 Modified files: . : WHATS_NEW lib/metadata : metadata-exported.h raid_manip.c Log message: LVM_WRITE and LVM_READ are 64bit constants Revert John patch, which fixed only 1 place where ~LVM_WRITE was in use and convert ommited LVM_READ/WRITE flags to 64bit constants as well. (Since both 'status' flags for LV and VG are 64bit.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2107&r2=1.2108 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.210&r2=1.211 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/raid_manip.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14 --- LVM2/WHATS_NEW 2011/09/14 02:45:36 1.2107 +++ LVM2/WHATS_NEW 2011/09/14 09:57:35 1.2108 @@ -3,7 +3,6 @@ Fix lv_mirror_count to handle mirrored stripes properly. Fix failure to down-convert a mirror to linear due to udev "dev open" conflict Fix mirrored log creation when PE size is small - force log_size >= region_size - Fix improper RAID 64-bit status flag reset when and'ing against 32-bit flag. Fix log size calculation when only a log is being added to a mirror. Work around resume_lv causing error LV scanning during splitmirror operation. Add 7th lv_attr char to show the related kernel target. --- LVM2/lib/metadata/metadata-exported.h 2011/09/08 20:55:39 1.210 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/14 09:57:35 1.211 @@ -88,8 +88,8 @@ #define THIN_POOL_DATA UINT64_C(0x0000004000000000) /* LV */ #define THIN_POOL_METADATA UINT64_C(0x0000008000000000) /* LV */ -#define LVM_READ 0x00000100U /* LV VG 32-bit */ -#define LVM_WRITE 0x00000200U /* LV VG 32-bit */ +#define LVM_READ UINT64_C(0x00000100) /* LV, VG */ +#define LVM_WRITE UINT64_C(0x00000200) /* LV, VG */ #define CLUSTERED UINT64_C(0x00000400) /* VG */ //#define SHARED UINT64_C(0x00000800) /* VG */ --- LVM2/lib/metadata/raid_manip.c 2011/09/13 16:33:21 1.13 +++ LVM2/lib/metadata/raid_manip.c 2011/09/14 09:57:35 1.14 @@ -971,11 +971,7 @@ if (!_lv_is_on_pvs(seg_lv(seg, s), splittable_pvs)) continue; lv_set_visible(seg_lv(seg, s)); - /* - * LVM_WRITE is 32-bit, if we don't '|' it with - * UINT64_C(0) it will remove all higher order flags - */ - seg_lv(seg, s)->status &= ~(UINT64_C(0) | LVM_WRITE); + seg_lv(seg, s)->status &= ~LVM_WRITE; break; } From zkabelac@sourceware.org Wed Sep 14 10:03:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 14 Sep 2011 10:03:00 -0000 Subject: LVM2/lib/metadata lv.c Message-ID: <20110914100315.5591.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-14 10:03:15 Modified files: lib/metadata : lv.c Log message: Add suggest parentheses around '&&' Follow gcc suggestion. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28 --- LVM2/lib/metadata/lv.c 2011/09/09 01:15:18 1.27 +++ LVM2/lib/metadata/lv.c 2011/09/14 10:03:15 1.28 @@ -406,8 +406,8 @@ else repstr[6] = '-'; - if ((lv_is_thin_volume(lv) && (seg = first_seg(lv)) && seg->pool_lv && (seg = first_seg(seg->pool_lv))) || - (lv_is_thin_pool(lv) && (seg = first_seg(lv))) && + if (((lv_is_thin_volume(lv) && (seg = first_seg(lv)) && seg->pool_lv && (seg = first_seg(seg->pool_lv))) || + (lv_is_thin_pool(lv) && (seg = first_seg(lv)))) && seg->zero_new_blocks) repstr[7] = 'z'; else From mbroz@sourceware.org Wed Sep 14 14:20:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Wed, 14 Sep 2011 14:20:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c Message-ID: <20110914142017.8439.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-09-14 14:20:17 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c Log message: Activate virtual snapshot origin exclusively (only on local node in cluster). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2108&r2=1.2109 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.284&r2=1.285 --- LVM2/WHATS_NEW 2011/09/14 09:57:35 1.2108 +++ LVM2/WHATS_NEW 2011/09/14 14:20:16 1.2109 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Activate virtual snapshot origin exclusively (only on local node in cluster). Fix lv_mirror_count to handle mirrored stripes properly. Fix failure to down-convert a mirror to linear due to udev "dev open" conflict Fix mirrored log creation when PE size is small - force log_size >= region_size --- LVM2/lib/metadata/lv_manip.c 2011/09/13 18:42:58 1.284 +++ LVM2/lib/metadata/lv_manip.c 2011/09/14 14:20:16 1.285 @@ -4154,7 +4154,7 @@ (!(org = _create_virtual_origin(cmd, vg, lv->name, lp->permission, lp->voriginextents)) || - !activate_lv(cmd, org))) { + !activate_lv_excl(cmd, org))) { log_error("Couldn't create virtual origin for LV %s", lv->name); if (org && !lv_remove(org)) From zkabelac@sourceware.org Wed Sep 14 16:07:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 14 Sep 2011 16:07:00 -0000 Subject: LVM2/libdm libdm-string.c Message-ID: <20110914160708.3957.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-14 16:07:08 Modified files: libdm : libdm-string.c Log message: Fix memory overwrite Transfer of build_dm_uuid() function into libdm made uuid_prefix as parameter, thus sizeof() was replaced with strlen() and room for '\0' missed. As it's only fix in current version - no whatsnew. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-string.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/libdm/libdm-string.c 2011/09/01 17:58:27 1.16 +++ LVM2/libdm/libdm-string.c 2011/09/14 16:07:07 1.17 @@ -347,7 +347,7 @@ if (!layer) layer = ""; - len = strlen(uuid_prefix) + strlen(lvid) + strlen(layer) + 1; + len = strlen(uuid_prefix) + strlen(lvid) + strlen(layer) + 2; if (!(dmuuid = dm_pool_alloc(mem, len))) { log_error("build_dm_name: Allocation failed for %" PRIsize_t From mbroz@sourceware.org Wed Sep 14 18:20:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Wed, 14 Sep 2011 18:20:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgchange.c Message-ID: <20110914182004.1844.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-09-14 18:20:04 Modified files: . : WHATS_NEW tools : vgchange.c Log message: Fix vgchange activation of snapshot with virtual origin. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2109&r2=1.2110 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123 --- LVM2/WHATS_NEW 2011/09/14 14:20:16 1.2109 +++ LVM2/WHATS_NEW 2011/09/14 18:20:03 1.2110 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix vgchange activation of snapshot with virtual origin. Activate virtual snapshot origin exclusively (only on local node in cluster). Fix lv_mirror_count to handle mirrored stripes properly. Fix failure to down-convert a mirror to linear due to udev "dev open" conflict --- LVM2/tools/vgchange.c 2011/09/07 08:41:48 1.122 +++ LVM2/tools/vgchange.c 2011/09/14 18:20:04 1.123 @@ -100,6 +100,10 @@ if (!lv_is_visible(lv)) continue; + /* If LV is sparse, activate origin instead */ + if (lv_is_cow(lv) && lv_is_virtual_origin(origin_from_cow(lv))) + lv = origin_from_cow(lv); + /* Only request activation of snapshot origin devices */ if ((lv->status & SNAPSHOT) || lv_is_cow(lv)) continue; From mbroz@sourceware.org Thu Sep 15 15:26:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 15 Sep 2011 15:26:00 -0000 Subject: LVM2 ./WHATS_NEW tools/lvcreate.c tools/lvresi ... Message-ID: <20110915152641.20268.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-09-15 15:26:40 Modified files: . : WHATS_NEW tools : lvcreate.c lvresize.c toollib.c tools.h Added files: test : t-lvcreate-large.sh Log message: Fix possible overflow of size if %FREE or %VG is used. https://bugzilla.redhat.com/show_bug.cgi?id=737087 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2110&r2=1.2111 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-large.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.240&r2=1.241 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.135&r2=1.136 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.230&r2=1.231 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.76&r2=1.77 --- LVM2/WHATS_NEW 2011/09/14 18:20:03 1.2110 +++ LVM2/WHATS_NEW 2011/09/15 15:26:40 1.2111 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix possible overflow of size if %FREE or %VG is used. Fix vgchange activation of snapshot with virtual origin. Activate virtual snapshot origin exclusively (only on local node in cluster). Fix lv_mirror_count to handle mirrored stripes properly. /cvs/lvm2/LVM2/test/t-lvcreate-large.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvcreate-large.sh +++ - 2011-09-15 15:26:41.117437000 +0000 @@ -0,0 +1,40 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# 'Exercise some lvcreate diagnostics' + +. lib/test + +aux prepare_vg 4 + +lvcreate -s -l 100%FREE -n $lv $vg --virtualsize 1024T + +#FIXME this should be 1024T +#check lv_field $vg/$lv size "128.00m" + +aux lvmconf 'devices/filter = [ "a/dev\/mapper\/.*$/", "a/dev\/LVMTEST/", "r/.*/" ]' + +pvcreate $DM_DEV_DIR/$vg/$lv +vgcreate $vg1 $DM_DEV_DIR/$vg/$lv + +lvcreate -l 100%FREE -n $lv1 $vg1 +check lv_field $vg1/$lv1 size "1024.00t" +lvresize -f -l 72%VG $vg1/$lv1 +check lv_field $vg1/$lv1 size "737.28t" +lvremove -ff $vg1/$lv1 + +lvcreate -l 100%VG -n $lv1 $vg1 +check lv_field $vg1/$lv1 size "1024.00t" +lvresize -f -l 72%VG $vg1/$lv1 +check lv_field $vg1/$lv1 size "737.28t" +lvremove -ff $vg1/$lv1 + +lvremove -ff $vg/$lv \ No newline at end of file --- LVM2/tools/lvcreate.c 2011/09/08 16:41:19 1.240 +++ LVM2/tools/lvcreate.c 2011/09/15 15:26:40 1.241 @@ -250,17 +250,17 @@ switch(lcp->percent) { case PERCENT_VG: - lp->extents = lp->extents * vg->extent_count / 100; + lp->extents = percent_of_extents(lp->extents, vg->extent_count); break; case PERCENT_FREE: - lp->extents = lp->extents * vg->free_count / 100; + lp->extents = percent_of_extents(lp->extents, vg->free_count); break; case PERCENT_PVS: if (!lcp->pv_count) - lp->extents = lp->extents * vg->extent_count / 100; + lp->extents = percent_of_extents(lp->extents, vg->extent_count); else { pv_extent_count = pv_list_extents_free(lp->pvh); - lp->extents = lp->extents * pv_extent_count / 100; + lp->extents = percent_of_extents(lp->extents, pv_extent_count); } break; case PERCENT_LV: @@ -278,7 +278,7 @@ log_error(INTERNAL_ERROR "Couldn't find origin volume."); return 0; } - lp->extents = lp->extents * origin->le_count / 100; + lp->extents = percent_of_extents(lp->extents, origin->le_count); break; case PERCENT_NONE: break; --- LVM2/tools/lvresize.c 2011/09/06 00:26:43 1.135 +++ LVM2/tools/lvresize.c 2011/09/15 15:26:40 1.136 @@ -433,27 +433,27 @@ switch(lp->percent) { case PERCENT_VG: - lp->extents = lp->extents * vg->extent_count / 100; + lp->extents = percent_of_extents(lp->extents, vg->extent_count); break; case PERCENT_FREE: - lp->extents = lp->extents * vg->free_count / 100; + lp->extents = percent_of_extents(lp->extents, vg->free_count); break; case PERCENT_LV: - lp->extents = lp->extents * lv->le_count / 100; + lp->extents = percent_of_extents(lp->extents, lv->le_count); break; case PERCENT_PVS: if (lp->argc) { pv_extent_count = pv_list_extents_free(pvh); - lp->extents = lp->extents * pv_extent_count / 100; + lp->extents = percent_of_extents(lp->extents, pv_extent_count); } else - lp->extents = lp->extents * vg->extent_count / 100; + lp->extents = percent_of_extents(lp->extents, vg->extent_count); break; case PERCENT_ORIGIN: if (!lv_is_cow(lv)) { log_error("Specified LV does not have an origin LV."); return EINVALID_CMD_LINE; } - lp->extents = lp->extents * origin_from_cow(lv)->le_count / 100; + lp->extents = percent_of_extents(lp->extents, origin_from_cow(lv)->le_count); break; case PERCENT_NONE: break; --- LVM2/tools/toollib.c 2011/09/07 08:41:48 1.230 +++ LVM2/tools/toollib.c 2011/09/15 15:26:40 1.231 @@ -1623,3 +1623,9 @@ return 1; } + +/* Return percents of extents and avoid overflow */ +uint32_t percent_of_extents(uint32_t percents, uint32_t count) +{ + return (uint32_t)((uint64_t)percents * (uint64_t)count / 100); +} --- LVM2/tools/tools.h 2011/07/08 19:42:11 1.76 +++ LVM2/tools/tools.h 2011/09/15 15:26:40 1.77 @@ -181,4 +181,5 @@ int mirror_remove_missing(struct cmd_context *cmd, struct logical_volume *lv, int force); +uint32_t percent_of_extents(uint32_t percents, uint32_t count); #endif From mornfall@sourceware.org Thu Sep 15 18:51:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Thu, 15 Sep 2011 18:51:00 -0000 Subject: LVM2 tools/lvresize.c test/t-lvresize-rounding.sh Message-ID: <20110915185112.31044.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-09-15 18:51:11 Modified files: tools : lvresize.c Added files: test : t-lvresize-rounding.sh Log message: When resizing LVs, always round in the safe direction, regardless of whether we were called as lvresize or lvreduce. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvresize-rounding.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.136&r2=1.137 /cvs/lvm2/LVM2/test/t-lvresize-rounding.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvresize-rounding.sh +++ - 2011-09-15 18:51:11.985248000 +0000 @@ -0,0 +1,25 @@ +# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 2 + +lvcreate -l 10 -n lv -i2 $vg + +lvextend -l +1 $vg/lv 2>&1 | tee log +grep 'down to stripe' log +lvresize -l +1 $vg/lv 2>&1 | tee log +grep 'down to stripe' log + +lvreduce -f -l -1 $vg/lv 2>&1 | tee log +grep 'up to stripe' log +lvresize -f -l -1 $vg/lv 2>&1 | tee log +grep 'up to stripe' log --- LVM2/tools/lvresize.c 2011/09/15 15:26:40 1.136 +++ LVM2/tools/lvresize.c 2011/09/15 18:51:11 1.137 @@ -606,7 +606,8 @@ stripesize_extents = 1; size_rest = seg_size % (lp->stripes * stripesize_extents); - if (size_rest && lp->resize == LV_REDUCE) { + /* Round toward the original size. */ + if (size_rest && lp->extents < lv->le_count) { log_print("Rounding size (%d extents) up to stripe " "boundary size for segment (%d extents)", lp->extents, lp->extents - size_rest + From mornfall@sourceware.org Thu Sep 15 20:01:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Thu, 15 Sep 2011 20:01:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20110915200121.13339.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-09-15 20:01:21 Modified files: . : WHATS_NEW Log message: Update WHATS_NEW. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2111&r2=1.2112 --- LVM2/WHATS_NEW 2011/09/15 15:26:40 1.2111 +++ LVM2/WHATS_NEW 2011/09/15 20:01:21 1.2112 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix rounding direction in lvresize when reducing volume size. Fix possible overflow of size if %FREE or %VG is used. Fix vgchange activation of snapshot with virtual origin. Activate virtual snapshot origin exclusively (only on local node in cluster). From mornfall@sourceware.org Fri Sep 16 09:59:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Fri, 16 Sep 2011 09:59:00 -0000 Subject: LVM2 lib/metadata/lv_manip.c test/t-lvcreate-s ... Message-ID: <20110916095943.957.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-09-16 09:59:43 Modified files: lib/metadata : lv_manip.c Added files: test : t-lvcreate-striped-mirror.sh Log message: Fix the divisibility check in the allocator for the mirror+stripe case (require divisibility by stripe count alone, not by (mirror*stripe)). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.285&r2=1.286 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-striped-mirror.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 --- LVM2/lib/metadata/lv_manip.c 2011/09/14 14:20:16 1.285 +++ LVM2/lib/metadata/lv_manip.c 2011/09/16 09:59:42 1.286 @@ -1917,10 +1917,11 @@ return 1; } - if (ah->area_multiple > 1 && - (ah->new_extents - alloc_state.allocated) % ah->area_count) { + if (ah->area_multiple > 1 && + (ah->new_extents - alloc_state.allocated) % ah->area_multiple) { log_error("Number of extents requested (%d) needs to be divisible by %d.", - ah->new_extents - alloc_state.allocated, ah->area_count); + ah->new_extents - alloc_state.allocated, + ah->area_multiple); return 0; } /cvs/lvm2/LVM2/test/t-lvcreate-striped-mirror.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvcreate-striped-mirror.sh +++ - 2011-09-16 09:59:43.392905000 +0000 @@ -0,0 +1,65 @@ +#!/bin/sh +# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test +aux prepare_vg 9 + +lvcreate -i2 -l2 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i2 -l4 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i3 -l3 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i4 -l4 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + + +lvcreate -i2 -l2 -m2 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i3 -l3 -m2 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i2 -l2 -m3 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i3 -l2 -m2 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +grep "Rounding size (2 extents) up to .* (3 extents)" log +lvremove -ff $vg + +lvcreate -i3 -l4 -m2 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +grep "Rounding size (4 extents) up to .* (6 extents)" log +lvremove -ff $vg + +lvcreate -i3 -l4 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +grep "Rounding size (4 extents) up to .* (6 extents)" log +lvremove -ff $vg + +lvcreate -i4 -l4 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +lvremove -ff $vg From mornfall@sourceware.org Fri Sep 16 10:02:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Fri, 16 Sep 2011 10:02:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20110916100214.2157.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-09-16 10:02:14 Modified files: . : WHATS_NEW Log message: Update WHATS_NEW. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2112&r2=1.2113 --- LVM2/WHATS_NEW 2011/09/15 20:01:21 1.2112 +++ LVM2/WHATS_NEW 2011/09/16 10:02:14 1.2113 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix overly strict extent-count divisibility requirements for striped mirrors. Fix rounding direction in lvresize when reducing volume size. Fix possible overflow of size if %FREE or %VG is used. Fix vgchange activation of snapshot with virtual origin. From zkabelac@sourceware.org Fri Sep 16 11:52:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 16 Sep 2011 11:52:00 -0000 Subject: LVM2/test t-lvcreate-pvtags.sh Message-ID: <20110916115233.19273.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-16 11:52:33 Modified files: test : t-lvcreate-pvtags.sh Log message: Remove vg at the test's end Speedup this test by removing mirrored vg when it's not longer needed. teardown() seems to be waiting here for too long. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-pvtags.sh.diff?cvsroot=lvm2&r1=1.9&r2=1.10 --- LVM2/test/t-lvcreate-pvtags.sh 2011/02/28 19:44:21 1.9 +++ LVM2/test/t-lvcreate-pvtags.sh 2011/09/16 11:52:33 1.10 @@ -43,3 +43,5 @@ # lvcreate mirror with a single PV arg not lvcreate -l1 -m1 --corelog $vg $dev1 + +vgremove -ff $vg From zkabelac@sourceware.org Fri Sep 16 11:53:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 16 Sep 2011 11:53:00 -0000 Subject: LVM2/lib/metadata merge.c Message-ID: <20110916115314.20320.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-16 11:53:14 Modified files: lib/metadata : merge.c Log message: Trim spaces on EOL Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49 --- LVM2/lib/metadata/merge.c 2011/09/08 16:41:18 1.48 +++ LVM2/lib/metadata/merge.c 2011/09/16 11:53:14 1.49 @@ -202,7 +202,7 @@ inc_error_count; } } else { - if (seg->pool_metadata_lv) { + if (seg->pool_metadata_lv) { log_error("LV %s: segment %u must not have thin pool metadata LV set", lv->name, seg_count); inc_error_count; @@ -222,7 +222,7 @@ inc_error_count; } - if (!seg->pool_lv) { + if (!seg->pool_lv) { log_error("LV %s: segment %u is missing thin pool LV", lv->name, seg_count); inc_error_count; @@ -232,7 +232,7 @@ inc_error_count; } } else { - if (seg->pool_lv) { + if (seg->pool_lv) { log_error("LV %s: segment %u must not have thin pool LV set", lv->name, seg_count); inc_error_count; From zkabelac@sourceware.org Fri Sep 16 11:59:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 16 Sep 2011 11:59:00 -0000 Subject: LVM2/lib/metadata lv_manip.c Message-ID: <20110916115923.21652.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-16 11:59:22 Modified files: lib/metadata : lv_manip.c Log message: Reset LV status when unlinking LV from VG When LV is unlinked, we want to catch problem in vg_validate, that LV has changed. i.e. catch LV has been removed and is no long thin_pool while still being referenced by some thin volume. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.286&r2=1.287 --- LVM2/lib/metadata/lv_manip.c 2011/09/16 09:59:42 1.286 +++ LVM2/lib/metadata/lv_manip.c 2011/09/16 11:59:22 1.287 @@ -3028,6 +3028,8 @@ dm_list_del(&lvl->list); + lv->status = 0; /* Reset */ + return 1; } From zkabelac@sourceware.org Fri Sep 16 12:01:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 16 Sep 2011 12:01:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20110916120148.22509.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-16 12:01:48 Modified files: . : WHATS_NEW Log message: Update Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2113&r2=1.2114 --- LVM2/WHATS_NEW 2011/09/16 10:02:14 1.2113 +++ LVM2/WHATS_NEW 2011/09/16 12:01:48 1.2114 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Reset LV status when unlinking LV from VG. Fix overly strict extent-count divisibility requirements for striped mirrors. Fix rounding direction in lvresize when reducing volume size. Fix possible overflow of size if %FREE or %VG is used. From zkabelac@sourceware.org Fri Sep 16 12:10:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 16 Sep 2011 12:10:00 -0000 Subject: LVM2 ./WHATS_NEW tools/lvmcmdline.c Message-ID: <20110916121003.24495.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-16 12:10:03 Modified files: . : WHATS_NEW tools : lvmcmdline.c Log message: Fix command line option decoding LVM has huge set of options now - it's approaching 60 short-arg less options and we get interesting case of misdetection for 'merge' option which has been put into the middle of options with 'short_arg' - thus certainly past 65. (ASCII 'A'). To avoid confusion of short_arg with long_opt number - add '128' to all such non-short-arg options. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2114&r2=1.2115 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.147&r2=1.148 --- LVM2/WHATS_NEW 2011/09/16 12:01:48 1.2114 +++ LVM2/WHATS_NEW 2011/09/16 12:10:02 1.2115 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix command line option decoding. Reset LV status when unlinking LV from VG. Fix overly strict extent-count divisibility requirements for striped mirrors. Fix rounding direction in lvresize when reducing volume size. --- LVM2/tools/lvmcmdline.c 2011/09/02 01:32:08 1.147 +++ LVM2/tools/lvmcmdline.c 2011/09/16 12:10:02 1.148 @@ -641,7 +641,7 @@ if (a->short_arg) (*o)->val = a->short_arg; else - (*o)->val = arg; + (*o)->val = arg + 128; (*o)++; } #endif @@ -662,7 +662,7 @@ * the_args. */ if ((a->short_arg && (opt == a->short_arg)) || - (!a->short_arg && (opt == arg))) + (!a->short_arg && (opt == (arg + 128)))) return arg; } From zkabelac@sourceware.org Fri Sep 16 12:12:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 16 Sep 2011 12:12:00 -0000 Subject: LVM2/lib/metadata lv_manip.c Message-ID: <20110916121254.25068.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-16 12:12:54 Modified files: lib/metadata : lv_manip.c Log message: Remove thin volumes before thin pools When user wants to remove thin pool - check if there are no thin volumes using it. If so - query before removal (or -ff for no question) and remove them first. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.287&r2=1.288 --- LVM2/lib/metadata/lv_manip.c 2011/09/16 11:59:22 1.287 +++ LVM2/lib/metadata/lv_manip.c 2011/09/16 12:12:51 1.288 @@ -3178,6 +3178,22 @@ } } + if (lv_is_thin_pool(lv) && dm_list_size(&lv->segs_using_this_lv)) { + /* remove thin LVs first */ + if ((force == PROMPT) && + yes_no_prompt("Do you really want to remove all thin volumes when removing " + "pool logical volume %s? [y/n]: ", lv->name) == 'n') { + log_error("Logical volume %s not removed", lv->name); + return 0; + } + dm_list_iterate_safe(snh, snht, &lv->segs_using_this_lv) { + if (!lv_remove_with_dependencies(cmd, + dm_list_item(snh, struct seg_list)->seg->lv, + force, level + 1)) + return 0; + } + } + return lv_remove_single(cmd, lv, force); } From zkabelac@sourceware.org Fri Sep 16 12:24:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 16 Sep 2011 12:24:00 -0000 Subject: LVM2/test t-lvcreate-thin.sh Message-ID: <20110916122359.27089.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-16 12:23:59 Added files: test : t-lvcreate-thin.sh Log message: Add inital thin testing Currently test is skipped by default (since it needs code hack to work) Check command line options to create & remove thin pools and thin volumes. Activation code for thin LV support is missing, thus it only works without driver loaded. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-thin.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 /cvs/lvm2/LVM2/test/t-lvcreate-thin.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvcreate-thin.sh +++ - 2011-09-16 12:23:59.826257000 +0000 @@ -0,0 +1,146 @@ +#!/bin/sh + +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# test currently needs to drop +# 'return NULL' in _lv_create_an_lv after log_error("Can't create %s without using " +exit 200 + +. lib/test + +aux prepare_vg 4 + +# FIXME: !!!disabled activation for testing for now!!! +aux lvmconf "global/activation = 0" + +check_lv_exists_() +{ + for d in $*; do + check lv_exists $vg $d + done +} + + +# Create named pool only +lvcreate -L4M -T $vg/pool1 +lvcreate -L4M -T --thinpool $vg/pool2 +lvcreate -L4M -T --thinpool pool3 $vg +lvcreate -L4M --type thin $vg/pool4 +lvcreate -L4M --type thin --thinpool $vg/pool5 +lvcreate -L4M --type thin --thinpool pool6 $vg +lvcreate -L4M --type thin_pool $vg/pool7 +lvcreate -L4M --type thin_pool --thinpool $vg/pool8 +lvcreate -L4M --type thin_pool --thinpool pool9 $vg + +lvremove $vg/pool1 $vg/pool2 $vg/pool3 $vg/pool4 $vg/pool5 $vg/pool6 $vg/pool7 $vg/pool8 $vg/pool9 + + +# Create default pool name +lvcreate -L8M -T $vg +lvcreate -L8M --type thin $vg +lvcreate -L8M --type thin_pool $vg + +lvremove $vg/lvol0 $vg/lvol1 $vg/lvol2 + + +# Create default pool and default thin LV +lvcreate -L8M -V2G -T $vg +lvcreate -L8M -V2G --type thin $vg + +lvremove -ff $vg/lvol0 $vg/lvol2 + + +# Create given pool and default thin LV +lvcreate -L8M -V2G -T $vg/pool1 +lvcreate -L8M -V2G -T --thinpool $vg/pool2 +lvcreate -L8M -V2G -T --thinpool pool3 $vg +lvcreate -L8M -V2G --type thin $vg/pool4 +lvcreate -L8M -V2G --type thin --thinpool $vg/pool5 +lvcreate -L8M -V2G --type thin --thinpool pool6 $vg + +check_lv_exists_ lvol0 lvol1 lvol2 lvol3 lvol4 lvol5 +lvremove -ff $vg/pool1 $vg/pool2 $vg/pool3 $vg/pool4 $vg/pool5 $vg/pool6 + + +# Create given pool and given thin LV +lvcreate -L8M -V2G -T $vg/pool1 --name lv1 +lvcreate -L8M -V2G -T $vg/pool2 --name $vg/lv2 +lvcreate -L8M -V2G -T --thinpool $vg/pool3 --name lv3 +lvcreate -L8M -V2G -T --thinpool $vg/pool4 --name $vg/lv4 +lvcreate -L8M -V2G -T --thinpool pool5 --name lv5 $vg +lvcreate -L8M -V2G -T --thinpool pool6 --name $vg/lv6 $vg + +check_lv_exists_ lv1 lv2 lv3 lv4 lv5 lv6 +lvremove -ff $vg/pool1 $vg/pool2 $vg/pool3 $vg/pool4 $vg/pool5 $vg/pool6 + + +lvcreate -L8M -V2G --type thin $vg/pool1 --name lv1 +lvcreate -L8M -V2G --type thin $vg/pool2 --name $vg/lv2 +lvcreate -L8M -V2G --type thin --thinpool $vg/pool3 --name lv3 +lvcreate -L8M -V2G --type thin --thinpool $vg/pool4 --name $vg/lv4 +lvcreate -L8M -V2G --type thin --thinpool pool5 --name lv5 $vg +lvcreate -L8M -V2G --type thin --thinpool pool6 --name $vg/lv6 $vg + +check_lv_exists_ lv1 lv2 lv3 lv4 lv5 lv6 +lvremove -ff $vg/pool1 $vg/pool2 $vg/pool3 $vg/pool4 $vg/pool5 $vg/pool6 + + +check vg_field $vg lv_count 0 + +# Create thin LV in existing pool +lvcreate -L8M -T $vg/pool +lvcreate -V2G -T $vg/pool +lvcreate -V2G -T --thinpool $vg/pool +lvcreate -V2G -T --thinpool pool $vg +lvcreate -V2G --type thin $vg/pool +lvcreate -V2G --type thin --thinpool $vg/pool +lvcreate -V2G --type thin --thinpool pool $vg + +check_lv_exists_ lvol0 lvol1 lvol2 lvol3 lvol4 lvol5 + + +lvcreate -V2G -T $vg/pool --name lv1 +lvcreate -V2G -T $vg/pool --name $vg/lv2 +lvcreate -V2G -T --thinpool $vg/pool --name lv3 +lvcreate -V2G -T --thinpool $vg/pool --name $vg/lv4 +lvcreate -V2G -T --thinpool pool --name lv5 $vg +lvcreate -V2G -T --thinpool pool --name $vg/lv6 $vg +lvcreate -V2G --type thin $vg/pool --name lv7 +lvcreate -V2G --type thin $vg/pool --name $vg/lv8 +lvcreate -V2G --type thin --thinpool $vg/pool --name lv9 +lvcreate -V2G --type thin --thinpool $vg/pool --name $vg/lv10 +lvcreate -V2G --type thin --thinpool pool --name lv11 $vg +lvcreate -V2G --type thin --thinpool pool --name $vg/lv12 $vg + +check_lv_exists_ lv1 lv2 lv3 lv4 lv5 lv6 lv7 lv8 lv9 lv10 lv11 lv12 +check vg_field $vg lv_count 19 +lvremove -ff $vg/pool + + +check vg_field $vg lv_count 0 + +exit 0 +# FIXME: !!!Unsupported yet!!! + +# Create snapshot of thinLV +lvcreate -L8M -V2G -T $vg/pool --name lv1 +should lvcreate -s $vg/lv1 +should lvcreate -s $vg/lv1 --name lv2 +should lvcreate -s $vg/lv1 --name $vg/lv3 +should lvcreate --type snapshot $vg/lv1 +should lvcreate --type snapshot $vg/lv1 --name lv4 +should lvcreate --type snapshot $vg/lv1 --name $vg/lv5 + +# Normal Snapshots +should lvcreate -s $vg/lv0 -L8M +should lvcreate -s $vg/lv0 -L8M --name lv6 +should lvcreate -s $vg/lv0 -L8M --name $vg/lv7 +should lvcreate -s lv0 -L12M --name $vg/lv8 From mbroz@sourceware.org Fri Sep 16 14:32:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Fri, 16 Sep 2011 14:32:00 -0000 Subject: LVM2/test t-lvcreate-large.sh Message-ID: <20110916143248.25236.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-09-16 14:32:47 Modified files: test : t-lvcreate-large.sh Log message: Disable t-lvcreate-large.sh for now with cluster. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-large.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/test/t-lvcreate-large.sh 2011/09/15 15:26:40 1.1 +++ LVM2/test/t-lvcreate-large.sh 2011/09/16 14:32:47 1.2 @@ -13,6 +13,9 @@ . lib/test +# FIXME: remove it later when locking in virtual origin is fixed +test -e LOCAL_CLVMD && exit 200 + aux prepare_vg 4 lvcreate -s -l 100%FREE -n $lv $vg --virtualsize 1024T From mbroz@sourceware.org Fri Sep 16 14:40:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Fri, 16 Sep 2011 14:40:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c Message-ID: <20110916144008.19274.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-09-16 14:40:07 Modified files: . : WHATS_NEW daemons/clvmd : clvmd.c Log message: Fix clvmd processing of invalid request on local socket. (rommer) Code now detects small packet and wrong arglen and reply with error intead of infinite loop. https://bugzilla.redhat.com/show_bug.cgi?id=738484 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2115&r2=1.2116 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.108&r2=1.109 --- LVM2/WHATS_NEW 2011/09/16 12:10:02 1.2115 +++ LVM2/WHATS_NEW 2011/09/16 14:40:06 1.2116 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix clvmd processing of invalid request on local socket. Fix command line option decoding. Reset LV status when unlinking LV from VG. Fix overly strict extent-count divisibility requirements for striped mirrors. --- LVM2/daemons/clvmd/clvmd.c 2011/08/12 02:16:46 1.108 +++ LVM2/daemons/clvmd/clvmd.c 2011/09/16 14:40:07 1.109 @@ -1061,6 +1061,7 @@ int missing_len; char buffer[PIPE_BUF]; + memset(buffer, 0, PIPE_BUF); len = read(thisfd->fd, buffer, sizeof(buffer)); if (len == -1 && errno == EINTR) return 1; @@ -1169,9 +1170,6 @@ return len; } - /* Free any old buffer space */ - free(thisfd->bits.localsock.cmd); - /* See if we have the whole message */ argslen = len - strlen(inheader->node) - sizeof(struct clvm_header); @@ -1180,6 +1178,22 @@ if (missing_len < 0) missing_len = 0; + /* We need at least sizeof(struct clvm_header) bytes in buffer */ + if (len < sizeof(struct clvm_header) || argslen < 0) { + struct clvm_header reply; + reply.cmd = CLVMD_CMD_REPLY; + reply.status = EINVAL; + reply.arglen = 0; + reply.flags = 0; + send_message(&reply, sizeof(reply), our_csid, + thisfd->fd, + "Error sending EINVAL reply to local user"); + return 0; + } + + /* Free any old buffer space */ + free(thisfd->bits.localsock.cmd); + /* Save the message */ thisfd->bits.localsock.cmd = malloc(len + missing_len); @@ -1203,15 +1217,23 @@ char *argptr = inheader->node + strlen(inheader->node) + 1; - while (missing_len > 0 && len >= 0) { + while (missing_len > 0) { DEBUGLOG ("got %d bytes, need another %d (total %d)\n", argslen, missing_len, inheader->arglen); len = read(thisfd->fd, argptr + argslen, missing_len); - if (len >= 0) { + if (len == -1 && errno == EINTR) + continue; + if (len > 0) { missing_len -= len; argslen += len; + } else { + /* EOF or error on socket */ + DEBUGLOG("EOF on local socket\n"); + free(thisfd->bits.localsock.cmd); + thisfd->bits.localsock.cmd = NULL; + return 0; } } } From jbrassow@sourceware.org Fri Sep 16 16:41:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Fri, 16 Sep 2011 16:41:00 -0000 Subject: LVM2/lib/metadata mirror.c Message-ID: <20110916164138.17664.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-16 16:41:37 Modified files: lib/metadata : mirror.c Log message: After suspend/resume following a splitmirror op, call sync_local_dev_names to settle udev before calling deactivate_lv. This is an intra-release regression (no WHATS_NEW entry required). It is part of the fix for the current WHATS_NEW entry: Work around resume_lv causing error LV scanning during splitmirror operation. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.169&r2=1.170 --- LVM2/lib/metadata/mirror.c 2011/09/14 09:54:21 1.169 +++ LVM2/lib/metadata/mirror.c 2011/09/16 16:41:37 1.170 @@ -747,6 +747,7 @@ * - commit VG changes * - activate the new LV */ + sync_local_dev_names(lv->vg->cmd); new_lv = NULL; dm_list_iterate_items(lvl, &split_images) { if (!new_lv) { From jbrassow@sourceware.org Fri Sep 16 18:39:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Fri, 16 Sep 2011 18:39:00 -0000 Subject: LVM2/lib/metadata lv_manip.c Message-ID: <20110916183904.12434.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-16 18:39:04 Modified files: lib/metadata : lv_manip.c Log message: Fix Bug 738832 - core to disk log conversion fails with internal error This bug showed up when trying to add a log to a mirror whose images are on multiple devices. This is an intra-release regression and no WHATS_NEW entry will be added. The error was introduce in the following commit: 2d8a2f35c77fdeef1dbe0ef791db8530d07826eb The solution is to recognise in _alloc_init that if there are no mirrors or stripes specified, then 'new_extents' should be zero. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.288&r2=1.289 --- LVM2/lib/metadata/lv_manip.c 2011/09/16 12:12:51 1.288 +++ LVM2/lib/metadata/lv_manip.c 2011/09/16 18:39:03 1.289 @@ -767,7 +767,10 @@ return NULL; } - ah->new_extents = new_extents; + if (mirrors || stripes) + ah->new_extents = new_extents; + else + ah->new_extents = 0; ah->area_count = area_count; ah->parity_count = segtype->parity_devs; ah->region_size = region_size; @@ -801,7 +804,7 @@ ah->log_area_count = metadata_area_count; ah->log_len = !metadata_area_count ? 0 : mirror_log_extents(ah->region_size, extent_size, - ah->new_extents / ah->area_multiple); + new_extents / ah->area_multiple); } for (s = 0; s < alloc_count; s++) From zkabelac@sourceware.org Sat Sep 17 13:33:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 17 Sep 2011 13:33:00 -0000 Subject: LVM2/daemons/lvmetad lvmetad-core.c Message-ID: <20110917133352.18009.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-17 13:33:51 Modified files: daemons/lvmetad: lvmetad-core.c Log message: Fix for gcc compilation warnings and put _XOPEN_SOURCE so pthread_mutexattr is properly defined. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26 --- LVM2/daemons/lvmetad/lvmetad-core.c 2011/09/02 11:04:12 1.25 +++ LVM2/daemons/lvmetad/lvmetad-core.c 2011/09/17 13:33:51 1.26 @@ -1,3 +1,6 @@ +#define _GNU_SOURCE +#define _XOPEN_SOURCE 500 /* pthread */ + #include #include #include @@ -19,6 +22,7 @@ } lock; } lvmetad_state; +__attribute__ ((format(printf, 1, 2))) static void debug(const char *fmt, ...) { va_list ap; va_start(ap, fmt); @@ -42,8 +46,11 @@ * allocating memory that we never release. Not good. */ static struct dm_config_tree *lock_vg(lvmetad_state *s, const char *id) { + pthread_mutex_t *vg; + struct dm_config_tree *cft; + lock_vgs(s); - pthread_mutex_t *vg = dm_hash_lookup(s->lock.vg, id); + vg = dm_hash_lookup(s->lock.vg, id); if (!vg) { pthread_mutexattr_t rec; pthread_mutexattr_init(&rec); @@ -53,7 +60,7 @@ dm_hash_insert(s->lock.vg, id, vg); } pthread_mutex_lock(vg); - struct dm_config_tree *cft = dm_hash_lookup(s->vgs, id); + cft = dm_hash_lookup(s->vgs, id); unlock_vgs(s); return cft; } @@ -81,6 +88,7 @@ const char *field, const char *flag, int want) { struct dm_config_value *value = NULL, *pred = NULL; struct dm_config_node *node = dm_config_find_node(parent->child, field); + struct dm_config_value *new; if (node) value = node->v; @@ -112,7 +120,7 @@ node->parent = parent; parent->child = node; } - struct dm_config_value *new = dm_config_create_value(cft); + new = dm_config_create_value(cft); new->type = DM_CFG_STRING; new->v.str = flag; new->next = node->v; @@ -126,10 +134,11 @@ struct dm_config_tree *cft, struct dm_config_node *vg, int act) { + struct dm_config_node *pv; int complete = 1; lock_pvs(s); - struct dm_config_node *pv = pvs(vg); + pv = pvs(vg); while (pv) { const char *uuid = dm_config_find_str(pv->child, "id", NULL); int found = uuid ? (dm_hash_lookup(s->pvs, uuid) ? 1 : 0) : 0; @@ -151,18 +160,21 @@ static response vg_by_uuid(lvmetad_state *s, request r) { + struct dm_config_tree *cft; + struct dm_config_node *metadata; + struct dm_config_node *n; + response res = { .buffer = NULL }; const char *uuid = daemon_request_str(r, "uuid", "NONE"); + debug("vg_by_uuid: %s (vgs = %p)\n", uuid, s->vgs); - struct dm_config_tree *cft = lock_vg(s, uuid); + cft = lock_vg(s, uuid); if (!cft || !cft->root) { unlock_vg(s, uuid); return daemon_reply_simple("failed", "reason = %s", "uuid not found", NULL); } - struct dm_config_node *metadata = cft->root; + metadata = cft->root; - response res = { .buffer = NULL }; - struct dm_config_node *n; res.cft = dm_config_create(NULL, 0); /* The response field */ @@ -249,14 +261,19 @@ * (anything that might have been retained is copied). */ static int update_metadata(lvmetad_state *s, const char *_vgid, struct dm_config_node *metadata) { + struct dm_config_tree *cft; + struct dm_config_tree *old; + const char *vgid; int retval = 0; + int haveseq = -1; + int seq; + lock_vgs(s); - struct dm_config_tree *old = dm_hash_lookup(s->vgs, _vgid); + old = dm_hash_lookup(s->vgs, _vgid); lock_vg(s, _vgid); unlock_vgs(s); - int seq = dm_config_find_int(metadata, "metadata/seqno", -1); - int haveseq = -1; + seq = dm_config_find_int(metadata, "metadata/seqno", -1); if (old) haveseq = dm_config_find_int(old->root, "metadata/seqno", -1); @@ -278,9 +295,9 @@ goto out; } - struct dm_config_tree *cft = dm_config_create(NULL, 0); + cft = dm_config_create(NULL, 0); cft->root = dm_config_clone_node(cft, metadata, 0); - const char *vgid = dm_config_find_str(cft->root, "metadata/id", NULL); + vgid = dm_config_find_str(cft->root, "metadata/id", NULL); if (!vgid) goto out; @@ -313,6 +330,7 @@ struct dm_config_node *metadata = dm_config_find_node(r.cft->root, "metadata"); const char *pvid = daemon_request_str(r, "uuid", NULL); const char *vgid = daemon_request_str(r, "metadata/id", NULL); + int complete = 0; if (!pvid) return daemon_reply_simple("failed", "reason = %s", "need PV UUID", NULL); @@ -338,7 +356,6 @@ unlock_pvid_map(s); } - int complete = 0; if (vgid) { struct dm_config_tree *cft = lock_vg(s, vgid); complete = update_pv_status(s, cft, cft->root, 0); @@ -374,14 +391,13 @@ static int init(daemon_state *s) { + pthread_mutexattr_t rec; lvmetad_state *ls = s->private; ls->pvs = dm_hash_create(32); ls->vgs = dm_hash_create(32); ls->pvid_map = dm_hash_create(32); - ls->lock.vg = dm_hash_create(32); - pthread_mutexattr_t rec; pthread_mutexattr_init(&rec); pthread_mutexattr_settype(&rec, PTHREAD_MUTEX_RECURSIVE_NP); pthread_mutex_init(&ls->lock.pvs, NULL); @@ -400,9 +416,10 @@ static int fini(daemon_state *s) { - debug("fini\n"); lvmetad_state *ls = s->private; struct dm_hash_node *n = dm_hash_get_first(ls->vgs); + + debug("fini\n"); while (n) { dm_config_destroy(dm_hash_get_data(ls->vgs, n)); n = dm_hash_get_next(ls->vgs, n); @@ -447,6 +464,7 @@ s.handler = handler; s.socket_path = "/var/run/lvm/lvmetad.socket"; s.pidfile = "/var/run/lvm/lvmetad.pid"; + s.log_level = 0; while ((opt = getopt(argc, argv, "?fhVdR")) != EOF) { switch (opt) { From zkabelac@sourceware.org Sat Sep 17 14:49:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 17 Sep 2011 14:49:00 -0000 Subject: LVM2/daemons/common daemon-client.c daemon-ser ... Message-ID: <20110917144919.19685.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-17 14:49:18 Modified files: daemons/common : daemon-client.c daemon-server.c daemon-shared.c Log message: More gcc warnings removed Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/daemons/common/daemon-client.c 2011/08/31 12:18:40 1.7 +++ LVM2/daemons/common/daemon-client.c 2011/09/17 14:49:18 1.8 @@ -9,8 +9,9 @@ #include // ENOMEM daemon_handle daemon_open(daemon_info i) { - daemon_handle h; + daemon_handle h = { .protocol = 0 }; struct sockaddr_un sockaddr; + if ((h.socket_fd = socket(PF_UNIX, SOCK_STREAM /* | SOCK_NONBLOCK */, 0)) < 0) { perror("socket"); goto error; @@ -23,7 +24,6 @@ perror("connect"); goto error; } - h.protocol = 0; return h; error: if (h.socket_fd >= 0) @@ -59,16 +59,19 @@ daemon_reply daemon_send_simple(daemon_handle h, char *id, ...) { + static const daemon_reply err = { .error = ENOMEM, .buffer = NULL, .cft = NULL }; + daemon_request rq; + daemon_reply repl; va_list ap; + va_start(ap, id); - daemon_request rq = { .buffer = format_buffer("request", id, ap) }; + rq.buffer = format_buffer("request", id, ap); + va_end(ap); - if (!rq.buffer) { - daemon_reply err = { .error = ENOMEM, .buffer = NULL, .cft = NULL }; + if (!rq.buffer) return err; - } - daemon_reply repl = daemon_send(h, rq); + repl = daemon_send(h, rq); dm_free(rq.buffer); return repl; } --- LVM2/daemons/common/daemon-server.c 2011/08/31 12:39:58 1.13 +++ LVM2/daemons/common/daemon-server.c 2011/09/17 14:49:18 1.14 @@ -204,12 +204,15 @@ response daemon_reply_simple(const char *id, ...) { va_list ap; + response res = { .cft = NULL }; + va_start(ap, id); - response res = { .buffer = format_buffer("response", id, ap), .cft = NULL }; - if (!res.buffer) + if (!(res.buffer = format_buffer("response", id, ap))) res.error = ENOMEM; + va_end(ap); + return res; } @@ -238,6 +241,8 @@ { struct thread_baton *b = baton; request req; + response res; + while (1) { if (!read_buffer(b->client.socket_fd, &req.buffer)) goto fail; @@ -245,7 +250,7 @@ req.cft = dm_config_from_string(req.buffer); if (!req.cft) fprintf(stderr, "error parsing request:\n %s\n", req.buffer); - response res = b->s.handler(b->s, b->client, req); + res = b->s.handler(b->s, b->client, req); if (req.cft) dm_config_destroy(req.cft); dm_free(req.buffer); @@ -268,25 +273,24 @@ static int handle_connect(daemon_state s) { + struct thread_baton *baton; struct sockaddr_un sockaddr; - client_handle client; + client_handle client = { .thread_id = 0 }; socklen_t sl = sizeof(sockaddr); - int client_fd = accept(s.socket_fd, (struct sockaddr *) &sockaddr, &sl); - if (client_fd < 0) + + client.socket_fd = accept(s.socket_fd, (struct sockaddr *) &sockaddr, &sl); + if (client.socket_fd < 0) return 0; - struct thread_baton *baton = malloc(sizeof(struct thread_baton)); - if (!baton) + if (!(baton = malloc(sizeof(struct thread_baton)))) return 0; - client.socket_fd = client_fd; - client.read_buf = 0; - client.private = 0; baton->s = s; baton->client = client; if (pthread_create(&baton->client.thread_id, NULL, client_thread, baton)) return 0; + return 1; } --- LVM2/daemons/common/daemon-shared.c 2011/08/31 12:18:40 1.5 +++ LVM2/daemons/common/daemon-shared.c 2011/09/17 14:49:18 1.6 @@ -17,6 +17,8 @@ int read_buffer(int fd, char **buffer) { int bytes = 0; int buffersize = 32; + char *new; + char *end; *buffer = malloc(buffersize + 1); while (1) { @@ -30,14 +32,12 @@ if (bytes == buffersize) { buffersize += 1024; - char *new = realloc(*buffer, buffersize + 1); - if (new) - *buffer = new; - else + if (!(new = realloc(*buffer, buffersize + 1))) goto fail; + + *buffer = new; } else { (*buffer)[bytes] = 0; - char *end; if ((end = strstr((*buffer) + bytes - 2, "\n\n"))) { *end = 0; break; /* success, we have the full message now */ From zkabelac@sourceware.org Sat Sep 17 14:50:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 17 Sep 2011 14:50:00 -0000 Subject: LVM2/daemons Makefile.in lvmetad/Makefile.in Message-ID: <20110917145024.20030.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-17 14:50:23 Modified files: daemons : Makefile.in daemons/lvmetad: Makefile.in Log message: Build fixes for lvmetad Should now be giving better build order and install lvmetad. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/Makefile.in.diff?cvsroot=lvm2&r1=1.19&r2=1.20 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/Makefile.in.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/daemons/Makefile.in 2011/09/02 14:49:00 1.19 +++ LVM2/daemons/Makefile.in 2011/09/17 14:50:22 1.20 @@ -16,8 +16,11 @@ top_builddir = @top_builddir@ ifeq ("@BUILD_LVMETAD@", "yes") -LIB_STATIC=libdaemon.a + SUBDIRS += lvmetad + +LIB_STATIC = libdaemon.a SOURCES = common/daemon-shared.c common/daemon-server.c common/daemon-client.c +lvmetad.device-mapper: $(LIB_STATIC) endif .PHONY: dmeventd clvmd cmirrord lvmetad @@ -30,12 +33,6 @@ SUBDIRS += cmirrord endif -ifeq ("@BUILD_LVMETAD@", "yes") - SUBDIRS += lvmetad -# FIXME: build dependency order needs rule fixing, using hack -all: libdaemon.a -endif - ifeq ("@BUILD_DMEVENTD@", "yes") SUBDIRS += dmeventd ifneq ("$(CFLOW_CMD)", "") --- LVM2/daemons/lvmetad/Makefile.in 2011/08/31 11:31:58 1.1 +++ LVM2/daemons/lvmetad/Makefile.in 2011/09/17 14:50:23 1.2 @@ -19,11 +19,9 @@ TARGETS = lvmetad lvmetad-testclient -.PHONY: install_lib_dynamic install_lib_static install_include \ - install_pkgconfig install_dmeventd_dynamic install_dmeventd_static \ - install_lib install_dmeventd +.PHONY: install_lvmetad -INCLUDES += -I$(top_srcdir)/daemons/common/ +INCLUDES += -I$(top_srcdir)/daemons/common INSTALL_LVMETAD_TARGETS = install_lvmetad CLEAN_TARGETS = lvmetad lvmetad-testclient @@ -52,7 +50,8 @@ #-include $(top_builddir)/daemons/dmeventd/plugins/mirror/$(LIB_NAME)-lvm2mirror.cflow #endif -install_lvmetad: $(INSTALL_DMEVENTD_TARGETS) +install_lvmetad: lvmetad + $(INSTALL_PROGRAM) -D $< $(sbindir)/$( CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 00:29:12 Modified files: daemons : Makefile.in daemons/lvmetad: Makefile.in Log message: Few more updates to lvmetad build deps It seem lvmetad deps must be expressed after the include. Also adding lvmetad deps to device-mapper target in daemons dir. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/Makefile.in.diff?cvsroot=lvm2&r1=1.20&r2=1.21 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/Makefile.in.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/daemons/Makefile.in 2011/09/17 14:50:22 1.20 +++ LVM2/daemons/Makefile.in 2011/09/19 00:29:11 1.21 @@ -1,5 +1,5 @@ # -# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -20,13 +20,12 @@ LIB_STATIC = libdaemon.a SOURCES = common/daemon-shared.c common/daemon-server.c common/daemon-client.c -lvmetad.device-mapper: $(LIB_STATIC) endif .PHONY: dmeventd clvmd cmirrord lvmetad ifneq ("@CLVMD@", "none") - SUBDIRS = clvmd + SUBDIRS += clvmd endif ifeq ("@BUILD_CMIRRORD@", "yes") @@ -49,3 +48,9 @@ ifeq ("@BUILD_DMEVENTD@", "yes") device-mapper: dmeventd.device-mapper endif + +ifeq ("@BUILD_LVMETAD@", "yes") +device-mapper: lvmetad.device-mapper +lvmetad.device-mapper: $(LIB_STATIC) +endif + --- LVM2/daemons/lvmetad/Makefile.in 2011/09/17 14:50:23 1.2 +++ LVM2/daemons/lvmetad/Makefile.in 2011/09/19 00:29:12 1.3 @@ -31,10 +31,9 @@ include $(top_builddir)/make.tmpl -all: device-mapper device-mapper: $(TARGETS) -LIBS += -ldevmapper -ldaemon -lpthread +LIBS += -ldevmapper -ldaemon $(PTHREAD_LIBS) lvmetad: lvmetad-core.o $(CC) $(CFLAGS) $(LDFLAGS) -L$(top_builddir)/daemons -o $@ lvmetad-core.o \ From zkabelac@sourceware.org Mon Sep 19 12:48:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 12:48:00 -0000 Subject: LVM2 ./WHATS_NEW lib/misc/lvm-exec.c Message-ID: <20110919124803.6874.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 12:48:02 Modified files: . : WHATS_NEW lib/misc : lvm-exec.c Log message: Move debug message so it does not look like we are executing command in the middle of critical_section in log trace. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2116&r2=1.2117 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-exec.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14 --- LVM2/WHATS_NEW 2011/09/16 14:40:06 1.2116 +++ LVM2/WHATS_NEW 2011/09/19 12:48:02 1.2117 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Move debug message in exec_cmd after sync_local_dev_names. Fix clvmd processing of invalid request on local socket. Fix command line option decoding. Reset LV status when unlinking LV from VG. --- LVM2/lib/misc/lvm-exec.c 2011/08/04 14:30:51 1.13 +++ LVM2/lib/misc/lvm-exec.c 2011/09/19 12:48:02 1.14 @@ -54,7 +54,6 @@ int status; char buf[PATH_MAX * 2]; - log_verbose("Executing: %s", _verbose_args(argv, buf, sizeof(buf))); if (rstatus) *rstatus = -1; @@ -63,6 +62,8 @@ if (!sync_local_dev_names(cmd)) /* Flush ops and reset dm cookie */ return_0; + log_verbose("Executing: %s", _verbose_args(argv, buf, sizeof(buf))); + if ((pid = fork()) == -1) { log_error("fork failed: %s", strerror(errno)); return 0; From zkabelac@sourceware.org Mon Sep 19 12:49:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 12:49:00 -0000 Subject: LVM2/test t-dmeventd-restart.sh Message-ID: <20110919124915.7786.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 12:49:14 Modified files: test : t-dmeventd-restart.sh Log message: Test speed up Removing vg reduces time execution of this test. Teardown has some wait states here... Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-dmeventd-restart.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/test/t-dmeventd-restart.sh 2011/03/02 12:49:13 1.3 +++ LVM2/test/t-dmeventd-restart.sh 2011/09/19 12:49:14 1.4 @@ -38,3 +38,5 @@ sleep 3 lvchange --monitor y --verbose $vg/3way 2>&1 | tee lvchange.out not grep 'already monitored' lvchange.out + +vgremove -ff $vg From zkabelac@sourceware.org Mon Sep 19 12:50:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 12:50:00 -0000 Subject: LVM2/test Makefile.in Message-ID: <20110919125018.8120.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 12:50:17 Modified files: test : Makefile.in Log message: Add link for fsadm script Prepare to enabling t-fsadm.sh test Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.57&r2=1.58 --- LVM2/test/Makefile.in 2011/08/31 11:31:58 1.57 +++ LVM2/test/Makefile.in 2011/09/19 12:50:17 1.58 @@ -101,6 +101,7 @@ ln -fs "$(abs_top_builddir)/daemons/dmeventd/dmeventd" lib/dmeventd ln -fs "$(abs_top_builddir)/daemons/lvmetad/lvmetad" lib/lvmetad ln -fs "$(abs_top_builddir)/scripts/vgimportclone.sh" lib/vgimportclone + ln -fs "$(abs_top_builddir)/scripts/fsadm.sh" lib/fsadm touch $@ clean: From zkabelac@sourceware.org Mon Sep 19 13:43:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 13:43:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/fsadm.sh Message-ID: <20110919134351.27212.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 13:43:50 Modified files: . : WHATS_NEW scripts : fsadm.sh Log message: Fix missing '$' in test Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2117&r2=1.2118 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.24&r2=1.25 --- LVM2/WHATS_NEW 2011/09/19 12:48:02 1.2117 +++ LVM2/WHATS_NEW 2011/09/19 13:43:50 1.2118 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix missing '$' in test for content of "$LVM" in fsadm script. Move debug message in exec_cmd after sync_local_dev_names. Fix clvmd processing of invalid request on local socket. Fix command line option decoding. --- LVM2/scripts/fsadm.sh 2010/11/11 12:17:15 1.24 +++ LVM2/scripts/fsadm.sh 2011/09/19 13:43:50 1.25 @@ -446,7 +446,7 @@ test -n "$TUNE_EXT" -a -n "$RESIZE_EXT" -a -n "$TUNE_REISER" -a -n "$RESIZE_REISER" \ -a -n "$TUNE_XFS" -a -n "$RESIZE_XFS" -a -n "$MOUNT" -a -n "$UMOUNT" -a -n "$MKDIR" \ -a -n "$RMDIR" -a -n "$BLOCKDEV" -a -n "$BLKID" -a -n "$GREP" -a -n "$READLINK" \ - -a -n "$DATE" -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "LVM" \ + -a -n "$DATE" -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "$LVM" \ || error "Required command definitions in the script are missing!" $LVM version >/dev/null 2>&1 || error "Could not run lvm binary '$LVM'" From zkabelac@sourceware.org Mon Sep 19 13:47:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 13:47:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/fsadm.sh Message-ID: <20110919134739.29958.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 13:47:38 Modified files: . : WHATS_NEW scripts : fsadm.sh Log message: Surround all executed commands with quotes In case someone would use filename paths with spaces when changing this script surround commands with '"'. With default settings there is no change in behavior. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2118&r2=1.2119 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.25&r2=1.26 --- LVM2/WHATS_NEW 2011/09/19 13:43:50 1.2118 +++ LVM2/WHATS_NEW 2011/09/19 13:47:37 1.2119 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Surround all executed commands with quotes in fsadm script. Fix missing '$' in test for content of "$LVM" in fsadm script. Move debug message in exec_cmd after sync_local_dev_names. Fix clvmd processing of invalid request on local socket. --- LVM2/scripts/fsadm.sh 2011/09/19 13:43:50 1.25 +++ LVM2/scripts/fsadm.sh 2011/09/19 13:47:38 1.26 @@ -127,7 +127,7 @@ test "$MOUNTPOINT" = "$TEMPDIR" && MOUNTPOINT="" temp_umount if [ -n "$REMOUNT" ]; then verbose "Remounting unmounted filesystem back" - dry $MOUNT "$VOLUME" "$MOUNTED" + dry "$MOUNT" "$VOLUME" "$MOUNTED" fi IFS=$IFS_OLD trap 2 @@ -140,7 +140,7 @@ _FSADM_YES=$YES export _FSADM_YES unset FSADM_RUNNING - dry exec $LVM lvresize $VERB $FORCE -r -L${NEWSIZE}b $VOLUME_ORIG + dry exec "$LVM" lvresize $VERB $FORCE -r -L${NEWSIZE}b "$VOLUME_ORIG" fi # error exit status for break @@ -175,7 +175,7 @@ detect_fs() { VOLUME_ORIG=$1 VOLUME=${1#/dev/} - VOLUME=$($READLINK $READLINK_E "/dev/$VOLUME") || error "Cannot get readlink $1" + VOLUME=$("$READLINK" $READLINK_E "/dev/$VOLUME") || error "Cannot get readlink $1" RVOLUME=$VOLUME case "$RVOLUME" in /dev/dm-[0-9]*) @@ -184,7 +184,7 @@ esac # use /dev/null as cache file to be sure about the result # not using option '-o value' to be compatible with older version of blkid - FSTYPE=$($BLKID -c /dev/null -s TYPE "$VOLUME") || error "Cannot get FSTYPE of \"$VOLUME\"" + FSTYPE=$("$BLKID" -c /dev/null -s TYPE "$VOLUME") || error "Cannot get FSTYPE of \"$VOLUME\"" FSTYPE=${FSTYPE##*TYPE=\"} # cut quotation marks FSTYPE=${FSTYPE%%\"*} verbose "\"$FSTYPE\" filesystem found on \"$VOLUME\"" @@ -193,12 +193,12 @@ # check if the given device is already mounted and where # FIXME: resolve swap usage and device stacking detect_mounted() { - test -e $PROCMOUNTS || error "Cannot detect mounted device $VOLUME" + test -e "$PROCMOUNTS" || error "Cannot detect mounted device \"$VOLUME\"" - MOUNTED=$($GREP ^"$VOLUME" $PROCMOUNTS) + MOUNTED=$("$GREP" ^"$VOLUME" "$PROCMOUNTS") # for empty string try again with real volume name - test -z "$MOUNTED" && MOUNTED=$($GREP ^"$RVOLUME" $PROCMOUNTS) + test -z "$MOUNTED" && MOUNTED=$("$GREP" ^"$RVOLUME" "$PROCMOUNTS") # cut device name prefix and trim everything past mountpoint # echo translates \040 to spaces @@ -207,8 +207,8 @@ # for systems with different device names - check also mount output if test -z "$MOUNTED" ; then - MOUNTED=$(LANG=C $MOUNT | $GREP ^"$VOLUME") - test -z "$MOUNTED" && MOUNTED=$(LANG=C $MOUNT | $GREP ^"$RVOLUME") + MOUNTED=$(LANG=C "$MOUNT" | "$GREP" ^"$VOLUME") + test -z "$MOUNTED" && MOUNTED=$(LANG=C "$MOUNT" | "$GREP" ^"$RVOLUME") MOUNTED=${MOUNTED##* on } MOUNTED=${MOUNTED% type *} # allow type in the mount name fi @@ -219,12 +219,12 @@ # get the full size of device in bytes detect_device_size() { # check if blockdev supports getsize64 - $BLOCKDEV 2>&1 | $GREP getsize64 >/dev/null + "$BLOCKDEV" 2>&1 | "$GREP" getsize64 >/dev/null if test $? -eq 0; then - DEVSIZE=$($BLOCKDEV --getsize64 "$VOLUME") || error "Cannot read size of device \"$VOLUME\"" + DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME") || error "Cannot read size of device \"$VOLUME\"" else - DEVSIZE=$($BLOCKDEV --getsize "$VOLUME") || error "Cannot read size of device \"$VOLUME\"" - SSSIZE=$($BLOCKDEV --getss "$VOLUME") || error "Cannot block size read device \"$VOLUME\"" + DEVSIZE=$("$BLOCKDEV" --getsize "$VOLUME") || error "Cannot read size of device \"$VOLUME\"" + SSSIZE=$("$BLOCKDEV" --getss "$VOLUME") || error "Cannot block size read device \"$VOLUME\"" DEVSIZE=$(($DEVSIZE * $SSSIZE)) fi } @@ -237,14 +237,14 @@ } temp_mount() { - dry $MKDIR -p -m 0000 "$TEMPDIR" || error "Failed to create $TEMPDIR" - dry $MOUNT "$VOLUME" "$TEMPDIR" || error "Failed to mount $TEMPDIR" + dry "$MKDIR" -p -m 0000 "$TEMPDIR" || error "Failed to create $TEMPDIR" + dry "$MOUNT" "$VOLUME" "$TEMPDIR" || error "Failed to mount $TEMPDIR" } temp_umount() { - dry $UMOUNT "$TEMPDIR" || error "Failed to umount $TEMPDIR" - dry $RMDIR "${TEMPDIR}" || error "Failed to remove $TEMPDIR" - dry $RMDIR "${TEMPDIR%%m}" || error "Failed to remove ${TEMPDIR%%m}" + dry "$UMOUNT" "$TEMPDIR" || error "Failed to umount \"$TEMPDIR\"" + dry "$RMDIR" "${TEMPDIR}" || error "Failed to remove \"$TEMPDIR\"" + dry "$RMDIR" "${TEMPDIR%%m}" || error "Failed to remove \"${TEMPDIR%%m}\"" } yes_no() { @@ -263,7 +263,7 @@ } try_umount() { - yes_no "Do you want to unmount \"$MOUNTED\"" && dry $UMOUNT "$MOUNTED" && return 0 + yes_no "Do you want to unmount \"$MOUNTED\"" && dry "$UMOUNT" "$MOUNTED" && return 0 error "Cannot proceed with mounted filesystem \"$MOUNTED\"" } @@ -277,13 +277,13 @@ #################################### resize_ext() { verbose "Parsing $TUNE_EXT -l \"$VOLUME\"" - for i in $(LANG=C $TUNE_EXT -l "$VOLUME"); do + for i in $(LANG=C "$TUNE_EXT" -l "$VOLUME"); do case "$i" in "Block size"*) BLOCKSIZE=${i##* } ;; "Block count"*) BLOCKCOUNT=${i##* } ;; esac done - validate_parsing $TUNE_EXT + validate_parsing "$TUNE_EXT" decode_size $1 $BLOCKSIZE FSFORCE=$FORCE @@ -293,14 +293,14 @@ if test -n "$MOUNTED" ; then # Forced fsck -f for umounted extX filesystem. case "$-" in - *i*) dry $FSCK $YES -f "$VOLUME" ;; - *) dry $FSCK -f -p "$VOLUME" ;; + *i*) dry "$FSCK" $YES -f "$VOLUME" ;; + *) dry "$FSCK" -f -p "$VOLUME" ;; esac fi fi verbose "Resizing filesystem on device \"$VOLUME\" to $NEWSIZE bytes ($BLOCKCOUNT -> $NEWBLOCKCOUNT blocks of $BLOCKSIZE bytes)" - dry $RESIZE_EXT $FSFORCE "$VOLUME" $NEWBLOCKCOUNT + dry "$RESIZE_EXT" $FSFORCE "$VOLUME" $NEWBLOCKCOUNT } ############################# @@ -312,19 +312,19 @@ detect_mounted && verbose "ReiserFS resizes only unmounted filesystem" && try_umount REMOUNT=$MOUNTED verbose "Parsing $TUNE_REISER \"$VOLUME\"" - for i in $(LANG=C $TUNE_REISER "$VOLUME"); do + for i in $(LANG=C "$TUNE_REISER" "$VOLUME"); do case "$i" in "Blocksize"*) BLOCKSIZE=${i##*: } ;; "Count of blocks"*) BLOCKCOUNT=${i##*: } ;; esac done - validate_parsing $TUNE_REISER + validate_parsing "$TUNE_REISER" decode_size $1 $BLOCKSIZE verbose "Resizing \"$VOLUME\" $BLOCKCOUNT -> $NEWBLOCKCOUNT blocks ($NEWSIZE bytes, bs: $NEWBLOCKCOUNT)" if [ -n "$YES" ]; then - echo y | dry $RESIZE_REISER -s $NEWSIZE "$VOLUME" + echo y | dry "$RESIZE_REISER" -s $NEWSIZE "$VOLUME" else - dry $RESIZE_REISER -s $NEWSIZE "$VOLUME" + dry "$RESIZE_REISER" -s $NEWSIZE "$VOLUME" fi } @@ -341,18 +341,18 @@ temp_mount || error "Cannot mount Xfs filesystem" fi verbose "Parsing $TUNE_XFS \"$MOUNTPOINT\"" - for i in $(LANG=C $TUNE_XFS "$MOUNTPOINT"); do + for i in $(LANG=C "$TUNE_XFS" "$MOUNTPOINT"); do case "$i" in "data"*) BLOCKSIZE=${i##*bsize=} ; BLOCKCOUNT=${i##*blocks=} ;; esac done BLOCKSIZE=${BLOCKSIZE%%[^0-9]*} BLOCKCOUNT=${BLOCKCOUNT%%[^0-9]*} - validate_parsing $TUNE_XFS + validate_parsing "$TUNE_XFS" decode_size $1 $BLOCKSIZE if [ $NEWBLOCKCOUNT -gt $BLOCKCOUNT ]; then verbose "Resizing Xfs mounted on \"$MOUNTPOINT\" to fill device \"$VOLUME\"" - dry $RESIZE_XFS $MOUNTPOINT + dry "$RESIZE_XFS" $MOUNTPOINT elif [ $NEWBLOCKCOUNT -eq $BLOCKCOUNT ]; then verbose "Xfs filesystem already has the right size" else @@ -387,7 +387,7 @@ # only one supported #################################### diff_dates() { - echo $(( $($DATE -u -d"$1" +%s 2>/dev/null) - $($DATE -u -d"$2" +%s 2>/dev/null) )) + echo $(( $("$DATE" -u -d"$1" +%s 2>/dev/null) - $("$DATE" -u -d"$2" +%s 2>/dev/null) )) } ################### @@ -404,7 +404,7 @@ "ext2"|"ext3"|"ext4") IFS_CHECK=$IFS IFS=$NL - for i in $(LANG=C $TUNE_EXT -l "$VOLUME"); do + for i in $(LANG=C "$TUNE_EXT" -l "$VOLUME"); do case "$i" in "Last mount"*) LASTMOUNT=${i##*: } ;; "Last checked"*) LASTCHECKED=${i##*: } ;; @@ -424,11 +424,11 @@ esac case "$FSTYPE" in - "xfs") dry $XFS_CHECK "$VOLUME" ;; + "xfs") dry "$XFS_CHECK" "$VOLUME" ;; *) # check if executed from interactive shell environment case "$-" in - *i*) dry $FSCK $YES $FORCE "$VOLUME" ;; - *) dry $FSCK $FORCE -p "$VOLUME" ;; + *i*) dry "$FSCK" $YES $FORCE "$VOLUME" ;; + *) dry "$FSCK" $FORCE -p "$VOLUME" ;; esac esac } @@ -449,12 +449,12 @@ -a -n "$DATE" -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "$LVM" \ || error "Required command definitions in the script are missing!" -$LVM version >/dev/null 2>&1 || error "Could not run lvm binary '$LVM'" -$($READLINK -e / >/dev/null 2>&1) || READLINK_E="-f" +"$LVM" version >/dev/null 2>&1 || error "Could not run lvm binary \"$LVM\"" +$("$READLINK" -e / >/dev/null 2>&1) || READLINK_E="-f" TEST64BIT=$(( 1000 * 1000000000000 )) -test $TEST64BIT -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic" -$(echo Y | $GREP Y >/dev/null) || error "Grep does not work properly" -test $($DATE -u -d"Jan 01 00:00:01 1970" +%s) -eq 1 || error "Date translation does not work" +test "$TEST64BIT" -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic" +$(echo Y | "$GREP" Y >/dev/null) || error "Grep does not work properly" +test $("$DATE" -u -d"Jan 01 00:00:01 1970" +%s) -eq 1 || error "Date translation does not work" if [ "$#" -eq 0 ] ; then From zkabelac@sourceware.org Mon Sep 19 13:51:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 13:51:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/fsadm.sh Message-ID: <20110919135110.31100.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 13:51:10 Modified files: . : WHATS_NEW scripts : fsadm.sh Log message: Support different PATH setting When fsadm is test - it needs to execute lvm and fsadm from non-standard path setting. So adding a support in fsadm script when user set LVM_BINARY, then the lvm command invoced from fsadm will have the same PATH setting as before entering fsadm command. Needed for testing. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2119&r2=1.2120 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.26&r2=1.27 --- LVM2/WHATS_NEW 2011/09/19 13:47:37 1.2119 +++ LVM2/WHATS_NEW 2011/09/19 13:51:09 1.2120 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Support different PATH setting for fsadm script testing. Surround all executed commands with quotes in fsadm script. Fix missing '$' in test for content of "$LVM" in fsadm script. Move debug message in exec_cmd after sync_local_dev_names. --- LVM2/scripts/fsadm.sh 2011/09/19 13:47:38 1.26 +++ LVM2/scripts/fsadm.sh 2011/09/19 13:51:10 1.27 @@ -31,6 +31,7 @@ TOOL=fsadm +_SAVEPATH=$PATH PATH=/sbin:/usr/sbin:/bin:/usr/sbin:$PATH # utilities @@ -140,9 +141,10 @@ _FSADM_YES=$YES export _FSADM_YES unset FSADM_RUNNING + test -n "$LVM_BINARY" && PATH=$_SAVEPATH dry exec "$LVM" lvresize $VERB $FORCE -r -L${NEWSIZE}b "$VOLUME_ORIG" fi - + # error exit status for break exit ${1:-1} } From zkabelac@sourceware.org Mon Sep 19 13:52:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 13:52:00 -0000 Subject: LVM2/test t-fsadm.sh Message-ID: <20110919135222.31358.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 13:52:22 Modified files: test : t-fsadm.sh Log message: Enable t-fsadm test Now all commands are executed from preffered directory. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-fsadm.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/test/t-fsadm.sh 2011/01/31 22:05:30 1.6 +++ LVM2/test/t-fsadm.sh 2011/09/19 13:52:22 1.7 @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2008-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2008-2011 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -10,7 +10,6 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA test_description='Exercise fsadm filesystem resize' -exit 200 . lib/test @@ -32,6 +31,8 @@ vg_lv="$vg/$lv1" dev_vg_lv="$DM_DEV_DIR/$vg_lv" mount_dir="$TESTDIR/mnt" +# for recursive call +export LVM_BINARY=$(which lvm) test ! -d $mount_dir && mkdir $mount_dir @@ -75,13 +76,13 @@ fsadm --lvresize resize $vg_lv 30M # Fails - not enough space for 4M fs - not fsadm --lvresize resize $dev_vg_lv 4M + not fsadm -y --lvresize resize $dev_vg_lv 4M lvresize -L+10M -r $vg_lv lvreduce -L10M -r $vg_lv fscheck_ext3 mount $dev_vg_lv $mount_dir - not fsadm --lvresize resize $vg_lv 9M + not fsadm -y --lvresize resize $vg_lv 4M lvresize -L+20M -r -n $vg_lv umount $mount_dir fscheck_ext3 @@ -121,3 +122,5 @@ lvresize -f -L20M $vg_lv fi + +vgremove -ff $vg From jbrassow@sourceware.org Mon Sep 19 14:28:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Mon, 19 Sep 2011 14:28:00 -0000 Subject: LVM2/lib/metadata mirror.c Message-ID: <20110919142824.15359.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-19 14:28:24 Modified files: lib/metadata : mirror.c Log message: fix compiler warning. Compiler says variable may be used uninitialized. It can't be, but we initialize the variable to NULL anyway. Also, remove the double initialization of another variable. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.170&r2=1.171 --- LVM2/lib/metadata/mirror.c 2011/09/16 16:41:37 1.170 +++ LVM2/lib/metadata/mirror.c 2011/09/19 14:28:23 1.171 @@ -584,7 +584,7 @@ struct logical_volume *detached_log_lv = NULL; struct lv_segment *mirrored_seg = first_seg(lv); struct dm_list split_images; - struct lv_list *lvl, *new_lvl; + struct lv_list *lvl, *new_lvl = NULL; struct cmd_context *cmd = lv->vg->cmd; if (!(lv->status & MIRRORED)) { @@ -748,7 +748,6 @@ * - activate the new LV */ sync_local_dev_names(lv->vg->cmd); - new_lv = NULL; dm_list_iterate_items(lvl, &split_images) { if (!new_lv) { /* Grab 1st sub-LV for later */ From zkabelac@sourceware.org Mon Sep 19 14:52:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 14:52:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/fsadm.sh Message-ID: <20110919145234.15298.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 14:52:33 Modified files: . : WHATS_NEW scripts : fsadm.sh Log message: Add support for non /dev devices Since test suite is not using /dev - add support for such dirs into fsadm. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2120&r2=1.2121 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.27&r2=1.28 --- LVM2/WHATS_NEW 2011/09/19 13:51:09 1.2120 +++ LVM2/WHATS_NEW 2011/09/19 14:52:33 1.2121 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add support for non /dev device paths into fsadm script. Support different PATH setting for fsadm script testing. Surround all executed commands with quotes in fsadm script. Fix missing '$' in test for content of "$LVM" in fsadm script. --- LVM2/scripts/fsadm.sh 2011/09/19 13:51:10 1.27 +++ LVM2/scripts/fsadm.sh 2011/09/19 14:52:33 1.28 @@ -177,7 +177,7 @@ detect_fs() { VOLUME_ORIG=$1 VOLUME=${1#/dev/} - VOLUME=$("$READLINK" $READLINK_E "/dev/$VOLUME") || error "Cannot get readlink $1" + VOLUME=$("$READLINK" $READLINK_E "/dev/$VOLUME") || VOLUME=$("$READLINK" $READLINK_E "$VOLUME_ORIG") || error "Cannot get readlink \"$1\"" RVOLUME=$VOLUME case "$RVOLUME" in /dev/dm-[0-9]*) From zkabelac@sourceware.org Mon Sep 19 14:54:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 14:54:00 -0000 Subject: LVM2 ./WHATS_NEW lib/misc/lvm-exec.c Message-ID: <20110919145425.15594.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 14:54:23 Modified files: . : WHATS_NEW lib/misc : lvm-exec.c Log message: Use log_error instead of log_verbose when executed command fails Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2121&r2=1.2122 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-exec.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15 --- LVM2/WHATS_NEW 2011/09/19 14:52:33 1.2121 +++ LVM2/WHATS_NEW 2011/09/19 14:54:23 1.2122 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Use log_error instead of log_verbose when executed command fails. Add support for non /dev device paths into fsadm script. Support different PATH setting for fsadm script testing. Surround all executed commands with quotes in fsadm script. --- LVM2/lib/misc/lvm-exec.c 2011/09/19 12:48:02 1.14 +++ LVM2/lib/misc/lvm-exec.c 2011/09/19 14:54:23 1.15 @@ -96,7 +96,7 @@ if (WEXITSTATUS(status)) { if (rstatus) { *rstatus = WEXITSTATUS(status); - log_verbose("%s failed: %u", argv[0], *rstatus); + log_error("%s failed: %u", argv[0], *rstatus); } else log_error("%s failed: %u", argv[0], WEXITSTATUS(status)); return 0; From zkabelac@sourceware.org Mon Sep 19 15:54:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 15:54:00 -0000 Subject: LVM2/test Makefile.in Message-ID: <20110919155416.29372.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 15:54:15 Modified files: test : Makefile.in Log message: Ensure fsadm.sh is executable When the srcdir == builddir we get the link on non-exectable file. So make always sure fsadm.sh is executable script file. Add cleanup target for lib/fsadm. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.58&r2=1.59 --- LVM2/test/Makefile.in 2011/09/19 12:50:17 1.58 +++ LVM2/test/Makefile.in 2011/09/19 15:54:15 1.59 @@ -101,6 +101,7 @@ ln -fs "$(abs_top_builddir)/daemons/dmeventd/dmeventd" lib/dmeventd ln -fs "$(abs_top_builddir)/daemons/lvmetad/lvmetad" lib/lvmetad ln -fs "$(abs_top_builddir)/scripts/vgimportclone.sh" lib/vgimportclone + chmod +x "$(abs_top_builddir)/scripts/fsadm.sh" ln -fs "$(abs_top_builddir)/scripts/fsadm.sh" lib/fsadm touch $@ @@ -109,6 +110,6 @@ if test "$(srcdir)" != . ; then rm -f $(subst $(srcdir)/, ,$(RUN)) lvm2app.sh ; fi CLEAN_TARGETS += .lib-dir-stamp .test-stamp $(LIB) \ - lib/dmsetup lib/clvmd lib/dmeventd lib/vgimportclone + lib/dmsetup lib/clvmd lib/dmeventd lib/vgimportclone lib/fsadm .NOTPARALLEL: From zkabelac@sourceware.org Mon Sep 19 18:38:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 18:38:00 -0000 Subject: LVM2 lib/misc/lvm-exec.c ./WHATS_NEW Message-ID: <20110919183844.17228.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 18:38:43 Modified files: lib/misc : lvm-exec.c . : WHATS_NEW Log message: Revert patch Caller of exec must report log_error when rstatus is passed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-exec.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2122&r2=1.2123 --- LVM2/lib/misc/lvm-exec.c 2011/09/19 14:54:23 1.15 +++ LVM2/lib/misc/lvm-exec.c 2011/09/19 18:38:43 1.16 @@ -96,7 +96,7 @@ if (WEXITSTATUS(status)) { if (rstatus) { *rstatus = WEXITSTATUS(status); - log_error("%s failed: %u", argv[0], *rstatus); + log_verbose("%s failed: %u", argv[0], *rstatus); } else log_error("%s failed: %u", argv[0], WEXITSTATUS(status)); return 0; --- LVM2/WHATS_NEW 2011/09/19 14:54:23 1.2122 +++ LVM2/WHATS_NEW 2011/09/19 18:38:43 1.2123 @@ -1,6 +1,5 @@ Version 2.02.89 - ================================== - Use log_error instead of log_verbose when executed command fails. Add support for non /dev device paths into fsadm script. Support different PATH setting for fsadm script testing. Surround all executed commands with quotes in fsadm script. From zkabelac@sourceware.org Mon Sep 19 18:40:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 18:40:00 -0000 Subject: LVM2/test/api percent.sh Message-ID: <20110919184052.17903.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 18:40:52 Modified files: test/api : percent.sh Log message: Another vgremove for speedup It seems like test-suite is significantly slowed down on removal phase. Maybe it should be part of generic teardown - though the reason of slowdown should be also discovered - probably related to retry loop ? Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/percent.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/test/api/percent.sh 2011/06/09 18:58:01 1.6 +++ LVM2/test/api/percent.sh 2011/09/19 18:40:51 1.7 @@ -24,3 +24,5 @@ lvcreate -m 1 -n mirr $vg -l 1 --mirrorlog core lvs $vg aux apitest percent $vg + +vgremove -ff $vg From zkabelac@sourceware.org Mon Sep 19 19:36:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 19:36:00 -0000 Subject: LVM2 ./WHATS_NEW man/fsadm.8.in scripts/fsadm.sh Message-ID: <20110919193654.18353.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 19:36:53 Modified files: . : WHATS_NEW man : fsadm.8.in scripts : fsadm.sh Log message: Add support for DM_DEV_DIR Follow other commands support this directory setting. Useful for test suite. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2123&r2=1.2124 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/fsadm.8.in.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.28&r2=1.29 --- LVM2/WHATS_NEW 2011/09/19 18:38:43 1.2123 +++ LVM2/WHATS_NEW 2011/09/19 19:36:52 1.2124 @@ -1,6 +1,6 @@ Version 2.02.89 - ================================== - Add support for non /dev device paths into fsadm script. + Add support for DM_DEV_DIR device path into fsadm script. Support different PATH setting for fsadm script testing. Surround all executed commands with quotes in fsadm script. Fix missing '$' in test for content of "$LVM" in fsadm script. --- LVM2/man/fsadm.8.in 2011/09/07 08:50:35 1.5 +++ LVM2/man/fsadm.8.in 2011/09/19 19:36:53 1.6 @@ -63,6 +63,10 @@ .TP .B TMPDIR The temporary directory name for mount points. Defaults to "/tmp". +.TP +.B DM_DEV_DIR +The device directory name. +Defaults to "/dev" and must be an absolute path. .SH SEE ALSO .BR lvm (8), --- LVM2/scripts/fsadm.sh 2011/09/19 14:52:33 1.28 +++ LVM2/scripts/fsadm.sh 2011/09/19 19:36:53 1.29 @@ -67,12 +67,14 @@ FSTYPE=unknown VOLUME=unknown TEMPDIR="${TMPDIR:-/tmp}/${TOOL}_${RANDOM}$$/m" +DM_DEV_DIR="${DM_DEV_DIR:-/dev}" BLOCKSIZE= BLOCKCOUNT= MOUNTPOINT= MOUNTED= REMOUNT= PROCMOUNTS="/proc/mounts" +NULL="$DM_DEV_DIR/null" IFS_OLD=$IFS # without bash $'\n' @@ -176,17 +178,18 @@ # dereference device name if it is symbolic link detect_fs() { VOLUME_ORIG=$1 - VOLUME=${1#/dev/} - VOLUME=$("$READLINK" $READLINK_E "/dev/$VOLUME") || VOLUME=$("$READLINK" $READLINK_E "$VOLUME_ORIG") || error "Cannot get readlink \"$1\"" + VOLUME=${1/#"${DM_DEV_DIR}/"/} + VOLUME=$("$READLINK" $READLINK_E "$DM_DEV_DIR/$VOLUME") || error "Cannot get readlink \"$1\"" RVOLUME=$VOLUME case "$RVOLUME" in + # hardcoded /dev since udev does not create these entries elsewhere /dev/dm-[0-9]*) - read &1 && VOLUME="/dev/mapper/$SYSVOLUME" + read &1 && VOLUME="$DM_DEV_DIR/mapper/$SYSVOLUME" ;; esac - # use /dev/null as cache file to be sure about the result + # use null device as cache file to be sure about the result # not using option '-o value' to be compatible with older version of blkid - FSTYPE=$("$BLKID" -c /dev/null -s TYPE "$VOLUME") || error "Cannot get FSTYPE of \"$VOLUME\"" + FSTYPE=$("$BLKID" -c "$NULL" -s TYPE "$VOLUME") || error "Cannot get FSTYPE of \"$VOLUME\"" FSTYPE=${FSTYPE##*TYPE=\"} # cut quotation marks FSTYPE=${FSTYPE%%\"*} verbose "\"$FSTYPE\" filesystem found on \"$VOLUME\"" @@ -221,7 +224,7 @@ # get the full size of device in bytes detect_device_size() { # check if blockdev supports getsize64 - "$BLOCKDEV" 2>&1 | "$GREP" getsize64 >/dev/null + "$BLOCKDEV" 2>&1 | "$GREP" getsize64 >"$NULL" if test $? -eq 0; then DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME") || error "Cannot read size of device \"$VOLUME\"" else @@ -389,7 +392,7 @@ # only one supported #################################### diff_dates() { - echo $(( $("$DATE" -u -d"$1" +%s 2>/dev/null) - $("$DATE" -u -d"$2" +%s 2>/dev/null) )) + echo $(( $("$DATE" -u -d"$1" +%s 2>"$NULL") - $("$DATE" -u -d"$2" +%s 2>"$NULL") )) } ################### @@ -451,11 +454,11 @@ -a -n "$DATE" -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "$LVM" \ || error "Required command definitions in the script are missing!" -"$LVM" version >/dev/null 2>&1 || error "Could not run lvm binary \"$LVM\"" -$("$READLINK" -e / >/dev/null 2>&1) || READLINK_E="-f" +"$LVM" version >"$NULL" 2>&1 || error "Could not run lvm binary \"$LVM\"" +$("$READLINK" -e / >"$NULL" 2>&1) || READLINK_E="-f" TEST64BIT=$(( 1000 * 1000000000000 )) test "$TEST64BIT" -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic" -$(echo Y | "$GREP" Y >/dev/null) || error "Grep does not work properly" +$(echo Y | "$GREP" Y >"$NULL") || error "Grep does not work properly" test $("$DATE" -u -d"Jan 01 00:00:01 1970" +%s) -eq 1 || error "Date translation does not work" From zkabelac@sourceware.org Mon Sep 19 19:37:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 19 Sep 2011 19:37:00 -0000 Subject: LVM2/test t-fsadm.sh Message-ID: <20110919193727.25238.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-19 19:37:26 Modified files: test : t-fsadm.sh Log message: Unmount works with -y Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-fsadm.sh.diff?cvsroot=lvm2&r1=1.7&r2=1.8 --- LVM2/test/t-fsadm.sh 2011/09/19 13:52:22 1.7 +++ LVM2/test/t-fsadm.sh 2011/09/19 19:37:26 1.8 @@ -117,8 +117,9 @@ fscheck_reiserfs mount $dev_vg_lv $mount_dir - not fsadm -y --lvresize resize $vg_lv 20M + fsadm -y --lvresize resize $vg_lv 30M umount $mount_dir + fscheck_reiserfs lvresize -f -L20M $vg_lv fi From zkabelac@sourceware.org Wed Sep 21 10:39:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 21 Sep 2011 10:39:00 -0000 Subject: LVM2 ./WHATS_NEW test/t-fsadm.sh tools/lvresize.c Message-ID: <20110921103948.18576.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-21 10:39:47 Modified files: . : WHATS_NEW test : t-fsadm.sh tools : lvresize.c Log message: Add missing log_error() to lvresize command when fsadm tool fails Also add test case Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2124&r2=1.2125 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-fsadm.sh.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.137&r2=1.138 --- LVM2/WHATS_NEW 2011/09/19 19:36:52 1.2124 +++ LVM2/WHATS_NEW 2011/09/21 10:39:47 1.2125 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add missing log_error() to lvresize command when fsadm tool fails. Add support for DM_DEV_DIR device path into fsadm script. Support different PATH setting for fsadm script testing. Surround all executed commands with quotes in fsadm script. --- LVM2/test/t-fsadm.sh 2011/09/19 19:37:26 1.8 +++ LVM2/test/t-fsadm.sh 2011/09/21 10:39:47 1.9 @@ -83,6 +83,7 @@ fscheck_ext3 mount $dev_vg_lv $mount_dir not fsadm -y --lvresize resize $vg_lv 4M + echo n | not lvresize -L4M -r -n $vg_lv lvresize -L+20M -r -n $vg_lv umount $mount_dir fscheck_ext3 --- LVM2/tools/lvresize.c 2011/09/15 18:51:11 1.137 +++ LVM2/tools/lvresize.c 2011/09/21 10:39:47 1.138 @@ -676,15 +676,15 @@ if (!lp->nofsck && !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_CHECK, &status)) { if (status != FSADM_CHECK_FAILS_FOR_MOUNTED) { - stack; + log_error("Filesystem check failed."); return ECMD_FAILED; } - /* some filesystems supports online resize */ + /* some filesystems supports online resize */ } if ((lp->resize == LV_REDUCE) && !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE, NULL)) { - stack; + log_error("Filesystem resize failed."); return ECMD_FAILED; } } From zkabelac@sourceware.org Wed Sep 21 10:42:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Wed, 21 Sep 2011 10:42:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/cmirrord/clogd.c daem ... Message-ID: <20110921104254.19358.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-21 10:42:53 Modified files: . : WHATS_NEW daemons/cmirrord: clogd.c functions.c Log message: Check for failing 'stat' and skip this loop iteration (since data in statbuf are invalid). Check whether sysconf managed to find _SC_PAGESIZE. Report at least debug warning about failing unlink (logging scheme here seems to be a different then in lvm). Duplicate terminal FDs and use similar code as is made in clvmd and cleanup warns about missing open/close tests. FIXME: Looks like we already have 3 instancies of the same code in lvm repo. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2125&r2=1.2126 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/clogd.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/cmirrord/functions.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29 --- LVM2/WHATS_NEW 2011/09/21 10:39:47 1.2125 +++ LVM2/WHATS_NEW 2011/09/21 10:42:53 1.2126 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add missing error checks for some system calls in cmirrord. Add missing log_error() to lvresize command when fsadm tool fails. Add support for DM_DEV_DIR device path into fsadm script. Support different PATH setting for fsadm script testing. --- LVM2/daemons/cmirrord/clogd.c 2011/09/06 18:11:21 1.14 +++ LVM2/daemons/cmirrord/clogd.c 2011/09/21 10:42:53 1.15 @@ -134,6 +134,12 @@ { int pid; int status; + int devnull; + + if ((devnull = open("/dev/null", O_RDWR)) == -1) { + LOG_ERROR("Can't open /dev/null: %s", strerror(errno)); + exit(EXIT_FAILURE); + } signal(SIGTERM, &parent_exit_handler); @@ -182,10 +188,15 @@ chdir("/"); umask(0); - close(0); close(1); close(2); - open("/dev/null", O_RDONLY); /* reopen stdin */ - open("/dev/null", O_WRONLY); /* reopen stdout */ - open("/dev/null", O_WRONLY); /* reopen stderr */ + if (close(0) || close(1) || close(2)) { + LOG_ERROR("Failed to close terminal FDs"); + exit(EXIT_FAILURE); + } + + if ((dup2(devnull, 0) < 0) || /* reopen stdin */ + (dup2(devnull, 1) < 0) || /* reopen stdout */ + (dup2(devnull, 2) < 0)) /* reopen stderr */ + exit(EXIT_FAILURE); LOG_OPEN("cmirrord", LOG_PID, LOG_DAEMON); --- LVM2/daemons/cmirrord/functions.c 2011/09/06 18:24:27 1.28 +++ LVM2/daemons/cmirrord/functions.c 2011/09/21 10:42:53 1.29 @@ -329,7 +329,10 @@ */ sprintf(path_rtn, "/dev/mapper/%s", dep->d_name); - stat(path_rtn, &statbuf); + if (stat(path_rtn, &statbuf) < 0) { + LOG_DBG("Unable to stat %s", path_rtn); + continue; + } if (S_ISBLK(statbuf.st_mode) && (major(statbuf.st_rdev) == major) && (minor(statbuf.st_rdev) == minor)) { @@ -476,7 +479,12 @@ lc->sync_count = (log_sync == NOSYNC) ? region_count : 0; if (disk_log) { - page_size = sysconf(_SC_PAGESIZE); + if ((page_size = sysconf(_SC_PAGESIZE)) < 0) { + LOG_ERROR("Unable to read pagesize: %s", + strerror(errno)); + r = errno; + goto fail; + } pages = *(lc->clean_bits) / page_size; pages += *(lc->clean_bits) % page_size ? 1 : 0; pages += 1; /* for header */ @@ -489,7 +497,10 @@ goto fail; } if (unlink_path) - unlink(disk_path); + if (unlink(disk_path) < 0) { + LOG_DBG("Warning: Unable to unlink log device, %s: %s", + disk_path, strerror(errno)); + } lc->disk_fd = r; lc->disk_size = pages * page_size; From mbroz@sourceware.org Wed Sep 21 13:40:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Wed, 21 Sep 2011 13:40:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/refresh_clvmd.c Message-ID: <20110921134048.5227.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-09-21 13:40:47 Modified files: . : WHATS_NEW daemons/clvmd : refresh_clvmd.c Log message: Always sent the whole command header in restart/reload clvmd commands. (Newly added check catch this as invalid packet.) (N.B. that code is so fragile that it need full rewrite soon:-) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2126&r2=1.2127 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/refresh_clvmd.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16 --- LVM2/WHATS_NEW 2011/09/21 10:42:53 1.2126 +++ LVM2/WHATS_NEW 2011/09/21 13:40:46 1.2127 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Always send the whole clvmd packet header in refresh commands. Add missing error checks for some system calls in cmirrord. Add missing log_error() to lvresize command when fsadm tool fails. Add support for DM_DEV_DIR device path into fsadm script. --- LVM2/daemons/clvmd/refresh_clvmd.c 2011/04/08 14:40:18 1.15 +++ LVM2/daemons/clvmd/refresh_clvmd.c 2011/09/21 13:40:46 1.16 @@ -149,14 +149,20 @@ /* Build the structure header and parse-out wildcard node names */ static void _build_header(struct clvm_header *head, int cmd, const char *node, - int len) + unsigned int len) { head->cmd = cmd; head->status = 0; head->flags = 0; head->xid = 0; head->clientid = 0; - head->arglen = len; + if (len) + /* 1 byte is used from struct clvm_header.args[1], so -> len - 1 */ + head->arglen = len - 1; + else { + head->arglen = 0; + *head->args = '\0'; + } if (node) { /* @@ -198,12 +204,12 @@ if (_clvmd_sock == -1) return 0; - /* 1 byte is used from struct clvm_header.args[1], so -> len - 1 */ - _build_header(head, cmd, node, len - 1); - memcpy(head->node + strlen(head->node) + 1, data, len); + _build_header(head, cmd, node, len); + if (len) + memcpy(head->node + strlen(head->node) + 1, data, len); status = _send_request(outbuf, sizeof(struct clvm_header) + - strlen(head->node) + len - 1, &retbuf, no_response); + strlen(head->node) + len, &retbuf, no_response); if (!status || no_response) goto out; From agk@sourceware.org Wed Sep 21 16:36:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 21 Sep 2011 16:36:00 -0000 Subject: LVM2/tools pvmove.c Message-ID: <20110921163640.16609.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-21 16:36:39 Modified files: tools : pvmove.c Log message: FIXMEs to note problems with some error paths. (Perhaps safer to disable them until they can be fixed completely?) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87 --- LVM2/tools/pvmove.c 2011/08/30 14:55:19 1.86 +++ LVM2/tools/pvmove.c 2011/09/21 16:36:39 1.87 @@ -365,6 +365,7 @@ } if (!_suspend_lvs(cmd, first_time, lv_mirr, lvs_changed)) { + /* FIXME vg_revert must be moved *before* any LV resumes */ vg_revert(vg); goto_out; } @@ -388,13 +389,16 @@ /* * Nothing changed yet, try to revert pvmove. + * FIXME This error path is incomplete and unsafe. */ log_error("Temporary pvmove mirror activation failed."); /* Ensure that temporary mrror is deactivate even on other nodes. */ + /* FIXME Unsafe to proceed if this fails without checking explicitly that no pvmove LVs are still active */ (void)deactivate_lv(cmd, lv_mirr); /* Revert metadata */ + /* FIXME Use --abort code instead? */ if (!_detach_pvmove_mirror(cmd, lv_mirr) || !lv_remove(lv_mirr) || !vg_write(vg) || !vg_commit(vg)) From zkabelac@sourceware.org Thu Sep 22 09:45:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 22 Sep 2011 09:45:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-command.c Message-ID: <20110922094525.13161.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-22 09:45:24 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Add all exclusive locks to clvmd restart option args Fix bug when only every even lock has been passed. Warning: currently -E causes clvmd to exit with usage text being printed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2127&r2=1.2128 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/WHATS_NEW 2011/09/21 13:40:46 1.2127 +++ LVM2/WHATS_NEW 2011/09/22 09:45:24 1.2128 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add all exclusive locks to clvmd restart option args. Always send the whole clvmd packet header in refresh commands. Add missing error checks for some system calls in cmirrord. Add missing log_error() to lvresize command when fsadm tool fails. --- LVM2/daemons/clvmd/clvmd-command.c 2011/06/03 09:05:30 1.56 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/09/22 09:45:24 1.57 @@ -369,7 +369,6 @@ DEBUGLOG("clvmd restart requested\n"); /* Count exclusively-open LVs */ - hn = NULL; do { hn = get_next_excl_lock(hn, &lv_name); if (lv_name) @@ -403,6 +402,7 @@ */ /* Now add the exclusively-open LVs */ + hn = NULL; do { hn = get_next_excl_lock(hn, &lv_name); if (lv_name) { @@ -414,7 +414,6 @@ goto_out; DEBUGLOG("excl lock: %s\n", lv_name); - hn = get_next_excl_lock(hn, &lv_name); } } while (hn && *lv_name); argv[argc++] = NULL; From zkabelac@sourceware.org Thu Sep 22 09:47:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 22 Sep 2011 09:47:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-command.c Message-ID: <20110922094734.13600.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-22 09:47:34 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Clvmd restart cleanup Patch fixes Clang warnings about possible access via lv_name NULL pointer. Replaces allocation of memory (strdup) with just pointer assignment (since execve is being called anyway). Checks for !*lv_name only when lv_name is defined. (and as I'm not quite sure what state this really is - putting a FIXME around - as this rather looks suspicios ??). Add debug print of passed clvmd args. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2128&r2=1.2129 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58 --- LVM2/WHATS_NEW 2011/09/22 09:45:24 1.2128 +++ LVM2/WHATS_NEW 2011/09/22 09:47:34 1.2129 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Cleanup restart clvmd code (no memory allocation, debug print passed args). Add all exclusive locks to clvmd restart option args. Always send the whole clvmd packet header in refresh commands. Add missing error checks for some system calls in cmirrord. --- LVM2/daemons/clvmd/clvmd-command.c 2011/09/22 09:45:24 1.57 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/09/22 09:47:34 1.58 @@ -361,39 +361,38 @@ static int restart_clvmd(void) { - char **argv = NULL; - char *debug_arg = NULL, *lv_name; - int i, argc = 0, max_locks = 0; + const char **argv; + char *lv_name; + int argc = 0, max_locks = 0; struct dm_hash_node *hn = NULL; + char debug_arg[16]; DEBUGLOG("clvmd restart requested\n"); /* Count exclusively-open LVs */ do { hn = get_next_excl_lock(hn, &lv_name); - if (lv_name) + if (lv_name) { max_locks++; - } while (hn && *lv_name); + if (!*lv_name) + break; /* FIXME: Is this error ? */ + } + } while (hn); /* clvmd + locks (-E uuid) + debug (-d X) + NULL */ - argv = malloc((max_locks * 2 + 4) * sizeof(*argv)); - if (!argv) + if (!(argv = malloc((max_locks * 2 + 4) * sizeof(*argv)))) goto_out; /* * Build the command-line */ - argv[argc++] = strdup("clvmd"); - if (!argv[0]) - goto_out; + argv[argc++] = "clvmd"; /* Propogate debug options */ if (clvmd_get_debug()) { - if (!(debug_arg = malloc(16)) || - dm_snprintf(debug_arg, 16, "-d%u", clvmd_get_debug()) < 0) + if (dm_snprintf(debug_arg, sizeof(debug_arg), "-d%u", clvmd_get_debug()) < 0) goto_out; argv[argc++] = debug_arg; - debug_arg = NULL; } /* @@ -406,30 +405,26 @@ do { hn = get_next_excl_lock(hn, &lv_name); if (lv_name) { - argv[argc] = strdup("-E"); - if (!argv[argc++]) - goto_out; - argv[argc] = strdup(lv_name); - if (!argv[argc++]) - goto_out; - + if (!*lv_name) + break; /* FIXME: Is this error ? */ + argv[argc++] = "-E"; + argv[argc++] = lv_name; DEBUGLOG("excl lock: %s\n", lv_name); } - } while (hn && *lv_name); - argv[argc++] = NULL; + } while (hn); + argv[argc] = NULL; /* Exec new clvmd */ DEBUGLOG("--- Restarting %s ---\n", CLVMD_PATH); + for (argc = 1; argv[argc]; argc++) DEBUGLOG("--- %d: %s\n", argc, argv[argc]); + /* NOTE: This will fail when downgrading! */ - execve(CLVMD_PATH, argv, NULL); + execve(CLVMD_PATH, (char **)argv, NULL); out: /* We failed */ DEBUGLOG("Restart of clvmd failed.\n"); - for (i = 0; i < argc && argv[i]; i++) - free(argv[i]); free(argv); - free(debug_arg); return EIO; } From jbrassow@sourceware.org Thu Sep 22 15:33:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Thu, 22 Sep 2011 15:33:00 -0000 Subject: LVM2/lib/metadata raid_manip.c Message-ID: <20110922153322.597.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-22 15:33:21 Modified files: lib/metadata : raid_manip.c Log message: When up-converting a RAID1 array, we need to allocate new larger arrays for seg->areas and seg->meta_areas. We also need to copy the memory from the old arrays to the newly allocated arrays. The amount of memory to copy was determined by seg->area_count. However, seg->area_count was being set to the higher value after copying the 'seg->areas' information, but before copying the 'seg->meta_areas' information. This means we were copying more memory than necessary for 'seg->meta_areas' - something that could lead to a segfault. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/raid_manip.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15 --- LVM2/lib/metadata/raid_manip.c 2011/09/14 09:57:35 1.14 +++ LVM2/lib/metadata/raid_manip.c 2011/09/22 15:33:21 1.15 @@ -499,7 +499,6 @@ goto fail; memcpy(new_areas, seg->areas, seg->area_count * sizeof(*seg->areas)); seg->areas = new_areas; - seg->area_count = new_count; /* Expand meta_areas array */ if (!(new_areas = dm_pool_zalloc(lv->vg->cmd->mem, @@ -508,6 +507,7 @@ memcpy(new_areas, seg->meta_areas, seg->area_count * sizeof(*seg->meta_areas)); seg->meta_areas = new_areas; + seg->area_count = new_count; /* Set segment areas for metadata sub_lvs */ s = old_count; From jbrassow@sourceware.org Thu Sep 22 15:36:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Thu, 22 Sep 2011 15:36:00 -0000 Subject: LVM2 ./WHATS_NEW tools/lvcreate.c Message-ID: <20110922153622.13112.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-22 15:36:21 Modified files: . : WHATS_NEW tools : lvcreate.c Log message: Disallow the creation of mirrors (mirror or raid1 segtype) with only one leg. If you specify the segment type (e.g. --type mirror) and the mirrors argument as zero, it would result in a mirrored LV with only one image. While the device may be valid in theory, it should not be allowed in practice. It also makes it difficult on the conversion tools, since they react badly to single-image mirrors. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2129&r2=1.2130 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.241&r2=1.242 --- LVM2/WHATS_NEW 2011/09/22 09:47:34 1.2129 +++ LVM2/WHATS_NEW 2011/09/22 15:36:21 1.2130 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Disallow the creation of mirrors (mirror or raid1 segtype) with only one leg. Cleanup restart clvmd code (no memory allocation, debug print passed args). Add all exclusive locks to clvmd restart option args. Always send the whole clvmd packet header in refresh commands. --- LVM2/tools/lvcreate.c 2011/09/15 15:26:40 1.241 +++ LVM2/tools/lvcreate.c 2011/09/22 15:36:21 1.242 @@ -618,8 +618,13 @@ if (arg_count(cmd, mirrors_ARG)) { lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0) + 1; - if (lp->mirrors == 1) + if (lp->mirrors == 1) { + if (segtype_is_mirrored(lp->segtype)) { + log_error("Image count for segtype \"%s\" cannot be 0.", lp->segtype->name); + return 0; + } log_print("Redundant mirrors argument: default is 0"); + } if (arg_sign_value(cmd, mirrors_ARG, 0) == SIGN_MINUS) { log_error("Mirrors argument may not be negative"); return 0; From prajnoha@sourceware.org Thu Sep 22 17:09:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 22 Sep 2011 17:09:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm ... Message-ID: <20110922170950.22096.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-22 17:09:49 Modified files: . : WHATS_NEW_DM libdm : libdevmapper.h libdm/ioctl : libdm-iface.c libdm-targets.h Log message: Add dm_task_retry_remove fn to use retry logic for device removal. This call ensures that the dm device removal is retried several times before failing. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.499&r2=1.500 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.149&r2=1.150 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-targets.h.diff?cvsroot=lvm2&r1=1.31&r2=1.32 --- LVM2/WHATS_NEW_DM 2011/09/13 15:13:41 1.499 +++ LVM2/WHATS_NEW_DM 2011/09/22 17:09:48 1.500 @@ -1,6 +1,6 @@ Version 1.02.68 - ================================== - Retry DM_DEVICE_REMOVE ioctl if device is busy. + Add dm_task_retry_remove fn to use retry logic for device removal. Remove unused passed parameters for _mirror_emit_segment_line(). Add dm_config and string character escaping functions to libdevmapper. Mark unreleased memory pools as internal error. --- LVM2/libdm/libdevmapper.h 2011/09/02 01:32:09 1.149 +++ LVM2/libdm/libdevmapper.h 2011/09/22 17:09:48 1.150 @@ -191,6 +191,7 @@ int dm_task_query_inactive_table(struct dm_task *dmt); int dm_task_suppress_identical_reload(struct dm_task *dmt); int dm_task_secure_data(struct dm_task *dmt); +int dm_task_retry_remove(struct dm_task *dmt); /* * Enable checks for common mistakes such as issuing ioctls in an unsafe order. --- LVM2/libdm/ioctl/libdm-iface.c 2011/09/13 15:13:41 1.120 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/09/22 17:09:48 1.121 @@ -828,6 +828,13 @@ return 1; } +int dm_task_retry_remove(struct dm_task *dmt) +{ + dmt->retry_remove = 1; + + return 1; +} + int dm_task_query_inactive_table(struct dm_task *dmt) { dmt->query_inactive_table = 1; @@ -1539,16 +1546,15 @@ return sanitised_message; } -#define DM_REMOVE_IOCTL_RETRIES 25 - static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command, - unsigned repeat_count) + unsigned buffer_repeat_count, + unsigned retry_repeat_count, + int *retryable) { struct dm_ioctl *dmi; int ioctl_with_uevent; - int retries = DM_REMOVE_IOCTL_RETRIES; - dmi = _flatten(dmt, repeat_count); + dmi = _flatten(dmt, buffer_repeat_count); if (!dmi) { log_error("Couldn't create ioctl argument."); return NULL; @@ -1609,7 +1615,7 @@ } log_debug("dm %s %s%s %s%s%s %s%.0d%s%.0d%s" - "%s%c%c%s%s%s%s%s %.0" PRIu64 " %s [%u]", + "%s%c%c%s%s%s%s%s%s %.0" PRIu64 " %s [%u] (*%u)", _cmd_data_v4[dmt->type].name, dmt->new_uuid ? "UUID " : "", dmi->name, dmi->uuid, dmt->newname ? " " : "", @@ -1624,29 +1630,18 @@ dmt->no_flush ? 'N' : 'F', dmt->read_only ? "R" : "", dmt->skip_lockfs ? "S " : "", + dmt->retry_remove ? "T " : "", dmt->secure_data ? "W " : "", dmt->query_inactive_table ? "I " : "", dmt->enable_checks ? "C" : "", dmt->sector, _sanitise_message(dmt->message), - dmi->data_size); + dmi->data_size, retry_repeat_count); #ifdef DM_IOCTLS -repeat_dm_ioctl: if (ioctl(_control_fd, command, dmi) < 0) { if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) || (dmt->type == DM_DEVICE_MKNODES) || (dmt->type == DM_DEVICE_STATUS))) dmi->flags &= ~DM_EXISTS_FLAG; /* FIXME */ - /* - * FIXME: This is a workaround for asynchronous events generated - * as a result of using the WATCH udev rule with which we - * have no way of synchronizing. Processing such events in - * parallel causes devices to be open. - */ - else if (errno == EBUSY && (dmt->type == DM_DEVICE_REMOVE) && retries--) { - log_debug("device-mapper: device is busy, retrying removal"); - usleep(200000); - goto repeat_dm_ioctl; - } else { if (_log_suppress) log_verbose("device-mapper: %s ioctl " @@ -1658,6 +1653,9 @@ "failed: %s", _cmd_data_v4[dmt->type].name, strerror(errno)); + + *retryable = errno == EBUSY; + _dm_zfree_dmi(dmi); return NULL; } @@ -1680,6 +1678,9 @@ update_devs(); } +#define DM_IOCTL_RETRIES 25 +#define DM_RETRY_USLEEP_DELAY 200000 + int dm_task_run(struct dm_task *dmt) { struct dm_ioctl *dmi; @@ -1687,6 +1688,8 @@ int check_udev; int rely_on_udev; int suspended_counter; + unsigned ioctl_retry = 1; + int retryable; if ((unsigned) dmt->type >= (sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) { @@ -1734,7 +1737,14 @@ /* FIXME Detect and warn if cookie set but should not be. */ repeat_ioctl: - if (!(dmi = _do_dm_ioctl(dmt, command, _ioctl_buffer_double_factor))) { + if (!(dmi = _do_dm_ioctl(dmt, command, _ioctl_buffer_double_factor, + ioctl_retry, &retryable))) { + if (retryable && dmt->type == DM_DEVICE_REMOVE && + dmt->retry_remove && ++ioctl_retry <= DM_IOCTL_RETRIES) { + usleep(DM_RETRY_USLEEP_DELAY); + goto repeat_ioctl; + } + _udev_complete(dmt); return 0; } --- LVM2/libdm/ioctl/libdm-targets.h 2011/08/09 17:56:48 1.31 +++ LVM2/libdm/ioctl/libdm-targets.h 2011/09/22 17:09:49 1.32 @@ -63,6 +63,7 @@ int cookie_set; int new_uuid; int secure_data; + int retry_remove; int enable_checks; char *uuid; From prajnoha@sourceware.org Thu Sep 22 17:12:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 22 Sep 2011 17:12:00 -0000 Subject: LVM2 ./WHATS_NEW_DM man/dmsetup.8.in tools/dms ... Message-ID: <20110922171229.24006.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-22 17:12:28 Modified files: . : WHATS_NEW_DM man : dmsetup.8.in tools : dmsetup.c Log message: Add --retry option for dmsetup remove to retry removal if not successful. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.500&r2=1.501 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/dmsetup.8.in.diff?cvsroot=lvm2&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.168&r2=1.169 --- LVM2/WHATS_NEW_DM 2011/09/22 17:09:48 1.500 +++ LVM2/WHATS_NEW_DM 2011/09/22 17:12:28 1.501 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Add --retry option for dmsetup remove to retry removal if not successful. Add dm_task_retry_remove fn to use retry logic for device removal. Remove unused passed parameters for _mirror_emit_segment_line(). Add dm_config and string character escaping functions to libdevmapper. --- LVM2/man/dmsetup.8.in 2011/07/01 14:09:20 1.42 +++ LVM2/man/dmsetup.8.in 2011/09/22 17:12:28 1.43 @@ -11,7 +11,7 @@ .I [{ --addnodeonresume | --addnodeoncreate }] .br .B dmsetup remove -.I [-f|--force] device_name +.I [-f|--force] [--retry] device_name .br .B dmsetup remove_all .I [-f|--force] @@ -280,7 +280,7 @@ correspond to mapped devices currently loaded by the device-mapper kernel driver, adding, changing or removing nodes as necessary. .IP \fBremove -.I [-f|--force] device_name +.I [-f|--force] [--retry] device_name .br Removes a device. It will no longer be visible to dmsetup. Open devices cannot be removed except with older kernels @@ -290,7 +290,10 @@ be removed because an uninterruptible process is waiting for I/O to return from it, adding --force will replace the table with one that fails all I/O, which might allow the -process to be killed. +process to be killed. If an attempt to remove a device fails, +perhaps because a process run from a quick udev rule +temporarily opened the device, the --retry option will cause +the operation to be retried for a few seconds before failing. .IP \fBremove_all .I [-f|--force] .br --- LVM2/tools/dmsetup.c 2011/08/11 19:18:18 1.168 +++ LVM2/tools/dmsetup.c 2011/09/22 17:12:28 1.169 @@ -140,6 +140,7 @@ NOUDEVSYNC_ARG, OPTIONS_ARG, READAHEAD_ARG, + RETRY_ARG, ROWS_ARG, SEPARATOR_ARG, SETUUID_ARG, @@ -1279,6 +1280,9 @@ if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, udev_flags)) goto out; + if (_switches[RETRY_ARG] && task == DM_DEVICE_REMOVE) + dm_task_retry_remove(dmt); + r = dm_task_run(dmt); out: @@ -2805,7 +2809,7 @@ " [--checks] [-v|--verbose [-v|--verbose ...]]\n" " [-r|--readonly] [--noopencount] [--nolockfs] [--inactive]\n" " [--udevcookie [cookie]] [--noudevrules] [--noudevsync] [--verifyudev]\n" - " [-y|--yes] [--readahead [+]|auto|none]\n" + " [-y|--yes] [--readahead [+]|auto|none] [--retry]\n" " [-c|-C|--columns] [-o ] [-O|--sort ]\n" " [--nameprefixes] [--noheadings] [--separator ]\n\n"); for (i = 0; _commands[i].name; i++) @@ -3178,6 +3182,7 @@ {"noudevsync", 0, &ind, NOUDEVSYNC_ARG}, {"options", 1, &ind, OPTIONS_ARG}, {"readahead", 1, &ind, READAHEAD_ARG}, + {"retry", 0, &ind, RETRY_ARG}, {"rows", 0, &ind, ROWS_ARG}, {"separator", 1, &ind, SEPARATOR_ARG}, {"setuuid", 0, &ind, SETUUID_ARG}, @@ -3362,6 +3367,8 @@ } } } + if ((ind == RETRY_ARG)) + _switches[RETRY_ARG]++; if ((ind == ROWS_ARG)) _switches[ROWS_ARG]++; if ((ind == SETUUID_ARG)) From prajnoha@sourceware.org Thu Sep 22 17:17:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 22 Sep 2011 17:17:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm ... Message-ID: <20110922171708.26829.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-22 17:17:07 Modified files: . : WHATS_NEW_DM libdm : libdevmapper.h libdm-common.c Log message: Add dm_set_sysfs_dir to libdevmapper to set sysfs location. Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.501&r2=1.502 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.150&r2=1.151 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125 --- LVM2/WHATS_NEW_DM 2011/09/22 17:12:28 1.501 +++ LVM2/WHATS_NEW_DM 2011/09/22 17:17:07 1.502 @@ -1,5 +1,7 @@ Version 1.02.68 - ================================== + Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set. + Add dm_set_sysfs_dir to libdevmapper to set sysfs location. Add --retry option for dmsetup remove to retry removal if not successful. Add dm_task_retry_remove fn to use retry logic for device removal. Remove unused passed parameters for _mirror_emit_segment_line(). --- LVM2/libdm/libdevmapper.h 2011/09/22 17:09:48 1.150 +++ LVM2/libdm/libdevmapper.h 2011/09/22 17:17:07 1.151 @@ -256,6 +256,12 @@ const char *dm_dir(void); /* + * Configure sysfs directory, /sys by default + */ +int dm_set_sysfs_dir(const char *dir); +const char *dm_sysfs_dir(void); + +/* * Determine whether a major number belongs to device-mapper or not. */ int dm_is_dm_major(uint32_t major); --- LVM2/libdm/libdm-common.c 2011/07/08 15:34:47 1.124 +++ LVM2/libdm/libdm-common.c 2011/09/22 17:17:07 1.125 @@ -58,6 +58,7 @@ #endif static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR; +static char _sysfs_dir[PATH_MAX] = "/sys/"; static int _verbose = 0; static int _suspended_dev_counter = 0; @@ -1008,32 +1009,53 @@ _pop_node_ops(); } -int dm_set_dev_dir(const char *dev_dir) +static int _canonicalize_and_set_dir(const char *src, const char *suffix, size_t max_len, char *dir) { size_t len; const char *slash; - if (*dev_dir != '/') { - log_debug("Invalid dev_dir value, %s: " - "not an absolute name.", dev_dir); + + if (*src != '/') { + log_debug("Invalid directory value, %s: " + "not an absolute name.", src); return 0; } - len = strlen(dev_dir); - slash = dev_dir[len-1] == '/' ? "" : "/"; + len = strlen(src); + slash = src[len-1] == '/' ? "" : "/"; - if (dm_snprintf(_dm_dir, sizeof _dm_dir, "%s%s%s", dev_dir, slash, DM_DIR) < 0) { - log_debug("Invalid dev_dir value, %s: name too long.", dev_dir); + if (dm_snprintf(dir, max_len, "%s%s%s", src, slash, suffix ? suffix : "") < 0) { + log_debug("Invalid directory value, %s: name too long.", src); return 0; } return 1; } +int dm_set_dev_dir(const char *dev_dir) +{ + return _canonicalize_and_set_dir(dev_dir, DM_DIR, sizeof _dm_dir, _dm_dir); +} + const char *dm_dir(void) { return _dm_dir; } +int dm_set_sysfs_dir(const char *sysfs_dir) +{ + if (!sysfs_dir || !*sysfs_dir) { + _sysfs_dir[0] = '\0'; + return 1; + } + else + return _canonicalize_and_set_dir(sysfs_dir, NULL, sizeof _sysfs_dir, _sysfs_dir); +} + +const char *dm_sysfs_dir(void) +{ + return _sysfs_dir; +} + int dm_mknodes(const char *name) { struct dm_task *dmt; From prajnoha@sourceware.org Thu Sep 22 17:23:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 22 Sep 2011 17:23:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm ... Message-ID: <20110922172337.28612.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-22 17:23:36 Modified files: . : WHATS_NEW_DM libdm : libdevmapper.h libdm-common.c libdm-file.c Log message: Add dm_device_has_holders fn to to check use of the device by another device. Add dm_device_has_mounted_fs fn to check mounted filesystem on a device. This requires sysfs directory to be correctly set via dm_set_sysfs_dir (/sys by default). If sysfs dir is not used or it's set incorrectly, dm_device_has_{holders,mounted_fs} will return 0! Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.502&r2=1.503 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.151&r2=1.152 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-file.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/WHATS_NEW_DM 2011/09/22 17:17:07 1.502 +++ LVM2/WHATS_NEW_DM 2011/09/22 17:23:35 1.503 @@ -1,5 +1,7 @@ Version 1.02.68 - ================================== + Add dm_device_has_mounted_fs fn to check mounted filesystem on a device. + Add dm_device_has_holders fn to to check use of the device by another device. Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set. Add dm_set_sysfs_dir to libdevmapper to set sysfs location. Add --retry option for dmsetup remove to retry removal if not successful. --- LVM2/libdm/libdevmapper.h 2011/09/22 17:17:07 1.151 +++ LVM2/libdm/libdevmapper.h 2011/09/22 17:23:36 1.152 @@ -267,6 +267,19 @@ int dm_is_dm_major(uint32_t major); /* + * Determine whether a device has any holders (devices + * using this device). If sysfs is not used (or configured + * incorrectly), returns 0. + */ +int dm_device_has_holders(uint32_t major, uint32_t minor); + +/* + * Determine whether a device contains mounted filesystem. + * If sysfs is not used (or configured incorrectly), returns 0. + */ +int dm_device_has_mounted_fs(uint32_t major, uint32_t minor); + +/* * Release library resources */ void dm_lib_release(void); @@ -1069,6 +1082,8 @@ */ int dm_create_dir(const char *dir); +int dm_is_empty_dir(const char *dir); + /* * Close a stream, with nicer error checking than fclose's. * Derived from gnulib's close-stream.c. --- LVM2/libdm/libdm-common.c 2011/09/22 17:17:07 1.125 +++ LVM2/libdm/libdm-common.c 2011/09/22 17:23:36 1.126 @@ -1056,6 +1056,106 @@ return _sysfs_dir; } +int dm_device_has_holders(uint32_t major, uint32_t minor) +{ + char sysfs_path[PATH_MAX]; + struct stat st; + + if (!*_sysfs_dir) + return 0; + + if (dm_snprintf(sysfs_path, PATH_MAX, "%sdev/block/%" PRIu32 + ":%" PRIu32 "/holders", _sysfs_dir, major, minor) < 0) { + log_error("sysfs_path dm_snprintf failed"); + return 0; + } + + if (stat(sysfs_path, &st)) { + log_sys_error("stat", sysfs_path); + return 0; + } + + return !dm_is_empty_dir(sysfs_path); +} + +static int _mounted_fs_on_device(const char *kernel_dev_name) +{ + char sysfs_path[PATH_MAX]; + struct dirent *dirent; + DIR *d; + struct stat st; + int r = 0; + + if (dm_snprintf(sysfs_path, PATH_MAX, "%sfs", _sysfs_dir) < 0) { + log_error("sysfs_path dm_snprintf failed"); + return 0; + } + + if (!(d = opendir(sysfs_path))) { + if (errno != ENOENT) + log_sys_error("opendir", sysfs_path); + return 0; + } + + while ((dirent = readdir(d))) { + if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..")) + continue; + + if (dm_snprintf(sysfs_path, PATH_MAX, "%sfs/%s/%s", + _sysfs_dir, dirent->d_name, kernel_dev_name) < 0) { + log_error("sysfs_path dm_snprintf failed"); + break; + } + + if (!stat(sysfs_path, &st)) { + /* found! */ + r = 1; + break; + } + else if (errno != ENOENT) { + log_sys_error("stat", sysfs_path); + break; + } + } + + if (closedir(d)) + log_error("_fs_present_on_device: %s: closedir failed", kernel_dev_name); + + return r; +} + +int dm_device_has_mounted_fs(uint32_t major, uint32_t minor) +{ + char sysfs_path[PATH_MAX]; + char temp_path[PATH_MAX]; + char *kernel_dev_name; + ssize_t size; + + if (!*_sysfs_dir) + return 0; + + /* Get kernel device name first */ + if (dm_snprintf(sysfs_path, PATH_MAX, "%sdev/block/%" PRIu32 ":%" PRIu32, + _sysfs_dir, major, minor) < 0) { + log_error("sysfs_path dm_snprintf failed"); + return 0; + } + + if ((size = readlink(sysfs_path, temp_path, PATH_MAX)) < 0) { + log_sys_error("readlink", sysfs_path); + return 0; + } + + if (!(kernel_dev_name = strrchr(temp_path, '/'))) { + log_error("Could not locate device kernel name in sysfs path %s", temp_path); + return 0; + } + kernel_dev_name += 1; + + /* Check /sys/fs// presence */ + return _mounted_fs_on_device(kernel_dev_name); +} + int dm_mknodes(const char *name) { struct dm_task *dmt; --- LVM2/libdm/libdm-file.c 2011/08/04 17:56:12 1.16 +++ LVM2/libdm/libdm-file.c 2011/09/22 17:23:36 1.17 @@ -76,6 +76,26 @@ return 0; } +int dm_is_empty_dir(const char *dir) +{ + struct dirent *dirent; + DIR *d; + + if (!(d = opendir(dir))) { + log_sys_error("opendir", dir); + return 0; + } + + while ((dirent = readdir(d))) + if (strcmp(dirent->d_name, ".") && strcmp(dirent->d_name, "..")) + break; + + if (closedir(d)) + log_sys_error("closedir", dir); + + return dirent ? 0 : 1; +} + int dm_fclose(FILE *stream) { int prev_fail = ferror(stream); From prajnoha@sourceware.org Thu Sep 22 17:33:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 22 Sep 2011 17:33:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ... Message-ID: <20110922173352.32524.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-22 17:33:51 Modified files: . : WHATS_NEW lib/activate : activate.c activate.h lib/commands : toolcontext.c lib/metadata : lv_manip.c libdm : libdm-deptree.c Log message: Replace open_count check with holders/mounted_fs check on lvremove path. Before, we used to display "Can't remove open logical volume" which was generic. There 3 possibilities of how a device could be opened: - used by another device - having a filesystem on that device which is mounted - opened directly by an application With the help of sysfs info, we can distinguish the first two situations. The third one will be subject to "remove retry" logic - if it's opened quickly (e.g. a parallel scan from within a udev rule run), this will finish quickly and we can remove it once it has finished. If it's a legitimate application that keeps the device opened, we'll do our best to remove the device, but we will fail finally after a few retries. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2130&r2=1.2131 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.212&r2=1.213 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.79&r2=1.80 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.135&r2=1.136 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.289&r2=1.290 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110 --- LVM2/WHATS_NEW 2011/09/22 15:36:21 1.2130 +++ LVM2/WHATS_NEW 2011/09/22 17:33:50 1.2131 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Replace open_count check with holders/mounted_fs check on lvremove path. Disallow the creation of mirrors (mirror or raid1 segtype) with only one leg. Cleanup restart clvmd code (no memory allocation, debug print passed args). Add all exclusive locks to clvmd restart option args. --- LVM2/lib/activate/activate.c 2011/08/30 14:55:16 1.212 +++ LVM2/lib/activate/activate.c 2011/09/22 17:33:50 1.213 @@ -526,6 +526,31 @@ return r; } +int lv_check_not_in_use(struct cmd_context *cmd __attribute__((unused)), + struct logical_volume *lv, struct lvinfo *info) +{ + if (!info->exists) + return 1; + + /* If sysfs is not used, use open_count information only. */ + if (!*dm_sysfs_dir()) + return !info->open_count; + + if (dm_device_has_holders(info->major, info->minor)) { + log_error("Logical volume %s/%s is used by another device.", + lv->vg->name, lv->name); + return 0; + } + + if (dm_device_has_mounted_fs(info->major, info->minor)) { + log_error("Logical volume %s/%s contains a filesystem in use.", + lv->vg->name, lv->name); + return 0; + } + + return 1; +} + /* * Returns 1 if percent set, else 0 on failure. */ @@ -1437,11 +1462,9 @@ } if (lv_is_visible(lv)) { - if (info.open_count) { - log_error("LV %s/%s in use: not deactivating", - lv->vg->name, lv->name); - goto out; - } + if (!lv_check_not_in_use(cmd, lv, &info)) + goto_out; + if (lv_is_origin(lv) && _lv_has_open_snapshots(lv)) goto_out; } --- LVM2/lib/activate/activate.h 2011/08/11 18:24:41 1.79 +++ LVM2/lib/activate/activate.h 2011/09/22 17:33:51 1.80 @@ -80,6 +80,9 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, struct lvinfo *info, int with_open_count, int with_read_ahead); +int lv_check_not_in_use(struct cmd_context *cmd, struct logical_volume *lv, + struct lvinfo *info); + /* * Returns 1 if activate_lv has been set: 1 = activate; 0 = don't. */ --- LVM2/lib/commands/toolcontext.c 2011/09/02 12:38:43 1.135 +++ LVM2/lib/commands/toolcontext.c 2011/09/22 17:33:51 1.136 @@ -264,6 +264,7 @@ /* FIXME Use global value of sysfs_dir everywhere instead cmd->sysfs_dir. */ _get_sysfs_dir(cmd); set_sysfs_dir_path(cmd->sysfs_dir); + dm_set_sysfs_dir(cmd->sysfs_dir); /* activation? */ cmd->default_settings.activation = find_config_tree_int(cmd, --- LVM2/lib/metadata/lv_manip.c 2011/09/16 18:39:03 1.289 +++ LVM2/lib/metadata/lv_manip.c 2011/09/22 17:33:51 1.290 @@ -3099,11 +3099,8 @@ /* FIXME Ensure not referred to by another existing LVs */ if (lv_info(cmd, lv, 0, &info, 1, 0)) { - if (info.open_count) { - log_error("Can't remove open logical volume \"%s\"", - lv->name); - return 0; - } + if (!lv_check_not_in_use(cmd, lv, &info)) + return_0; if (lv_is_active(lv) && (force == PROMPT) && lv_is_visible(lv) && --- LVM2/libdm/libdm-deptree.c 2011/09/07 08:37:48 1.109 +++ LVM2/libdm/libdm-deptree.c 2011/09/22 17:33:51 1.110 @@ -940,6 +940,30 @@ return r; } +static int _check_device_not_in_use(struct dm_info *info) +{ + if (!info->exists) + return 1; + + /* If sysfs is not used, use open_count information only. */ + if (!*dm_sysfs_dir()) + return !info->open_count; + + if (dm_device_has_holders(info->major, info->minor)) { + log_error("Device %" PRIu32 ":%" PRIu32 " is used " + "by another device.", info->major, info->minor); + return 0; + } + + if (dm_device_has_mounted_fs(info->major, info->minor)) { + log_error("Device %" PRIu32 ":%" PRIu32 " contains " + "a filesystem in use.", info->major, info->minor); + return 0; + } + + return 1; +} + /* Check if all parent nodes of given node have open_count == 0 */ static int _node_has_closed_parents(struct dm_tree_node *node, const char *uuid_prefix, @@ -1184,9 +1208,11 @@ !info.exists) continue; + if (!_check_device_not_in_use(&info)) + continue; + /* Also checking open_count in parent nodes of presuspend_node */ - if (info.open_count || - (child->presuspend_node && + if ((child->presuspend_node && !_node_has_closed_parents(child->presuspend_node, uuid_prefix, uuid_prefix_len))) { /* Only report error from (likely non-internal) dependency at top level */ From prajnoha@sourceware.org Thu Sep 22 17:36:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 22 Sep 2011 17:36:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm ... Message-ID: <20110922173652.3351.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-22 17:36:51 Modified files: . : WHATS_NEW_DM libdm : libdevmapper.h libdm-deptree.c Log message: Add dm_tree_retry_remove to use retry logic for device removal in a dm_tree. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.503&r2=1.504 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.152&r2=1.153 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111 --- LVM2/WHATS_NEW_DM 2011/09/22 17:23:35 1.503 +++ LVM2/WHATS_NEW_DM 2011/09/22 17:36:50 1.504 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Add dm_tree_retry_remove to use retry logic for device removal in a dm_tree. Add dm_device_has_mounted_fs fn to check mounted filesystem on a device. Add dm_device_has_holders fn to to check use of the device by another device. Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set. --- LVM2/libdm/libdevmapper.h 2011/09/22 17:23:36 1.152 +++ LVM2/libdm/libdevmapper.h 2011/09/22 17:36:50 1.153 @@ -422,6 +422,11 @@ void dm_tree_use_no_flush_suspend(struct dm_tree_node *dnode); /* + * Retry removal of each device if not successful. + */ +void dm_tree_retry_remove(struct dm_tree_node *dnode); + +/* * Is the uuid prefix present in the tree? * Only returns 0 if every node was checked successfully. * Returns 1 if the tree walk has to be aborted. --- LVM2/libdm/libdm-deptree.c 2011/09/22 17:33:51 1.110 +++ LVM2/libdm/libdm-deptree.c 2011/09/22 17:36:50 1.111 @@ -222,7 +222,8 @@ struct dm_hash_table *uuids; struct dm_tree_node root; int skip_lockfs; /* 1 skips lockfs (for non-snapshots) */ - int no_flush; /* 1 sets noflush (mirrors/multipath) */ + int no_flush; /* 1 sets noflush (mirrors/multipath) */ + int retry_remove; /* 1 retries remove if not successful */ uint32_t cookie; }; @@ -1006,7 +1007,7 @@ } static int _deactivate_node(const char *name, uint32_t major, uint32_t minor, - uint32_t *cookie, uint16_t udev_flags) + uint32_t *cookie, uint16_t udev_flags, int retry) { struct dm_task *dmt; int r = 0; @@ -1029,6 +1030,10 @@ if (!dm_task_set_cookie(dmt, cookie, udev_flags)) goto out; + + if (retry) + dm_task_retry_remove(dmt); + r = dm_task_run(dmt); /* FIXME Until kernel returns actual name so dm-iface.c can handle it */ @@ -1231,7 +1236,8 @@ continue; if (!_deactivate_node(name, info.major, info.minor, - &child->dtree->cookie, child->udev_flags)) { + &child->dtree->cookie, child->udev_flags, + child->dtree->retry_remove)) { log_error("Unable to deactivate %s (%" PRIu32 ":%" PRIu32 ")", name, info.major, info.minor); @@ -1266,6 +1272,11 @@ dnode->dtree->no_flush = 1; } +void dm_tree_retry_remove(struct dm_tree_node *dnode) +{ + dnode->dtree->retry_remove = 1; +} + int dm_tree_suspend_children(struct dm_tree_node *dnode, const char *uuid_prefix, size_t uuid_prefix_len) From prajnoha@sourceware.org Thu Sep 22 17:39:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 22 Sep 2011 17:39:00 -0000 Subject: LVM2 ./WHATS_NEW doc/example.conf.in lib/activ ... Message-ID: <20110922173959.24717.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-22 17:39:58 Modified files: . : WHATS_NEW doc : example.conf.in lib/activate : dev_manager.c lib/commands : toolcontext.c lib/config : defaults.h lib/misc : lvm-globals.c lvm-globals.h Log message: Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2131&r2=1.2132 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.31&r2=1.32 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.231&r2=1.232 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.136&r2=1.137 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.83&r2=1.84 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.h.diff?cvsroot=lvm2&r1=1.13&r2=1.14 --- LVM2/WHATS_NEW 2011/09/22 17:33:50 1.2131 +++ LVM2/WHATS_NEW 2011/09/22 17:39:56 1.2132 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV. Replace open_count check with holders/mounted_fs check on lvremove path. Disallow the creation of mirrors (mirror or raid1 segtype) with only one leg. Cleanup restart clvmd code (no memory allocation, debug print passed args). --- LVM2/doc/example.conf.in 2011/08/12 02:16:46 1.31 +++ LVM2/doc/example.conf.in 2011/09/22 17:39:57 1.32 @@ -465,6 +465,11 @@ # Useful for diagnosing problems with LVM2/udev interactions. verify_udev_operations = 0 + # If set to 1 and if deactivation of an LV fails, perhaps because + # a process run from a quick udev rule temporarily opened the device, + # retry the operation for a few seconds before failing. + retry_deactivation = 1 + # How to fill in missing stripes if activating an incomplete volume. # Using "error" will make inaccessible parts of the device return # I/O errors on access. You can instead use a device path, in which --- LVM2/lib/activate/dev_manager.c 2011/08/30 14:55:16 1.231 +++ LVM2/lib/activate/dev_manager.c 2011/09/22 17:39:57 1.232 @@ -1782,6 +1782,8 @@ goto_out; break; case DEACTIVATE: + if (retry_deactivation()) + dm_tree_retry_remove(root); /* Deactivate LV and all devices it references that nothing else has open. */ r = dm_tree_deactivate_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1); if (!r) --- LVM2/lib/commands/toolcontext.c 2011/09/22 17:33:51 1.136 +++ LVM2/lib/commands/toolcontext.c 2011/09/22 17:39:57 1.137 @@ -303,6 +303,9 @@ "activation/udev_sync", DEFAULT_UDEV_SYNC); + init_retry_deactivation(find_config_tree_int(cmd, "activation/retry_deactivation", + DEFAULT_RETRY_DEACTIVATION)); + init_activation_checks(find_config_tree_int(cmd, "activation/checks", DEFAULT_ACTIVATION_CHECKS)); --- LVM2/lib/config/defaults.h 2011/09/09 00:54:49 1.83 +++ LVM2/lib/config/defaults.h 2011/09/22 17:39:57 1.84 @@ -81,6 +81,7 @@ #define DEFAULT_UDEV_RULES 1 #define DEFAULT_UDEV_SYNC 1 #define DEFAULT_VERIFY_UDEV_OPERATIONS 0 +#define DEFAULT_RETRY_DEACTIVATION 1 #define DEFAULT_ACTIVATION_CHECKS 0 #define DEFAULT_EXTENT_SIZE 4096 /* In KB */ #define DEFAULT_MAX_PV 0 --- LVM2/lib/misc/lvm-globals.c 2011/09/01 13:30:11 1.14 +++ LVM2/lib/misc/lvm-globals.c 2011/09/22 17:39:57 1.15 @@ -42,6 +42,7 @@ static int _error_message_produced = 0; static unsigned _is_static = 0; static int _udev_checking = 1; +static int _retry_deactivation = DEFAULT_RETRY_DEACTIVATION; static int _activation_checks = 0; static char _sysfs_dir_path[PATH_MAX] = ""; static int _dev_disable_after_error_count = DEFAULT_DISABLE_AFTER_ERROR_COUNT; @@ -134,6 +135,11 @@ log_debug("LVM udev checking disabled"); } +void init_retry_deactivation(int retry) +{ + _retry_deactivation = retry; +} + void init_activation_checks(int checks) { if ((_activation_checks = checks)) @@ -272,6 +278,11 @@ return _udev_checking; } +int retry_deactivation(void) +{ + return _retry_deactivation; +} + int activation_checks(void) { return _activation_checks; --- LVM2/lib/misc/lvm-globals.h 2011/08/11 17:46:14 1.13 +++ LVM2/lib/misc/lvm-globals.h 2011/09/22 17:39:57 1.14 @@ -42,6 +42,7 @@ void init_pv_min_size(uint64_t sectors); void init_activation_checks(int checks); void init_detect_internal_vg_cache_corruption(int detect); +void init_retry_deactivation(int retry); void set_cmd_name(const char *cmd_name); void set_sysfs_dir_path(const char *path); @@ -67,6 +68,7 @@ uint64_t pv_min_size(void); int activation_checks(void); int detect_internal_vg_cache_corruption(void); +int retry_deactivation(void); #define DMEVENTD_MONITOR_IGNORE -1 int dmeventd_monitor_mode(void); From prajnoha@sourceware.org Thu Sep 22 18:00:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 22 Sep 2011 18:00:00 -0000 Subject: LVM2/libdm/ioctl libdm-iface.c Message-ID: <20110922180000.5722.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-22 17:59:59 Modified files: libdm/ioctl : libdm-iface.c Log message: Initialize 'retryable' variable. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122 --- LVM2/libdm/ioctl/libdm-iface.c 2011/09/22 17:09:48 1.121 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/09/22 17:59:58 1.122 @@ -1689,7 +1689,7 @@ int rely_on_udev; int suspended_counter; unsigned ioctl_retry = 1; - int retryable; + int retryable = 0; if ((unsigned) dmt->type >= (sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) { From zkabelac@sourceware.org Fri Sep 23 09:48:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 23 Sep 2011 09:48:00 -0000 Subject: LVM2 ./WHATS_NEW_DM man/Makefile.in Message-ID: <20110923094822.20009.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-23 09:48:21 Modified files: . : WHATS_NEW_DM man : Makefile.in Log message: Build all man pages When running plain 'make' in man dir - do also those for device-mapper target. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.504&r2=1.505 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/Makefile.in.diff?cvsroot=lvm2&r1=1.40&r2=1.41 --- LVM2/WHATS_NEW_DM 2011/09/22 17:36:50 1.504 +++ LVM2/WHATS_NEW_DM 2011/09/23 09:48:21 1.505 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Add dependency for dm man pages to man subdirectory make target all:. Add dm_tree_retry_remove to use retry logic for device removal in a dm_tree. Add dm_device_has_mounted_fs fn to check mounted filesystem on a device. Add dm_device_has_holders fn to to check use of the device by another device. --- LVM2/man/Makefile.in 2010/07/01 10:57:03 1.40 +++ LVM2/man/Makefile.in 2011/09/23 09:48:21 1.41 @@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -60,7 +60,7 @@ install: install_cluster endif -all: man +all: man device-mapper .PHONY: man install_man5 install_man8 From zkabelac@sourceware.org Fri Sep 23 09:51:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 23 Sep 2011 09:51:00 -0000 Subject: LVM2 ./WHATS_NEW_DM man/dmsetup.8.in Message-ID: <20110923095137.20944.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-23 09:51:37 Modified files: . : WHATS_NEW_DM man : dmsetup.8.in Log message: Update dmsetup man page While dmsetup command properly shows all dmsetup resume supported options, man page missed to document it. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.505&r2=1.506 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/dmsetup.8.in.diff?cvsroot=lvm2&r1=1.43&r2=1.44 --- LVM2/WHATS_NEW_DM 2011/09/23 09:48:21 1.505 +++ LVM2/WHATS_NEW_DM 2011/09/23 09:51:37 1.506 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Update dmsetup resume man with --addnodeonresume/create options. Add dependency for dm man pages to man subdirectory make target all:. Add dm_tree_retry_remove to use retry logic for device removal in a dm_tree. Add dm_device_has_mounted_fs fn to check mounted filesystem on a device. --- LVM2/man/dmsetup.8.in 2011/09/22 17:12:28 1.43 +++ LVM2/man/dmsetup.8.in 2011/09/23 09:51:37 1.44 @@ -20,7 +20,7 @@ .I [--nolockfs] [--noflush] device_name .br .B dmsetup resume -.I device_name +.I device_name [{ --addnodeonresume | --addnodeoncreate }] .br .B dmsetup load .I device_name [--table | table_file] @@ -313,7 +313,7 @@ Sets the uuid of a device that was created without a uuid. After a uuid has been set it cannot be changed. .IP \fBresume -.I device_name +.I device_name [{ --addnodeonresume | --addnodeoncreate }] .br Un-suspends a device. If an inactive table has been loaded, it becomes live. From jbrassow@sourceware.org Fri Sep 23 15:17:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Fri, 23 Sep 2011 15:17:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv.c Message-ID: <20110923151756.19057.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-23 15:17:54 Modified files: . : WHATS_NEW lib/metadata : lv.c Log message: Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE. RAID_META is already handled. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2132&r2=1.2133 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29 --- LVM2/WHATS_NEW 2011/09/22 17:39:56 1.2132 +++ LVM2/WHATS_NEW 2011/09/23 15:17:54 1.2133 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE. Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV. Replace open_count check with holders/mounted_fs check on lvremove path. Disallow the creation of mirrors (mirror or raid1 segtype) with only one leg. --- LVM2/lib/metadata/lv.c 2011/09/14 10:03:15 1.28 +++ LVM2/lib/metadata/lv.c 2011/09/23 15:17:54 1.29 @@ -304,6 +304,48 @@ return (percent == PERCENT_100) ? 1 : 0; } +static int _lv_raid_image_in_sync(const struct logical_volume *lv) +{ + percent_t percent; + struct lv_segment *raid_seg; + + if (!(lv->status & RAID_IMAGE)) { + log_error(INTERNAL_ERROR "%s is not a RAID image", lv->name); + return 0; + } + + raid_seg = get_only_segment_using_this_lv(first_seg(lv)->lv); + if (!raid_seg) { + log_error("Failed to find RAID segment for %s", lv->name); + return 0; + } + + if (!seg_is_raid(raid_seg)) { + log_error("%s on %s is not a RAID segment", + raid_seg->lv->name, lv->name); + return 0; + } + + if (!lv_raid_percent(raid_seg->lv, &percent)) + return_0; + + if (percent == PERCENT_100) + return 1; + + /* + * FIXME: Get individual RAID image status. + * The status health characters reported from a RAID target + * indicate whether the whole array or just individual devices + * are in-sync. If the corresponding character for this image + * was 'A', we could report a more accurate status. This is + * especially so in the case of failures or rebuildings. + * + * We need to test the health characters anyway to report + * the correct 4th attr character. Just need to figure out + * where to put this functionality. + */ + return 0; +} char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv) { percent_t snap_percent; @@ -327,6 +369,8 @@ /* Origin takes precedence over mirror and thin volume */ else if (lv_is_origin(lv)) repstr[0] = (lv_is_merging_origin(lv)) ? 'O' : 'o'; + else if (lv->status & RAID) + repstr[0] = (lv->status & LV_NOTSYNCED) ? 'R' : 'r'; else if (lv->status & MIRRORED) repstr[0] = (lv->status & LV_NOTSYNCED) ? 'M' : 'm'; else if (lv_is_thin_volume(lv)) @@ -341,6 +385,8 @@ repstr[0] = 'e'; else if (lv->status & MIRROR_IMAGE) repstr[0] = (_lv_mimage_in_sync(lv)) ? 'i' : 'I'; + else if (lv->status & RAID_IMAGE) + repstr[0] = (_lv_raid_image_in_sync(lv)) ? 'i' : 'I'; else if (lv->status & MIRROR_LOG) repstr[0] = 'l'; else if (lv_is_cow(lv)) { From jbrassow@sourceware.org Fri Sep 23 17:04:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Fri, 23 Sep 2011 17:04:00 -0000 Subject: LVM2/doc lvm2-raid.txt Message-ID: <20110923170443.16620.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-23 17:04:42 Modified files: doc : lvm2-raid.txt Log message: Update the RAID design doc to reflect some of the new options introduce (e.g. --merge and --trackchanges) and document the coding steps of up/down-conversion, splitting RAID1 images, and merging RAID1 images. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/lvm2-raid.txt.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/doc/lvm2-raid.txt 2011/07/14 17:00:59 1.1 +++ LVM2/doc/lvm2-raid.txt 2011/09/23 17:04:41 1.2 @@ -38,9 +38,10 @@ "raid6_nc" - RAID6 Rotating parity N with data continuation The exception to 'no shorthand options' will be where the RAID implementations can displace traditional tagets. This is the case with 'mirror' and 'raid1'. -In these cases, a switch will exist in lvm.conf allowing the user to specify -which implementation they want. When this is in place, the segment type is -inferred from the argument, '-m' for example. +In this case, "mirror_segtype_default" - found under the "global" section in +lvm.conf - can be set to "mirror" or "raid1". The segment type inferred when +the '-m' option is used will be taken from this setting. The default segment +types can be overridden on the command line by using the '--type' argument. Line 02: Region size is relevant for all RAID types. It defines the granularity for @@ -91,14 +92,15 @@ 02: [-R/--regionsize ] \ 03: [-i/--stripes <#>] [-I,--stripesize ] \ 04: [-m/--mirrors <#>] \ -05: [--splitmirrors <#>] \ -06: [--replace ] \ -07: [--[min|max]recoveryrate ] \ -08: [--stripecache ] \ -09: [--writemostly ] \ -10: [--maxwritebehind ] \ -11: vg/lv -12: [devices] +05: [--merge] +06: [--splitmirrors <#> [--trackchanges]] \ +07: [--replace ] \ +08: [--[min|max]recoveryrate ] \ +09: [--stripecache ] \ +10: [--writemostly ] \ +11: [--maxwritebehind ] \ +12: vg/lv +13: [devices] lvconvert should work exactly as it does now when dealing with mirrors - even if(when) we switch to MD RAID1. Of course, there are no plans to @@ -115,28 +117,46 @@ a RAID device of a different type. For example, you could change from RAID4 to RAID5 or RAID5 to RAID6. -Line 02/03/04/05: +Line 02/03/04: These are familiar options - all of which would now be available as options for change. (However, it'd be nice if we didn't have regionsize in there. It's simple on the kernel side, but is just an extra - often unecessary - parameter to many functions in the LVM codebase.) +Line 05: +This option is used to merge an LV back into a RAID1 array - provided it was +split for temporary read-only use by '--splitmirrors 1 --trackchanges'. + Line 06: +The '--splitmirrors <#>' argument should be familiar from the "mirror" segment +type. It allows RAID1 images to be split from the array to form a new LV. +Either the original LV or the split LV - or both - could become a linear LV as +a result. If the '--trackchanges' argument is specified in addition to +'--splitmirrors', an LV will be split from the array. It will be read-only. +This operation does not change the original array - except that it uses an empty +slot to hold the position of the split LV which it expects to return in the +future (see the '--merge' argument). It tracks any changes that occur to the +array while the slot is kept in reserve. If the LV is merged back into the +array, only the changes are resync'ed to the returning image. Repeating the +'lvconvert' operation without the '--trackchanges' option will complete the +split of the LV permanently. + +Line 07: This option allows the user to specify a sub_lv (e.g. a mirror image) or a particular device for replacement. The device (or all the devices in the sub_lv) will be removed and replaced with different devices from the VG. -Line 07/08/09/10: +Line 08/09/10/11: It should be possible to alter these parameters of a RAID device. As with lvcreate, however, I'm not entirely certain how to best define some of these. We don't need all the capabilities at once though, so it isn't a pressing issue. -Line 11: +Line 12: The LV to operate on. -Line 12: +Line 13: Devices that are to be used to satisfy the conversion request. If the operation removes devices or splits a mirror, then the devices specified form the list of candidates for removal. If the operation adds or replaces @@ -173,7 +193,7 @@ | [foo_rmeta_1's lv_segment] LVM Meta-data format --------------------- +==================== The RAID format will need to be able to store parameters that are unique to RAID and unique to specific RAID sub-devices. It will be modeled after that of mirroring. @@ -238,8 +258,13 @@ array as a whole. In these cases, the status field of the sub-lv's themselves will hold these flags - the meaning being only useful in the larger context. + +############################################## +# Chapter 3: LVM RAID implementation details # +############################################## + New Segment Type(s) -------------------- +=================== I've created a new file 'lib/raid/raid.c' that will handle the various different RAID types. While there will be a unique segment type for each RAID variant, they will all share a common backend - segtype_handler functions and @@ -262,7 +287,7 @@ should not affect the way size is calculated via the area_multiple. Allocation ----------- +========== When a RAID device is created, metadata LVs must be created along with the data LVs that will ultimately compose the top-level RAID array. For the foreseeable future, the metadata LVs must reside on the same device as (or @@ -287,8 +312,8 @@ 1) how many parity devices are required and 2) does an allocated area need to be split out for the metadata LVs after finding the space to fill the request. We simply add these two fields to the 'alloc_handle' data structure as, -'parity_count' and 'alloc_and_split_meta'. These two fields get set simply -in '_alloc_init'. The 'segtype->parity_devs' holds the number of parity +'parity_count' and 'alloc_and_split_meta'. These two fields get set in +'_alloc_init'. The 'segtype->parity_devs' holds the number of parity drives and can be directly copied to 'ah->parity_count' and 'alloc_and_split_meta' is set when a RAID segtype is detected and 'metadata_area_count' has been specified. With these two variables set, we @@ -296,3 +321,86 @@ find the actual space, they stop not when they have found ah->area_count but when they have found (ah->area_count + ah->parity_count). +Conversion +========== +RAID -> RAID, adding images +--------------------------- +When adding images to a RAID array, metadata and data components must be added +as a pair. It is best to perform as many operations as possible before writing +new LVM metadata. This allows us to error-out without having to unwind any +changes. It also makes things easier if the machine should crash during a +conversion operation. Thus, the actions performed when adding a new image are: + 1) Allocate the required number of metadata/data pairs using the method + describe above in 'Allocation' (i.e. find the metadata/data space + as one unit and split the space between them after found - this keeps + them together on the same device). + 2) Form the metadata/data LVs from the allocated space (leave them + visible) - setting required RAID_[IMAGE | META] flags as appropriate. + 3) Write the LVM metadata + 4) Activate and clear the metadata LVs. The clearing of the metadata + requires the LVM metadata be written (step 3) and is a requirement + before adding the new metadata LVs to the array. If the metadata + is not cleared, it carry residual superblock state from a previous + array the device may have been part of. + 5) Deactivate new sub-LVs and set them "hidden". + 6) expand the 'first_seg(raid_lv)->areas' and '->meta_areas' array + for inclusion of the new sub-LVs + 7) Add new sub-LVs and update 'first_seg(raid_lv)->area_count' + 8) Commit new LVM metadata +Failure during any of these steps will not affect the original RAID array. In +the worst scenario, the user may have to remove the new sub-LVs that did not +yet make it into the array. + +RAID -> RAID, removing images +----------------------------- +To remove images from a RAID, the metadata/data LV pairs must be removed +together. This is pretty straight-forward, but one place where RAID really +differs from the "mirror" segment type is how the resulting "holes" are filled. +When a device is removed from a "mirror" segment type, it is identified, moved +to the end of the 'mirrored_seg->areas' array, and then removed. This action +causes the other images to shift down and fill the position of the device which +was removed. While "raid1" could be handled in this way, the other RAID types +could not be - it would corrupt the ordering of the data on the array. Thus, +when a device is removed from a RAID array, the corresponding metadata/data +sub-LVs are removed from the 'raid_seg->meta_areas' and 'raid_seg->areas' arrays. +The slot in these 'lv_segment_area' arrays are set to 'AREA_UNASSIGNED'. RAID +is perfectly happy to construct a DM table mapping with '- -' if it comes across +area assigned in such a way. The pair of dashes is a valid way to tell the RAID +kernel target that the slot should be considered empty. So, we can remove +devices from a RAID array without affecting the correct operation of the RAID. +(It also becomes easy to replace the empty slots properly if a spare device is +available.) In the case of RAID1 device removal, the empty slot can be safely +eliminated. This is done by shifting the higher indexed devices down to fill +the slot. Even the names of the images will be renamed to properly reflect +their index in the array. Unlike the "mirror" segment type, you will never have +an image named "*_rimage_1" occupying the index position 0. + +As with adding images, removing images holds off on commiting LVM metadata +until all possible changes have been made. This reduces the likelyhood of bad +intermediate stages being left due to a failure of operation or machine crash. + +RAID1 '--splitmirrors', '--trackchanges', and '--merge' operations +----------------------------------------------------------------- +This suite of operations is only available to the "raid1" segment type. + +Splitting an image from a RAID1 array is almost identical to the removal of +an image described above. However, the metadata LV associated with the split +image is removed and the data LV is kept and promoted to a top-level device. +(i.e. It is made visible and stripped of its RAID_IMAGE status flags.) + +When the '--trackchanges' option is given along with the '--splitmirrors' +argument, the metadata LV is left as part of the original array. The data LV +is set as 'VISIBLE' and read-only (~LVM_WRITE). When the array DM table is +being created, it notices the read-only, VISIBLE nature of the sub-LV and puts +in the '- -' sentinel. Only a single image can be split from the mirror and +the name of the sub-LV cannot be changed. Unlike '--splitmirrors' on its own, +the '--name' argument must not be specified. Therefore, the name of the newly +split LV will remain the same '_rimage_', where 'N' is the index of the +slot in the array for which it is associated. + +When an LV which was split from a RAID1 array with the '--trackchanges' option +is merged back into the array, its read/write status is restored and it is +set as "hidden" again. Recycling the array (suspend/resume) restores the sub-LV +to its position in the array and begins the process of sync'ing the changes that +were made since the time it was split from the array. + From agk@sourceware.org Fri Sep 23 17:05:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 23 Sep 2011 17:05:00 -0000 Subject: LVM2/man Makefile.in Message-ID: <20110923170544.16915.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-23 17:05:44 Modified files: man : Makefile.in Log message: missing Makefile dep Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/Makefile.in.diff?cvsroot=lvm2&r1=1.41&r2=1.42 --- LVM2/man/Makefile.in 2011/09/23 09:48:21 1.41 +++ LVM2/man/Makefile.in 2011/09/23 17:05:44 1.42 @@ -68,7 +68,7 @@ man: $(MAN5) $(MAN8) $(MAN8CLUSTER) -$(MAN5) $(MAN8) $(MAN8CLUSTER): Makefile +$(MAN5) $(MAN8) $(MAN8DM) $(MAN8CLUSTER): Makefile %: %.in @case "$@" in \ From agk@sourceware.org Fri Sep 23 17:16:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 23 Sep 2011 17:16:00 -0000 Subject: LVM2/libdm/ioctl libdm-iface.c Message-ID: <20110923171629.21970.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-23 17:16:28 Modified files: libdm/ioctl : libdm-iface.c Log message: explain why we may now retry Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123 --- LVM2/libdm/ioctl/libdm-iface.c 2011/09/22 17:59:58 1.122 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/09/23 17:16:28 1.123 @@ -1654,6 +1654,11 @@ _cmd_data_v4[dmt->type].name, strerror(errno)); + /* + * It's sometimes worth retrying after EBUSY in case + * it's a transient failure caused by an asynchronous + * process quickly scanning the device. + */ *retryable = errno == EBUSY; _dm_zfree_dmi(dmi); @@ -1739,6 +1744,12 @@ repeat_ioctl: if (!(dmi = _do_dm_ioctl(dmt, command, _ioctl_buffer_double_factor, ioctl_retry, &retryable))) { + /* + * Async udev rules that scan devices commonly cause transient + * failures. Normally you'd expect the user to have made sure + * nothing was using the device before issuing REMOVE, so it's + * worth retrying in case the failure is indeed transient. + */ if (retryable && dmt->type == DM_DEVICE_REMOVE && dmt->retry_remove && ++ioctl_retry <= DM_IOCTL_RETRIES) { usleep(DM_RETRY_USLEEP_DELAY); From jbrassow@sourceware.org Fri Sep 23 19:21:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Fri, 23 Sep 2011 19:21:00 -0000 Subject: LVM2/man lvs.8.in Message-ID: <20110923192153.18763.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-23 19:21:53 Modified files: man : lvs.8.in Log message: update man page for new RAID lv_attr characters. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvs.8.in.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/man/lvs.8.in 2011/09/09 01:15:18 1.16 +++ LVM2/man/lvs.8.in 2011/09/23 19:21:53 1.17 @@ -69,10 +69,11 @@ .RS .IP 1 3 Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, -(O)rigin with merging snapshot, (s)napshot, merging (S)napshot, (p)vmove, -(v)irtual, mirror (i)mage, mirror (I)mage out-of-sync, mirror (l)og device, -under (c)onversion, thin (V)olume, (t)hin pool, (T)hin pool data, thin pool -m(e)tadata +(O)rigin with merging snapshot, (r)aid, (R)aid without initial sync, +(s)napshot, merging (S)napshot, (p)vmove, (v)irtual, +mirror or raid (i)mage, mirror or raid (I)mage out-of-sync, mirror (l)og device, +under (c)onversion, thin (V)olume, (t)hin pool, (T)hin pool data, raid or +thin pool m(e)tadata .IP 2 3 Permissions: (w)riteable, (r)ead-only .IP 3 3 From prajnoha@sourceware.org Sat Sep 24 11:47:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Sat, 24 Sep 2011 11:47:00 -0000 Subject: LVM2/libdm libdm-common.c Message-ID: <20110924114754.22576.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-24 11:47:53 Modified files: libdm : libdm-common.c Log message: readlink does not append a null byte to the output string! Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127 --- LVM2/libdm/libdm-common.c 2011/09/22 17:23:36 1.126 +++ LVM2/libdm/libdm-common.c 2011/09/24 11:47:53 1.127 @@ -1145,6 +1145,7 @@ log_sys_error("readlink", sysfs_path); return 0; } + temp_path[size] = '\0'; if (!(kernel_dev_name = strrchr(temp_path, '/'))) { log_error("Could not locate device kernel name in sysfs path %s", temp_path); From zkabelac@sourceware.org Sat Sep 24 20:48:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 24 Sep 2011 20:48:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons ... Message-ID: <20110924204835.29357.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 20:48:34 Modified files: . : WHATS_NEW daemons/clvmd : clvmd.c lvm-functions.c lvm-functions.h man : clvmd.8.in Log message: CLVMD bugfix support for args -S -E Bugfix: Add (most probably unfinished) support for -E arg with list of exclusive locks. (During clvmd restart all exclusive locks would have been lost and in fact, if there would have been an exclusive lock, usage text would be printed and clvmd exits.) Instead of parsing list options multiple times every time some lock UUID is checked - put them straight into the hash table - make the code easier to understand as well. Remove was_ex_lock() function (replaced with dm_hash_lookup()). Swap return value for get_initial_state() (1 means success). Update man pages and usage info for -E option. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2133&r2=1.2134 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.h.diff?cvsroot=lvm2&r1=1.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/clvmd.8.in.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/WHATS_NEW 2011/09/23 15:17:54 1.2133 +++ LVM2/WHATS_NEW 2011/09/24 20:48:34 1.2134 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix restart of clvmd (preserve exlusive locks). (2.02.64) Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE. Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV. Replace open_count check with holders/mounted_fs check on lvremove path. --- LVM2/daemons/clvmd/clvmd.c 2011/09/16 14:40:07 1.109 +++ LVM2/daemons/clvmd/clvmd.c 2011/09/24 20:48:34 1.110 @@ -78,7 +78,7 @@ }; struct lvm_startup_params { - char **argv; + struct dm_hash_table *excl_uuid; }; static debug_t debug = DEBUG_OFF; @@ -149,6 +149,7 @@ " -h Show this help information\n" " -d[n] Set debug logging (0:none, 1:stderr (implies -f option), 2:syslog)\n" " -f Don't fork, run in the foreground\n" + " -E Take this lock uuid as exclusively locked resource (for restart)\n" " -R Tell all running clvmds in the cluster to reload their device cache\n" " -S Restart clvmd, preserving exclusive locks\n" " -C Sets debug level (from -d) on all clvmd instances clusterwide\n" @@ -348,6 +349,11 @@ { NULL, 0, 0, 0 } }; + if (!(lvm_params.excl_uuid = dm_hash_create(128))) { + fprintf(stderr, "Failed to allocate hash table\n"); + return 1; + } + /* Deal with command-line arguments */ opterr = 0; optind = 0; @@ -391,6 +397,12 @@ case 'I': cluster_iface = parse_cluster_interface(optarg); break; + case 'E': + if (!dm_hash_insert(lvm_params.excl_uuid, optarg, optarg)) { + fprintf(stderr, "Failed to allocate hash entry\n"); + return 1; + } + break; case 'T': start_timeout = atoi(optarg); if (start_timeout <= 0) { @@ -565,7 +577,6 @@ /* Don't let anyone else to do work until we are started */ pthread_mutex_lock(&lvm_start_mutex); - lvm_params.argv = argv; pthread_create(&lvm_thread, NULL, lvm_thread_fn, &lvm_params); /* Tell the rest of the cluster our version number */ @@ -603,6 +614,8 @@ free(delfd); } + dm_hash_destroy(lvm_params.excl_uuid); + return 0; } @@ -1978,7 +1991,7 @@ pthread_sigmask(SIG_BLOCK, &ss, NULL); /* Initialise the interface to liblvm */ - init_clvm(lvm_params->argv); + init_clvm(lvm_params->excl_uuid); /* Allow others to get moving */ pthread_mutex_unlock(&lvm_start_mutex); --- LVM2/daemons/clvmd/lvm-functions.c 2011/08/10 20:25:29 1.122 +++ LVM2/daemons/clvmd/lvm-functions.c 2011/09/24 20:48:34 1.123 @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -694,34 +694,11 @@ } /* - * Compare the uuid with the list of exclusive locks that clvmd - * held before it was restarted, so we can get the right kind - * of lock now we are restarting. - */ -static int was_ex_lock(char *uuid, char **argv) -{ - int optnum = 0; - char *opt = argv[optnum]; - - while (opt) { - if (strcmp(opt, "-E") == 0) { - opt = argv[++optnum]; - if (opt && (strcmp(opt, uuid) == 0)) { - DEBUGLOG("Lock %s is exclusive\n", uuid); - return 1; - } - } - opt = argv[++optnum]; - } - return 0; -} - -/* * Ideally, clvmd should be started before any LVs are active * but this may not be the case... * I suppose this also comes in handy if clvmd crashes, not that it would! */ -static int get_initial_state(char **argv) +static int get_initial_state(struct dm_hash_table *excl_uuid) { int lock_mode; char lv[64], vg[64], flags[25], vg_flags[25]; @@ -733,7 +710,7 @@ "r"); if (!lvs) - return 1; + return 0; while (fgets(line, sizeof(line), lvs)) { if (sscanf(line, "%s %s %s %s\n", vg, lv, flags, vg_flags) == 4) { @@ -759,12 +736,10 @@ memcpy(&uuid[58], &lv[32], 6); uuid[64] = '\0'; - lock_mode = LCK_READ; - /* Look for this lock in the list of EX locks we were passed on the command-line */ - if (was_ex_lock(uuid, argv)) - lock_mode = LCK_EXCL; + lock_mode = (dm_hash_lookup(excl_uuid, uuid)) ? + LCK_EXCL : LCK_READ; DEBUGLOG("getting initial lock for %s\n", uuid); hold_lock(uuid, lock_mode, LCKF_NOQUEUE); @@ -773,7 +748,8 @@ } if (fclose(lvs)) DEBUGLOG("lvs fclose failed: %s\n", strerror(errno)); - return 0; + + return 1; } static void lvm2_log_fn(int level, const char *file, int line, int dm_errno, @@ -880,14 +856,14 @@ } /* Called to initialise the LVM context of the daemon */ -int init_clvm(char **argv) +int init_clvm(struct dm_hash_table *excl_uuid) { /* Use LOG_DAEMON for syslog messages instead of LOG_USER */ init_syslog(LOG_DAEMON); openlog("clvmd", LOG_PID, LOG_DAEMON); /* Initialise already held locks */ - if (get_initial_state(argv)) + if (!get_initial_state(excl_uuid)) log_error("Cannot load initial lock states."); if (!(cmd = create_toolcontext(1, NULL, 0))) { --- LVM2/daemons/clvmd/lvm-functions.h 2011/08/09 18:11:00 1.16 +++ LVM2/daemons/clvmd/lvm-functions.h 2011/09/24 20:48:34 1.17 @@ -27,7 +27,7 @@ char *resource); extern int do_check_lvm1(const char *vgname); extern int do_refresh_cache(void); -extern int init_clvm(char **argv); +extern int init_clvm(struct dm_hash_table *excl_uuid); extern void destroy_lvm(void); extern void init_lvhash(void); extern void destroy_lvhash(void); --- LVM2/man/clvmd.8.in 2011/08/09 18:11:00 1.6 +++ LVM2/man/clvmd.8.in 2011/09/24 20:48:34 1.7 @@ -4,6 +4,7 @@ .SH SYNOPSIS .B clvmd [\-d[]] [\-C] [\-h] +[\-E ] [\-R] [\-S] [\-t ] @@ -69,6 +70,9 @@ .br This timeout will be ignored if you start clvmd with the -d switch. .TP +.I \-E +Pass lock uuid to be reacquired exclusively when clvmd is restarted. +.TP .I \-R Tells all the running clvmds in the cluster to reload their device cache and re-read the lvm configuration file. This command should be run whenever the From zkabelac@sourceware.org Sat Sep 24 20:50:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 24 Sep 2011 20:50:00 -0000 Subject: LVM2 ./WHATS_NEW ./configure ./configure.in da ... Message-ID: <20110924205037.29958.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 20:50:36 Modified files: . : WHATS_NEW configure configure.in daemons/clvmd : clvmd-command.c lvm-functions.c man : Makefile.in clvmd.8.in Log message: CLVMD support for LVM_CLVMD_BINARY and LVM_BINARY Read 2 environmental vars to learn about overide position for CLVMD and LVM binaries. We support LVM_BINARY in other script - and this way we could easily test restart in our test-suite. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2134&r2=1.2135 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.157&r2=1.158 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.171&r2=1.172 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.123&r2=1.124 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/Makefile.in.diff?cvsroot=lvm2&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/clvmd.8.in.diff?cvsroot=lvm2&r1=1.7&r2=1.8 --- LVM2/WHATS_NEW 2011/09/24 20:48:34 1.2134 +++ LVM2/WHATS_NEW 2011/09/24 20:50:35 1.2135 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Support env vars LVM_CLVMD_BINARY and LVM_BINARY in clvmd. Fix restart of clvmd (preserve exlusive locks). (2.02.64) Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE. Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV. --- LVM2/configure 2011/08/31 11:39:32 1.157 +++ LVM2/configure 2011/09/24 20:50:35 1.158 @@ -626,6 +626,7 @@ MIRRORS LVM_RELEASE_DATE LVM_RELEASE +LVM_PATH LVM_PATCHLEVEL LVM_MINOR LVM_MAJOR @@ -664,6 +665,7 @@ COPTIMISE_FLAG CONFDIR CMDLIB +CLVMD_PATH CLVMD_CMANAGERS CLVMD CLUSTER @@ -9913,18 +9915,20 @@ lvm_exec_prefix=$exec_prefix test "$lvm_exec_prefix" = NONE && lvm_exec_prefix=$prefix test "$lvm_exec_prefix" = NONE && lvm_exec_prefix=$ac_default_prefix +LVM_PATH="$lvm_exec_prefix/sbin/lvm" cat >>confdefs.h <<_ACEOF -#define LVM_PATH "$lvm_exec_prefix/sbin/lvm" +#define LVM_PATH "$LVM_PATH" _ACEOF if test "$CLVMD" != none; then clvmd_prefix=$ac_default_prefix + CLVMD_PATH="$clvmd_prefix/sbin/clvmd" test "$prefix" != NONE && clvmd_prefix=$prefix cat >>confdefs.h <<_ACEOF -#define CLVMD_PATH "$clvmd_prefix/sbin/clvmd" +#define CLVMD_PATH "$CLVMD_PATH" _ACEOF fi @@ -10205,6 +10209,8 @@ + + ################################################################################ ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/lvmetad/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile" --- LVM2/configure.in 2011/08/31 11:31:57 1.171 +++ LVM2/configure.in 2011/09/24 20:50:36 1.172 @@ -1180,13 +1180,14 @@ lvm_exec_prefix=$exec_prefix test "$lvm_exec_prefix" = NONE && lvm_exec_prefix=$prefix test "$lvm_exec_prefix" = NONE && lvm_exec_prefix=$ac_default_prefix -AC_DEFINE_UNQUOTED(LVM_PATH, ["$lvm_exec_prefix/sbin/lvm"], [Path to lvm binary.]) +LVM_PATH="$lvm_exec_prefix/sbin/lvm" +AC_DEFINE_UNQUOTED(LVM_PATH, ["$LVM_PATH"], [Path to lvm binary.]) if test "$CLVMD" != none; then clvmd_prefix=$ac_default_prefix + CLVMD_PATH="$clvmd_prefix/sbin/clvmd" test "$prefix" != NONE && clvmd_prefix=$prefix - AC_DEFINE_UNQUOTED(CLVMD_PATH, ["$clvmd_prefix/sbin/clvmd"], - [Path to clvmd binary.]) + AC_DEFINE_UNQUOTED(CLVMD_PATH, ["$CLVMD_PATH"], [Path to clvmd binary.]) fi ################################################################################ @@ -1309,6 +1310,7 @@ AC_SUBST(CLUSTER) AC_SUBST(CLVMD) AC_SUBST(CLVMD_CMANAGERS) +AC_SUBST(CLVMD_PATH) AC_SUBST(CMAN_CFLAGS) AC_SUBST(CMAN_LIBS) AC_SUBST(CMDLIB) @@ -1357,6 +1359,7 @@ AC_SUBST(LVM_MAJOR) AC_SUBST(LVM_MINOR) AC_SUBST(LVM_PATCHLEVEL) +AC_SUBST(LVM_PATH) AC_SUBST(LVM_RELEASE) AC_SUBST(LVM_RELEASE_DATE) AC_SUBST(MIRRORS) --- LVM2/daemons/clvmd/clvmd-command.c 2011/09/22 09:47:34 1.58 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/09/24 20:50:36 1.59 @@ -366,6 +366,7 @@ int argc = 0, max_locks = 0; struct dm_hash_node *hn = NULL; char debug_arg[16]; + const char *clvmd = getenv("LVM_CLVMD_BINARY") ? : CLVMD_PATH; DEBUGLOG("clvmd restart requested\n"); @@ -415,11 +416,11 @@ argv[argc] = NULL; /* Exec new clvmd */ - DEBUGLOG("--- Restarting %s ---\n", CLVMD_PATH); + DEBUGLOG("--- Restarting %s ---\n", clvmd); for (argc = 1; argv[argc]; argc++) DEBUGLOG("--- %d: %s\n", argc, argv[argc]); /* NOTE: This will fail when downgrading! */ - execve(CLVMD_PATH, (char **)argv, NULL); + execve(clvmd, (char **)argv, NULL); out: /* We failed */ DEBUGLOG("Restart of clvmd failed.\n"); --- LVM2/daemons/clvmd/lvm-functions.c 2011/09/24 20:48:34 1.123 +++ LVM2/daemons/clvmd/lvm-functions.c 2011/09/24 20:50:36 1.124 @@ -704,13 +704,20 @@ char lv[64], vg[64], flags[25], vg_flags[25]; char uuid[65]; char line[255]; - FILE *lvs = - popen - (LVM_PATH " lvs --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr", - "r"); + char *lvs_cmd; + const char *lvm_binary = getenv("LVM_BINARY") ? : LVM_PATH; + FILE *lvs; + + if (dm_asprintf(&lvs_cmd, "%s lvs --config 'log{command_names=0 prefix=\"\"}' " + "--nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr", + lvm_binary) < 0) + return 0; - if (!lvs) + /* FIXME: Maybe link and use liblvm2cmd directly instead of fork */ + if (!(lvs = popen(lvs_cmd, "r"))) { + dm_free(lvs_cmd); return 0; + } while (fgets(line, sizeof(line), lvs)) { if (sscanf(line, "%s %s %s %s\n", vg, lv, flags, vg_flags) == 4) { @@ -749,6 +756,8 @@ if (fclose(lvs)) DEBUGLOG("lvs fclose failed: %s\n", strerror(errno)); + dm_free(lvs_cmd); + return 1; } --- LVM2/man/Makefile.in 2011/09/23 17:05:44 1.42 +++ LVM2/man/Makefile.in 2011/09/24 20:50:36 1.43 @@ -73,7 +73,7 @@ %: %.in @case "$@" in \ */*) ;; \ - *) echo "Creating $@" ; $(SED) -e "s+#VERSION#+$(LVM_VERSION)+;s+#DEFAULT_SYS_DIR#+$(DEFAULT_SYS_DIR)+;s+#DEFAULT_ARCHIVE_DIR#+$(DEFAULT_ARCHIVE_DIR)+;s+#DEFAULT_BACKUP_DIR#+$(DEFAULT_BACKUP_DIR)+;s+#DEFAULT_CACHE_DIR#+$(DEFAULT_CACHE_DIR)+;s+#DEFAULT_LOCK_DIR#+$(DEFAULT_LOCK_DIR)+" $< > $@ ;; \ + *) echo "Creating $@" ; $(SED) -e "s+#VERSION#+$(LVM_VERSION)+;s+#DEFAULT_SYS_DIR#+$(DEFAULT_SYS_DIR)+;s+#DEFAULT_ARCHIVE_DIR#+$(DEFAULT_ARCHIVE_DIR)+;s+#DEFAULT_BACKUP_DIR#+$(DEFAULT_BACKUP_DIR)+;s+#DEFAULT_CACHE_DIR#+$(DEFAULT_CACHE_DIR)+;s+#DEFAULT_LOCK_DIR#+$(DEFAULT_LOCK_DIR)+;s+#CLVMD_PATH#+@CLVMD_PATH@+;s+#LVM_PATH#+@LVM_PATH@+;" $< > $@ ;; \ esac install_man5: $(MAN5) --- LVM2/man/clvmd.8.in 2011/09/24 20:48:34 1.7 +++ LVM2/man/clvmd.8.in 2011/09/24 20:50:36 1.8 @@ -95,5 +95,15 @@ .TP .I \-V Display the version of the cluster LVM daemon. + +.SH ENVIRONMENT VARIABLES +.TP +.B LVM_CLVMD_BINARY +The CLVMD binary to use when clmvd restart is requested. +Defaults to #CLVMD_PATH#. +.TP +.B LVM_BINARY +The LVM2 binary to use. Defaults to #LVM_PATH#. + .SH SEE ALSO .BR lvm (8) From zkabelac@sourceware.org Sat Sep 24 20:54:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 24 Sep 2011 20:54:00 -0000 Subject: LVM2/test t-000-basic.sh lib/aux.sh lib/test.sh Message-ID: <20110924205436.30741.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 20:54:36 Modified files: test : t-000-basic.sh test/lib : aux.sh test.sh Log message: Detect unusable nodes on fs Test whether nodes could be used on given filesystem where TMP dir is being used and skip teardown quicker in fail case. (makes the problem quickly obvious if you try to such fs). Skip teardown_dev if we have not created any devs yet. and do not mkdir /dev/mapper dir when LVM_TEST_DEVDIR is set. Drop this test from t-000-basic.sh. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-000-basic.sh.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/test.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/test/t-000-basic.sh 2011/01/05 00:16:20 1.11 +++ LVM2/test/t-000-basic.sh 2011/09/24 20:54:35 1.12 @@ -1,4 +1,4 @@ -# Copyright (C) 2009 Red Hat, Inc. All rights reserved. +# Copyright (C) 2009-2011 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -20,11 +20,6 @@ # ensure they are the same diff -u actual expected -mknod $DM_DEV_DIR/null c 1 3 || \ - error "Can't create nodes on filesystem" -echo >$DM_DEV_DIR/null || \ - error "Filesystem for tests does not allow using device nodes (check nodev)" - # ensure we can create devices (uses dmsetup, etc) aux prepare_devs 5 --- LVM2/test/lib/aux.sh 2011/08/31 11:31:58 1.29 +++ LVM2/test/lib/aux.sh 2011/09/24 20:54:36 1.30 @@ -164,7 +164,7 @@ echo -n . - teardown_devs + test -d $DM_DEV_DIR/mapper && teardown_devs echo -n . --- LVM2/test/lib/test.sh 2011/08/31 12:42:55 1.6 +++ LVM2/test/lib/test.sh 2011/09/24 20:54:36 1.7 @@ -34,10 +34,15 @@ export LVM_SYSTEM_DIR=$TESTDIR/etc DM_DEV_DIR=$TESTDIR/dev -test -n "$LVM_TEST_DEVDIR" && DM_DEV_DIR="$LVM_TEST_DEVDIR" +mkdir $LVM_SYSTEM_DIR $TESTDIR/lib $DM_DEV_DIR +if test -n "$LVM_TEST_DEVDIR" ; then + DM_DEV_DIR="$LVM_TEST_DEVDIR" +else + mknod $DM_DEV_DIR/testnull c 1 3 || exit 1; + echo >$DM_DEV_DIR/testnull || { echo "Filesystem does support devices in $DM_DEV_DIR (mounted with nodev?)"; exit 1; } + mkdir -p $DM_DEV_DIR/mapper +fi export DM_DEV_DIR -mkdir $LVM_SYSTEM_DIR $TESTDIR/lib -mkdir -p $DM_DEV_DIR $DM_DEV_DIR/mapper cd $TESTDIR From zkabelac@sourceware.org Sat Sep 24 20:57:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 24 Sep 2011 20:57:00 -0000 Subject: LVM2 ./configure ./configure.in daemons/Makefi ... Message-ID: <20110924205750.32303.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 20:57:49 Modified files: . : configure configure.in daemons : Makefile.in daemons/lvmetad: Makefile.in Added files: daemons/common : Makefile.in Log message: Use Makefile for daemmons/common library. Next iteration for better fit of lvmetad compilation. Move build of libdaemon.a into common subdir Makefile. libdaemon.a is device-mapper target. Build and install lvmetad as lvm2 target. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.158&r2=1.159 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.172&r2=1.173 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/Makefile.in.diff?cvsroot=lvm2&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/Makefile.in.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/Makefile.in.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/configure 2011/09/24 20:50:35 1.158 +++ LVM2/configure 2011/09/24 20:57:49 1.159 @@ -10212,7 +10212,7 @@ ################################################################################ -ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/lvmetad/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile" +ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/common/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/lvmetad/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -10906,6 +10906,7 @@ "daemons/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/Makefile" ;; "daemons/clvmd/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/clvmd/Makefile" ;; "daemons/cmirrord/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/cmirrord/Makefile" ;; + "daemons/common/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/common/Makefile" ;; "daemons/dmeventd/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/dmeventd/Makefile" ;; "daemons/dmeventd/libdevmapper-event.pc") CONFIG_FILES="$CONFIG_FILES daemons/dmeventd/libdevmapper-event.pc" ;; "daemons/dmeventd/plugins/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/dmeventd/plugins/Makefile" ;; --- LVM2/configure.in 2011/09/24 20:50:36 1.172 +++ LVM2/configure.in 2011/09/24 20:57:49 1.173 @@ -1410,6 +1410,7 @@ daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile +daemons/common/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile --- LVM2/daemons/Makefile.in 2011/09/19 00:29:11 1.21 +++ LVM2/daemons/Makefile.in 2011/09/24 20:57:49 1.22 @@ -16,13 +16,10 @@ top_builddir = @top_builddir@ ifeq ("@BUILD_LVMETAD@", "yes") - SUBDIRS += lvmetad - -LIB_STATIC = libdaemon.a -SOURCES = common/daemon-shared.c common/daemon-server.c common/daemon-client.c + SUBDIRS += common lvmetad endif -.PHONY: dmeventd clvmd cmirrord lvmetad +.PHONY: dmeventd clvmd common cmirrord lvmetad ifneq ("@CLVMD@", "none") SUBDIRS += clvmd @@ -40,7 +37,7 @@ endif ifeq ($(MAKECMDGOALS),distclean) - SUBDIRS = clvmd cmirrord dmeventd lvmetad + SUBDIRS = clvmd cmirrord common dmeventd lvmetad endif include $(top_builddir)/make.tmpl @@ -50,7 +47,6 @@ endif ifeq ("@BUILD_LVMETAD@", "yes") -device-mapper: lvmetad.device-mapper -lvmetad.device-mapper: $(LIB_STATIC) +lvmetad: common.device-mapper endif /cvs/lvm2/LVM2/daemons/common/Makefile.in,v --> standard output revision 1.1 --- LVM2/daemons/common/Makefile.in +++ - 2011-09-24 20:57:50.640380000 +0000 @@ -0,0 +1,22 @@ +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# This file is part of the device-mapper userspace tools. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU Lesser General Public License v.2.1. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ + +LIB_STATIC = libdaemon.a +SOURCES = daemon-shared.c daemon-server.c daemon-client.c + +include $(top_builddir)/make.tmpl + +device-mapper: $(LIB_STATIC) --- LVM2/daemons/lvmetad/Makefile.in 2011/09/19 00:29:12 1.3 +++ LVM2/daemons/lvmetad/Makefile.in 2011/09/24 20:57:49 1.4 @@ -22,8 +22,6 @@ .PHONY: install_lvmetad INCLUDES += -I$(top_srcdir)/daemons/common -INSTALL_LVMETAD_TARGETS = install_lvmetad -CLEAN_TARGETS = lvmetad lvmetad-testclient CFLOW_LIST = $(SOURCES) CFLOW_LIST_TARGET = $(LIB_NAME).cflow @@ -31,12 +29,10 @@ include $(top_builddir)/make.tmpl -device-mapper: $(TARGETS) - LIBS += -ldevmapper -ldaemon $(PTHREAD_LIBS) lvmetad: lvmetad-core.o - $(CC) $(CFLAGS) $(LDFLAGS) -L$(top_builddir)/daemons -o $@ lvmetad-core.o \ + $(CC) $(CFLAGS) $(LDFLAGS) -L$(top_builddir)/daemons/common -o $@ lvmetad-core.o \ $(DL_LIBS) $(LVMLIBS) $(LIBS) -rdynamic # TODO: No idea. No idea how to test either. @@ -52,6 +48,6 @@ install_lvmetad: lvmetad $(INSTALL_PROGRAM) -D $< $(sbindir)/$( CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 21:00:53 Modified files: daemons/dmeventd: Makefile.in daemons/dmeventd/plugins/lvm2: Makefile.in daemons/dmeventd/plugins/mirror: Makefile.in daemons/dmeventd/plugins/raid: Makefile.in daemons/dmeventd/plugins/snapshot: Makefile.in tools : Makefile.in Log message: Drop cleanup of .exported_symbols_generated in DISTCLEAN_TARGETS Makefile cosmetics - since .exported_symbols_generated in cleardir: target via make.tmpl, there is no need to set them in DISTCLEAN_TARGETS. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/Makefile.in.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/lvm2/Makefile.in.diff?cvsroot=lvm2&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/Makefile.in.diff?cvsroot=lvm2&r1=1.22&r2=1.23 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/raid/Makefile.in.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/snapshot/Makefile.in.diff?cvsroot=lvm2&r1=1.17&r2=1.18 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/Makefile.in.diff?cvsroot=lvm2&r1=1.122&r2=1.123 --- LVM2/daemons/dmeventd/Makefile.in 2010/08/16 22:54:36 1.45 +++ LVM2/daemons/dmeventd/Makefile.in 2011/09/24 21:00:52 1.46 @@ -1,5 +1,5 @@ # -# Copyright (C) 2005-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved. # # This file is part of the device-mapper userspace tools. # @@ -105,4 +105,4 @@ install_device-mapper: install_include install_lib install_dmeventd -DISTCLEAN_TARGETS += libdevmapper-event.pc .exported_symbols_generated +DISTCLEAN_TARGETS += libdevmapper-event.pc --- LVM2/daemons/dmeventd/plugins/lvm2/Makefile.in 2010/09/30 10:08:58 1.6 +++ LVM2/daemons/dmeventd/plugins/lvm2/Makefile.in 2011/09/24 21:00:52 1.7 @@ -1,5 +1,5 @@ # -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -29,5 +29,3 @@ install_lvm2: install_lib_shared install: install_lvm2 - -DISTCLEAN_TARGETS += .exported_symbols_generated --- LVM2/daemons/dmeventd/plugins/mirror/Makefile.in 2010/09/30 10:08:59 1.22 +++ LVM2/daemons/dmeventd/plugins/mirror/Makefile.in 2011/09/24 21:00:52 1.23 @@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2005, 2008-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2005, 2008-2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -35,5 +35,3 @@ install_lvm2: install_dm_plugin install: install_lvm2 - -DISTCLEAN_TARGETS += .exported_symbols_generated --- LVM2/daemons/dmeventd/plugins/raid/Makefile.in 2011/08/11 05:00:21 1.1 +++ LVM2/daemons/dmeventd/plugins/raid/Makefile.in 2011/09/24 21:00:53 1.2 @@ -1,6 +1,5 @@ # -# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2005, 2008-2011 Red Hat, Inc. All rights reserved. +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -35,5 +34,3 @@ install_lvm2: install_dm_plugin install: install_lvm2 - -DISTCLEAN_TARGETS += .exported_symbols_generated --- LVM2/daemons/dmeventd/plugins/snapshot/Makefile.in 2010/09/30 10:08:59 1.17 +++ LVM2/daemons/dmeventd/plugins/snapshot/Makefile.in 2011/09/24 21:00:53 1.18 @@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. # # This file is part of the LVM2. # @@ -31,5 +31,3 @@ install_lvm2: install_dm_plugin install: install_lvm2 - -DISTCLEAN_TARGETS += .exported_symbols_generated --- LVM2/tools/Makefile.in 2010/10/15 09:41:21 1.122 +++ LVM2/tools/Makefile.in 2011/09/24 21:00:53 1.123 @@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -203,5 +203,3 @@ install_lvm2: $(INSTALL_LVM_TARGETS) install: install_lvm2 install_device-mapper - -DISTCLEAN_TARGETS += .exported_symbols_generated From zkabelac@sourceware.org Sat Sep 24 21:05:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 24 Sep 2011 21:05:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/Makefile.in Message-ID: <20110924210503.1680.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 21:05:03 Modified files: . : WHATS_NEW scripts : Makefile.in Log message: Fix install_ocf When builddir is different from srcdir install_ocf: has not been able to find files for installation. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2135&r2=1.2136 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/Makefile.in.diff?cvsroot=lvm2&r1=1.21&r2=1.22 --- LVM2/WHATS_NEW 2011/09/24 20:50:35 1.2135 +++ LVM2/WHATS_NEW 2011/09/24 21:05:03 1.2136 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix install_ocf make target when srcdir != builddir. (2.02.80) Support env vars LVM_CLVMD_BINARY and LVM_BINARY in clvmd. Fix restart of clvmd (preserve exlusive locks). (2.02.64) Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE. --- LVM2/scripts/Makefile.in 2011/07/28 12:57:26 1.21 +++ LVM2/scripts/Makefile.in 2011/09/24 21:05:03 1.22 @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2006-2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -28,6 +28,7 @@ endif vpath %.sh $(srcdir) +vpath %.ocf $(srcdir) %_install: %.sh $(INSTALL_PROGRAM) -D $< $(sbindir)/$(basename $( CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 21:10:19 Modified files: . : WHATS_NEW test : Makefile.in Log message: Improvements Simplify RUN_BASE Put .tests-stamp deps only for check target and fix its cleanup. Fix abs_top_srcdir. vgimportclone needs srcdir. Clean api subdir. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2136&r2=1.2137 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.59&r2=1.60 --- LVM2/WHATS_NEW 2011/09/24 21:05:03 1.2136 +++ LVM2/WHATS_NEW 2011/09/24 21:10:19 1.2137 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Improve testing Makefile. Fix install_ocf make target when srcdir != builddir. (2.02.80) Support env vars LVM_CLVMD_BINARY and LVM_BINARY in clvmd. Fix restart of clvmd (preserve exlusive locks). (2.02.64) --- LVM2/test/Makefile.in 2011/09/19 15:54:15 1.59 +++ LVM2/test/Makefile.in 2011/09/24 21:10:19 1.60 @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2007-2011 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -31,7 +31,7 @@ VERBOSE ?= 0 ALL = $(shell find $(srcdir) \( -name t-\*.sh -or -path */api/\*.sh \) | sort) RUN = $(shell find $(srcdir) -regextype posix-egrep \( -name t-\*.sh -or -path */api/\*.sh \) -and -regex "$(srcdir)/.*($(T)).*" -and -not -regex "$(srcdir)/.*($(S)).*" | sort) -RUN_BASE = $(shell echo $(RUN) | xargs -n 1 echo | sed -e s,^$(srcdir)/,,) +RUN_BASE = $(subst $(srcdir)/,,$(RUN)) # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) @@ -40,7 +40,9 @@ dm_udev_synchronisation = 1 endif -all check: .tests-stamp +all: check + +check: .tests-stamp make -C api tests @echo Testing with locking_type 1 VERBOSE=$(VERBOSE) ./lib/harness $(RUN_BASE) @@ -71,7 +73,7 @@ rm -f $@-t echo 'top_srcdir=$(top_srcdir)' >> $@-t echo 'abs_top_builddir=$(abs_top_builddir)' >> $@-t - echo 'abs_top_srcdir=$(abs_top_builddir)' >> $@-t + echo 'abs_top_srcdir=$(abs_top_srcdir)' >> $@-t echo 'abs_srcdir=$(abs_srcdir)' >> $@-t echo 'abs_builddir=$(abs_builddir)' >> $@-t echo 'export DM_UDEV_SYNCHRONISATION=$(dm_udev_synchronisation)' >> $@-t @@ -81,35 +83,35 @@ lib/check lib/aux lib/test lib/utils lib/get lib/lvm-wrapper \ lib/paths +CMDS = lvm $(shell cat $(top_builddir)/tools/.commands) + .tests-stamp: $(ALL) $(LIB) @if test "$(srcdir)" != . ; then \ echo "Copying tests to builddir."; \ for f in $(ALL); do cp $$f `echo $$f | sed -e s,^$(srcdir)/,,`; done; \ fi - touch .tests-stamp + touch $@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ -.lib-dir-stamp: +.lib-dir-stamp: $(top_srcdir)/scripts/fsadm.sh mkdir -p lib - for i in lvm $$(cat ../tools/.commands); do \ - ln -fs lvm-wrapper lib/$$i; \ - done + for i in $(CMDS); do ln -fs lvm-wrapper lib/$$i; done ln -fs "$(abs_top_builddir)/tools/dmsetup" lib/dmsetup ln -fs "$(abs_top_builddir)/daemons/clvmd/clvmd" lib/clvmd ln -fs "$(abs_top_builddir)/daemons/dmeventd/dmeventd" lib/dmeventd ln -fs "$(abs_top_builddir)/daemons/lvmetad/lvmetad" lib/lvmetad - ln -fs "$(abs_top_builddir)/scripts/vgimportclone.sh" lib/vgimportclone - chmod +x "$(abs_top_builddir)/scripts/fsadm.sh" - ln -fs "$(abs_top_builddir)/scripts/fsadm.sh" lib/fsadm + ln -fs "$(abs_top_srcdir)/scripts/vgimportclone.sh" lib/vgimportclone + cp -f "$(top_srcdir)/scripts/fsadm.sh" lib/fsadm + @chmod +x lib/fsadm touch $@ clean: - for i in lvm $$(cat ../tools/.commands); do rm -f lib/$$i; done - if test "$(srcdir)" != . ; then rm -f $(subst $(srcdir)/, ,$(RUN)) lvm2app.sh ; fi + make -C api clean + test "$(srcdir)" != . && rm -f $(RUN_BASE) lvm2app.sh -CLEAN_TARGETS += .lib-dir-stamp .test-stamp $(LIB) \ - lib/dmsetup lib/clvmd lib/dmeventd lib/vgimportclone lib/fsadm +CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $(LIB) $(addprefix lib/,$(CMDS)) \ + lib/clvmd lib/dmeventd lib/dmsetup lib/lvmetad lib/fsadm lib/vgimportclone .NOTPARALLEL: From zkabelac@sourceware.org Sat Sep 24 21:12:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 24 Sep 2011 21:12:00 -0000 Subject: LVM2/test/lib harness.c Message-ID: <20110924211236.3175.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 21:12:35 Modified files: test/lib : harness.c Log message: Avoid sending garbage to terminal in verbose mode. When read in drain returned <0 value, terminal content has been trashed. Remove unneeded memset() and use whole buffer. Free readbuf before exit (valgrind). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/harness.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8 --- LVM2/test/lib/harness.c 2011/03/10 14:47:22 1.7 +++ LVM2/test/lib/harness.c 2011/09/24 21:12:35 1.8 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Red Hat, Inc. All rights reserved. + * Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -126,14 +126,13 @@ static void drain(void) { int sz; char buf[2048]; - memset(buf, 0, 2048); while (1) { - sz = read(fds[1], buf, 2047); - if (verbose) - write(1, buf, sz); + sz = read(fds[1], buf, sizeof(buf)); if (sz <= 0) return; + if (verbose) + write(1, buf, sz); if (readbuf_used + sz >= readbuf_sz) { readbuf_sz = readbuf_sz ? 2 * readbuf_sz : 4096; readbuf = realloc(readbuf, readbuf_sz); @@ -291,5 +290,7 @@ return s.nfailed > 0 || die; } + free(readbuf); + return die; } From zkabelac@sourceware.org Sat Sep 24 21:15:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 24 Sep 2011 21:15:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110924211514.3746.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 21:15:14 Modified files: test/lib : aux.sh Log message: Allow overwrite for VERIFY_UDEV When running tests it might be useful to have an override option when testing on real /dev and some broken system (i.e. Debian and its rules). So one can use: LVM_TEST_DEVDIR=/dev LVM_VERIFY_UDEV=1 make check Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.30&r2=1.31 --- LVM2/test/lib/aux.sh 2011/09/24 20:54:36 1.30 +++ LVM2/test/lib/aux.sh 2011/09/24 21:15:13 1.31 @@ -371,9 +371,9 @@ lvmconf() { if test -z "$LVM_TEST_LOCKING"; then LVM_TEST_LOCKING=1; fi if test "$DM_DEV_DIR" = "/dev"; then - VERIFY_UDEV=0; + LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-0}; else - VERIFY_UDEV=1; + LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-1}; fi test -f CONFIG_VALUES || { cat > CONFIG_VALUES <<-EOF @@ -401,7 +401,7 @@ activation/checks = 1 activation/udev_sync = 1 activation/udev_rules = 1 -activation/verify_udev_operations = $VERIFY_UDEV +activation/verify_udev_operations = $LVM_VERIFY_UDEV activation/polling_interval = 0 activation/snapshot_autoextend_percent = 50 activation/snapshot_autoextend_threshold = 50 From zkabelac@sourceware.org Sat Sep 24 21:19:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sat, 24 Sep 2011 21:19:00 -0000 Subject: LVM2 ./WHATS_NEW lib/raid/raid.c lib/unknown/u ... Message-ID: <20110924211931.5233.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-24 21:19:31 Modified files: . : WHATS_NEW lib/raid : raid.c lib/unknown : unknown.c Log message: Fix log_error() usage Cosmetic - skip when error has been just printed in raid segtype. Add missing log_error if allocation would fail for unknown segtype. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2137&r2=1.2138 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/raid/raid.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/unknown/unknown.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9 --- LVM2/WHATS_NEW 2011/09/24 21:10:19 1.2137 +++ LVM2/WHATS_NEW 2011/09/24 21:19:30 1.2138 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Fix log_error() usage in raid and unknown segtype initialisation. Improve testing Makefile. Fix install_ocf make target when srcdir != builddir. (2.02.80) Support env vars LVM_CLVMD_BINARY and LVM_BINARY in clvmd. --- LVM2/lib/raid/raid.c 2011/08/31 15:19:20 1.11 +++ LVM2/lib/raid/raid.c 2011/09/24 21:19:30 1.12 @@ -338,7 +338,7 @@ if (!segtype) { log_error("Failed to allocate memory for %s segtype", raid_type); - return_NULL; + return NULL; } segtype->cmd = cmd; --- LVM2/lib/unknown/unknown.c 2011/08/30 14:55:18 1.8 +++ LVM2/lib/unknown/unknown.c 2011/09/24 21:19:30 1.9 @@ -94,8 +94,10 @@ { struct segment_type *segtype = dm_zalloc(sizeof(*segtype)); - if (!segtype) - return_NULL; + if (!segtype) { + log_error("Failed to allocate memory for unknown segtype"); + return NULL; + } segtype->cmd = cmd; segtype->ops = &_unknown_ops; From zkabelac@sourceware.org Sun Sep 25 19:37:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sun, 25 Sep 2011 19:37:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-cman.c da ... Message-ID: <20110925193701.15704.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-25 19:37:01 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-cman.c clvmd-command.c clvmd-comms.h clvmd-corosync.c clvmd-openais.c clvmd-singlenode.c Added files: test : t-clvmd-restart.sh Log message: Restart CLVMD with same cluster manager Add named cluster_ops to easily learn the name of the active cluster manager, so we are able to restart singlenode manager in testing. Add simple test for clvmd -S (restart) and -R (refresh) (though it needs some extensions). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2138&r2=1.2139 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-cman.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-comms.h.diff?cvsroot=lvm2&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-corosync.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-openais.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-singlenode.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-clvmd-restart.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 --- LVM2/WHATS_NEW 2011/09/24 21:19:30 1.2138 +++ LVM2/WHATS_NEW 2011/09/25 19:37:00 1.2139 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Restart CLVMD with same cluster manager. Fix log_error() usage in raid and unknown segtype initialisation. Improve testing Makefile. Fix install_ocf make target when srcdir != builddir. (2.02.80) --- LVM2/daemons/clvmd/clvmd-cman.c 2011/01/19 23:09:31 1.29 +++ LVM2/daemons/clvmd/clvmd-cman.c 2011/09/25 19:37:00 1.30 @@ -479,6 +479,7 @@ } static struct cluster_ops _cluster_cman_ops = { + .name = "cman", .cluster_init_completed = _cluster_init_completed, .cluster_send_message = _cluster_send_message, .name_from_csid = _name_from_csid, --- LVM2/daemons/clvmd/clvmd-command.c 2011/09/24 20:50:36 1.59 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/09/25 19:37:00 1.60 @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -381,7 +381,7 @@ } while (hn); /* clvmd + locks (-E uuid) + debug (-d X) + NULL */ - if (!(argv = malloc((max_locks * 2 + 4) * sizeof(*argv)))) + if (!(argv = malloc((max_locks * 2 + 5) * sizeof(*argv)))) goto_out; /* @@ -396,10 +396,8 @@ argv[argc++] = debug_arg; } - /* - * FIXME: specify used cluster backend - * argv[argc++] = strdup("-Isinglenode"); - */ + argv[argc++] = "-I"; + argv[argc++] = clops->name; /* Now add the exclusively-open LVs */ hn = NULL; --- LVM2/daemons/clvmd/clvmd-comms.h 2011/08/09 18:11:00 1.13 +++ LVM2/daemons/clvmd/clvmd-comms.h 2011/09/25 19:37:00 1.14 @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -23,6 +23,7 @@ struct local_client; struct cluster_ops { + const char *name; void (*cluster_init_completed) (void); int (*cluster_send_message) (const void *buf, int msglen, --- LVM2/daemons/clvmd/clvmd-corosync.c 2011/01/19 23:09:31 1.15 +++ LVM2/daemons/clvmd/clvmd-corosync.c 2011/09/25 19:37:00 1.16 @@ -598,6 +598,7 @@ } static struct cluster_ops _cluster_corosync_ops = { + .name = "corosync", .cluster_init_completed = NULL, .cluster_send_message = _cluster_send_message, .name_from_csid = _name_from_csid, --- LVM2/daemons/clvmd/clvmd-openais.c 2011/03/13 18:08:26 1.17 +++ LVM2/daemons/clvmd/clvmd-openais.c 2011/09/25 19:37:00 1.18 @@ -667,6 +667,7 @@ } static struct cluster_ops _cluster_openais_ops = { + .name = "openais", .cluster_init_completed = NULL, .cluster_send_message = _cluster_send_message, .name_from_csid = _name_from_csid, --- LVM2/daemons/clvmd/clvmd-singlenode.c 2011/08/04 12:13:51 1.11 +++ LVM2/daemons/clvmd/clvmd-singlenode.c 2011/09/25 19:37:00 1.12 @@ -267,6 +267,7 @@ } static struct cluster_ops _cluster_singlenode_ops = { + .name = "singlenode", .cluster_init_completed = NULL, .cluster_send_message = _cluster_send_message, .name_from_csid = _name_from_csid, /cvs/lvm2/LVM2/test/t-clvmd-restart.sh,v --> standard output revision 1.1 --- LVM2/test/t-clvmd-restart.sh +++ - 2011-09-25 19:37:01.914932000 +0000 @@ -0,0 +1,44 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +export LVM_CLVMD_BINARY="lib/clvmd" +export LVM_BINARY="lib/lvm" + +. lib/test + +# only clvmd based test, skip otherwise +test -e LOCAL_CLVMD || skip + +aux prepare_devs 1 + +vgcreate --clustered y $vg $(cat DEVICES) + +lvcreate -an --zero n -n $lv1 -l1 $vg +lvcreate -an --zero n -n $lv2 -l1 $vg +lvcreate -l1 $vg + +lvchange -aey $vg/$lv1 +lvchange -aey $vg/$lv2 + +"$LVM_CLVMD_BINARY" -S +sleep .2 +# restarted clvmd has the same PID (no fork, only execve) +NEW_LOCAL_CLVMD=$(pgrep clvmd) +read LOCAL_CLVMD < LOCAL_CLVMD +test "$LOCAL_CLVMD" -eq "$NEW_LOCAL_CLVMD" + +# FIXME: Hmm - how could we test exclusivity is preserved in singlenode ? +lvchange -an $vg/$lv1 +lvchange -ay $vg/$lv1 + +lib/clvmd -R + +vgremove -ff $vg From zkabelac@sourceware.org Sun Sep 25 19:39:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sun, 25 Sep 2011 19:39:00 -0000 Subject: LVM2/libdm libdm-config.c Message-ID: <20110925193938.17248.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-25 19:39:38 Modified files: libdm : libdm-config.c Log message: Chheck for failing filename strdup Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8 --- LVM2/libdm/libdm-config.c 2011/09/25 19:38:59 1.7 +++ LVM2/libdm/libdm-config.c 2011/09/25 19:39:38 1.8 @@ -127,8 +127,13 @@ c->exists = 0; c->keep_open = keep_open; c->custom = NULL; - if (filename) - c->filename = dm_pool_strdup(c->mem, filename); + if (filename && + !(c->filename = dm_pool_strdup(c->mem, filename))) { + log_error("Failed to duplicate filename."); + dm_pool_destroy(mem); + return 0; + } + return &c->cft; } From zkabelac@sourceware.org Sun Sep 25 19:39:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sun, 25 Sep 2011 19:39:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdm-config.c Message-ID: <20110925193859.17068.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-25 19:38:59 Modified files: . : WHATS_NEW_DM libdm : libdm-config.c Log message: Use NULL for pointers Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.506&r2=1.507 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/WHATS_NEW_DM 2011/09/23 09:51:37 1.506 +++ LVM2/WHATS_NEW_DM 2011/09/25 19:38:59 1.507 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Improve libdm-config error path reporting. Update dmsetup resume man with --addnodeonresume/create options. Add dependency for dm man pages to man subdirectory make target all:. Add dm_tree_retry_remove to use retry logic for device removal in a dm_tree. --- LVM2/libdm/libdm-config.c 2011/09/02 01:32:09 1.6 +++ LVM2/libdm/libdm-config.c 2011/09/25 19:38:59 1.7 @@ -523,7 +523,7 @@ struct dm_config_node *root = NULL, *n, *l = NULL; while (p->t != TOK_EOF) { if (!(n = _section(p))) - return_0; + return_NULL; if (!root) root = n; @@ -540,10 +540,10 @@ /* IDENTIFIER SECTION_B_CHAR VALUE* SECTION_E_CHAR */ struct dm_config_node *root, *n, *l = NULL; if (!(root = _create_node(p->mem))) - return_0; + return_NULL; if (!(root->key = _dup_tok(p))) - return_0; + return_NULL; match(TOK_IDENTIFIER); @@ -551,7 +551,7 @@ match(TOK_SECTION_B); while (p->t != TOK_SECTION_E) { if (!(n = _section(p))) - return_0; + return_NULL; if (!root->child) root->child = n; @@ -564,7 +564,7 @@ } else { match(TOK_EQ); if (!(root->v = _value(p))) - return_0; + return_NULL; } return root; @@ -578,7 +578,7 @@ match(TOK_ARRAY_B); while (p->t != TOK_ARRAY_E) { if (!(l = _type(p))) - return_0; + return_NULL; if (!h) h = l; @@ -595,7 +595,7 @@ */ if (!h) { if (!(h = _create_value(p->mem))) - return NULL; + return_NULL; h->type = DM_CFG_EMPTY_ARRAY; } @@ -633,7 +633,7 @@ p->tb++, p->te--; /* strip "'s */ if (!(v->v.str = _dup_tok(p))) - return_0; + return_NULL; p->te++; match(TOK_STRING); break; @@ -643,7 +643,7 @@ p->tb++, p->te--; /* strip "'s */ if (!(str = _dup_tok(p))) - return_0; + return_NULL; dm_unescape_double_quotes(str); v->v.str = str; p->te++; @@ -653,7 +653,7 @@ default: log_error("Parse error at byte %" PRIptrdiff_t " (line %d): expected a value", p->tb - p->fb + 1, p->line); - return 0; + return NULL; } return v; } From zkabelac@sourceware.org Sun Sep 25 19:40:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sun, 25 Sep 2011 19:40:00 -0000 Subject: LVM2/libdm libdm-config.c Message-ID: <20110925194029.17546.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-25 19:40:29 Modified files: libdm : libdm-config.c Log message: Simplier attribute format No need to repeat whole declaration for static function. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9 --- LVM2/libdm/libdm-config.c 2011/09/25 19:39:38 1.8 +++ LVM2/libdm/libdm-config.c 2011/09/25 19:40:29 1.9 @@ -316,8 +316,7 @@ return 1; } -static int _line_append(struct output_line *outline, const char *fmt, ...) - __attribute__ ((format(printf, 2, 3))); +__attribute__ ((format(printf, 2, 3))) static int _line_append(struct output_line *outline, const char *fmt, ...) { char buf[4096]; From zkabelac@sourceware.org Sun Sep 25 19:41:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sun, 25 Sep 2011 19:41:00 -0000 Subject: LVM2/libdm libdm-config.c Message-ID: <20110925194127.17721.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-25 19:41:27 Modified files: libdm : libdm-config.c Log message: Replace test for NULL of root->child with test for NULL l It's 100% equivalent test - since it always happen for the first iteration. But the check for 'l' is understandable with analyzers - since analyzer is not smart enough to deduce connection between root->child == NULL. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10 --- LVM2/libdm/libdm-config.c 2011/09/25 19:40:29 1.9 +++ LVM2/libdm/libdm-config.c 2011/09/25 19:41:27 1.10 @@ -557,7 +557,7 @@ if (!(n = _section(p))) return_NULL; - if (!root->child) + if (!l) root->child = n; else l->sib = n; From zkabelac@sourceware.org Sun Sep 25 19:42:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sun, 25 Sep 2011 19:42:00 -0000 Subject: LVM2/libdm libdm-config.c Message-ID: <20110925194245.17935.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-25 19:42:45 Modified files: libdm : libdm-config.c Log message: Add backtrace when allocation fails for _type Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11 --- LVM2/libdm/libdm-config.c 2011/09/25 19:41:27 1.10 +++ LVM2/libdm/libdm-config.c 2011/09/25 19:42:45 1.11 @@ -605,7 +605,8 @@ } } else - h = _type(p); + if (!(h = _type(p))) + return_NULL; return h; } From zkabelac@sourceware.org Sun Sep 25 19:43:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sun, 25 Sep 2011 19:43:00 -0000 Subject: LVM2/libdm libdm-config.c Message-ID: <20110925194344.18116.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-25 19:43:43 Modified files: libdm : libdm-config.c Log message: Add missing log_error messages Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 --- LVM2/libdm/libdm-config.c 2011/09/25 19:42:45 1.11 +++ LVM2/libdm/libdm-config.c 2011/09/25 19:43:43 1.12 @@ -543,8 +543,10 @@ { /* IDENTIFIER SECTION_B_CHAR VALUE* SECTION_E_CHAR */ struct dm_config_node *root, *n, *l = NULL; - if (!(root = _create_node(p->mem))) - return_NULL; + if (!(root = _create_node(p->mem))) { + log_error("Failed to allocate section node"); + return NULL; + } if (!(root->key = _dup_tok(p))) return_NULL; @@ -598,8 +600,10 @@ * Special case for an empty array. */ if (!h) { - if (!(h = _create_value(p->mem))) - return_NULL; + if (!(h = _create_value(p->mem))) { + log_error("Failed to allocate value"); + return NULL; + } h->type = DM_CFG_EMPTY_ARRAY; } @@ -617,8 +621,10 @@ struct dm_config_value *v = _create_value(p->mem); char *str; - if (!v) + if (!v) { + log_error("Failed to allocate type value"); return NULL; + } switch (p->t) { case TOK_INT: @@ -1251,8 +1257,10 @@ { struct dm_config_node *new_cn; - if (!cn) + if (!cn) { + log_error("Cannot clone NULL config node."); return NULL; + } if (!(new_cn = _create_node(mem))) { log_error("Failed to clone config node."); From zkabelac@sourceware.org Sun Sep 25 19:45:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Sun, 25 Sep 2011 19:45:00 -0000 Subject: LVM2/libdm libdm-config.c Message-ID: <20110925194541.18853.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-25 19:45:40 Modified files: libdm : libdm-config.c Log message: Remove test for NULL Since it's internal function and we always check for NULL value before call - this is safe. Just for case add nonnull attribute so analyzer might better catch error. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-config.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13 --- LVM2/libdm/libdm-config.c 2011/09/25 19:43:43 1.12 +++ LVM2/libdm/libdm-config.c 2011/09/25 19:45:40 1.13 @@ -1225,14 +1225,12 @@ return 0; } +__attribute__((nonnull(1, 2))) static struct dm_config_value *_clone_config_value(struct dm_pool *mem, const struct dm_config_value *v) { struct dm_config_value *new_cv; - if (!v) - return NULL; - if (!(new_cv = _create_value(mem))) { log_error("Failed to clone config value."); return NULL; From zkabelac@sourceware.org Mon Sep 26 07:51:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 26 Sep 2011 07:51:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-command.c ... Message-ID: <20110926075126.9130.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-26 07:51:25 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c test : t-clvmd-restart.sh Log message: Use execvp for clvmd restart Since execve passed only NULL as environ, we had lost all environment vars on restart - thus actually running 'different' clvmd then the one at start. Preserving environ allows to restart clvmd with the same settings (i.e. LD_LIBRARY_PATH) Add test for second restart. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2139&r2=1.2140 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-clvmd-restart.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/WHATS_NEW 2011/09/25 19:37:00 1.2139 +++ LVM2/WHATS_NEW 2011/09/26 07:51:23 1.2140 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Use execvp for CLVMD restart to preserve environment settings. Restart CLVMD with same cluster manager. Fix log_error() usage in raid and unknown segtype initialisation. Improve testing Makefile. --- LVM2/daemons/clvmd/clvmd-command.c 2011/09/25 19:37:00 1.60 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/09/26 07:51:24 1.61 @@ -418,7 +418,7 @@ for (argc = 1; argv[argc]; argc++) DEBUGLOG("--- %d: %s\n", argc, argv[argc]); /* NOTE: This will fail when downgrading! */ - execve(clvmd, (char **)argv, NULL); + execvp(clvmd, (char **)argv); out: /* We failed */ DEBUGLOG("Restart of clvmd failed.\n"); --- LVM2/test/t-clvmd-restart.sh 2011/09/25 19:37:00 1.1 +++ LVM2/test/t-clvmd-restart.sh 2011/09/26 07:51:24 1.2 @@ -9,13 +9,15 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -export LVM_CLVMD_BINARY="lib/clvmd" -export LVM_BINARY="lib/lvm" +# set before test's clvmd is started, so it's passed in environ +export LVM_CLVMD_BINARY=clvmd +export LVM_BINARY=lvm . lib/test # only clvmd based test, skip otherwise test -e LOCAL_CLVMD || skip +read LOCAL_CLVMD < LOCAL_CLVMD aux prepare_devs 1 @@ -30,15 +32,22 @@ "$LVM_CLVMD_BINARY" -S sleep .2 -# restarted clvmd has the same PID (no fork, only execve) +# restarted clvmd has the same PID (no fork, only execvp) +NEW_LOCAL_CLVMD=$(pgrep clvmd) +test "$LOCAL_CLVMD" -eq "$NEW_LOCAL_CLVMD" + +# try restart once more + +"$LVM_CLVMD_BINARY" -S +sleep .2 +# restarted clvmd has the same PID (no fork, only execvp) NEW_LOCAL_CLVMD=$(pgrep clvmd) -read LOCAL_CLVMD < LOCAL_CLVMD test "$LOCAL_CLVMD" -eq "$NEW_LOCAL_CLVMD" # FIXME: Hmm - how could we test exclusivity is preserved in singlenode ? lvchange -an $vg/$lv1 lvchange -ay $vg/$lv1 -lib/clvmd -R +"$LVM_CLVMD_BINARY" -R vgremove -ff $vg From prajnoha@sourceware.org Mon Sep 26 10:17:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Mon, 26 Sep 2011 10:17:00 -0000 Subject: LVM2 lib/activate/activate.c libdm/libdm-deptree.c Message-ID: <20110926101758.13423.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-09-26 10:17:52 Modified files: lib/activate : activate.c libdm : libdm-deptree.c Log message: Add log_error even for general device in use when we can't do the sysfs checks. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.213&r2=1.214 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112 --- LVM2/lib/activate/activate.c 2011/09/22 17:33:50 1.213 +++ LVM2/lib/activate/activate.c 2011/09/26 10:17:51 1.214 @@ -533,8 +533,15 @@ return 1; /* If sysfs is not used, use open_count information only. */ - if (!*dm_sysfs_dir()) - return !info->open_count; + if (!*dm_sysfs_dir()) { + if (info->open_count) { + log_error("Logical volume %s/%s in use.", + lv->vg->name, lv->name); + return 0; + } + + return 1; + } if (dm_device_has_holders(info->major, info->minor)) { log_error("Logical volume %s/%s is used by another device.", --- LVM2/libdm/libdm-deptree.c 2011/09/22 17:36:50 1.111 +++ LVM2/libdm/libdm-deptree.c 2011/09/26 10:17:52 1.112 @@ -947,8 +947,15 @@ return 1; /* If sysfs is not used, use open_count information only. */ - if (!*dm_sysfs_dir()) - return !info->open_count; + if (!*dm_sysfs_dir()) { + if (info->open_count) { + log_error("Device %" PRIu32 ":%" PRIu32 " in use", + info->major, info->minor); + return 0; + } + + return 1; + } if (dm_device_has_holders(info->major, info->minor)) { log_error("Device %" PRIu32 ":%" PRIu32 " is used " From zkabelac@sourceware.org Mon Sep 26 13:11:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 26 Sep 2011 13:11:00 -0000 Subject: LVM2/lib/display display.c Message-ID: <20110926131104.5465.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-26 13:11:03 Modified files: lib/display : display.c Log message: Show some Thin related info in lvdisplay Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118 --- LVM2/lib/display/display.c 2011/03/01 20:17:56 1.117 +++ LVM2/lib/display/display.c 2011/09/26 13:11:02 1.118 @@ -548,6 +548,18 @@ snap_seg->origin->name); } + if (lv_is_thin_volume(lv)) { + log_print("LV Thin pool %s%s/%s", lv->vg->cmd->dev_dir, + lv->vg->name, first_seg(lv)->pool_lv->name); + } else if (lv_is_thin_pool(lv)) { + log_print("LV Thin metadada %s%s/%s", lv->vg->cmd->dev_dir, + lv->vg->name, first_seg(lv)->pool_metadata_lv->name); + log_print("LV Thin data pool %s%s/%s", lv->vg->cmd->dev_dir, + lv->vg->name, seg_lv(first_seg(lv), 0)->name); + log_print("LV zero new blocks %s", + first_seg(lv)->zero_new_blocks ? "yes" : "no"); + } + if (inkernel && info.suspended) log_print("LV Status suspended"); else From agk@sourceware.org Tue Sep 27 12:33:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 27 Sep 2011 12:33:00 -0000 Subject: LVM2/lib/report columns.h Message-ID: <20110927123337.13233.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-27 12:33:37 Modified files: lib/report : columns.h Log message: correct thin_pool width Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/columns.h.diff?cvsroot=lvm2&r1=1.47&r2=1.48 --- LVM2/lib/report/columns.h 2011/09/09 00:54:49 1.47 +++ LVM2/lib/report/columns.h 2011/09/27 12:33:36 1.48 @@ -80,7 +80,7 @@ FIELD(LVS, lv, STR, "Convert", lvid, 7, convertlv, convert_lv, "For lvconvert, Name of temporary LV created by lvconvert.", 0) FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, lv_tags, "Tags, if any.", 0) FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, mirror_log, "For mirrors, the LV holding the synchronisation log.", 0) -FIELD(LVS, lv, STR, "Pool", lvid, 3, poollv, thin_pool, "For thinly-provisioned devices, the pool LV holding the data.", 0) +FIELD(LVS, lv, STR, "Pool", lvid, 4, poollv, thin_pool, "For thinly-provisioned devices, the pool LV holding the data.", 0) FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, modules, "Kernel device-mapper modules required for this LV.", 0) FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, pv_fmt, "Type of metadata.", 0) From agk@sourceware.org Tue Sep 27 12:34:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 27 Sep 2011 12:34:00 -0000 Subject: LVM2/lib/display display.c Message-ID: <20110927123414.14634.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-27 12:34:14 Modified files: lib/display : display.c Log message: typo Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119 --- LVM2/lib/display/display.c 2011/09/26 13:11:02 1.118 +++ LVM2/lib/display/display.c 2011/09/27 12:34:14 1.119 @@ -552,7 +552,7 @@ log_print("LV Thin pool %s%s/%s", lv->vg->cmd->dev_dir, lv->vg->name, first_seg(lv)->pool_lv->name); } else if (lv_is_thin_pool(lv)) { - log_print("LV Thin metadada %s%s/%s", lv->vg->cmd->dev_dir, + log_print("LV Thin metadata %s%s/%s", lv->vg->cmd->dev_dir, lv->vg->name, first_seg(lv)->pool_metadata_lv->name); log_print("LV Thin data pool %s%s/%s", lv->vg->cmd->dev_dir, lv->vg->name, seg_lv(first_seg(lv), 0)->name); From agk@sourceware.org Tue Sep 27 12:37:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 27 Sep 2011 12:37:00 -0000 Subject: LVM2/tools lvcreate.c Message-ID: <20110927123708.15798.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-27 12:37:07 Modified files: tools : lvcreate.c Log message: better -m0 error message, but there's an internal logic error to fix instead Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.242&r2=1.243 --- LVM2/tools/lvcreate.c 2011/09/22 15:36:21 1.242 +++ LVM2/tools/lvcreate.c 2011/09/27 12:37:07 1.243 @@ -575,11 +575,14 @@ /* * Check selected options are compatible and determine segtype */ +// FIXME -m0 implies *striped* if (arg_count(cmd, thin_ARG) && arg_count(cmd,mirrors_ARG)) { log_error("--thin and --mirrors are incompatible."); return 0; } +// FIXME -m0 implies *striped* + /* Set default segtype */ if (arg_count(cmd, mirrors_ARG)) segtype_str = find_config_tree_str(cmd, "global/mirror_segtype_default", DEFAULT_MIRROR_SEGTYPE); @@ -620,7 +623,7 @@ lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0) + 1; if (lp->mirrors == 1) { if (segtype_is_mirrored(lp->segtype)) { - log_error("Image count for segtype \"%s\" cannot be 0.", lp->segtype->name); + log_error("--mirrors must be at least 1 with segment type %s.", lp->segtype->name); return 0; } log_print("Redundant mirrors argument: default is 0"); From agk@sourceware.org Tue Sep 27 17:09:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 27 Sep 2011 17:09:00 -0000 Subject: LVM2 ./WHATS_NEW lib/locking/locking.c lib/loc ... Message-ID: <20110927170945.16826.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-27 17:09:44 Modified files: . : WHATS_NEW lib/locking : locking.c locking.h lib/metadata : lv_manip.c metadata-exported.h metadata.c tools : pvmove.c Log message: Abort if _finish_pvmove suspend_lvs fails instead of cleaning up incompletely. Change suspend_lvs to call vg_revert internally. Change vg_revert to void and remove superfluous calls after failed vg_commit. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2140&r2=1.2141 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.67&r2=1.68 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.290&r2=1.291 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.211&r2=1.212 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.467&r2=1.468 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88 --- LVM2/WHATS_NEW 2011/09/26 07:51:23 1.2140 +++ LVM2/WHATS_NEW 2011/09/27 17:09:42 1.2141 @@ -1,5 +1,8 @@ Version 2.02.89 - ================================== + Abort if _finish_pvmove suspend_lvs fails instead of cleaning up incompletely. + Change suspend_lvs to call vg_revert internally. + Change vg_revert to void and remove superfluous calls after failed vg_commit. Use execvp for CLVMD restart to preserve environment settings. Restart CLVMD with same cluster manager. Fix log_error() usage in raid and unknown segtype initialisation. --- LVM2/lib/locking/locking.c 2011/08/11 15:27:46 1.98 +++ LVM2/lib/locking/locking.c 2011/09/27 17:09:43 1.99 @@ -493,8 +493,13 @@ return r; } -/* Lock a list of LVs */ -int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs) +/* + * Lock a list of LVs. + * On failure to lock any LV, calls vg_revert() if vg_to_revert is set and + * then unlocks any LVs on the list already successfully locked. + */ +int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs, + struct volume_group *vg_to_revert) { struct dm_list *lvh; struct lv_list *lvl; @@ -502,6 +507,8 @@ dm_list_iterate_items(lvl, lvs) { if (!suspend_lv(cmd, lvl->lv)) { log_error("Failed to suspend %s", lvl->lv->name); + if (vg_to_revert) + vg_revert(vg_to_revert); dm_list_uniterate(lvh, lvs, &lvl->list) { lvl = dm_list_item(lvh, struct lv_list); if (!resume_lv(cmd, lvl->lv)) --- LVM2/lib/locking/locking.h 2011/08/10 20:25:30 1.67 +++ LVM2/lib/locking/locking.h 2011/09/27 17:09:43 1.68 @@ -187,7 +187,9 @@ int sync_dev_names(struct cmd_context* cmd); /* Process list of LVs */ -int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs); +struct volume_group; +int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs, + struct volume_group *vg_to_revert); int resume_lvs(struct cmd_context *cmd, struct dm_list *lvs); int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs, unsigned exclusive); --- LVM2/lib/metadata/lv_manip.c 2011/09/22 17:33:51 1.290 +++ LVM2/lib/metadata/lv_manip.c 2011/09/27 17:09:43 1.291 @@ -2793,11 +2793,8 @@ if (!vg_write(vg)) return 0; - - if (!suspend_lvs(cmd, &lvs_changed)) { - vg_revert(vg); + if (!suspend_lvs(cmd, &lvs_changed, vg)) goto_out; - } if (!(r = vg_commit(vg))) stack; --- LVM2/lib/metadata/metadata-exported.h 2011/09/14 09:57:35 1.211 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/27 17:09:43 1.212 @@ -400,7 +400,7 @@ */ int vg_write(struct volume_group *vg); int vg_commit(struct volume_group *vg); -int vg_revert(struct volume_group *vg); +void vg_revert(struct volume_group *vg); struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name, const char *vgid, int warnings, int *consistent); struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name, --- LVM2/lib/metadata/metadata.c 2011/09/07 08:34:22 1.467 +++ LVM2/lib/metadata/metadata.c 2011/09/27 17:09:43 1.468 @@ -2685,7 +2685,7 @@ } /* Don't commit any pending changes */ -int vg_revert(struct volume_group *vg) +void vg_revert(struct volume_group *vg) { struct metadata_area *mda; @@ -2701,8 +2701,6 @@ "after reverted update for VG %s.", vg->name); remote_revert_cached_metadata(vg); - - return 1; } /* Make orphan PVs look like a VG */ --- LVM2/tools/pvmove.c 2011/09/21 16:36:39 1.87 +++ LVM2/tools/pvmove.c 2011/09/27 17:09:43 1.88 @@ -307,17 +307,21 @@ static int _suspend_lvs(struct cmd_context *cmd, unsigned first_time, struct logical_volume *lv_mirr, - struct dm_list *lvs_changed) + struct dm_list *lvs_changed, + struct volume_group *vg_to_revert) { /* * Suspend lvs_changed the first time. * Suspend mirrors on subsequent calls. */ if (first_time) { - if (!suspend_lvs(cmd, lvs_changed)) + if (!suspend_lvs(cmd, lvs_changed, vg_to_revert)) return_0; - } else if (!suspend_lv(cmd, lv_mirr)) + } else if (!suspend_lv(cmd, lv_mirr)) { + if (vg_to_revert) + vg_revert(vg_to_revert); return_0; + } return 1; } @@ -364,16 +368,14 @@ return 0; } - if (!_suspend_lvs(cmd, first_time, lv_mirr, lvs_changed)) { - /* FIXME vg_revert must be moved *before* any LV resumes */ - vg_revert(vg); - goto_out; + if (!_suspend_lvs(cmd, first_time, lv_mirr, lvs_changed, vg)) { + log_error("ABORTING: Volume group metadata update failed."); + goto out; } /* Commit on-disk metadata */ if (!vg_commit(vg)) { log_error("ABORTING: Volume group metadata update failed."); - vg_revert(vg); goto out; } @@ -555,16 +557,15 @@ } /* Suspend LVs changed (implicitly suspends lv_mirr) */ - if (!suspend_lvs(cmd, lvs_changed)) { - log_error("Locking LVs to remove temporary mirror failed"); - r = 0; + if (!suspend_lvs(cmd, lvs_changed, vg)) { + log_error("ABORTING: Locking LVs to remove temporary mirror failed"); + return 0; } /* Store metadata without dependencies on mirror segments */ if (!vg_commit(vg)) { log_error("ABORTING: Failed to write new data locations " "to disk."); - vg_revert(vg); if (!resume_lv(cmd, lv_mirr)) stack; if (!resume_lvs(cmd, lvs_changed)) From agk@sourceware.org Tue Sep 27 17:29:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 27 Sep 2011 17:29:00 -0000 Subject: LVM2 ./WHATS_NEW tools/pvmove.c Message-ID: <20110927172934.27589.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-27 17:29:34 Modified files: . : WHATS_NEW tools : pvmove.c Log message: Replace incomplete pvmove activation failure recovery code with a message. As it stands, the recovery code can make things worse sometimes so it's better to insist on a proper 'pvmove --abort' cleanup. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2141&r2=1.2142 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89 --- LVM2/WHATS_NEW 2011/09/27 17:09:42 1.2141 +++ LVM2/WHATS_NEW 2011/09/27 17:29:33 1.2142 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Replace incomplete pvmove activation failure recovery code with a message. Abort if _finish_pvmove suspend_lvs fails instead of cleaning up incompletely. Change suspend_lvs to call vg_revert internally. Change vg_revert to void and remove superfluous calls after failed vg_commit. --- LVM2/tools/pvmove.c 2011/09/27 17:09:43 1.88 +++ LVM2/tools/pvmove.c 2011/09/27 17:29:33 1.89 @@ -390,22 +390,9 @@ } /* - * Nothing changed yet, try to revert pvmove. - * FIXME This error path is incomplete and unsafe. + * FIXME Run --abort internally here. */ - log_error("Temporary pvmove mirror activation failed."); - - /* Ensure that temporary mrror is deactivate even on other nodes. */ - /* FIXME Unsafe to proceed if this fails without checking explicitly that no pvmove LVs are still active */ - (void)deactivate_lv(cmd, lv_mirr); - - /* Revert metadata */ - /* FIXME Use --abort code instead? */ - if (!_detach_pvmove_mirror(cmd, lv_mirr) || - !lv_remove(lv_mirr) || - !vg_write(vg) || !vg_commit(vg)) - log_error("ABORTING: Restoring original configuration " - "before pvmove failed. Run pvmove --abort."); + log_error("ABORTING: Temporary pvmove mirror activation failed. Run pvmove --abort."); goto_out; } } From agk@sourceware.org Tue Sep 27 22:43:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 27 Sep 2011 22:43:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ... Message-ID: <20110927224343.23639.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-09-27 22:43:42 Modified files: . : WHATS_NEW daemons/clvmd : lvm-functions.c lib/activate : activate.c activate.h dev_manager.c lib/locking : cluster_locking.c file_locking.c locking.c locking.h no_locking.c libdm : libdm-deptree.c tools : pvmove.c Log message: Introduce revert_lv for better pvmove cleanup. (One further fix needed to remove the stray pvmove LVs left behind.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2142&r2=1.2143 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.214&r2=1.215 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.80&r2=1.81 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.232&r2=1.233 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.68&r2=1.69 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/no_locking.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90 --- LVM2/WHATS_NEW 2011/09/27 17:29:33 1.2142 +++ LVM2/WHATS_NEW 2011/09/27 22:43:40 1.2143 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Introduce revert_lv for better pvmove cleanup. Replace incomplete pvmove activation failure recovery code with a message. Abort if _finish_pvmove suspend_lvs fails instead of cleaning up incompletely. Change suspend_lvs to call vg_revert internally. --- LVM2/daemons/clvmd/lvm-functions.c 2011/09/24 20:50:36 1.124 +++ LVM2/daemons/clvmd/lvm-functions.c 2011/09/27 22:43:40 1.125 @@ -406,7 +406,7 @@ /* Resume the LV if it was active */ static int do_resume_lv(char *resource, unsigned char lock_flags) { - int oldmode, origin_only, exclusive; + int oldmode, origin_only, exclusive, revert; /* Is it open ? */ oldmode = get_current_lock(resource); @@ -416,8 +416,9 @@ } origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0; exclusive = (oldmode == LCK_EXCL) ? 1 : 0; + revert = (lock_flags & LCK_REVERT_MODE) ? 1 : 0; - if (!lv_resume_if_active(cmd, resource, origin_only, exclusive)) + if (!lv_resume_if_active(cmd, resource, origin_only, exclusive, revert)) return EIO; return 0; --- LVM2/lib/activate/activate.c 2011/09/26 10:17:51 1.214 +++ LVM2/lib/activate/activate.c 2011/09/27 22:43:40 1.215 @@ -190,7 +190,7 @@ return 1; } int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s, - unsigned origin_only, unsigned exclusive) + unsigned origin_only, unsigned exclusive, unsigned revert) { return 1; } @@ -1356,14 +1356,16 @@ laopts->origin_only = 0; if (test_mode()) { - _skip("Resuming %s%s.", lv->name, laopts->origin_only ? " without snapshots" : ""); + _skip("Resuming %s%s%s.", lv->name, laopts->origin_only ? " without snapshots" : "", + laopts->revert ? " (reverting)" : ""); r = 1; goto out; } - log_debug("Resuming LV %s/%s%s%s.", lv->vg->name, lv->name, + log_debug("Resuming LV %s/%s%s%s%s.", lv->vg->name, lv->name, error_if_not_active ? "" : " if active", - laopts->origin_only ? " without snapshots" : ""); + laopts->origin_only ? " without snapshots" : "", + laopts->revert ? " (reverting)" : ""); if (!lv_info(cmd, lv, laopts->origin_only, &info, 0, 0)) goto_out; @@ -1395,7 +1397,7 @@ /* Returns success if the device is not active */ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s, - unsigned origin_only, unsigned exclusive) + unsigned origin_only, unsigned exclusive, unsigned revert) { struct lv_activate_opts laopts = { .origin_only = origin_only, @@ -1404,7 +1406,8 @@ * non-clustered target should be used. This only happens * if exclusive is set. */ - .exclusive = exclusive + .exclusive = exclusive, + .revert = revert }; return _lv_resume(cmd, lvid_s, &laopts, 0); --- LVM2/lib/activate/activate.h 2011/09/22 17:33:51 1.80 +++ LVM2/lib/activate/activate.h 2011/09/27 22:43:40 1.81 @@ -34,6 +34,7 @@ int exclusive; int origin_only; int no_merging; + unsigned revert; }; /* target attribute flags */ @@ -63,7 +64,7 @@ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only); int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only); int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s, - unsigned origin_only, unsigned exclusive); + unsigned origin_only, unsigned exclusive, unsigned revert); int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive); int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive); --- LVM2/lib/activate/dev_manager.c 2011/09/22 17:39:57 1.232 +++ LVM2/lib/activate/dev_manager.c 2011/09/27 22:43:41 1.233 @@ -1590,7 +1590,7 @@ layer ? UINT32_C(0) : (uint32_t) lv->major, layer ? UINT32_C(0) : (uint32_t) lv->minor, _read_only_lv(lv), - (lv->vg->status & PRECOMMITTED) ? 1 : 0, + ((lv->vg->status & PRECOMMITTED) | laopts->revert) ? 1 : 0, lvlayer, _get_udev_flags(dm, lv, layer)))) return_0; --- LVM2/lib/locking/cluster_locking.c 2011/08/30 14:55:17 1.58 +++ LVM2/lib/locking/cluster_locking.c 2011/09/27 22:43:41 1.59 @@ -327,6 +327,9 @@ if (flags & LCK_ORIGIN_ONLY) args[1] |= LCK_ORIGIN_ONLY_MODE; + if (flags & LCK_REVERT) + args[1] |= LCK_REVERT_MODE; + if (mirror_in_sync()) args[1] |= LCK_MIRROR_NOSYNC_MODE; --- LVM2/lib/locking/file_locking.c 2011/08/09 11:44:57 1.60 +++ LVM2/lib/locking/file_locking.c 2011/09/27 22:43:41 1.61 @@ -257,6 +257,7 @@ { char lockfile[PATH_MAX]; unsigned origin_only = (flags & LCK_ORIGIN_ONLY) ? 1 : 0; + unsigned revert = (flags & LCK_REVERT) ? 1 : 0; switch (flags & LCK_SCOPE_MASK) { case LCK_VG: @@ -292,8 +293,8 @@ case LCK_LV: switch (flags & LCK_TYPE_MASK) { case LCK_UNLOCK: - log_very_verbose("Unlocking LV %s%s", resource, origin_only ? " without snapshots" : ""); - if (!lv_resume_if_active(cmd, resource, origin_only, 0)) + log_very_verbose("Unlocking LV %s%s%s", resource, origin_only ? " without snapshots" : "", revert ? " (reverting)" : ""); + if (!lv_resume_if_active(cmd, resource, origin_only, 0, revert)) return 0; break; case LCK_NULL: --- LVM2/lib/locking/locking.c 2011/09/27 17:09:43 1.99 +++ LVM2/lib/locking/locking.c 2011/09/27 22:43:41 1.100 @@ -493,6 +493,20 @@ return r; } +/* Unlock and revert list of LVs */ +int revert_lvs(struct cmd_context *cmd, struct dm_list *lvs) +{ + struct lv_list *lvl; + int r = 1; + + dm_list_iterate_items(lvl, lvs) + if (!revert_lv(cmd, lvl->lv)) { + r = 0; + stack; + } + + return r; +} /* * Lock a list of LVs. * On failure to lock any LV, calls vg_revert() if vg_to_revert is set and @@ -511,7 +525,7 @@ vg_revert(vg_to_revert); dm_list_uniterate(lvh, lvs, &lvl->list) { lvl = dm_list_item(lvh, struct lv_list); - if (!resume_lv(cmd, lvl->lv)) + if (!revert_lv(cmd, lvl->lv)) stack; } --- LVM2/lib/locking/locking.h 2011/09/27 17:09:43 1.68 +++ LVM2/lib/locking/locking.h 2011/09/27 22:43:41 1.69 @@ -97,6 +97,7 @@ #define LCK_CLUSTER_VG 0x00000080U /* VG is clustered */ #define LCK_CACHE 0x00000100U /* Operation on cache only using P_ lock */ #define LCK_ORIGIN_ONLY 0x00000200U /* Operation should bypass any snapshots */ +#define LCK_REVERT 0x00000400U /* Revert any incomplete change */ /* * Additional lock bits for cluster communication via args[1] @@ -107,6 +108,7 @@ #define LCK_CONVERT 0x08 /* Convert existing lock */ #define LCK_ORIGIN_ONLY_MODE 0x20 /* Same as above */ #define LCK_TEST_MODE 0x10 /* Test mode: No activation */ +#define LCK_REVERT_MODE 0x40 /* Remove inactive tables */ /* * Special cases of VG locks. @@ -164,6 +166,7 @@ #define resume_lv(cmd, lv) lock_lv_vol(cmd, lv, LCK_LV_RESUME) #define resume_lv_origin(cmd, lv) lock_lv_vol(cmd, lv, LCK_LV_RESUME | LCK_ORIGIN_ONLY) +#define revert_lv(cmd, lv) lock_lv_vol(cmd, lv, LCK_LV_RESUME | LCK_REVERT) #define suspend_lv(cmd, lv) lock_lv_vol(cmd, lv, LCK_LV_SUSPEND | LCK_HOLD) #define suspend_lv_origin(cmd, lv) lock_lv_vol(cmd, lv, LCK_LV_SUSPEND | LCK_HOLD | LCK_ORIGIN_ONLY) #define deactivate_lv(cmd, lv) lock_lv_vol(cmd, lv, LCK_LV_DEACTIVATE) @@ -191,6 +194,7 @@ int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs, struct volume_group *vg_to_revert); int resume_lvs(struct cmd_context *cmd, struct dm_list *lvs); +int revert_lvs(struct cmd_context *cmd, struct dm_list *lvs); int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs, unsigned exclusive); /* Interrupt handling */ --- LVM2/lib/locking/no_locking.c 2011/08/09 11:44:57 1.29 +++ LVM2/lib/locking/no_locking.c 2011/09/27 22:43:41 1.30 @@ -46,7 +46,7 @@ case LCK_NULL: return lv_deactivate(cmd, resource); case LCK_UNLOCK: - return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0); + return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0); case LCK_READ: return lv_activate_with_filter(cmd, resource, 0); case LCK_WRITE: --- LVM2/libdm/libdm-deptree.c 2011/09/26 10:17:52 1.112 +++ LVM2/libdm/libdm-deptree.c 2011/09/27 22:43:41 1.113 @@ -610,6 +610,8 @@ if (!info->exists || !info->inactive_table) return 1; +// FIXME Get inactive deps. If any dev referenced has 1 opener and no live table, remove it after the clear. + log_verbose("Clearing inactive table %s (%" PRIu32 ":%" PRIu32 ")", name, info->major, info->minor); --- LVM2/tools/pvmove.c 2011/09/27 17:29:33 1.89 +++ LVM2/tools/pvmove.c 2011/09/27 22:43:42 1.90 @@ -370,13 +370,19 @@ if (!_suspend_lvs(cmd, first_time, lv_mirr, lvs_changed, vg)) { log_error("ABORTING: Volume group metadata update failed."); - goto out; + if (!first_time && !revert_lv(cmd, lv_mirr)) + stack; + return 0; } /* Commit on-disk metadata */ if (!vg_commit(vg)) { log_error("ABORTING: Volume group metadata update failed."); - goto out; + if (!_resume_lvs(cmd, first_time, lv_mirr, lvs_changed)) + stack; + if (!first_time && !revert_lv(cmd, lv_mirr)) + stack; + return 0; } /* Activate the temporary mirror LV */ @@ -403,7 +409,9 @@ if (!_resume_lvs(cmd, first_time, lv_mirr, lvs_changed)) r = 0; - backup(vg); + if (r) + backup(vg); + return r; } @@ -546,6 +554,8 @@ /* Suspend LVs changed (implicitly suspends lv_mirr) */ if (!suspend_lvs(cmd, lvs_changed, vg)) { log_error("ABORTING: Locking LVs to remove temporary mirror failed"); + if (!revert_lv(cmd, lv_mirr)) + stack; return 0; } @@ -553,9 +563,9 @@ if (!vg_commit(vg)) { log_error("ABORTING: Failed to write new data locations " "to disk."); - if (!resume_lv(cmd, lv_mirr)) + if (!revert_lv(cmd, lv_mirr)) stack; - if (!resume_lvs(cmd, lvs_changed)) + if (!revert_lvs(cmd, lvs_changed)) stack; return 0; } From jbrassow@sourceware.org Wed Sep 28 16:32:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Wed, 28 Sep 2011 16:32:00 -0000 Subject: LVM2/scripts gdbinit Message-ID: <20110928163223.29878.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-09-28 16:32:22 Modified files: scripts : gdbinit Log message: New handy gdb debugging function, "dm_list_size" Example: (gdb) dm_list_size &split_images 1 list items Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/gdbinit.diff?cvsroot=lvm2&r1=1.10&r2=1.11 --- LVM2/scripts/gdbinit 2011/09/13 13:57:02 1.10 +++ LVM2/scripts/gdbinit 2011/09/28 16:32:22 1.11 @@ -16,6 +16,7 @@ printf "\n\n" printf "Loading commands:\n" +printf " - dm_list_size \n" printf " - first_seg \n" printf " - lv_status \n" printf " - lv_status_r \n" @@ -27,8 +28,8 @@ printf "Use 'help ' for more info\n" printf "\n\n" printf "Popular breakpoints:\n" -printf "break _raid_add_images\n" -printf "run --type raid1 -m 1 vg/lv\n" +printf "break _get_udev_flags\n" +printf "run --splitmirrors 1 -n split vg/lv\n" printf "\n\n" set follow-fork-mode child @@ -40,6 +41,24 @@ # External functions should have a corresponding 'document' # section. Internal functions should have leading comments +define dm_list_size + set $_DLS_list_head = (struct dm_list *)$arg0 + set $_DLS_list = $_DLS_list_head->n + set $_DLS_size = 0 + + while (($_DLS_list != $_DLS_list_head) && ($_DLS_size < 100)) + set $_DLS_list = $_DLS_list->n + set $_DLS_size++ + end + + printf "%d list items\n", $_DLS_size +end + +document dm_list_size +Returns the number of elements in the dm_list + + Usage: dm_list_size +end # # __first_seg From zkabelac@sourceware.org Thu Sep 29 08:51:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 29 Sep 2011 08:51:00 -0000 Subject: LVM2/libdm libdm-deptree.c Message-ID: <20110929085056.13681.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-29 08:50:55 Modified files: libdm : libdm-deptree.c Log message: Just add warning about potential problem exteding dm_segtypes Since raid target is using now dm_segtypes also for search purpose. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114 --- LVM2/libdm/libdm-deptree.c 2011/09/27 22:43:41 1.113 +++ LVM2/libdm/libdm-deptree.c 2011/09/29 08:50:54 1.114 @@ -80,6 +80,11 @@ { SEG_RAID6_ZR, "raid6_zr"}, { SEG_RAID6_NR, "raid6_nr"}, { SEG_RAID6_NC, "raid6_nc"}, + + /* + *WARNING: Since 'raid' target overloads this 1:1 mapping table + * for search do not add new enum elements past them! + */ { SEG_RAID5_LS, "raid5"}, /* same as "raid5_ls" (default for MD also) */ { SEG_RAID6_ZR, "raid6"}, /* same as "raid6_zr" */ { SEG_LAST, NULL }, From zkabelac@sourceware.org Thu Sep 29 08:53:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 29 Sep 2011 08:53:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm ... Message-ID: <20110929085349.14351.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-29 08:53:49 Modified files: . : WHATS_NEW_DM libdm : libdevmapper.h libdm-deptree.c Log message: Add supporting function for thinp New dm_tree_node_add_thin_pool_target() and dm_tree_node_add_thin_target() This API is highly experimental and unstable for now. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.507&r2=1.508 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.153&r2=1.154 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115 --- LVM2/WHATS_NEW_DM 2011/09/25 19:38:59 1.507 +++ LVM2/WHATS_NEW_DM 2011/09/29 08:53:48 1.508 @@ -1,5 +1,6 @@ Version 1.02.68 - ================================== + Add functions to support thin provisioning target (API unstable). Improve libdm-config error path reporting. Update dmsetup resume man with --addnodeonresume/create options. Add dependency for dm man pages to man subdirectory make target all:. --- LVM2/libdm/libdevmapper.h 2011/09/22 17:36:50 1.153 +++ LVM2/libdm/libdevmapper.h 2011/09/29 08:53:48 1.154 @@ -535,6 +535,22 @@ uint32_t slog_region_size); /* End of Replicator API */ +/* API for thin provisioning is experimental, DO NOT USE. */ +int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, + uint64_t size, + uint64_t transation_id, + const char *pool_uuid, + const char *metadata_uuid, + uint32_t data_block_size, + uint64_t low_water_mark, + unsigned skip_block_zeroeing); /* Maybe separate _set_ call ? */ + +int dm_tree_node_add_thin_target(struct dm_tree_node *node, + uint64_t size, + uint64_t transation_id, + const char *thin_pool_uuid, + uint32_t device_id); + void dm_tree_node_set_presuspend_node(struct dm_tree_node *node, struct dm_tree_node *presuspend_node); --- LVM2/libdm/libdm-deptree.c 2011/09/29 08:50:54 1.114 +++ LVM2/libdm/libdm-deptree.c 2011/09/29 08:53:48 1.115 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Red Hat, Inc. All rights reserved. + * Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved. * * This file is part of the device-mapper userspace tools. * @@ -29,6 +29,12 @@ #define REPLICATOR_LOCAL_SITE 0 +#define THIN_MIN_DATA_SIZE 128 +#define THIN_MAX_DATA_SIZE 2097152 +#define THIN_MAX_DEVICE_ID ((1 << 24) - 1) + +#define QUOTE(x) #x + /* Supported segment types */ enum { SEG_CRYPT, @@ -42,6 +48,8 @@ SEG_SNAPSHOT_MERGE, SEG_STRIPED, SEG_ZERO, + SEG_THIN_POOL, + SEG_THIN, SEG_RAID1, SEG_RAID4, SEG_RAID5_LA, @@ -71,6 +79,8 @@ { SEG_SNAPSHOT_MERGE, "snapshot-merge" }, { SEG_STRIPED, "striped" }, { SEG_ZERO, "zero"}, + { SEG_THIN_POOL, "thin-pool"}, + { SEG_THIN, "thin"}, { SEG_RAID1, "raid1"}, { SEG_RAID4, "raid4"}, { SEG_RAID5_LA, "raid5_la"}, @@ -156,6 +166,14 @@ uint64_t rdevice_index; /* Replicator-dev */ uint64_t rebuilds; /* raid */ + + struct dm_tree_node *metadata; /* Thin_pool */ + struct dm_tree_node *pool; /* Thin_pool, Thin */ + uint32_t data_block_size; /* Thin_pool */ + uint64_t low_water_mark; /* Thin_pool */ + unsigned skip_block_zeroeing; /* Thin_pool */ + uint32_t device_id; /* Thin */ + }; /* Per-device properties */ @@ -1825,6 +1843,7 @@ int r; int target_type_is_raid = 0; char originbuf[DM_FORMAT_DEV_BUFSIZE], cowbuf[DM_FORMAT_DEV_BUFSIZE]; + char pool[DM_FORMAT_DEV_BUFSIZE], metadata[DM_FORMAT_DEV_BUFSIZE]; switch(seg->type) { case SEG_ERROR: @@ -1892,6 +1911,20 @@ return_0; break; + case SEG_THIN_POOL: + if (!_build_dev_string(metadata, sizeof(metadata), seg->metadata)) + return_0; + if (!_build_dev_string(pool, sizeof(pool), seg->pool)) + return_0; + EMIT_PARAMS(pos, "%s %s %d %" PRIu64 " %s", metadata, pool, + seg->data_block_size, seg->low_water_mark, + seg->skip_block_zeroeing ? "1 skip_block_zeroing" : ""); + break; + case SEG_THIN: + if (!_build_dev_string(pool, sizeof(pool), seg->pool)) + return_0; + EMIT_PARAMS(pos, "%s %d", pool, seg->device_id); + break; } switch(seg->type) { @@ -1901,6 +1934,8 @@ case SEG_SNAPSHOT_ORIGIN: case SEG_SNAPSHOT_MERGE: case SEG_ZERO: + case SEG_THIN_POOL: + case SEG_THIN: break; case SEG_CRYPT: case SEG_LINEAR: @@ -2602,6 +2637,85 @@ return 1; } +int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, + uint64_t size, + uint64_t transation_id, + const char *pool_uuid, + const char *metadata_uuid, + uint32_t data_block_size, + uint64_t low_water_mark, + unsigned skip_block_zeroeing) +{ + struct load_segment *seg; + + if (data_block_size < THIN_MIN_DATA_SIZE) { + log_error("Data block size %d is lower then " + QUOTE(THIN_MIN_DATA_SIZE) " sectors.", + data_block_size); + return 0; + } + + if (data_block_size > THIN_MAX_DATA_SIZE) { + log_error("Data block size %d is higher then " + QUOTE(THIN_MAX_DATA_SIZE) " sectors.", + data_block_size); + return 0; + } + + if (!(seg = _add_segment(node, SEG_THIN_POOL, size))) + return_0; + + if (!(seg->metadata = dm_tree_find_node_by_uuid(node->dtree, metadata_uuid))) { + log_error("Missing metadata uuid %s.", metadata_uuid); + return 0; + } + + if (!_link_tree_nodes(node, seg->metadata)) + return_0; + + if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree, pool_uuid))) { + log_error("Missing pool uuid %s.", pool_uuid); + return 0; + } + + if (!_link_tree_nodes(node, seg->pool)) + return_0; + + seg->data_block_size = data_block_size; + seg->low_water_mark = low_water_mark; + seg->skip_block_zeroeing = skip_block_zeroeing; + + return 1; +} + +int dm_tree_node_add_thin_target(struct dm_tree_node *node, + uint64_t size, + uint64_t transation_id, + const char *thin_pool_uuid, + uint32_t device_id) +{ + struct load_segment *seg; + + if (device_id > THIN_MAX_DEVICE_ID) { + log_error("Device id %d is higher then " QUOTE(THIN_MAX_DEVICE_ID) ".", + device_id); + return 0; + } + + if (!(seg = _add_segment(node, SEG_THIN, size))) + return_0; + + if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree, thin_pool_uuid))) { + log_error("Missing thin pool uuid %s.", thin_pool_uuid); + return 0; + } + + if (!_link_tree_nodes(node, seg->pool)) + return_0; + + return 1; +} + static int _add_area(struct dm_tree_node *node, struct load_segment *seg, struct dm_tree_node *dev_node, uint64_t offset) { struct seg_area *area; From zkabelac@sourceware.org Thu Sep 29 08:56:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 29 Sep 2011 08:56:00 -0000 Subject: LVM2/lib activate/dev_manager.c metadata/lv_ma ... Message-ID: <20110929085640.15316.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-29 08:56:39 Modified files: lib/activate : dev_manager.c lib/metadata : lv_manip.c merge.c metadata-exported.h lib/thin : thin.c Log message: Add experimental code for activation of thinp targets No dm messages yes - just a base functionality in the steps of other targets. For now usable only for debugging and tracing. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.233&r2=1.234 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.291&r2=1.292 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.212&r2=1.213 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13 --- LVM2/lib/activate/dev_manager.c 2011/09/27 22:43:41 1.233 +++ LVM2/lib/activate/dev_manager.c 2011/09/29 08:56:38 1.234 @@ -1485,7 +1485,13 @@ } else if (lv_is_cow(seg->lv) && !layer) { if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, laopts, "cow")) return_0; + } else if (lv_is_thin_volume(seg->lv)) { + if (!_add_new_lv_to_dtree(dm, dtree, seg->pool_lv, laopts, NULL)) + return_0; } else { + if (lv_is_thin_pool(seg->lv) && + !_add_new_lv_to_dtree(dm, dtree, seg->pool_metadata_lv, laopts, NULL)) + return_0; /* Add any LVs used by this segment */ for (s = 0; s < seg->area_count; s++) { if ((seg_type(seg, s) == AREA_LV) && --- LVM2/lib/metadata/lv_manip.c 2011/09/27 17:09:43 1.291 +++ LVM2/lib/metadata/lv_manip.c 2011/09/29 08:56:38 1.292 @@ -2602,9 +2602,17 @@ r = _lv_extend_layered_lv(ah, lv, extents, 0, stripes, stripe_size); - if (r && segtype_is_thin_pool(segtype)) - r = lv_add_segment(ah, ah->area_count, 1, first_seg(lv)->pool_metadata_lv, - get_segtype_from_string(lv->vg->cmd, "striped"), 0, 0, 0); + if (r && segtype_is_thin_pool(segtype)) { + /* FIXME: resize metadata size here for now */ + struct logical_volume *tmeta = first_seg(lv)->pool_metadata_lv; + if ((r = lv_add_segment(ah, ah->area_count, 1, tmeta, + get_segtype_from_string(lv->vg->cmd, "striped"), 0, 0, 0))) { + if (!(r = lv_extend(tmeta, first_seg(tmeta)->segtype, + 1, 0, 1, 0, 10, NULL, allocatable_pvs, ALLOC_INHERIT))) + stack; + } else + stack; + } } alloc_destroy(ah); return r; @@ -4106,6 +4114,13 @@ if (seg_is_thin_pool(lp) && lp->zero) first_seg(lv)->zero_new_blocks = 1; + if (seg_is_thin_pool(lp)) { + /* FIXME: add lvcreate params - maybe -c/--chunksize?, + * use lowwatermark via lvm.conf global for all thinpools ?*/ + first_seg(lv)->data_block_size = 128; + first_seg(lv)->low_water_mark = 4096; + } + if (lp->log_count && !seg_is_raid(first_seg(lv)) && seg_is_mirrored(first_seg(lv))) { if (!add_mirror_log(cmd, lv, lp->log_count, --- LVM2/lib/metadata/merge.c 2011/09/16 11:53:14 1.49 +++ LVM2/lib/metadata/merge.c 2011/09/29 08:56:39 1.50 @@ -201,6 +201,12 @@ lv->name, seg_count); inc_error_count; } + + if (seg->data_block_size < 128 || seg->data_block_size > 2097152) { + log_error("LV %s: thin pool segment %u data block size %d is out of range", + lv->name, seg_count, seg->data_block_size); + inc_error_count; + } } else { if (seg->pool_metadata_lv) { log_error("LV %s: segment %u must not have thin pool metadata LV set", @@ -231,6 +237,12 @@ lv->name, seg_count); inc_error_count; } + + if (seg->device_id >= (1 << 24)) { + log_error("LV %s: thin volume segment %u pool LV to large device id %d", + lv->name, seg_count, seg->device_id); + inc_error_count; + } } else { if (seg->pool_lv) { log_error("LV %s: segment %u must not have thin pool LV set", --- LVM2/lib/metadata/metadata-exported.h 2011/09/27 17:09:43 1.212 +++ LVM2/lib/metadata/metadata-exported.h 2011/09/29 08:56:39 1.213 @@ -335,9 +335,11 @@ struct lv_segment_area *meta_areas; /* For RAID */ struct logical_volume *pool_metadata_lv;/* For thin_pool */ uint64_t transaction_id; /* For thin_pool */ - uint32_t zero_new_blocks; /* For thin_pool */ + uint64_t low_water_mark; /* For thin_pool */ + uint32_t data_block_size; /* For thin_pool, 128..2097152 */ + unsigned zero_new_blocks; /* For thin_pool */ struct logical_volume *pool_lv; /* For thin */ - uint64_t device_id; /* For thin */ + uint32_t device_id; /* For thin, 24bit */ struct logical_volume *replicator;/* For replicator-devs - link to replicator LV */ struct logical_volume *rlog_lv; /* For replicators */ --- LVM2/lib/thin/thin.c 2011/09/08 16:41:19 1.12 +++ LVM2/lib/thin/thin.c 2011/09/29 08:56:39 1.13 @@ -70,6 +70,12 @@ if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id)) return SEG_LOG_ERROR("Could not read transaction_id for"); + if (!dm_config_get_uint64(sn, "low_water_mark", &seg->low_water_mark)) + return SEG_LOG_ERROR("Could not read low_water_mark"); + + if (!dm_config_get_uint32(sn, "data_block_size", &seg->data_block_size)) + return SEG_LOG_ERROR("Could not read data_block_size"); + if (dm_config_has_node(sn, "zero_new_blocks") && !dm_config_get_uint32(sn, "zero_new_blocks", &seg->zero_new_blocks)) return SEG_LOG_ERROR("Could not read zero_new_blocks for"); @@ -92,12 +98,45 @@ outf(f, "pool = \"%s\"", seg_lv(seg, 0)->name); outf(f, "metadata = \"%s\"", seg->pool_metadata_lv->name); outf(f, "transaction_id = %" PRIu64, seg->transaction_id); + outf(f, "low_water_mark = %" PRIu64, seg->low_water_mark); + outf(f, "data_block_size = %d", seg->data_block_size); if (seg->zero_new_blocks) outf(f, "zero_new_blocks = 1"); return 1; } +#ifdef DEVMAPPER_SUPPORT +static int _thin_pool_add_target_line(struct dev_manager *dm, + struct dm_pool *mem __attribute__((unused)), + struct cmd_context *cmd __attribute__((unused)), + void **target_state __attribute__((unused)), + struct lv_segment *seg, + const struct lv_activate_opts *laopts __attribute__((unused)), + struct dm_tree_node *node, uint64_t len, + uint32_t *pvmove_mirror_count __attribute__((unused))) +{ + char *metadata_dlid, *pool_dlid; + + if (!(metadata_dlid = build_dm_uuid(mem, seg->pool_metadata_lv->lvid.s, NULL))) { + log_error("Failed to build uuid for metadata LV %s.", seg->pool_metadata_lv->name); + return 0; + } + + if (!(pool_dlid = build_dm_uuid(mem, seg_lv(seg, 0)->lvid.s, NULL))) { + log_error("Failed to build uuid for pool LV %s.", seg_lv(seg, 0)->name); + return 0; + } + + if (!dm_tree_node_add_thin_pool_target(node, len, 0, metadata_dlid, pool_dlid, + seg->data_block_size, seg->low_water_mark, + seg->zero_new_blocks ? 0 : 1)) + return_0; + + return 1; +} +#endif + static const char *_thin_name(const struct lv_segment *seg) { return seg->segtype->name; @@ -126,7 +165,7 @@ return SEG_LOG_ERROR("Unknown origin %s in", lv_name); } - if (!dm_config_get_uint64(sn, "device_id", &seg->device_id)) + if (!dm_config_get_uint32(sn, "device_id", &seg->device_id)) return SEG_LOG_ERROR("Could not read device_id for"); return 1; @@ -135,7 +174,7 @@ static int _thin_text_export(const struct lv_segment *seg, struct formatter *f) { outf(f, "thin_pool = \"%s\"", seg->pool_lv->name); - outf(f, "device_id = %" PRIu64, seg->device_id); + outf(f, "device_id = %d", seg->device_id); if (seg->origin) outf(f, "origin = \"%s\"", seg->origin->name); @@ -144,6 +183,28 @@ } #ifdef DEVMAPPER_SUPPORT +static int _thin_add_target_line(struct dev_manager *dm, + struct dm_pool *mem __attribute__((unused)), + struct cmd_context *cmd __attribute__((unused)), + void **target_state __attribute__((unused)), + struct lv_segment *seg, + const struct lv_activate_opts *laopts __attribute__((unused)), + struct dm_tree_node *node, uint64_t len, + uint32_t *pvmove_mirror_count __attribute__((unused))) +{ + char *thin_pool_dlid; + + if (!(thin_pool_dlid = build_dm_uuid(mem, seg->pool_lv->lvid.s, NULL))) { + log_error("Failed to build uuid for thin pool LV %s.", seg->pool_lv->name); + return 0; + } + + if (!dm_tree_node_add_thin_target(node, len, 0, thin_pool_dlid, seg->device_id)) + return_0; + + return 1; +} + static int _thin_target_percent(void **target_state __attribute__((unused)), percent_t *percent, struct dm_pool *mem __attribute__((unused)), @@ -194,6 +255,10 @@ .text_import = _thin_pool_text_import, .text_import_area_count = _thin_pool_text_import_area_count, .text_export = _thin_pool_text_export, +#ifdef DEVMAPPER_SUPPORT + .add_target_line = _thin_pool_add_target_line, + .target_present = _thin_target_present, +#endif .modules_needed = _thin_modules_needed, .destroy = _thin_destroy, }; @@ -203,6 +268,7 @@ .text_import = _thin_text_import, .text_export = _thin_text_export, #ifdef DEVMAPPER_SUPPORT + .add_target_line = _thin_add_target_line, .target_percent = _thin_target_percent, .target_present = _thin_target_present, #endif From zkabelac@sourceware.org Thu Sep 29 08:57:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 29 Sep 2011 08:57:00 -0000 Subject: LVM2/daemons/clvmd clvmd-singlenode.c Message-ID: <20110929085723.16221.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-29 08:57:22 Modified files: daemons/clvmd : clvmd-singlenode.c Log message: Typo in debug message Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-singlenode.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13 --- LVM2/daemons/clvmd/clvmd-singlenode.c 2011/09/25 19:37:00 1.12 +++ LVM2/daemons/clvmd/clvmd-singlenode.c 2011/09/29 08:57:21 1.13 @@ -56,7 +56,7 @@ } /* Set Close-on-exec */ if (fcntl(listen_fd, F_SETFD, 1)) { - DEBUGLOG("Setting CLOEXEC on client fd faile: %s\n", strerror(errno)); + DEBUGLOG("Setting CLOEXEC on client fd failed: %s\n", strerror(errno)); goto error; } From zkabelac@sourceware.org Thu Sep 29 08:58:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 29 Sep 2011 08:58:00 -0000 Subject: LVM2/test t-clvmd-restart.sh Message-ID: <20110929085828.17291.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-29 08:58:27 Modified files: test : t-clvmd-restart.sh Log message: Let the utils to prepare PVs Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-clvmd-restart.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/test/t-clvmd-restart.sh 2011/09/26 07:51:24 1.2 +++ LVM2/test/t-clvmd-restart.sh 2011/09/29 08:58:27 1.3 @@ -19,7 +19,7 @@ test -e LOCAL_CLVMD || skip read LOCAL_CLVMD < LOCAL_CLVMD -aux prepare_devs 1 +aux prepare_pvs 1 vgcreate --clustered y $vg $(cat DEVICES) From zkabelac@sourceware.org Thu Sep 29 09:03:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 29 Sep 2011 09:03:00 -0000 Subject: LVM2/lib/metadata merge.c Message-ID: <20110929090336.18702.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-29 09:03:36 Modified files: lib/metadata : merge.c Log message: Fix bad error message for thinp validation Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51 --- LVM2/lib/metadata/merge.c 2011/09/29 08:56:39 1.50 +++ LVM2/lib/metadata/merge.c 2011/09/29 09:03:36 1.51 @@ -239,7 +239,7 @@ } if (seg->device_id >= (1 << 24)) { - log_error("LV %s: thin volume segment %u pool LV to large device id %d", + log_error("LV %s: thin volume segment %u has too large device id %d", lv->name, seg_count, seg->device_id); inc_error_count; }