From prajnoha@sourceware.org Wed Jun 1 12:24:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Wed, 01 Jun 2011 12:24:00 -0000 Subject: LVM2 ./WHATS_NEW tools/lvconvert.c Message-ID: <20110601122417.22472.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-06-01 12:24:16 Modified files: . : WHATS_NEW tools : lvconvert.c Log message: Clarify error message when unable to convert an LV into a snapshot of an LV. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2000&r2=1.2001 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.162&r2=1.163 --- LVM2/WHATS_NEW 2011/05/24 14:12:36 1.2000 +++ LVM2/WHATS_NEW 2011/06/01 12:24:15 1.2001 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Clarify error message when unable to convert an LV into a snapshot of an LV. Add and use dev_open_readonly and variations. Do not log a superfluous stack message when the lv is properly processed. Do not issue an error message when unable to remove .cache on read-only fs. --- LVM2/tools/lvconvert.c 2011/05/07 13:56:13 1.162 +++ LVM2/tools/lvconvert.c 2011/06/01 12:24:16 1.163 @@ -1391,7 +1391,7 @@ } if (org->status & (LOCKED|PVMOVE|MIRRORED) || lv_is_cow(org)) { - log_error("Unable to create a snapshot of a %s LV.", + log_error("Unable to convert an LV into a snapshot of a %s LV.", org->status & LOCKED ? "locked" : org->status & PVMOVE ? "pvmove" : org->status & MIRRORED ? "mirrored" : From agk@sourceware.org Wed Jun 1 15:30:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 01 Jun 2011 15:30:00 -0000 Subject: LVM2 ./WHATS_NEW lib/label/label.c Message-ID: <20110601153037.16927.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-01 15:30:36 Modified files: . : WHATS_NEW lib/label : label.c Log message: Report sector containing label in verbose message. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2001&r2=1.2002 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/label/label.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54 --- LVM2/WHATS_NEW 2011/06/01 12:24:15 1.2001 +++ LVM2/WHATS_NEW 2011/06/01 15:30:36 1.2002 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Report sector containing label in verbose message. Clarify error message when unable to convert an LV into a snapshot of an LV. Add and use dev_open_readonly and variations. Do not log a superfluous stack message when the lv is properly processed. --- LVM2/lib/label/label.c 2011/05/28 09:48:16 1.53 +++ LVM2/lib/label/label.c 2011/06/01 15:30:36 1.54 @@ -156,8 +156,10 @@ dm_list_iterate_items(li, &_labellers) { if (li->l->ops->can_handle(li->l, (char *) lh, sector + scan_sector)) { - log_very_verbose("%s: %s label detected", - dev_name(dev), li->name); + log_very_verbose("%s: %s label detected at " + "sector %" PRIu64, + dev_name(dev), li->name, + sector + scan_sector); if (found) { log_error("Ignoring additional label " "on %s at sector %" PRIu64, From agk@sourceware.org Wed Jun 1 19:21:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 01 Jun 2011 19:21:00 -0000 Subject: LVM2 tools/commands.h tools/tools.h tools/lvcr ... Message-ID: <20110601192106.21049.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-01 19:21:04 Modified files: tools : commands.h tools.h lvcreate.c man : lvcreate.8.in . : WHATS_NEW lib/metadata : metadata-exported.h lv_manip.c liblvm : lvm_lv.c Log message: Permit --available with lvcreate so non-snapshot LVs need not be activated. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.157&r2=1.158 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.74&r2=1.75 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.230&r2=1.231 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvcreate.8.in.diff?cvsroot=lvm2&r1=1.18&r2=1.19 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2002&r2=1.2003 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.191&r2=1.192 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.258&r2=1.259 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36 --- LVM2/tools/commands.h 2010/10/25 11:20:56 1.157 +++ LVM2/tools/commands.h 2011/06/01 19:21:03 1.158 @@ -148,6 +148,7 @@ 0, "lvcreate " "\n" "\t[-A|--autobackup {y|n}]\n" + "\t[-a|--available [e|l]y|n]\n" "\t[--addtag Tag]\n" "\t[--alloc AllocationPolicy]\n" "\t[-C|--contiguous {y|n}]\n" @@ -198,12 +199,12 @@ "\t[PhysicalVolumePath...]\n\n", - addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG, - corelog_ARG, extents_ARG, ignoremonitoring_ARG, major_ARG, 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) + addtag_ARG, alloc_ARG, autobackup_ARG, available_ARG, chunksize_ARG, + contiguous_ARG, corelog_ARG, extents_ARG, ignoremonitoring_ARG, major_ARG, + 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) xx(lvdisplay, "Display information about a logical volume", --- LVM2/tools/tools.h 2010/11/30 11:53:33 1.74 +++ LVM2/tools/tools.h 2011/06/01 19:21:03 1.75 @@ -87,14 +87,6 @@ PERCENT_ORIGIN } percent_type_t; -enum { - CHANGE_AY = 0, - CHANGE_AN = 1, - CHANGE_AE = 2, - CHANGE_ALY = 3, - CHANGE_ALN = 4 -}; - #define ARG_COUNTABLE 0x00000001 /* E.g. -vvvv */ #define ARG_GROUPABLE 0x00000002 /* E.g. --addtag */ --- LVM2/tools/lvcreate.c 2011/03/25 21:56:28 1.230 +++ LVM2/tools/lvcreate.c 2011/06/01 19:21:03 1.231 @@ -429,12 +429,21 @@ !_read_mirror_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->activate == CHANGE_AN || lp->activate == CHANGE_ALN) { + if (lp->zero) { + log_error("--available n requires --zero n"); + return 0; + } + } + /* * Alloc policy */ --- LVM2/man/lvcreate.8.in 2010/05/28 03:50:18 1.18 +++ LVM2/man/lvcreate.8.in 2011/06/01 19:21:04 1.19 @@ -5,6 +5,7 @@ .B lvcreate [\-\-addtag Tag] [\-\-alloc AllocationPolicy] +[\-a|\-\-available y|n|ey|en|ly|ln] [\-A|\-\-autobackup y|n] [\-C|\-\-contiguous y|n] [\-d|\-\-debug] [\-h|\-?|\-\-help] [\-\-noudevsync] [\-\-ignoremonitoring] @@ -55,6 +56,18 @@ .SH OPTIONS See \fBlvm\fP for common options. .TP +.I \-a, \-\-available y|n|ey|en|ly|ln +Controls the availability of the Logical Volumes for immediate use after +the command finishes running. +By default, new Logical Volumes are activated automatically (-ay). +If it is possible technically, -an will leave the new Logical Volume inactive. +But for example, snapshots can only be created +in the active state so -an cannot be used with --snapshot. +Normally the --zero n argument has to be supplied too because zeroing (the +default behaviour) also requires activation. +If clustered locking is enabled, -aey will activate exclusively +on one node and -aly will activate only on the local node. +.TP .I \-c, \-\-chunksize ChunkSize Power of 2 chunk size for the snapshot logical volume between 4k and 512k. .TP --- LVM2/WHATS_NEW 2011/06/01 15:30:36 1.2002 +++ LVM2/WHATS_NEW 2011/06/01 19:21:04 1.2003 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Permit --available with lvcreate so non-snapshot LVs need not be activated. Report sector containing label in verbose message. Clarify error message when unable to convert an LV into a snapshot of an LV. Add and use dev_open_readonly and variations. --- LVM2/lib/metadata/metadata-exported.h 2011/05/07 13:32:05 1.191 +++ LVM2/lib/metadata/metadata-exported.h 2011/06/01 19:21:04 1.192 @@ -78,6 +78,7 @@ #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 */ @@ -360,7 +361,8 @@ struct physical_volume *pvcreate_single(struct cmd_context *cmd, const char *pv_name, - struct pvcreate_params *pp); + struct pvcreate_params *pp, + int write_now); void pvcreate_params_set_defaults(struct pvcreate_params *pp); /* @@ -372,7 +374,7 @@ 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, - uint64_t *label_sector, int warnings, + int warnings, int scan_label_only); struct dm_list *get_pvs(struct cmd_context *cmd); @@ -519,6 +521,17 @@ uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size, uint32_t extent_size); +/* + * Activation options + */ +typedef enum { + CHANGE_AY = 0, + CHANGE_AN = 1, + CHANGE_AE = 2, + CHANGE_ALY = 3, + CHANGE_ALN = 4 +} activation_change_t; + /* FIXME: refactor and reduce the size of this struct! */ struct lvcreate_params { /* flags */ @@ -529,6 +542,7 @@ int log_count; /* mirror */ int nosync; /* mirror */ int activation_monitoring; /* all */ + activation_change_t activate; /* non-snapshot, non-mirror */ char *origin; /* snap */ const char *vg_name; /* all */ --- LVM2/lib/metadata/lv_manip.c 2011/04/09 19:05:24 1.258 +++ LVM2/lib/metadata/lv_manip.c 2011/06/01 19:21:04 1.259 @@ -3711,7 +3711,9 @@ "exception store."); goto revert_new_lv; } - } else if (!activate_lv(cmd, lv)) { + } else if ((lp->activate == CHANGE_AY && !activate_lv(cmd, lv)) || + (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) goto deactivate_and_revert_new_lv; --- LVM2/liblvm/lvm_lv.c 2011/02/03 01:24:46 1.35 +++ LVM2/liblvm/lvm_lv.c 2011/06/01 19:21:04 1.36 @@ -111,6 +111,7 @@ lp->major = -1; lp->minor = -1; lp->activation_monitoring = DEFAULT_DMEVENTD_MONITOR; + lp->activate = CHANGE_AY; lp->vg_name = vg->name; lp->lv_name = lvname; /* FIXME: check this for safety */ lp->pvh = &vg->pvs; From agk@sourceware.org Wed Jun 1 19:26:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 01 Jun 2011 19:26:00 -0000 Subject: LVM2/lib/mm memlock.c Message-ID: <20110601192638.25194.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-01 19:26:38 Modified files: lib/mm : memlock.c Log message: Report sector containing label in verbose message. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42 --- LVM2/lib/mm/memlock.c 2011/04/29 00:21:15 1.41 +++ LVM2/lib/mm/memlock.c 2011/06/01 19:26:38 1.42 @@ -374,6 +374,8 @@ static void _lock_mem_if_needed(struct cmd_context *cmd) { + log_debug("Lock: Memlock counters: locked:%d critical:%d daemon:%d", + _mem_locked, _critical_section_count, _memlock_count_daemon); if (!_mem_locked && ((_critical_section_count + _memlock_count_daemon) == 1)) { _mem_locked = 1; @@ -383,8 +385,8 @@ static void _unlock_mem_if_possible(struct cmd_context *cmd) { - log_debug("UnlockMem l:%d cs:%d md:%d", _mem_locked, - _critical_section_count, _memlock_count_daemon); + log_debug("Unlock: Memlock counters: locked:%d critical:%d daemon:%d", + _mem_locked, _critical_section_count, _memlock_count_daemon); if (_mem_locked && !_critical_section_count && !_memlock_count_daemon) { From agk@sourceware.org Wed Jun 1 19:29:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 01 Jun 2011 19:29:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ... Message-ID: <20110601192944.28004.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-01 19:29:34 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lvmcache.h lib/format1 : format1.c import-export.c lib/format_text: format-text.c import_vsn1.c lib/metadata : metadata.c metadata.h pv.h vg.c vg.h tools : pvcreate.c pvremove.c pvresize.c toollib.c Log message: Defer writing PV labels to vg_write. Store label_sector only in struct physical_volume. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2003&r2=1.2004 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.38&r2=1.39 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.138&r2=1.139 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.180&r2=1.181 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.456&r2=1.457 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.243&r2=1.244 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/pv.h.diff?cvsroot=lvm2&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.h.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvremove.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.226&r2=1.227 --- LVM2/WHATS_NEW 2011/06/01 19:21:04 1.2003 +++ LVM2/WHATS_NEW 2011/06/01 19:29:31 1.2004 @@ -1,5 +1,7 @@ Version 2.02.86 - ================================= + Defer writing PV labels to vg_write. + Store label_sector only in struct physical_volume. Permit --available with lvcreate so non-snapshot LVs need not be activated. Report sector containing label in verbose message. Clarify error message when unable to convert an LV into a snapshot of an LV. --- LVM2/lib/cache/lvmcache.c 2011/04/21 13:15:26 1.110 +++ LVM2/lib/cache/lvmcache.c 2011/06/01 19:29:32 1.111 @@ -539,7 +539,7 @@ struct lvmcache_info *info; char *vgname; - if (!device_from_pvid(cmd, (const struct id *)pvid, NULL)) { + if (!device_from_pvid(cmd, (const struct id *)pvid, NULL, NULL)) { log_error("Couldn't find device with uuid %s.", pvid); return NULL; } @@ -769,31 +769,41 @@ return pvids; } -struct device *device_from_pvid(struct cmd_context *cmd, const struct id *pvid, - unsigned *scan_done_once) +static struct device *_device_from_pvid(const struct id *pvid, + uint64_t *label_sector) { - struct label *label; struct lvmcache_info *info; + struct label *label; - /* Already cached ? */ if ((info = info_from_pvid((const char *) pvid, 0))) { if (label_read(info->dev, &label, UINT64_C(0))) { info = (struct lvmcache_info *) label->info; - if (id_equal(pvid, (struct id *) &info->dev->pvid)) + if (id_equal(pvid, (struct id *) &info->dev->pvid)) { + if (label_sector) + *label_sector = label->sector; return info->dev; + } } } + return NULL; +} + +struct device *device_from_pvid(struct cmd_context *cmd, const struct id *pvid, + unsigned *scan_done_once, uint64_t *label_sector) +{ + struct device *dev; + + /* Already cached ? */ + dev = _device_from_pvid(pvid, label_sector); + if (dev) + return dev; lvmcache_label_scan(cmd, 0); /* Try again */ - if ((info = info_from_pvid((const char *) pvid, 0))) { - if (label_read(info->dev, &label, UINT64_C(0))) { - info = (struct lvmcache_info *) label->info; - if (id_equal(pvid, (struct id *) &info->dev->pvid)) - return info->dev; - } - } + dev = _device_from_pvid(pvid, label_sector); + if (dev) + return dev; if (critical_section() || (scan_done_once && *scan_done_once)) return NULL; @@ -803,13 +813,9 @@ *scan_done_once = 1; /* Try again */ - if ((info = info_from_pvid((const char *) pvid, 0))) { - if (label_read(info->dev, &label, UINT64_C(0))) { - info = (struct lvmcache_info *) label->info; - if (id_equal(pvid, (struct id *) &info->dev->pvid)) - return info->dev; - } - } + dev = _device_from_pvid(pvid, label_sector); + if (dev) + return dev; return NULL; } --- LVM2/lib/cache/lvmcache.h 2011/03/30 13:14:34 1.38 +++ LVM2/lib/cache/lvmcache.h 2011/06/01 19:29:32 1.39 @@ -99,7 +99,7 @@ struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only); const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid); struct device *device_from_pvid(struct cmd_context *cmd, const struct id *pvid, - unsigned *scan_done_once); + unsigned *scan_done_once, uint64_t *label_sector); const char *pvid_from_devname(struct cmd_context *cmd, const char *dev_name); char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid); --- LVM2/lib/format1/format1.c 2011/03/11 15:10:16 1.138 +++ LVM2/lib/format1/format1.c 2011/06/01 19:29:32 1.139 @@ -406,6 +406,8 @@ struct disk_list *dl; struct dm_list pvs; struct lvmcache_info *info; + int pe_count, pe_size, pe_start; + int r = 1; if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev, pv->vg_name, NULL, 0))) @@ -418,6 +420,10 @@ dm_list_init(&pvs); + pe_count = pv->pe_count; + pe_size = pv->pe_size; + pe_start = pv->pe_start; + /* Ensure any residual PE structure is gone */ pv->pe_size = pv->pe_count = 0; pv->pe_start = LVM1_PE_ALIGN; @@ -430,6 +436,8 @@ dl->mem = mem; dl->dev = pv->dev; + dm_list_init(&dl->uuids); + dm_list_init(&dl->lvds); if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv)) goto_bad; @@ -444,12 +452,18 @@ if (!write_disks(fmt, &pvs)) goto_bad; - dm_pool_destroy(mem); - return 1; + goto out; bad: + r = 0; + + out: + pv->pe_size = pe_size; + pv->pe_count = pe_count; + pv->pe_start = pe_start; + dm_pool_destroy(mem); - return 0; + return r; } static int _format1_vg_setup(struct format_instance *fid, struct volume_group *vg) --- LVM2/lib/format1/import-export.c 2011/03/13 23:05:48 1.117 +++ LVM2/lib/format1/import-export.c 2011/06/01 19:29:32 1.118 @@ -96,6 +96,8 @@ pv->pe_count = pvd->pe_total; pv->pe_alloc_count = 0; pv->pe_align = 0; + pv->is_labelled = 0; /* format1 PVs have no label */ + pv->label_sector = 0; /* Fix up pv size if missing or impossibly large */ if (!pv->size || pv->size > (1ULL << 62)) { @@ -149,7 +151,7 @@ memcpy(pvd->pv_uuid, pv->id.uuid, ID_LEN); - if (pv->vg_name && !is_orphan(pv)) { + if (pv->vg_name && !is_orphan(pv) && !(pv->status & UNLABELLED_PV)) { if (!_check_vg_name(pv->vg_name)) return_0; strncpy((char *)pvd->vg_name, pv->vg_name, sizeof(pvd->vg_name)); --- LVM2/lib/format_text/format-text.c 2011/05/28 09:48:15 1.180 +++ LVM2/lib/format_text/format-text.c 2011/06/01 19:29:33 1.181 @@ -45,10 +45,6 @@ uint32_t raw_metadata_buf_size; }; -struct text_fid_pv_context { - int64_t label_sector; -}; - struct dir_list { struct dm_list list; char dir[0]; @@ -1252,11 +1248,9 @@ /* Only for orphans */ static int _text_pv_write(const struct format_type *fmt, struct physical_volume *pv) { - struct text_fid_pv_context *fid_pv_tc; struct format_instance *fid = pv->fid; const char *pvid = (const char *) (*pv->old_id.uuid ? &pv->old_id : &pv->id); struct label *label; - int64_t label_sector; struct lvmcache_info *info; struct mda_context *mdac; struct metadata_area *mda; @@ -1271,15 +1265,7 @@ return_0; label = info->label; - - /* - * We can change the label sector for a - * plain PV that is not part of a VG only! - */ - if (fid && (!fid->type & FMT_INSTANCE_VG) && - (fid_pv_tc = (struct text_fid_pv_context *) pv->fid->private) && - ((label_sector = fid_pv_tc->label_sector) != -1)) - label->sector = label_sector; + label->sector = pv->label_sector; info->device_size = pv->size << SECTOR_SHIFT; info->fmt = fmt; @@ -1517,8 +1503,6 @@ unsigned long data_alignment_offset, struct physical_volume *pv) { - struct text_fid_pv_context *fid_pv_tc; - /* * Try to keep the value of PE start set to a firm value if requested. * This is usefull when restoring existing PE start value (backups etc.). @@ -1569,10 +1553,8 @@ return 0; } - if (label_sector != -1) { - fid_pv_tc = (struct text_fid_pv_context *) pv->fid->private; - fid_pv_tc->label_sector = label_sector; - } + if (label_sector != -1) + pv->label_sector = label_sector; return 1; } @@ -1735,16 +1717,9 @@ static int _create_pv_text_instance(struct format_instance *fid, const struct format_instance_ctx *fic) { - struct text_fid_pv_context *fid_pv_tc; struct lvmcache_info *info; - if (!(fid_pv_tc = (struct text_fid_pv_context *) - dm_pool_zalloc(fid->mem, sizeof(*fid_pv_tc)))) { - log_error("Couldn't allocate text_fid_pv_context."); - return 0; - } - fid_pv_tc->label_sector = -1; - fid->private = (void *) fid_pv_tc; + fid->private = NULL; if (!(fid->metadata_areas_index.array = dm_pool_zalloc(fid->mem, FMT_TEXT_MAX_MDAS_PER_PV * @@ -2332,7 +2307,7 @@ return 0; } - if (!(dev_area.dev = device_from_pvid(cmd, &id, NULL))) { + if (!(dev_area.dev = device_from_pvid(cmd, &id, NULL, NULL))) { char buffer[64] __attribute__((aligned(8))); if (!id_write_format(&id, buffer, sizeof(buffer))) --- LVM2/lib/format_text/import_vsn1.c 2011/04/29 19:06:17 1.87 +++ LVM2/lib/format_text/import_vsn1.c 2011/06/01 19:29:33 1.88 @@ -190,10 +190,13 @@ return 0; } + pv->is_labelled = 1; /* All format_text PVs are labelled. */ + /* * Convert the uuid into a device. */ - if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id, scan_done_once))) { + if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id, scan_done_once, + &pv->label_sector))) { char buffer[64] __attribute__((aligned(8))); if (!id_write_format(&pv->id, buffer, sizeof(buffer))) --- LVM2/lib/metadata/metadata.c 2011/05/07 13:32:05 1.456 +++ LVM2/lib/metadata/metadata.c 2011/06/01 19:29:33 1.457 @@ -38,7 +38,6 @@ struct dm_pool *pvmem, const char *pv_name, struct format_instance *fid, - uint64_t *label_sector, int warnings, int scan_label_only); static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd, @@ -192,6 +191,7 @@ * @vg - volume group to add to * @pv_name - name of the pv (to be removed) * @pv - physical volume to add to volume group + * @pp - physical volume creation params (OPTIONAL) * * Returns: * 0 - failure @@ -199,8 +199,9 @@ * FIXME: remove pv_name - obtain safely from pv */ int add_pv_to_vg(struct volume_group *vg, const char *pv_name, - struct physical_volume *pv) + struct physical_volume *pv, struct pvcreate_params *pp) { + struct pv_to_create *pvc; struct pv_list *pvl; struct format_instance *fid = vg->fid; struct dm_pool *mem = vg->vgmem; @@ -289,6 +290,16 @@ vg->extent_count += pv->pe_count; vg->free_count += pv->pe_count; + if (pv->status & UNLABELLED_PV) { + if (!(pvc = dm_pool_zalloc(mem, sizeof(*pvc)))) { + log_error("pv_to_create allocation for '%s' failed", pv_name); + return 0; + } + pvc->pv = pv; + pvc->pp = pp; + dm_list_add(&vg->pvs_to_create, &pvc->list); + } + return 1; } @@ -640,11 +651,11 @@ "physical volume", pv_name); return 0; } else if (!pv && pp) { - pv = pvcreate_single(vg->cmd, pv_name, pp); + pv = pvcreate_single(vg->cmd, pv_name, pp, 0); if (!pv) return 0; } - if (!add_pv_to_vg(vg, pv_name, pv)) { + if (!add_pv_to_vg(vg, pv_name, pv, pp)) { free_pv_fid(pv); return 0; } @@ -1318,7 +1329,7 @@ /* FIXME Check partition type is LVM unless --force is given */ /* Is there a pv here already? */ - pv = pv_read(cmd, name, NULL, 0, 0); + pv = pv_read(cmd, name, 0, 0); /* * If a PV has no MDAs it may appear to be an orphan until the @@ -1330,7 +1341,7 @@ free_pv_fid(pv); if (!scan_vgs_for_pvs(cmd, 0)) return_0; - pv = pv_read(cmd, name, NULL, 0, 0); + pv = pv_read(cmd, name, 0, 0); } /* Allow partial & exported VGs to be destroyed. */ @@ -1425,6 +1436,47 @@ pp->metadataignore = DEFAULT_PVMETADATAIGNORE; } + +static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_create *pvc) +{ + int zero = pvc->pp->zero; + struct physical_volume *pv = pvc->pv; + struct device *dev = pv->dev; + const char *pv_name = dev_name(dev); + + /* Wipe existing label first */ + if (!label_remove(pv_dev(pv))) { + log_error("Failed to wipe existing label on %s", pv_name); + return 0; + } + + if (zero) { + log_verbose("Zeroing start of device %s", pv_name); + if (!dev_open_quiet(dev)) { + log_error("%s not opened: device not zeroed", pv_name); + return 0; + } + + if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) { + log_error("%s not wiped: aborting", pv_name); + dev_close(dev); + return 0; + } + dev_close(dev); + } + + log_error("Writing physical volume data to disk \"%s\"", + pv_name); + + if (!(pv_write(cmd, pv, 1))) { + log_error("Failed to write physical volume \"%s\"", pv_name); + return 0; + } + + log_print("Physical volume \"%s\" successfully created", pv_name); + return 1; +} + /* * pvcreate_single() - initialize a device with PV label and metadata area * @@ -1438,7 +1490,8 @@ */ struct physical_volume * pvcreate_single(struct cmd_context *cmd, const char *pv_name, - struct pvcreate_params *pp) + struct pvcreate_params *pp, + int write_now) { struct physical_volume *pv = NULL; struct device *dev; @@ -1451,7 +1504,7 @@ pp = &default_pp; if (pp->idp) { - if ((dev = device_from_pvid(cmd, pp->idp, NULL)) && + if ((dev = device_from_pvid(cmd, pp->idp, NULL, NULL)) && (dev != dev_cache_get(pv_name, cmd->filter))) { if (!id_write_format((const struct id*)&pp->idp->uuid, buffer, sizeof(buffer))) @@ -1475,6 +1528,7 @@ } dm_list_init(&mdas); + if (!(pv = pv_create(cmd, dev, pp->idp, pp->size, pp->data_alignment, pp->data_alignment_offset, pp->pe_start ? pp->pe_start : PV_PE_START_CALC, @@ -1488,37 +1542,16 @@ log_verbose("Set up physical volume for \"%s\" with %" PRIu64 " available sectors", pv_name, pv_size(pv)); - /* Wipe existing label first */ - if (!label_remove(pv_dev(pv))) { - log_error("Failed to wipe existing label on %s", pv_name); - goto bad; - } - - if (pp->zero) { - log_verbose("Zeroing start of device %s", pv_name); - if (!dev_open_quiet(dev)) { - log_error("%s not opened: device not zeroed", pv_name); - goto bad; - } - - if (!dev_set(dev, UINT64_C(0), (size_t) 2048, 0)) { - log_error("%s not wiped: aborting", pv_name); - dev_close(dev); + if (write_now) { + struct pv_to_create pvc; + pvc.pp = pp; + pvc.pv = pv; + if (!_pvcreate_write(cmd, &pvc)) goto bad; - } - dev_close(dev); - } - - log_very_verbose("Writing physical volume data to disk \"%s\"", - pv_name); - - if (!(pv_write(cmd, pv, 0))) { - log_error("Failed to write physical volume \"%s\"", pv_name); - goto bad; + } else { + pv->status |= UNLABELLED_PV; } - log_print("Physical volume \"%s\" successfully created", pv_name); - return pv; bad: @@ -1815,7 +1848,7 @@ { struct physical_volume *pv; - if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) { + if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0))) { log_error("Physical volume %s not found", pv_name); goto bad; } @@ -1825,7 +1858,7 @@ if (!scan_vgs_for_pvs(cmd, 1)) goto_bad; free_pv_fid(pv); - if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) { + if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0))) { log_error("Physical volume %s not found", pv_name); goto bad; } @@ -2470,6 +2503,7 @@ int vg_write(struct volume_group *vg) { struct dm_list *mdah; + struct pv_to_create *pv_to_create; struct metadata_area *mda; if (!vg_validate(vg)) @@ -2507,6 +2541,12 @@ vg->seqno++; + dm_list_iterate_items(pv_to_create, &vg->pvs_to_create) { + if (!_pvcreate_write(vg->cmd, pv_to_create)) + return 0; + pv_to_create->pv->status &= ~UNLABELLED_PV; + } + /* Write to each copy of the metadata area */ dm_list_iterate_items(mda, &vg->fid->metadata_areas_in_use) { if (!mda->ops->vg_write) { @@ -2676,7 +2716,7 @@ dm_list_iterate_items(info, &vginfo->infos) { if (!(pv = _pv_read(cmd, vg->vgmem, dev_name(info->dev), - vg->fid, NULL, warnings, 0))) { + vg->fid, warnings, 0))) { continue; } if (!(pvl = dm_pool_zalloc(vg->vgmem, sizeof(*pvl)))) { @@ -3429,10 +3469,10 @@ * FIXME - liblvm todo - make into function that returns handle */ struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name, - uint64_t *label_sector, int warnings, + int warnings, int scan_label_only) { - return _pv_read(cmd, cmd->mem, pv_name, NULL, label_sector, warnings, scan_label_only); + return _pv_read(cmd, cmd->mem, pv_name, NULL, warnings, scan_label_only); } /* FIXME Use label functions instead of PV functions */ @@ -3440,7 +3480,6 @@ struct dm_pool *pvmem, const char *pv_name, struct format_instance *fid, - uint64_t *label_sector, int warnings, int scan_label_only) { struct physical_volume *pv; @@ -3460,8 +3499,6 @@ } info = (struct lvmcache_info *) label->info; - if (label_sector && *label_sector) - *label_sector = label->sector; pv = _alloc_pv(pvmem, dev); if (!pv) { @@ -3469,6 +3506,8 @@ return NULL; } + pv->label_sector = label->sector; + /* FIXME Move more common code up here */ if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, scan_label_only))) { log_error("Failed to read existing physical volume '%s'", @@ -4367,5 +4406,5 @@ */ struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name) { - return _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0); + return _pv_read(cmd, cmd->mem, pv_name, NULL, 1, 0); } --- LVM2/lib/metadata/metadata.h 2011/05/07 13:32:05 1.243 +++ LVM2/lib/metadata/metadata.h 2011/06/01 19:29:33 1.244 @@ -470,7 +470,8 @@ struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name); int add_pv_to_vg(struct volume_group *vg, const char *pv_name, - struct physical_volume *pv); + struct physical_volume *pv, struct pvcreate_params *pp); + int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton); uint64_t find_min_mda_size(struct dm_list *mdas); --- LVM2/lib/metadata/pv.h 2011/02/21 12:31:28 1.10 +++ LVM2/lib/metadata/pv.h 2011/06/01 19:29:33 1.11 @@ -51,6 +51,12 @@ unsigned long pe_align; unsigned long pe_align_offset; + /* This is true whenever the represented PV has a label associated. */ + uint64_t is_labelled:1; + + /* NB. label_sector is valid whenever is_labelled is true */ + uint64_t label_sector; + struct dm_list segments; /* Ordered pv_segments covering complete PV */ struct dm_list tags; }; --- LVM2/lib/metadata/vg.c 2011/03/10 12:43:30 1.9 +++ LVM2/lib/metadata/vg.c 2011/06/01 19:29:33 1.10 @@ -43,6 +43,7 @@ vg->alloc = ALLOC_NORMAL; dm_list_init(&vg->pvs); + dm_list_init(&vg->pvs_to_create); dm_list_init(&vg->lvs); dm_list_init(&vg->tags); dm_list_init(&vg->removed_pvs); --- LVM2/lib/metadata/vg.h 2011/04/29 19:06:17 1.11 +++ LVM2/lib/metadata/vg.h 2011/06/01 19:29:33 1.12 @@ -31,6 +31,12 @@ ALLOC_INHERIT } alloc_policy_t; +struct pv_to_create { + struct dm_list list; + struct physical_volume *pv; + struct pvcreate_params *pp; +}; + struct volume_group { struct cmd_context *cmd; struct dm_pool *vgmem; @@ -59,6 +65,13 @@ struct dm_list pvs; /* + * List of physical volumes that were used in vgextend but do not carry + * a PV label yet. They need to be pvcreate'd at vg_write time. + */ + + struct dm_list pvs_to_create; + + /* * logical volumes * The following relationship should always hold: * dm_list_size(lvs) = user visible lv_count + snapshot_count + other invisible LVs --- LVM2/tools/pvcreate.c 2011/03/11 14:56:56 1.94 +++ LVM2/tools/pvcreate.c 2011/06/01 19:29:34 1.95 @@ -112,7 +112,7 @@ unescape_colons_and_at_signs(argv[i], NULL, NULL); - if (!(pv = pvcreate_single(cmd, argv[i], &pp))) { + if (!(pv = pvcreate_single(cmd, argv[i], &pp, 1))) { stack; ret = ECMD_FAILED; } --- LVM2/tools/pvremove.c 2011/03/11 14:56:56 1.34 +++ LVM2/tools/pvremove.c 2011/06/01 19:29:34 1.35 @@ -30,7 +30,7 @@ /* Is there a pv here already? */ /* If not, this is an error unless you used -f. */ - if (!(pv = pv_read(cmd, name, NULL, 1, 0))) { + if (!(pv = pv_read(cmd, name, 1, 0))) { if (arg_count(cmd, force_ARG)) return 1; log_error("Physical Volume %s not found", name); @@ -52,7 +52,7 @@ goto bad; } free_pv_fid(pv); - if (!(pv = pv_read(cmd, name, NULL, 1, 0))) { + if (!(pv = pv_read(cmd, name, 1, 0))) { log_error("Failed to read physical volume %s", name); goto bad; } --- LVM2/tools/pvresize.c 2011/03/11 14:56:56 1.44 +++ LVM2/tools/pvresize.c 2011/06/01 19:29:34 1.45 @@ -43,7 +43,7 @@ return 0; } - if (!(pv = pv_read(cmd, pv_name, NULL, 1, 0))) { + if (!(pv = pv_read(cmd, pv_name, 1, 0))) { unlock_vg(cmd, vg_name); log_error("Unable to read PV \"%s\"", pv_name); return 0; --- LVM2/tools/toollib.c 2011/05/19 13:59:22 1.226 +++ LVM2/tools/toollib.c 2011/06/01 19:29:34 1.227 @@ -651,7 +651,7 @@ } while ((dev = dev_iter_get(iter))) { - if (!(pv = pv_read(cmd, dev_name(dev), NULL, 0, 0))) { + if (!(pv = pv_read(cmd, dev_name(dev), 0, 0))) { memset(&pv_dummy, 0, sizeof(pv_dummy)); dm_list_init(&pv_dummy.tags); dm_list_init(&pv_dummy.segments); @@ -737,7 +737,7 @@ } pv = pvl->pv; } else { - if (!(pv = pv_read(cmd, argv[opt], NULL, + if (!(pv = pv_read(cmd, argv[opt], 1, scan_label_only))) { log_error("Failed to read physical " "volume \"%s\"", argv[opt]); @@ -764,7 +764,7 @@ scanned = 1; free_pv_fid(pv); if (!(pv = pv_read(cmd, argv[opt], - NULL, 1, + 1, scan_label_only))) { log_error("Failed to read " "physical volume " From agk@sourceware.org Wed Jun 1 21:16:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 01 Jun 2011 21:16:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-command.c ... Message-ID: <20110601211657.29635.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-01 21:16:56 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c lvm-functions.c lib/locking : cluster_locking.c locking.h Log message: Propagate test mode to clvmd to skip activation and changes to held locks. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2004&r2=1.2005 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.116&r2=1.117 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.65&r2=1.66 --- LVM2/WHATS_NEW 2011/06/01 19:29:31 1.2004 +++ LVM2/WHATS_NEW 2011/06/01 21:16:55 1.2005 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Propagate test mode to clvmd to skip activation and changes to held locks. Defer writing PV labels to vg_write. Store label_sector only in struct physical_volume. Permit --available with lvcreate so non-snapshot LVs need not be activated. --- LVM2/daemons/clvmd/clvmd-command.c 2011/04/08 14:40:18 1.54 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/06/01 21:16:56 1.55 @@ -80,6 +80,9 @@ unsigned char lock_cmd; unsigned char lock_flags; + /* Reset test mode before we start */ + init_test(0); + /* Do the command */ switch (msg->cmd) { /* Just a test message */ @@ -109,6 +112,8 @@ lockname = &args[2]; /* Check to see if the VG is in use by LVM1 */ status = do_check_lvm1(lockname); + if (lock_flags & LCK_TEST_MODE) + init_test(1); do_lock_vg(lock_cmd, lock_flags, lockname); break; @@ -117,6 +122,8 @@ lock_cmd = args[0] & (LCK_NONBLOCK | LCK_HOLD | LCK_SCOPE_MASK | LCK_TYPE_MASK); lock_flags = args[1]; lockname = &args[2]; + if (lock_flags & LCK_TEST_MODE) + init_test(1); status = do_lock_lv(lock_cmd, lock_flags, lockname); /* Replace EIO with something less scary */ if (status == EIO) { @@ -251,6 +258,7 @@ int status = 0; char *lockname; + init_test(0); switch (header->cmd) { case CLVMD_CMD_TEST: status = sync_lock("CLVMD_TEST", LCK_EXCL, 0, &lockid); @@ -269,6 +277,8 @@ lock_cmd = args[0]; lock_flags = args[1]; lockname = &args[2]; + if (lock_flags & LCK_TEST_MODE) + init_test(1); status = pre_lock_lv(lock_cmd, lock_flags, lockname); break; @@ -300,6 +310,7 @@ char *args = header->node + strlen(header->node) + 1; char *lockname; + init_test(0); switch (header->cmd) { case CLVMD_CMD_TEST: status = @@ -311,6 +322,8 @@ lock_cmd = args[0]; lock_flags = args[1]; lockname = &args[2]; + if (lock_flags & LCK_TEST_MODE) + init_test(1); status = post_lock_lv(lock_cmd, lock_flags, lockname); break; --- LVM2/daemons/clvmd/lvm-functions.c 2011/05/07 13:50:13 1.116 +++ LVM2/daemons/clvmd/lvm-functions.c 2011/06/01 21:16:56 1.117 @@ -137,6 +137,7 @@ flags & LCK_MIRROR_NOSYNC_MODE ? "MIRROR_NOSYNC|" : "", flags & LCK_DMEVENTD_MONITOR_MODE ? "DMEVENTD_MONITOR|" : "", flags & LCK_ORIGIN_ONLY_MODE ? "ORIGIN_ONLY|" : "", + flags & LCK_TEST_MODE ? "TEST|" : "", flags & LCK_CONVERT ? "CONVERT|" : ""); if (len > 1) @@ -235,6 +236,9 @@ int saved_errno; struct lv_info *lvi; + if (test_mode()) + return 0; + /* Mask off invalid options */ flags &= LCKF_NOQUEUE | LCKF_CONVERT; @@ -298,6 +302,9 @@ int status; int saved_errno; + if (test_mode()) + return 0; + if (!(lvi = lookup_info(resource))) { DEBUGLOG("hold_unlock, lock not already held\n"); return 0; --- LVM2/lib/locking/cluster_locking.c 2011/04/08 14:40:19 1.55 +++ LVM2/lib/locking/cluster_locking.c 2011/06/01 21:16:56 1.56 @@ -329,6 +329,9 @@ if (mirror_in_sync()) args[1] |= LCK_MIRROR_NOSYNC_MODE; + if (test_mode()) + args[1] |= LCK_TEST_MODE; + /* * Must handle tri-state return from dmeventd_monitor_mode. * But DMEVENTD_MONITOR_IGNORE is not propagated across the cluster. --- LVM2/lib/locking/locking.h 2011/04/29 00:21:14 1.65 +++ LVM2/lib/locking/locking.h 2011/06/01 21:16:56 1.66 @@ -106,6 +106,7 @@ #define LCK_DMEVENTD_MONITOR_MODE 0x04 /* Register with dmeventd */ #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 */ /* * Special cases of VG locks. From mbroz@sourceware.org Thu Jun 2 08:58:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 02 Jun 2011 08:58:00 -0000 Subject: LVM2/daemons/lvmetad lvmetad-client.h Message-ID: <20110602085806.10724.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-02 08:58:06 Modified files: daemons/lvmetad: lvmetad-client.h Log message: Use /var/run/lvm for lvmetad socket. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-client.h.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/daemons/lvmetad/lvmetad-client.h 2011/05/13 08:17:26 1.1 +++ LVM2/daemons/lvmetad/lvmetad-client.h 2011/06/02 08:58:05 1.2 @@ -66,7 +66,7 @@ /* TODO configurable */ daemon_info lvmetad_info = { .path = "lvmetad", - .socket = "/var/run/lvmetad.socket", + .socket = "/var/run/lvm/lvmetad.socket", .autostart = 1 }; From mbroz@sourceware.org Thu Jun 2 09:02:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 02 Jun 2011 09:02:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/lvmdump.sh Message-ID: <20110602090204.11553.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-02 09:02:03 Modified files: . : WHATS_NEW scripts : lvmdump.sh Log message: Always use append to file in lvmdump (selinux policy - no file truncation). Workaround dmsetup ls --tree (terminal ioctl for width). (Until isatty() will be allowed by selinux policy.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2005&r2=1.2006 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/lvmdump.sh.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/WHATS_NEW 2011/06/01 21:16:55 1.2005 +++ LVM2/WHATS_NEW 2011/06/02 09:02:03 1.2006 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Always use append to file in lvmdump (selinux policy - no file truncation). Propagate test mode to clvmd to skip activation and changes to held locks. Defer writing PV labels to vg_write. Store label_sector only in struct physical_volume. --- LVM2/scripts/lvmdump.sh 2011/02/01 21:39:15 1.16 +++ LVM2/scripts/lvmdump.sh 2011/06/02 09:02:03 1.17 @@ -55,7 +55,7 @@ echo " -d dump into a directory instead of tarball" echo " -c if running clvmd, gather cluster data as well" echo "" - + exit 1 } @@ -116,7 +116,7 @@ myecho "Gathering LVM volume info..." myecho " vgscan..." - log "\"$LVM\" vgscan -vvvv > \"$dir/vgscan\" 2>&1" + log "\"$LVM\" vgscan -vvvv >> \"$dir/vgscan\" 2>&1" myecho " pvscan..." log "\"$LVM\" pvscan -v >> \"$dir/pvscan\" 2>> \"$log\"" @@ -125,10 +125,10 @@ log "\"$LVM\" lvs -a -o +devices >> \"$dir/lvs\" 2>> \"$log\"" myecho " pvs..." - log "\"$LVM\" pvs -a -v > \"$dir/pvs\" 2>> \"$log\"" + log "\"$LVM\" pvs -a -v >> \"$dir/pvs\" 2>> \"$log\"" myecho " vgs..." - log "\"$LVM\" vgs -v > \"$dir/vgs\" 2>> \"$log\"" + log "\"$LVM\" vgs -v >> \"$dir/vgs\" 2>> \"$log\"" fi if (( $clustered )); then @@ -146,7 +146,7 @@ echo "----------------------------------" if [ -f /proc/cluster/dlm_locks ] then - echo clvmd > /proc/cluster/dlm_locks + echo clvmd >> /proc/cluster/dlm_locks cat /proc/cluster/dlm_locks echo echo "RESOURCE DIR:" @@ -166,11 +166,11 @@ echo "MASTER:" cat /debug/dlm/clvmd_master fi - } > $dir/cluster_info + } >> $dir/cluster_info fi myecho "Gathering LVM & device-mapper version info..." -echo "LVM VERSION:" > "$dir/versions" +echo "LVM VERSION:" >> "$dir/versions" "$LVM" lvs --version >> "$dir/versions" 2>> "$log" echo "DEVICE MAPPER VERSION:" >> "$dir/versions" "$DMSETUP" --version >> "$dir/versions" 2>> "$log" @@ -180,25 +180,27 @@ "$DMSETUP" targets >> "$dir/versions" 2>> "$log" myecho "Gathering dmsetup info..." -log "\"$DMSETUP\" info -c > \"$dir/dmsetup_info\" 2>> \"$log\"" -log "\"$DMSETUP\" table > \"$dir/dmsetup_table\" 2>> \"$log\"" -log "\"$DMSETUP\" status > \"$dir/dmsetup_status\" 2>> \"$log\"" -log "\"$DMSETUP\" ls --tree > \"$dir/dmsetup_ls_tree\" 2>> \"$log\"" +log "\"$DMSETUP\" info -c >> \"$dir/dmsetup_info\" 2>> \"$log\"" +log "\"$DMSETUP\" table >> \"$dir/dmsetup_table\" 2>> \"$log\"" +log "\"$DMSETUP\" status >> \"$dir/dmsetup_status\" 2>> \"$log\"" + +# cat as workaround to avoid tty ioctl (selinux) +log "\"$DMSETUP\" ls --tree 2>> \"$log\" | cat >> \"$dir/dmsetup_ls_tree\"" myecho "Gathering process info..." -log "$PS alx > \"$dir/ps_info\" 2>> \"$log\"" +log "$PS alx >> \"$dir/ps_info\" 2>> \"$log\"" myecho "Gathering console messages..." -log "$TAIL -n 75 /var/log/messages > \"$dir/messages\" 2>> \"$log\"" +log "$TAIL -n 75 /var/log/messages >> \"$dir/messages\" 2>> \"$log\"" myecho "Gathering /etc/lvm info..." log "$CP -a /etc/lvm \"$dir/lvm\" 2>> \"$log\"" myecho "Gathering /dev listing..." -log "$LS -laR /dev > \"$dir/dev_listing\" 2>> \"$log\"" +log "$LS -laR /dev >> \"$dir/dev_listing\" 2>> \"$log\"" myecho "Gathering /sys/block listing..." -log "$LS -laR /sys/block > \"$dir/sysblock_listing\" 2>> \"$log\"" +log "$LS -laR /sys/block >> \"$dir/sysblock_listing\" 2>> \"$log\"" log "$LS -laR /sys/devices/virtual/block >> \"$dir/sysblock_listing\" 2>> \"$log\"" if (( $metadata )); then @@ -233,4 +235,3 @@ fi exit 0 - From mbroz@sourceware.org Thu Jun 2 09:08:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 02 Jun 2011 09:08:00 -0000 Subject: LVM2/scripts lvmdump.sh Message-ID: <20110602090816.13092.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-02 09:08:16 Modified files: scripts : lvmdump.sh Log message: Use append but except query for dlm locks:-) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/lvmdump.sh.diff?cvsroot=lvm2&r1=1.17&r2=1.18 --- LVM2/scripts/lvmdump.sh 2011/06/02 09:02:03 1.17 +++ LVM2/scripts/lvmdump.sh 2011/06/02 09:08:16 1.18 @@ -146,7 +146,7 @@ echo "----------------------------------" if [ -f /proc/cluster/dlm_locks ] then - echo clvmd >> /proc/cluster/dlm_locks + echo clvmd > /proc/cluster/dlm_locks cat /proc/cluster/dlm_locks echo echo "RESOURCE DIR:" From prajnoha@sourceware.org Fri Jun 3 09:05:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Fri, 03 Jun 2011 09:05:00 -0000 Subject: LVM2/daemons/clvmd clvmd-command.c lvm-functions.c Message-ID: <20110603090531.32297.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-06-03 09:05:31 Modified files: daemons/clvmd : clvmd-command.c lvm-functions.c Log message: Fix a few compile warnings. clvmd-command.c:84:2: warning: implicit declaration of function ??????init_test?????? lvm-functions.c:141:3: warning: too many arguments for format Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118 --- LVM2/daemons/clvmd/clvmd-command.c 2011/06/01 21:16:56 1.55 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/06/03 09:05:30 1.56 @@ -57,6 +57,7 @@ #include "clvmd-comms.h" #include "clvm.h" #include "clvmd.h" +#include "lvm-globals.h" #include "lvm-functions.h" #include "locking.h" --- LVM2/daemons/clvmd/lvm-functions.c 2011/06/01 21:16:56 1.117 +++ LVM2/daemons/clvmd/lvm-functions.c 2011/06/03 09:05:30 1.118 @@ -132,7 +132,7 @@ static char buf[128]; int len; - len = sprintf(buf, "0x%x ( %s%s%s%s%s)", flags, + len = sprintf(buf, "0x%x ( %s%s%s%s%s%s)", flags, flags & LCK_PARTIAL_MODE ? "PARTIAL_MODE|" : "", flags & LCK_MIRROR_NOSYNC_MODE ? "MIRROR_NOSYNC|" : "", flags & LCK_DMEVENTD_MONITOR_MODE ? "DMEVENTD_MONITOR|" : "", From mornfall@sourceware.org Sat Jun 4 21:46:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Sat, 04 Jun 2011 21:46:00 -0000 Subject: LVM2/test/api Makefile.in pe_start.c pe_start.sh Message-ID: <20110604214634.12098.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-04 21:46:34 Modified files: test/api : Makefile.in Added files: test/api : pe_start.c pe_start.sh Log message: Add an API test that shows how to find a value of pe_start for a VG without actually creating the VG on-disk. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/pe_start.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/pe_start.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/Makefile.in.diff?cvsroot=lvm2&r1=1.21&r2=1.22 /cvs/lvm2/LVM2/test/api/pe_start.c,v --> standard output revision 1.1 --- LVM2/test/api/pe_start.c +++ - 2011-06-04 21:46:34.530305000 +0000 @@ -0,0 +1,47 @@ +/* + * 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 + */ + +#undef NDEBUG + +#include "lvm2app.h" +#include "assert.h" + +int main(int argc, char *argv[]) +{ + lvm_t handle; + vg_t vg = NULL; + pv_t pv; + struct lvm_property_value v; + + handle = lvm_init(NULL); + assert(handle); + + vg = lvm_vg_create(handle, "test_vg"); + assert(vg); + + if (lvm_vg_extend(vg, argv[1])) + abort(); + + pv = lvm_pv_from_name(vg, argv[1]); + assert(pv); + + v = lvm_pv_get_property(pv, "pe_start"); + assert(v.is_valid); + fprintf(stderr, "pe_start = %d\n", (int)v.value.integer); + assert(v.value.integer == 2048 * 512); + + lvm_vg_close(vg); + lvm_quit(handle); + return 0; +} /cvs/lvm2/LVM2/test/api/pe_start.sh,v --> standard output revision 1.1 --- LVM2/test/api/pe_start.sh +++ - 2011-06-04 21:46:34.614299000 +0000 @@ -0,0 +1,17 @@ +# +# 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 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_devs 2 +aux apitest pe_start $dev1 --- LVM2/test/api/Makefile.in 2011/03/01 21:30:43 1.21 +++ LVM2/test/api/Makefile.in 2011/06/04 21:46:34 1.22 @@ -26,7 +26,7 @@ wrapper_SOURCES = test.c INCLUDES += -I../../include -TARGETS += vgtest.t percent.t +TARGETS += vgtest.t percent.t pe_start.t endif LVMLIBS = @LVM2APP_LIB@ -ldevmapper From mornfall@sourceware.org Sat Jun 4 21:55:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Sat, 04 Jun 2011 21:55:00 -0000 Subject: LVM2/test/api pe_start.c pe_start.sh Message-ID: <20110604215525.13241.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-04 21:55:25 Modified files: test/api : pe_start.c pe_start.sh Log message: Also check in the pe_start API test that the disks have not been touched. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/pe_start.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/pe_start.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/test/api/pe_start.c 2011/06/04 21:46:34 1.1 +++ LVM2/test/api/pe_start.c 2011/06/04 21:55:25 1.2 @@ -27,13 +27,13 @@ handle = lvm_init(NULL); assert(handle); - vg = lvm_vg_create(handle, "test_vg"); + vg = lvm_vg_create(handle, argv[1]); assert(vg); - if (lvm_vg_extend(vg, argv[1])) + if (lvm_vg_extend(vg, argv[2])) abort(); - pv = lvm_pv_from_name(vg, argv[1]); + pv = lvm_pv_from_name(vg, argv[2]); assert(pv); v = lvm_pv_get_property(pv, "pe_start"); --- LVM2/test/api/pe_start.sh 2011/06/04 21:46:34 1.1 +++ LVM2/test/api/pe_start.sh 2011/06/04 21:55:25 1.2 @@ -14,4 +14,6 @@ . lib/test aux prepare_devs 2 -aux apitest pe_start $dev1 +aux apitest pe_start test_vg $dev1 +not vgs test_vg +not pvs $dev1 From agk@sourceware.org Mon Jun 6 12:08:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 06 Jun 2011 12:08:00 -0000 Subject: LVM2/lib/metadata lv_manip.c Message-ID: <20110606120843.13575.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-06 12:08:42 Modified files: lib/metadata : lv_manip.c Log message: missing space in mesg Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.259&r2=1.260 --- LVM2/lib/metadata/lv_manip.c 2011/06/01 19:21:04 1.259 +++ LVM2/lib/metadata/lv_manip.c 2011/06/06 12:08:42 1.260 @@ -418,7 +418,7 @@ if (seg_is_striped(seg)) { if (reduction % seg->area_count) { log_error("Segment extent reduction %" PRIu32 - "not divisible by #stripes %" PRIu32, + " not divisible by #stripes %" PRIu32, reduction, seg->area_count); return 0; } From prajnoha@sourceware.org Wed Jun 8 08:49:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Wed, 08 Jun 2011 08:49:00 -0000 Subject: LVM2 ./WHATS_NEW lib/misc/lvm-file.c Message-ID: <20110608084954.2300.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-06-08 08:49:54 Modified files: . : WHATS_NEW lib/misc : lvm-file.c Log message: Fix create_temp_name to replace any '/' found in the hostname with '?'. There's a possibility someone will use the '/' in the hostname. Since we generate a temporary file name (path) including the hostname, any '/' would be ambiguous. We can always set such hostname using 'sethostname' from unistd.h. But the 'hostname' command already includes the check and removes the '/' char. However, some old versions still allow that. See: https://bugzilla.redhat.com/show_bug.cgi?id=711445. Since this is only a temporary name and the possibility of this error is quite negligible, we don't need any complex escape sequence here, just a simple char replace. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2006&r2=1.2007 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-file.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28 --- LVM2/WHATS_NEW 2011/06/02 09:02:03 1.2006 +++ LVM2/WHATS_NEW 2011/06/08 08:49:53 1.2007 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Fix create_temp_name to replace any '/' found in the hostname with '?'. Always use append to file in lvmdump (selinux policy - no file truncation). Propagate test mode to clvmd to skip activation and changes to held locks. Defer writing PV labels to vg_write. --- LVM2/lib/misc/lvm-file.c 2009/07/15 20:02:47 1.27 +++ LVM2/lib/misc/lvm-file.c 2011/06/08 08:49:54 1.28 @@ -35,6 +35,7 @@ int i, num; pid_t pid; char hostname[255]; + char *p; struct flock lock = { .l_type = F_WRLCK, .l_whence = 0, @@ -48,6 +49,12 @@ log_sys_error("gethostname", ""); strcpy(hostname, "nohostname"); } + else { + /* Replace any '/' with '?' found in the hostname. */ + p = hostname; + while ((p = strchr(p, '/'))) + *p = '?'; + } for (i = 0; i < 20; i++, num++) { From mbroz@sourceware.org Thu Jun 9 14:26:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 09 Jun 2011 14:26:00 -0000 Subject: LVM2/test t-topology-support.sh Message-ID: <20110609142648.3300.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 14:26:47 Modified files: test : t-topology-support.sh Log message: Fix topology test. Kernel version is misparsed in Fedora rawhide, just test sysfs file. SCSI_DEBUG_DEV is no longer exported, use provided file instead. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-topology-support.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/test/t-topology-support.sh 2011/01/05 00:16:20 1.6 +++ LVM2/test/t-topology-support.sh 2011/06/09 14:26:47 1.7 @@ -10,22 +10,16 @@ which mkfs.ext3 || exit 200 -# Get linux minor version -linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1) - -test $linux_minor -ge 31 || exit 200 - . lib/test check_logical_block_size() { - local DEV_=$1 - local LOGICAL_BS=$2 + local DEV_=$(cat SCSI_DEBUG_DEV) # Verify logical_block_size - requires Linux >= 2.6.31 SYSFS_LOGICAL_BLOCK_SIZE=`echo /sys/block/$(basename $DEV_)/queue/logical_block_size` if [ -f "$SYSFS_LOGICAL_BLOCK_SIZE" ] ; then ACTUAL_LOGICAL_BLOCK_SIZE=`cat $SYSFS_LOGICAL_BLOCK_SIZE` - test $ACTUAL_LOGICAL_BLOCK_SIZE = $LOGICAL_BS + test $ACTUAL_LOGICAL_BLOCK_SIZE = $1 fi } @@ -60,13 +54,21 @@ PER_DEV_SIZE=34 DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE)) +# Test that kernel supports topology +aux prepare_scsi_debug_dev $DEV_SIZE +if [ ! -e /sys/block/$(basename $(cat SCSI_DEBUG_DEV))/alignment_offset ] ; then + aux cleanup_scsi_debug_dev + exit 200 +fi +aux cleanup_scsi_debug_dev + # --------------------------------------------- # Create "desktop-class" 4K drive # (logical_block_size=512, physical_block_size=4096, alignment_offset=0): LOGICAL_BLOCK_SIZE=512 aux prepare_scsi_debug_dev $DEV_SIZE \ sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3 -check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE +check_logical_block_size $LOGICAL_BLOCK_SIZE aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE vgcreate -c n $vg $(cat DEVICES) @@ -81,7 +83,7 @@ LOGICAL_BLOCK_SIZE=512 aux prepare_scsi_debug_dev $DEV_SIZE \ sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3 lowest_aligned=7 -check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE +check_logical_block_size $LOGICAL_BLOCK_SIZE aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE vgcreate -c n $vg $(cat DEVICES) @@ -96,7 +98,7 @@ LOGICAL_BLOCK_SIZE=4096 aux prepare_scsi_debug_dev $DEV_SIZE \ sector_size=$LOGICAL_BLOCK_SIZE -check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE +check_logical_block_size $LOGICAL_BLOCK_SIZE aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE vgcreate -c n $vg $(cat DEVICES) From mbroz@sourceware.org Thu Jun 9 15:07:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 09 Jun 2011 15:07:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c Message-ID: <20110609150741.9287.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 15:07:41 Modified files: . : WHATS_NEW_DM libdm/ioctl : libdm-iface.c Log message: Accept kernel version 3 (3.0-rc and similar). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.468&r2=1.469 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104 --- LVM2/WHATS_NEW_DM 2011/04/29 19:05:11 1.468 +++ LVM2/WHATS_NEW_DM 2011/06/09 15:07:40 1.469 @@ -1,5 +1,6 @@ Version 1.02.65 - ================================== + Accept new kernel version 3 formats in initialisation. Version 1.02.64 - 29th April 2011 ================================== --- LVM2/libdm/ioctl/libdm-iface.c 2011/03/25 23:50:35 1.103 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/06/09 15:07:40 1.104 @@ -73,9 +73,9 @@ static unsigned _dm_version_patchlevel = 0; static int _log_suppress = 0; -static int _kernel_major; -static int _kernel_minor; -static int _kernel_release; +static int _kernel_major = 0; +static int _kernel_minor = 0; +static int _kernel_release = 0; /* * If the kernel dm driver only supports one major number @@ -152,6 +152,7 @@ { static int _uts_set = 0; struct utsname _uts; + int parts; if (_uts_set) return 1; @@ -160,10 +161,14 @@ log_error("uname failed: %s", strerror(errno)); return 0; } - if (sscanf(_uts.release, "%d.%d.%d", + + parts = sscanf(_uts.release, "%d.%d.%d", &_kernel_major, &_kernel_minor, - &_kernel_release) != 3) { + &_kernel_release); + + /* Kernels with a major number of 2 always had 3 parts. */ + if (parts < 1 || (_kernel_major < 3 && parts < 3)) { log_error("Could not determine kernel version used."); return 0; } From mbroz@sourceware.org Thu Jun 9 15:53:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 09 Jun 2011 15:53:00 -0000 Subject: LVM2/libdm libdm-deptree.c Message-ID: <20110609155301.19117.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 15:53:00 Modified files: libdm : libdm-deptree.c Log message: Fix another occurrence of linux kernel version check. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93 --- LVM2/libdm/libdm-deptree.c 2011/03/29 20:19:04 1.92 +++ LVM2/libdm/libdm-deptree.c 2011/06/09 15:52:59 1.93 @@ -1544,13 +1544,20 @@ int dm_log_userspace = 0; struct utsname uts; unsigned log_parm_count; - int pos = 0; + int pos = 0, parts; char logbuf[DM_FORMAT_DEV_BUFSIZE]; const char *logtype; - unsigned kmaj, kmin, krel; + unsigned kmaj = 0, kmin = 0, krel = 0; + + if (uname(&uts) == -1) { + log_error("Cannot read kernel release version."); + return 0; + } - if (uname(&uts) == -1 || sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) != 3) { - log_error("Cannot read kernel release version"); + /* Kernels with a major number of 2 always had 3 parts. */ + parts = sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel); + if (parts < 1 || (kmaj < 3 && parts < 3)) { + log_error("Wrong kernel release version %s.", uts.release); return 0; } From mbroz@sourceware.org Thu Jun 9 18:58:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 09 Jun 2011 18:58:00 -0000 Subject: LVM2/test t-pvcreate-operation-md.sh api/perce ... Message-ID: <20110609185802.7537.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 18:58:01 Modified files: test : t-pvcreate-operation-md.sh test/api : percent.sh test/lib : utils.sh Log message: Fix kernel version parsing in tests, use common function. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation-md.sh.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/percent.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/utils.sh.diff?cvsroot=lvm2&r1=1.4&r2=1.5 --- LVM2/test/t-pvcreate-operation-md.sh 2011/01/28 16:12:45 1.14 +++ LVM2/test/t-pvcreate-operation-md.sh 2011/06/09 18:58:00 1.15 @@ -70,12 +70,10 @@ $mddev check pv_field $mddev pe_start $pv_align -# Get linux minor version -linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1) # Test newer topology-aware alignment detection # - first added to 2.6.31 but not "reliable" until 2.6.33 -if [ $linux_minor -ge 33 ]; then +if kernel_at_least 2 6 33 ; then pv_align="1.00m" # optimal_io_size=131072, minimum_io_size=65536 pvcreate --metadatasize 128k \ @@ -84,7 +82,7 @@ fi # partition MD array directly, depends on blkext in Linux >= 2.6.28 -if [ $linux_minor -ge 28 ]; then +if kernel_at_least 2 6 28 ; then # create one partition sfdisk $mddev <= 2.6.31 # but reliable alignment_offset support requires kernel.org Linux >= 2.6.33 sysfs_alignment_offset=/sys/dev/block/${mddev_maj_min}/${base_mddev_p}/alignment_offset - [ -f $sysfs_alignment_offset -a $linux_minor -ge 33 ] && \ + [ -f $sysfs_alignment_offset ] && kernel_at_least 2 6 33 && \ alignment_offset=`cat $sysfs_alignment_offset` || \ alignment_offset=0 - if [ $alignment_offset -gt 0 ]; then + if [ $alignment_offset -gt 0 ]; then # default alignment is 1M, add alignment_offset pv_align=$((1048576+$alignment_offset))B pvcreate --metadatasize 128k $mddev_p @@ -125,7 +123,7 @@ fi # Test newer topology-aware alignment detection w/ --dataalignment override -if [ $linux_minor -ge 33 ]; then +if kernel_at_least 2 6 33 ; then cleanup_md pvcreate -f $dev1 pvcreate -f $dev2 --- LVM2/test/api/percent.sh 2011/01/28 16:11:14 1.5 +++ LVM2/test/api/percent.sh 2011/06/09 18:58:01 1.6 @@ -13,8 +13,7 @@ . lib/test -linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1) -test $linux_minor -le 32 && skip +kernel_at_least 2 6 33 || skip aux prepare_devs 2 vgcreate -c n -s 4k $vg $(cat DEVICES) --- LVM2/test/lib/utils.sh 2011/01/31 22:05:30 1.4 +++ LVM2/test/lib/utils.sh 2011/06/09 18:58:01 1.5 @@ -152,6 +152,23 @@ exit 200 } +kernel_at_least() { + major=$(uname -r |cut -d. -f1) + minor=$(uname -r |cut -d. -f2 | cut -d- -f1) + + test $major -gt $1 && return 0 + test $major -lt $1 && return 1 + test $minor -gt $2 && return 0 + test $minor -lt $2 && return 1 + test -z "$3" && return 0 + + minor2=$(uname -r | cut -d. -f3) + test -z "$minor2" && return 0 + test $minor2 -ge $3 2>/dev/null && return 0 + + return 1 +} + . lib/paths || { echo >&2 you must run make first; exit 1; } PATH=$abs_top_builddir/test/lib:$PATH From mbroz@sourceware.org Thu Jun 9 19:34:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 09 Jun 2011 19:34:00 -0000 Subject: LVM2 ./WHATS_NEW test/t-lvextend-percent-exten ... Message-ID: <20110609193450.15452.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 19:34:50 Modified files: . : WHATS_NEW test : t-lvextend-percent-extents.sh tools : lvresize.c Log message: Fix extent rounding for striped segments. We should never remove more extents than requested by user, so round up to next stripe boundary during lvreduce. Also this fixes round to zero sized LV bug: # lvcreate -i2 -I 64k -l10 -n lvs vg_test # lvreduce -f -l1 vg_test/lvs Rounding size (1 extents) down to stripe boundary size for segment (0 extents) WARNING: Reducing active logical volume to 0 THIS MAY DESTROY YOUR DATA (filesystem etc.) Reducing logical volume lvs to 0 Failed to suspend lvs Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2007&r2=1.2008 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvextend-percent-extents.sh.diff?cvsroot=lvm2&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131 --- LVM2/WHATS_NEW 2011/06/08 08:49:53 1.2007 +++ LVM2/WHATS_NEW 2011/06/09 19:34:49 1.2008 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Fix extent rounding for striped volumes (never reduce more than requested). Fix create_temp_name to replace any '/' found in the hostname with '?'. Always use append to file in lvmdump (selinux policy - no file truncation). Propagate test mode to clvmd to skip activation and changes to held locks. --- LVM2/test/t-lvextend-percent-extents.sh 2011/01/05 00:16:20 1.10 +++ LVM2/test/t-lvextend-percent-extents.sh 2011/06/09 19:34:49 1.11 @@ -99,3 +99,8 @@ lvreduce -f -l -$(( $pe_count * 1 )) $vg/$lv check lv_field $vg/$lv seg_count 1 +# do not reduce to 0 extents +lvremove -f $vg/$lv +lvcreate -i2 -I 64k -l10 -n $lv $vg +lvreduce -f -l1 $vg/$lv +check lv_field $vg/$lv lv_size "8.00m" --- LVM2/tools/lvresize.c 2011/04/06 21:32:21 1.130 +++ LVM2/tools/lvresize.c 2011/06/09 19:34:50 1.131 @@ -575,11 +575,17 @@ return EINVALID_CMD_LINE; } - if ((lp->stripes > 1)) { + if (lp->stripes > 1) { if (!(stripesize_extents = lp->stripe_size / vg->extent_size)) stripesize_extents = 1; - if ((size_rest = seg_size % (lp->stripes * stripesize_extents))) { + size_rest = seg_size % (lp->stripes * stripesize_extents); + if (size_rest && lp->resize == LV_REDUCE) { + log_print("Rounding size (%d extents) up to stripe " + "boundary size for segment (%d extents)", + lp->extents, lp->extents + size_rest); + lp->extents = lp->extents + size_rest; + } else if (size_rest) { log_print("Rounding size (%d extents) down to stripe " "boundary size for segment (%d extents)", lp->extents, lp->extents - size_rest); From mbroz@sourceware.org Thu Jun 9 19:36:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 09 Jun 2011 19:36:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/merge.c Message-ID: <20110609193616.17425.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 19:36:16 Modified files: . : WHATS_NEW lib/metadata : merge.c Log message: Validate mirror segments size Currently some operation with striped mirrors lead to corrupted metadata, this patch just add detection of such situation. Example: # lvcreate -i2 -l10 -n lvs vg_test # lvconvert -m1 vg_test/lvs # lvreduce -f -l1 vg_test/lvs Reducing logical volume lvs to 4.00 MiB Segment extent reduction 9not divisible by #stripes 2 Logical volume lvs successfully resized # lvremove vg_test/lvs Segment extent reduction 1not divisible by #stripes 2 LV segment lvs:0-4294967295 is incorrectly listed as being used by LV lvs_mimage_0 Internal error: LV segments corrupted in lvs_mimage_0. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2008&r2=1.2009 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44 --- LVM2/WHATS_NEW 2011/06/09 19:34:49 1.2008 +++ LVM2/WHATS_NEW 2011/06/09 19:36:16 1.2009 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Validate mirror segments size. Fix extent rounding for striped volumes (never reduce more than requested). Fix create_temp_name to replace any '/' found in the hostname with '?'. Always use append to file in lvmdump (selinux policy - no file truncation). --- LVM2/lib/metadata/merge.c 2010/05/21 12:43:02 1.43 +++ LVM2/lib/metadata/merge.c 2011/06/09 19:36:16 1.44 @@ -204,6 +204,16 @@ inc_error_count; } } + + if (complete_vg && seg_is_mirrored(seg) && + seg_type(seg, s) == AREA_LV && + seg_lv(seg, s)->le_count != seg->area_len) { + log_error("LV %s: mirrored LV segment %u has " + "wrong size %u (should be %u).", + lv->name, s, seg_lv(seg, s)->le_count, + seg->area_len); + inc_error_count; + } } le += seg->len; From mbroz@sourceware.org Thu Jun 9 19:38:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 09 Jun 2011 19:38:00 -0000 Subject: LVM2 ./WHATS_NEW test/t-lvconvert-mirror.sh to ... Message-ID: <20110609193857.21015.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 19:38:56 Modified files: . : WHATS_NEW test : t-lvconvert-mirror.sh tools : lvresize.c Log message: Fix mirrored stripe reduction. Patch adds check for stripe not only in direct LV segment but also in mirror image segment. This prevents bugs like: # lvcreate -i2 -l10 -n lv vg_test # lvconvert -m1 -i1 vg_test/lv # lvreduce -f -l1 vg_test/lv WARNING: Reducing active logical volume to 4.00 MiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Reducing logical volume lv to 4.00 MiB Segment extent reduction 9 not divisible by #stripes 2 Logical volume lv successfully resized # lvremove -f vg_test Segment extent reduction 1 not divisible by #stripes 2 LV segment lv:0-4294967295 is incorrectly listed as being used by LV lv_mimage_0 Internal error: LV segments corrupted in lv_mimage_0. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2009&r2=1.2010 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror.sh.diff?cvsroot=lvm2&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.131&r2=1.132 --- LVM2/WHATS_NEW 2011/06/09 19:36:16 1.2009 +++ LVM2/WHATS_NEW 2011/06/09 19:38:56 1.2010 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Fix reduction of mirrors with striped segments to always align to stripe size. Validate mirror segments size. Fix extent rounding for striped volumes (never reduce more than requested). Fix create_temp_name to replace any '/' found in the hostname with '?'. --- LVM2/test/t-lvconvert-mirror.sh 2011/01/05 00:16:20 1.9 +++ LVM2/test/t-lvconvert-mirror.sh 2011/06/09 19:38:56 1.10 @@ -240,3 +240,11 @@ check mirror $vg $lv1 $dev3 check mirror_no_temporaries $vg $lv1 check mirror_legs $vg $lv1 3 + +# simple mirrored stripe +aux prepare_vg 5 +lvcreate -i2 -l10 -n $lv1 $vg +lvconvert -m1 -i1 $vg/$lv1 +lvreduce -f -l1 $vg/$lv1 +lvextend -f -l10 $vg/$lv1 +lvremove -ff $vg/$lv1 --- LVM2/tools/lvresize.c 2011/06/09 19:34:50 1.131 +++ LVM2/tools/lvresize.c 2011/06/09 19:38:56 1.132 @@ -305,6 +305,34 @@ return 1; } +static uint32_t lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize) +{ + uint32_t s; + struct lv_segment *seg_mirr; + + /* If segment mirrored, check if images are striped */ + if (seg_is_mirrored(seg)) + for (s = 0; s < seg->area_count; s++) { + if (seg_type(seg, s) != AREA_LV) + continue; + seg_mirr = first_seg(seg_lv(seg, s)); + + if (seg_is_striped(seg_mirr)) { + seg = seg_mirr; + break; + } + } + + + if (seg_is_striped(seg)) { + *stripesize = seg->stripe_size; + return seg->area_count; + } + + *stripesize = 0; + return 0; +} + static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, struct lvresize_params *lp) { @@ -548,10 +576,8 @@ dm_list_iterate_items(seg, &lv->segments) { seg_extents = seg->len; - if (seg_is_striped(seg)) { - seg_stripesize = seg->stripe_size; - seg_stripes = seg->area_count; - } + /* Check for underlying stripe sizes */ + seg_stripes = lvseg_get_stripes(seg, &seg_stripesize); if (seg_is_mirrored(seg)) seg_mirrors = lv_mirror_count(seg->lv); From mbroz@sourceware.org Thu Jun 9 19:48:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 09 Jun 2011 19:48:00 -0000 Subject: LVM2/test/lib utils.sh Message-ID: <20110609194826.25066.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-09 19:48:26 Modified files: test/lib : utils.sh Log message: Fix kernel version test (RHEL: 2.6.32-123). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/utils.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/test/lib/utils.sh 2011/06/09 18:58:01 1.5 +++ LVM2/test/lib/utils.sh 2011/06/09 19:48:26 1.6 @@ -162,8 +162,8 @@ test $minor -lt $2 && return 1 test -z "$3" && return 0 - minor2=$(uname -r | cut -d. -f3) - test -z "$minor2" && return 0 + minor2=$(uname -r | cut -d. -f3 | cut -d- -f1) + test -z "$minor2" -a $3 -ne 0 && return 1 test $minor2 -ge $3 2>/dev/null && return 0 return 1 From agk@sourceware.org Sat Jun 11 00:03:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Sat, 11 Jun 2011 00:03:00 -0000 Subject: LVM2 ./WHATS_NEW ./WHATS_NEW_DM daemons/clvmd/ ... Message-ID: <20110611000310.10906.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-11 00:03:08 Modified files: . : WHATS_NEW WHATS_NEW_DM daemons/clvmd : lvm-functions.c lib/activate : activate.c dev_manager.c dev_manager.h lib/locking : locking.c lib/metadata : lv_manip.c metadata-exported.h mirror.c lib/mm : memlock.c memlock.h libdm : libdm-deptree.c tools : pvmove.c vgchange.c Log message: Major pvmove fix to issue ioctls in the correct order when multiple LVs are affected by the move. (Currently it's possible for I/O to become trapped between suspended devices amongst other problems. The current fix was selected so as to minimise the testing surface. I hope eventually to replace it with a cleaner one that extends the deptree code. Some lvconvert scenarios still suffer from related problems. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2010&r2=1.2011 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.469&r2=1.470 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.196&r2=1.197 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.216&r2=1.217 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.h.diff?cvsroot=lvm2&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.260&r2=1.261 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.192&r2=1.193 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.151&r2=1.152 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.h.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121 --- LVM2/WHATS_NEW 2011/06/09 19:38:56 1.2010 +++ LVM2/WHATS_NEW 2011/06/11 00:03:06 1.2011 @@ -1,5 +1,8 @@ Version 2.02.86 - ================================= + Fix ignored background polling default in vgchange -ay. + Fix pvmove activation sequences to avoid trapped I/O with multiple LVs. + Annotate critical section debug messages. Fix reduction of mirrors with striped segments to always align to stripe size. Validate mirror segments size. Fix extent rounding for striped volumes (never reduce more than requested). --- LVM2/WHATS_NEW_DM 2011/06/09 15:07:40 1.469 +++ LVM2/WHATS_NEW_DM 2011/06/11 00:03:06 1.470 @@ -1,6 +1,7 @@ Version 1.02.65 - ================================== - Accept new kernel version 3 formats in initialisation. + Delay resuming new preloaded mirror devices with core logs in deptree code. + Accept new kernel version 3 uname formats in initialisation. Version 1.02.64 - 29th April 2011 ================================== --- LVM2/daemons/clvmd/lvm-functions.c 2011/06/03 09:05:30 1.118 +++ LVM2/daemons/clvmd/lvm-functions.c 2011/06/11 00:03:06 1.119 @@ -384,9 +384,9 @@ goto error; if (lvi.suspended) { - critical_section_inc(cmd); + critical_section_inc(cmd, "resuming"); if (!lv_resume(cmd, resource, 0)) { - critical_section_dec(cmd); + critical_section_dec(cmd, "resumed"); goto error; } } --- LVM2/lib/activate/activate.c 2011/02/18 14:47:29 1.196 +++ LVM2/lib/activate/activate.c 2011/06/11 00:03:07 1.197 @@ -534,7 +534,7 @@ if (!activation()) return 0; - if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) return_0; if (!(r = dev_manager_transient(dm, lv))) @@ -556,7 +556,7 @@ if (!activation()) return 0; - if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) return_0; if (!(r = dev_manager_snapshot_percent(dm, lv, percent))) @@ -591,7 +591,7 @@ if (!info.exists) return 0; - if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) return_0; if (!(r = dev_manager_mirror_percent(dm, lv, wait, percent, event_nr))) @@ -631,7 +631,7 @@ int r; struct dev_manager *dm; - if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1))) return_0; if (!(r = dev_manager_activate(dm, lv, origin_only))) @@ -646,7 +646,7 @@ int r; struct dev_manager *dm; - if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1))) return_0; if (!(r = dev_manager_preload(dm, lv, origin_only, flush_required))) @@ -661,7 +661,7 @@ int r; struct dev_manager *dm; - if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) return_0; if (!(r = dev_manager_deactivate(dm, lv))) @@ -676,7 +676,11 @@ int r; struct dev_manager *dm; - if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) + /* + * When we are asked to manipulate (normally suspend/resume) the PVMOVE + * device directly, we don't want to touch the devices that use it. + */ + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1))) return_0; if (!(r = dev_manager_suspend(dm, lv, origin_only, lockfs, flush_required))) @@ -1080,7 +1084,9 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, int error_if_not_suspended) { - struct logical_volume *lv = NULL, *lv_pre = NULL; + struct logical_volume *lv = NULL, *lv_pre = NULL, *pvmove_lv = NULL; + struct lv_list *lvl_pre; + struct seg_list *sl; struct lvinfo info; int r = 0, lockfs = 0, flush_required = 0; @@ -1111,7 +1117,7 @@ if (!error_if_not_suspended) { r = 1; if (info.suspended) - critical_section_inc(cmd); + critical_section_inc(cmd, "already suspended"); } goto out; } @@ -1121,27 +1127,76 @@ lv_calculate_readahead(lv, NULL); - /* If VG was precommitted, preload devices for the LV */ + /* + * If VG was precommitted, preload devices for the LV. + * If the PVMOVE LV is being removed, it's only present in the old + * metadata and not the new, so we must explicitly add the new + * tables for all the changed LVs here, as the relationships + * are not found by walking the new metadata. + */ if ((lv_pre->vg->status & PRECOMMITTED)) { - if (!_lv_preload(lv_pre, origin_only, &flush_required)) { + if (!(lv_pre->status & LOCKED) && + (lv->status & LOCKED) && + (pvmove_lv = find_pvmove_lv_in_lv(lv))) { + /* Preload all the LVs above the PVMOVE LV */ + dm_list_iterate_items(sl, &pvmove_lv->segs_using_this_lv) { + if (!(lvl_pre = find_lv_in_vg(lv_pre->vg, sl->seg->lv->name))) { + /* FIXME Internal error? */ + log_error("LV %s missing from preload metadata", sl->seg->lv->name); + goto out; + } + if (!_lv_preload(lvl_pre->lv, origin_only, &flush_required)) + goto_out; + } + /* Now preload the PVMOVE LV itself */ + if (!(lvl_pre = find_lv_in_vg(lv_pre->vg, pvmove_lv->name))) { + /* FIXME Internal error? */ + log_error("LV %s missing from preload metadata", pvmove_lv->name); + goto out; + } + if (!_lv_preload(lvl_pre->lv, origin_only, &flush_required)) + goto_out; + } else if (!_lv_preload(lv_pre, origin_only, &flush_required)) /* FIXME Revert preloading */ goto_out; - } } if (!monitor_dev_for_events(cmd, lv, origin_only, 0)) /* FIXME Consider aborting here */ stack; - critical_section_inc(cmd); + critical_section_inc(cmd, "suspending"); + if (pvmove_lv) + critical_section_inc(cmd, "suspending pvmove LV"); if (!origin_only && (lv_is_origin(lv_pre) || lv_is_cow(lv_pre))) lockfs = 1; - if (!_lv_suspend_lv(lv, origin_only, lockfs, flush_required)) { - critical_section_dec(cmd); - goto out; + /* + * Suspending an LV directly above a PVMOVE LV also + * suspends other LVs using that same PVMOVE LV. + * FIXME Remove this and delay the 'clear node' until + * after the code knows whether there's a different + * inactive table to load or not instead so lv_suspend + * can be called separately for each LV safely. + */ + if ((lv_pre->vg->status & PRECOMMITTED) && + (lv_pre->status & LOCKED) && find_pvmove_lv_in_lv(lv_pre)) { + if (!_lv_suspend_lv(lv_pre, origin_only, lockfs, flush_required)) { + critical_section_dec(cmd, "failed precommitted suspend"); + if (pvmove_lv) + critical_section_dec(cmd, "failed precommitted suspend (pvmove)"); + goto_out; + } + } else { + /* Normal suspend */ + if (!_lv_suspend_lv(lv, origin_only, lockfs, flush_required)) { + critical_section_dec(cmd, "failed suspend"); + if (pvmove_lv) + critical_section_dec(cmd, "failed suspend (pvmove)"); + goto_out; + } } r = 1; @@ -1210,6 +1265,8 @@ if (error_if_not_active) goto_out; r = 1; + if (!info.suspended) + critical_section_dec(cmd, "already resumed"); goto out; } @@ -1224,7 +1281,7 @@ if (!_lv_activate_lv(lv, origin_only)) goto_out; - critical_section_dec(cmd); + critical_section_dec(cmd, "resumed"); if (!monitor_dev_for_events(cmd, lv, origin_only, 1)) stack; @@ -1316,9 +1373,9 @@ if (!monitor_dev_for_events(cmd, lv, 0, 0)) stack; - critical_section_inc(cmd); + critical_section_inc(cmd, "deactivating"); r = _lv_deactivate(lv); - critical_section_dec(cmd); + critical_section_dec(cmd, "deactivated"); if (!lv_info(cmd, lv, 0, &info, 0, 0) || info.exists) r = 0; @@ -1413,10 +1470,10 @@ if (exclusive) lv->status |= ACTIVATE_EXCL; - critical_section_inc(cmd); + critical_section_inc(cmd, "activating"); if (!(r = _lv_activate_lv(lv, 0))) stack; - critical_section_dec(cmd); + critical_section_dec(cmd, "activated"); if (r && !monitor_dev_for_events(cmd, lv, 0, 1)) stack; --- LVM2/lib/activate/dev_manager.c 2011/03/29 20:30:08 1.216 +++ LVM2/lib/activate/dev_manager.c 2011/06/11 00:03:07 1.217 @@ -49,6 +49,7 @@ void *target_state; uint32_t pvmove_mirror_count; int flush_required; + unsigned track_pvmove_deps; char *vg_name; }; @@ -640,7 +641,8 @@ * dev_manager implementation. */ struct dev_manager *dev_manager_create(struct cmd_context *cmd, - const char *vg_name) + const char *vg_name, + unsigned track_pvmove_deps) { struct dm_pool *mem; struct dev_manager *dm; @@ -657,6 +659,12 @@ if (!(dm->vg_name = dm_pool_strdup(dm->mem, vg_name))) goto_bad; + /* + * When we manipulate (normally suspend/resume) the PVMOVE + * device directly, there's no need to touch the LVs above. + */ + dm->track_pvmove_deps = track_pvmove_deps; + dm->target_state = NULL; dm_udev_set_sync_support(cmd->current_settings.udev_sync); @@ -1039,6 +1047,8 @@ */ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv, unsigned origin_only) { + struct seg_list *sl; + if (!origin_only && !_add_dev_to_dtree(dm, dtree, lv, NULL)) return_0; @@ -1053,6 +1063,12 @@ !_add_dev_to_dtree(dm, dtree, first_seg(lv)->log_lv, NULL)) return_0; + /* Add any LVs referencing a PVMOVE LV unless told not to. */ + if (dm->track_pvmove_deps && lv->status & PVMOVE) + dm_list_iterate_items(sl, &lv->segs_using_this_lv) + if (!_add_lv_to_dtree(dm, dtree, sl->seg->lv, origin_only)) + return_0; + /* Adding LV head of replicator adds all other related devs */ if (lv_is_replicator_dev(lv) && !_add_partial_replicator_to_dtree(dm, dtree, lv)) @@ -1436,10 +1452,11 @@ } static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, - struct logical_volume *lv, const char *layer) + struct logical_volume *lv, const char *layer) { struct lv_segment *seg; struct lv_layer *lvlayer; + struct seg_list *sl; struct dm_tree_node *dnode; const struct dm_info *dinfo; char *name, *dlid; @@ -1492,6 +1509,9 @@ * existing inactive table left behind. * Major/minor settings only apply to the visible layer. */ + /* FIXME Move the clear from here until later, so we can leave + * identical inactive tables untouched. (For pvmove.) + */ if (!(dnode = dm_tree_add_new_dev_with_udev_flags(dtree, name, dlid, layer ? UINT32_C(0) : (uint32_t) lv->major, layer ? UINT32_C(0) : (uint32_t) lv->minor, @@ -1528,6 +1548,12 @@ dm_tree_node_set_read_ahead(dnode, read_ahead, read_ahead_flags); + /* Add any LVs referencing a PVMOVE LV unless told not to */ + if (dm->track_pvmove_deps && (lv->status & PVMOVE)) + dm_list_iterate_items(sl, &lv->segs_using_this_lv) + if (!_add_new_lv_to_dtree(dm, dtree, sl->seg->lv, NULL)) + return_0; + return 1; } @@ -1744,10 +1770,6 @@ int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv, unsigned origin_only, int *flush_required) { - /* FIXME Update the pvmove implementation! */ - if ((lv->status & PVMOVE) || (lv->status & LOCKED)) - return 1; - if (!_tree_action(dm, lv, origin_only, PRELOAD)) return 0; --- LVM2/lib/activate/dev_manager.h 2010/11/30 22:28:06 1.36 +++ LVM2/lib/activate/dev_manager.h 2011/06/11 00:03:07 1.37 @@ -29,7 +29,8 @@ * Constructor and destructor. */ struct dev_manager *dev_manager_create(struct cmd_context *cmd, - const char *vg_name); + const char *vg_name, + unsigned track_pvmove_deps); void dev_manager_destroy(struct dev_manager *dm); void dev_manager_release(void); void dev_manager_exit(void); --- LVM2/lib/locking/locking.c 2011/04/28 20:29:59 1.94 +++ LVM2/lib/locking/locking.c 2011/06/11 00:03:07 1.95 @@ -167,7 +167,7 @@ return; if (lv_op == LV_SUSPEND) - critical_section_inc(cmd); + critical_section_inc(cmd, "locking for suspend"); } static void _unlock_memory(struct cmd_context *cmd, lv_operation_t lv_op) @@ -176,7 +176,7 @@ return; if (lv_op == LV_RESUME) - critical_section_dec(cmd); + critical_section_dec(cmd, "unlocking on resume"); } void reset_locking(void) --- LVM2/lib/metadata/lv_manip.c 2011/06/06 12:08:42 1.260 +++ LVM2/lib/metadata/lv_manip.c 2011/06/11 00:03:07 1.261 @@ -494,15 +494,19 @@ { uint32_t len = lv->le_count; - if (!lv_empty(lv)) + if (len && !lv_empty(lv)) return_0; + /* Minimum size required for a table. */ + if (!len) + len = 1; + /* * Since we are replacing the whatever-was-there with * an error segment, we should also clear any flags * that suggest it is anything other than "error". */ - lv->status &= ~MIRRORED; + lv->status &= ~(MIRRORED|PVMOVE); /* FIXME: Should we bug if we find a log_lv attached? */ --- LVM2/lib/metadata/metadata-exported.h 2011/06/01 19:21:04 1.192 +++ LVM2/lib/metadata/metadata-exported.h 2011/06/11 00:03:07 1.193 @@ -753,6 +753,7 @@ const char *name, const char *uuid, uint32_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); percent_t copy_percent(const struct logical_volume *lv_mirr); --- LVM2/lib/metadata/mirror.c 2011/04/28 20:30:00 1.151 +++ LVM2/lib/metadata/mirror.c 2011/06/11 00:03:07 1.152 @@ -1445,7 +1445,10 @@ return NULL; } -const char *get_pvmove_pvname_from_lv(struct logical_volume *lv) +/* + * Find first pvmove LV referenced by a segment of an LV. + */ +struct logical_volume *find_pvmove_lv_in_lv(struct logical_volume *lv) { struct lv_segment *seg; uint32_t s; @@ -1454,13 +1457,26 @@ for (s = 0; s < seg->area_count; s++) { if (seg_type(seg, s) != AREA_LV) continue; - return get_pvmove_pvname_from_lv_mirr(seg_lv(seg, s)); + if (seg_lv(seg, s)->status & PVMOVE) + return seg_lv(seg, s); } } return NULL; } +const char *get_pvmove_pvname_from_lv(struct logical_volume *lv) +{ + struct logical_volume *pvmove_lv; + + pvmove_lv = find_pvmove_lv_in_lv(lv); + + if (pvmove_lv) + return get_pvmove_pvname_from_lv_mirr(pvmove_lv); + else + return NULL; +} + struct logical_volume *find_pvmove_lv(struct volume_group *vg, struct device *dev, uint32_t lv_type) --- LVM2/lib/mm/memlock.c 2011/06/01 19:26:38 1.42 +++ LVM2/lib/mm/memlock.c 2011/06/11 00:03:07 1.43 @@ -395,19 +395,21 @@ } } -void critical_section_inc(struct cmd_context *cmd) +void critical_section_inc(struct cmd_context *cmd, const char *reason) { ++_critical_section_count; - log_debug("critical_section_inc to %d", _critical_section_count); + log_debug("critical_section_inc to %d (%s).", _critical_section_count, + reason); _lock_mem_if_needed(cmd); } -void critical_section_dec(struct cmd_context *cmd) +void critical_section_dec(struct cmd_context *cmd, const char *reason) { if (!_critical_section_count) log_error(INTERNAL_ERROR "_critical_section has dropped below 0."); --_critical_section_count; - log_debug("critical_section_dec to %d", _critical_section_count); + log_debug("critical_section_dec to %d (%s).", _critical_section_count, + reason); } int critical_section(void) --- LVM2/lib/mm/memlock.h 2011/04/28 20:30:00 1.8 +++ LVM2/lib/mm/memlock.h 2011/06/11 00:03:07 1.9 @@ -31,8 +31,8 @@ * memlock_reset() is necessary to clear the state after forking (polldaemon). */ -void critical_section_inc(struct cmd_context *cmd); -void critical_section_dec(struct cmd_context *cmd); +void critical_section_inc(struct cmd_context *cmd, const char *reason); +void critical_section_dec(struct cmd_context *cmd, const char *reason); int critical_section(void); void memlock_inc_daemon(struct cmd_context *cmd); void memlock_dec_daemon(struct cmd_context *cmd); --- LVM2/libdm/libdm-deptree.c 2011/06/09 15:52:59 1.93 +++ LVM2/libdm/libdm-deptree.c 2011/06/11 00:03:07 1.94 @@ -149,7 +149,16 @@ * and processing of dm tree). This will also flush all stacked dev * node operations, synchronizing with udev. */ - int immediate_dev_node; + unsigned immediate_dev_node; + + /* + * If the device size changed from zero and this is set, + * don't resume the device immediately, even if the device + * has parents. This works provided the parents do not + * validate the device size and is required by pvmove to + * avoid starting the mirror resync operation too early. + */ + unsigned delay_resume_if_new; }; /* Two of these used to join two nodes with uses and used_by. */ @@ -1795,7 +1804,7 @@ int r = 0; struct dm_task *dmt; struct load_segment *seg; - uint64_t seg_start = 0; + uint64_t seg_start = 0, existing_table_size; log_verbose("Loading %s table (%" PRIu32 ":%" PRIu32 ")", dnode->name, dnode->info.major, dnode->info.minor); @@ -1833,12 +1842,20 @@ log_verbose("Suppressed %s identical table reload.", dnode->name); + existing_table_size = dm_task_get_existing_table_size(dmt); if ((dnode->props.size_changed = - (dm_task_get_existing_table_size(dmt) == seg_start) ? 0 : 1)) + (existing_table_size == seg_start) ? 0 : 1)) { log_debug("Table size changed from %" PRIu64 " to %" - PRIu64 " for %s", - dm_task_get_existing_table_size(dmt), + PRIu64 " for %s", existing_table_size, seg_start, dnode->name); + /* + * Kernel usually skips size validation on zero-length devices + * now so no need to preload them. + */ + /* FIXME In which kernel version did this begin? */ + if (!existing_table_size && dnode->props.delay_resume_if_new) + dnode->props.size_changed = 0; + } } dnode->props.segment_count = 0; @@ -2181,7 +2198,10 @@ log_error("log uuid pool_strdup failed"); return 0; } - if (!(flags & DM_CORELOG)) { + if ((flags & DM_CORELOG)) + /* For pvmove: immediate resume (for size validation) isn't needed. */ + node->props.delay_resume_if_new = 1; + else { if (!(log_node = dm_tree_find_node_by_uuid(node->dtree, log_uuid))) { log_error("Couldn't find mirror log uuid %s.", log_uuid); return 0; --- LVM2/tools/pvmove.c 2011/03/29 20:19:04 1.83 +++ LVM2/tools/pvmove.c 2011/06/11 00:03:07 1.84 @@ -305,6 +305,51 @@ return 1; } +static int _suspend_lvs(struct cmd_context *cmd, unsigned first_time, + struct logical_volume *lv_mirr, + struct dm_list *lvs_changed) +{ + /* + * Suspend lvs_changed the first time. + * Suspend mirrors on subsequent calls. + */ + if (first_time) { + if (!suspend_lvs(cmd, lvs_changed)) + return_0; + } else if (!suspend_lv(cmd, lv_mirr)) + return_0; + + return 1; +} + +static int _resume_lvs(struct cmd_context *cmd, unsigned first_time, + struct logical_volume *lv_mirr, + struct dm_list *lvs_changed) +{ + /* + * Suspend lvs_changed the first time. + * Suspend mirrors on subsequent calls. + */ + + if (first_time) { + if (!resume_lvs(cmd, lvs_changed)) { + log_error("Unable to resume logical volumes"); + return 0; + } + } else if (!resume_lv(cmd, lv_mirr)) { + log_error("Unable to reactivate logical volume \"%s\"", + lv_mirr->name); + return 0; + } + + return 1; +} + +/* + * Called to set up initial pvmove LV and to advance the mirror + * to successive sections of it. + * (Not called after the last section completes.) + */ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, struct dm_list *lvs_changed, unsigned flags) @@ -319,30 +364,14 @@ return 0; } - /* Suspend lvs_changed */ - if (!suspend_lvs(cmd, lvs_changed)) { + if (!_suspend_lvs(cmd, first_time, lv_mirr, lvs_changed)) { vg_revert(vg); goto_out; } - /* Suspend mirrors on subsequent calls */ - if (!first_time) { - if (!suspend_lv(cmd, lv_mirr)) { - if (!resume_lvs(cmd, lvs_changed)) - stack; - vg_revert(vg); - goto_out; - } - } - /* Commit on-disk metadata */ if (!vg_commit(vg)) { log_error("ABORTING: Volume group metadata update failed."); - if (!first_time) - if (!resume_lv(cmd, lv_mirr)) - stack; - if (!resume_lvs(cmd, lvs_changed)) - stack; vg_revert(vg); goto out; } @@ -358,9 +387,6 @@ } /* - * FIXME: review ordering of operations above, - * temporary mirror should be preloaded in suspend. - * Also banned operation here when suspended. * Nothing changed yet, try to revert pvmove. */ log_error("Temporary pvmove mirror activation failed."); @@ -374,29 +400,16 @@ !vg_write(vg) || !vg_commit(vg)) log_error("ABORTING: Restoring original configuration " "before pvmove failed. Run pvmove --abort."); - - /* Unsuspend LVs */ - if(!resume_lvs(cmd, lvs_changed)) - stack; - - goto out; + goto_out; } - } else if (!resume_lv(cmd, lv_mirr)) { - log_error("Unable to reactivate logical volume \"%s\"", - lv_mirr->name); - if (!resume_lvs(cmd, lvs_changed)) - stack; - goto out; - } - - /* Unsuspend LVs */ - if (!resume_lvs(cmd, lvs_changed)) { - log_error("Unable to resume logical volumes"); - goto out; } r = 1; + out: + if (!_resume_lvs(cmd, first_time, lv_mirr, lvs_changed)) + r = 0; + backup(vg); return r; } @@ -524,7 +537,8 @@ int r = 1; if (!dm_list_empty(lvs_changed) && - !_detach_pvmove_mirror(cmd, lv_mirr)) { + (!_detach_pvmove_mirror(cmd, lv_mirr) || + !replace_lv_with_error_segment(lv_mirr))) { log_error("ABORTING: Removal of temporary mirror failed"); return 0; } @@ -536,18 +550,12 @@ return 0; } - /* Suspend LVs changed */ + /* Suspend LVs changed (implicitly suspends lv_mirr) */ if (!suspend_lvs(cmd, lvs_changed)) { log_error("Locking LVs to remove temporary mirror failed"); r = 0; } - /* Suspend mirror LV to flush pending I/O */ - if (!suspend_lv(cmd, lv_mirr)) { - log_error("Suspension of temporary mirror LV failed"); - r = 0; - } - /* Store metadata without dependencies on mirror segments */ if (!vg_commit(vg)) { log_error("ABORTING: Failed to write new data locations " --- LVM2/tools/vgchange.c 2011/03/02 20:00:09 1.120 +++ LVM2/tools/vgchange.c 2011/06/11 00:03:08 1.121 @@ -523,7 +523,7 @@ } if (!arg_count(cmd, refresh_ARG) && - arg_count(cmd, poll_ARG)) + background_polling()) if (!_vgchange_background_polling(cmd, vg)) return ECMD_FAILED; From agk@sourceware.org Sat Jun 11 12:55:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Sat, 11 Jun 2011 12:55:00 -0000 Subject: LVM2/libdm libdm-deptree.c Message-ID: <20110611125531.29363.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-11 12:55:31 Modified files: libdm : libdm-deptree.c Log message: Fix --mirrorlog mirrored. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95 --- LVM2/libdm/libdm-deptree.c 2011/06/11 00:03:07 1.94 +++ LVM2/libdm/libdm-deptree.c 2011/06/11 12:55:31 1.95 @@ -2210,6 +2210,10 @@ if (clustered) log_node->props.immediate_dev_node = 1; + /* The kernel validates the size of disk logs. */ + /* FIXME Propagate to any devices below */ + log_node->props.delay_resume_if_new = 0; + if (!_link_tree_nodes(node, log_node)) return_0; } From agk@sourceware.org Sun Jun 12 00:23:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Sun, 12 Jun 2011 00:23:00 -0000 Subject: LVM2 ./WHATS_NEW lib/mm/memlock.c Message-ID: <20110612002351.21003.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-12 00:23:50 Modified files: . : WHATS_NEW lib/mm : memlock.c Log message: Disable critical section internal errors until this can be fixed properly in libdevmapper. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2011&r2=1.2012 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44 --- LVM2/WHATS_NEW 2011/06/11 00:03:06 1.2011 +++ LVM2/WHATS_NEW 2011/06/12 00:23:50 1.2012 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Downgrade critical_section errors to debug level until it is moved to libdm. Fix ignored background polling default in vgchange -ay. Fix pvmove activation sequences to avoid trapped I/O with multiple LVs. Annotate critical section debug messages. --- LVM2/lib/mm/memlock.c 2011/06/11 00:03:07 1.43 +++ LVM2/lib/mm/memlock.c 2011/06/12 00:23:50 1.44 @@ -405,8 +405,9 @@ void critical_section_dec(struct cmd_context *cmd, const char *reason) { + /* FIXME Maintain accurate suspended device counter in libdevmapper */ if (!_critical_section_count) - log_error(INTERNAL_ERROR "_critical_section has dropped below 0."); + log_debug("_critical_section has dropped below 0."); --_critical_section_count; log_debug("critical_section_dec to %d (%s).", _critical_section_count, reason); From agk@sourceware.org Sun Jun 12 19:49:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Sun, 12 Jun 2011 19:49:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdm-report.c Message-ID: <20110612194941.19243.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-12 19:49:41 Modified files: . : WHATS_NEW_DM libdm : libdm-report.c Log message: Fix 'pvs -o pv_all' to include label fields. (Also removed recursion.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.470&r2=1.471 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-report.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 --- LVM2/WHATS_NEW_DM 2011/06/11 00:03:06 1.470 +++ LVM2/WHATS_NEW_DM 2011/06/12 19:49:40 1.471 @@ -1,5 +1,6 @@ Version 1.02.65 - ================================== + Fix "all" report field prefix matching to include label fields with pv_all. Delay resuming new preloaded mirror devices with core logs in deptree code. Accept new kernel version 3 uname formats in initialisation. --- LVM2/libdm/libdm-report.c 2011/04/08 14:40:20 1.44 +++ LVM2/libdm/libdm-report.c 2011/06/12 19:49:41 1.45 @@ -367,33 +367,32 @@ { size_t prefix_len; const struct dm_report_object_type *t; - char prefixed_all[32]; + uint32_t report_types = 0; + unsigned unprefixed_all_matched = 0; if (!strncasecmp(field, "all", 3) && flen == 3) { - if (strlen(rh->field_prefix)) { - strcpy(prefixed_all, rh->field_prefix); - strcat(prefixed_all, "all"); - /* - * Add also prefix to receive all attributes - * (e.g.LABEL/PVS use the same prefix) - */ - return rh->report_types | - _all_match(rh, prefixed_all, - strlen(prefixed_all)); - } else - return (rh->report_types) - ? rh->report_types : REPORT_TYPES_ALL; + /* If there's no report prefix, match all report types */ + if (!(flen = strlen(rh->field_prefix))) + return rh->report_types ? : REPORT_TYPES_ALL; + + /* otherwise include all fields beginning with the report prefix. */ + unprefixed_all_matched = 1; + field = rh->field_prefix; + report_types = rh->report_types; } + /* Combine all report types that have a matching prefix. */ for (t = rh->types; t->data_fn; t++) { prefix_len = strlen(t->prefix); + if (!strncasecmp(t->prefix, field, prefix_len) && - !strncasecmp(field + prefix_len, "all", 3) && - flen == prefix_len + 3) - return t->id; + ((unprefixed_all_matched && (flen == prefix_len)) || + (!strncasecmp(field + prefix_len, "all", 3) && + (flen == prefix_len + 3)))) + report_types |= t->id; } - return 0; + return report_types; } /* From agk@sourceware.org Mon Jun 13 03:32:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 13 Jun 2011 03:32:00 -0000 Subject: LVM2 ./WHATS_NEW ./WHATS_NEW_DM lib/mm/memlock ... Message-ID: <20110613033247.23259.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-13 03:32:46 Modified files: . : WHATS_NEW WHATS_NEW_DM lib/mm : memlock.c libdm : libdevmapper.h libdm-common.c libdm-common.h libdm-deptree.c libdm/ioctl : libdm-iface.c Log message: Maintain a count of the number of suspended devices in libdevmapper and use this for the LVM critical section logic. Also report an error if code tries to load a table while any device is known to be in the suspended state. (If the variety of problems these changes are showing up can't be fixed before the next release, the error messages can be reduced to debug level.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2012&r2=1.2013 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.471&r2=1.472 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.137&r2=1.138 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105 --- LVM2/WHATS_NEW 2011/06/12 00:23:50 1.2012 +++ LVM2/WHATS_NEW 2011/06/13 03:32:45 1.2013 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Use dm_get_suspended_counter in replacement critical_section logic. Downgrade critical_section errors to debug level until it is moved to libdm. Fix ignored background polling default in vgchange -ay. Fix pvmove activation sequences to avoid trapped I/O with multiple LVs. --- LVM2/WHATS_NEW_DM 2011/06/12 19:49:40 1.471 +++ LVM2/WHATS_NEW_DM 2011/06/13 03:32:45 1.472 @@ -1,5 +1,7 @@ Version 1.02.65 - ================================== + Warn if a table is loaded while a device is known to be in suspended state. + Add dm_get_suspended_counter() for number of devs in suspended state by lib. Fix "all" report field prefix matching to include label fields with pv_all. Delay resuming new preloaded mirror devices with core logs in deptree code. Accept new kernel version 3 uname formats in initialisation. --- LVM2/lib/mm/memlock.c 2011/06/12 00:23:50 1.44 +++ LVM2/lib/mm/memlock.c 2011/06/13 03:32:46 1.45 @@ -75,7 +75,7 @@ static void *_malloc_mem = NULL; static int _mem_locked = 0; -static int _critical_section_count = 0; +static int _critical_section = 0; static int _memlock_count_daemon = 0; static int _priority; static int _default_priority; @@ -374,10 +374,10 @@ static void _lock_mem_if_needed(struct cmd_context *cmd) { - log_debug("Lock: Memlock counters: locked:%d critical:%d daemon:%d", - _mem_locked, _critical_section_count, _memlock_count_daemon); + log_debug("Lock: Memlock counters: locked:%d critical:%d daemon:%d suspended:%d", + _mem_locked, _critical_section, _memlock_count_daemon, dm_get_suspended_counter()); if (!_mem_locked && - ((_critical_section_count + _memlock_count_daemon) == 1)) { + ((_critical_section + _memlock_count_daemon) == 1)) { _mem_locked = 1; _lock_mem(cmd); } @@ -385,10 +385,10 @@ static void _unlock_mem_if_possible(struct cmd_context *cmd) { - log_debug("Unlock: Memlock counters: locked:%d critical:%d daemon:%d", - _mem_locked, _critical_section_count, _memlock_count_daemon); + log_debug("Unlock: Memlock counters: locked:%d critical:%d daemon:%d suspended:%d", + _mem_locked, _critical_section, _memlock_count_daemon, dm_get_suspended_counter()); if (_mem_locked && - !_critical_section_count && + !_critical_section && !_memlock_count_daemon) { _unlock_mem(cmd); _mem_locked = 0; @@ -397,25 +397,25 @@ void critical_section_inc(struct cmd_context *cmd, const char *reason) { - ++_critical_section_count; - log_debug("critical_section_inc to %d (%s).", _critical_section_count, - reason); + if (!_critical_section) { + _critical_section = 1; + log_debug("Entering critical section (%s).", reason); + } + _lock_mem_if_needed(cmd); } void critical_section_dec(struct cmd_context *cmd, const char *reason) { - /* FIXME Maintain accurate suspended device counter in libdevmapper */ - if (!_critical_section_count) - log_debug("_critical_section has dropped below 0."); - --_critical_section_count; - log_debug("critical_section_dec to %d (%s).", _critical_section_count, - reason); + if (_critical_section && !dm_get_suspended_counter()) { + _critical_section = 0; + log_debug("Leaving critical section (%s).", reason); + } } int critical_section(void) { - return _critical_section_count; + return _critical_section; } /* @@ -428,7 +428,7 @@ void memlock_inc_daemon(struct cmd_context *cmd) { ++_memlock_count_daemon; - if (_memlock_count_daemon == 1 && _critical_section_count > 0) + if (_memlock_count_daemon == 1 && _critical_section > 0) log_error(INTERNAL_ERROR "_memlock_inc_daemon used in critical section."); log_debug("memlock_count_daemon inc to %d", _memlock_count_daemon); _lock_mem_if_needed(cmd); @@ -460,7 +460,7 @@ { log_debug("memlock reset."); _mem_locked = 0; - _critical_section_count = 0; + _critical_section = 0; _memlock_count_daemon = 0; } --- LVM2/libdm/libdevmapper.h 2011/03/10 12:48:40 1.137 +++ LVM2/libdm/libdevmapper.h 2011/06/13 03:32:46 1.138 @@ -74,6 +74,11 @@ */ int dm_log_is_non_default(void); +/* + * Number of devices currently in suspended state (via the library). + */ +int dm_get_suspended_counter(void); + enum { DM_DEVICE_CREATE, DM_DEVICE_RELOAD, --- LVM2/libdm/libdm-common.c 2011/04/22 11:56:41 1.117 +++ LVM2/libdm/libdm-common.c 2011/06/13 03:32:46 1.118 @@ -60,6 +60,7 @@ static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR; static int _verbose = 0; +static int _suspended_dev_counter = 0; #ifdef HAVE_SELINUX_LABEL_H static struct selabel_handle *_selabel_handle = NULL; @@ -173,6 +174,28 @@ return 1; } +void inc_suspended(void) +{ + _suspended_dev_counter++; + log_debug("Suspended device counter increased to %d", _suspended_dev_counter); +} + +void dec_suspended(void) +{ + if (!_suspended_dev_counter) { + log_error("Attempted to decrement suspended device counter below zero."); + return; + } + + _suspended_dev_counter--; + log_debug("Suspended device counter reduced to %d", _suspended_dev_counter); +} + +int dm_get_suspended_counter(void) +{ + return _suspended_dev_counter; +} + struct dm_task *dm_task_create(int type) { struct dm_task *dmt = dm_zalloc(sizeof(*dmt)); --- LVM2/libdm/libdm-common.h 2010/12/13 10:43:58 1.7 +++ LVM2/libdm/libdm-common.h 2011/06/13 03:32:46 1.8 @@ -33,4 +33,7 @@ void update_devs(void); void selinux_release(void); +void inc_suspended(void); +void dec_suspended(void); + #endif --- LVM2/libdm/libdm-deptree.c 2011/06/11 12:55:31 1.95 +++ LVM2/libdm/libdm-deptree.c 2011/06/13 03:32:46 1.96 @@ -1034,7 +1034,7 @@ static int _resume_node(const char *name, uint32_t major, uint32_t minor, uint32_t read_ahead, uint32_t read_ahead_flags, struct dm_info *newinfo, uint32_t *cookie, - uint16_t udev_flags) + uint16_t udev_flags, int already_suspended) { struct dm_task *dmt; int r = 0; @@ -1066,8 +1066,11 @@ if (!dm_task_set_cookie(dmt, cookie, udev_flags)) goto out; - if ((r = dm_task_run(dmt))) + if ((r = dm_task_run(dmt))) { + if (already_suspended) + dec_suspended(); r = dm_task_get_info(dmt, newinfo); + } out: dm_task_destroy(dmt); @@ -1106,8 +1109,10 @@ if (no_flush && !dm_task_no_flush(dmt)) log_error("Failed to set no_flush flag."); - if ((r = dm_task_run(dmt))) + if ((r = dm_task_run(dmt))) { + inc_suspended(); r = dm_task_get_info(dmt, newinfo); + } dm_task_destroy(dmt); @@ -1352,7 +1357,7 @@ if (!_resume_node(child->name, child->info.major, child->info.minor, child->props.read_ahead, child->props.read_ahead_flags, - &newinfo, &child->dtree->cookie, child->udev_flags)) { + &newinfo, &child->dtree->cookie, child->udev_flags, child->info.suspended)) { log_error("Unable to resume %s (%" PRIu32 ":%" PRIu32 ")", child->name, child->info.major, child->info.minor); @@ -1919,7 +1924,8 @@ if (!_resume_node(child->name, child->info.major, child->info.minor, child->props.read_ahead, child->props.read_ahead_flags, - &newinfo, &child->dtree->cookie, child->udev_flags)) { + &newinfo, &child->dtree->cookie, child->udev_flags, + child->info.suspended)) { log_error("Unable to resume %s (%" PRIu32 ":%" PRIu32 ")", child->name, child->info.major, child->info.minor); --- LVM2/libdm/ioctl/libdm-iface.c 2011/06/09 15:07:40 1.104 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/06/13 03:32:46 1.105 @@ -2026,6 +2026,7 @@ unsigned command; int check_udev; int udev_only; + int suspended_counter; #ifdef DM_COMPAT if (_dm_version == 1) @@ -2057,6 +2058,22 @@ return 0; } + if ((suspended_counter = dm_get_suspended_counter()) && + dmt->type == DM_DEVICE_RELOAD) + log_error("Performing unsafe table load while %d device(s) " + "are known to be suspended: " + "%s%s %s %s%.0d%s%.0d%s%s", + suspended_counter, + dmt->new_uuid ? "UUID " : "", + dmi->name, + dmi->uuid, + dmt->major > 0 ? "(" : "", + dmt->major > 0 ? dmt->major : 0, + dmt->major > 0 ? ":" : "", + dmt->minor > 0 ? dmt->minor : 0, + dmt->major > 0 && dmt->minor == 0 ? "0" : "", + dmt->major > 0 ? ") " : ""); + /* FIXME Detect and warn if cookie set but should not be. */ repeat_ioctl: if (!(dmi = _do_dm_ioctl(dmt, command, _ioctl_buffer_double_factor))) { From agk@sourceware.org Mon Jun 13 03:53:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 13 Jun 2011 03:53:00 -0000 Subject: LVM2/libdm/ioctl libdm-iface.c Message-ID: <20110613035302.15944.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-13 03:53:02 Modified files: libdm/ioctl : libdm-iface.c Log message: Fix fields in warning message. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106 --- LVM2/libdm/ioctl/libdm-iface.c 2011/06/13 03:32:46 1.105 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/06/13 03:53:02 1.106 @@ -2062,11 +2062,11 @@ dmt->type == DM_DEVICE_RELOAD) log_error("Performing unsafe table load while %d device(s) " "are known to be suspended: " - "%s%s %s %s%.0d%s%.0d%s%s", + "%s%s%s %s%.0d%s%.0d%s%s", suspended_counter, - dmt->new_uuid ? "UUID " : "", - dmi->name, - dmi->uuid, + dmt->dev_name ? : "", + dmt->uuid ? " UUID " : "", + dmt->uuid ? : "", dmt->major > 0 ? "(" : "", dmt->major > 0 ? dmt->major : 0, dmt->major > 0 ? ":" : "", From agk@sourceware.org Mon Jun 13 22:28:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 13 Jun 2011 22:28:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/m ... Message-ID: <20110613222805.12344.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-13 22:28:05 Modified files: . : WHATS_NEW lib/activate : activate.c lib/metadata : lv_manip.c Log message: Fix last snapshot removal to avoid table reload while a device is suspended. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2013&r2=1.2014 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.197&r2=1.198 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.261&r2=1.262 --- LVM2/WHATS_NEW 2011/06/13 03:32:45 1.2013 +++ LVM2/WHATS_NEW 2011/06/13 22:28:04 1.2014 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Fix last snapshot removal to avoid table reload while a device is suspended. Use dm_get_suspended_counter in replacement critical_section logic. Downgrade critical_section errors to debug level until it is moved to libdm. Fix ignored background polling default in vgchange -ay. --- LVM2/lib/activate/activate.c 2011/06/11 00:03:07 1.197 +++ LVM2/lib/activate/activate.c 2011/06/13 22:28:04 1.198 @@ -534,6 +534,8 @@ if (!activation()) return 0; + log_debug("Checking transient status for LV %s/%s", lv->vg->name, lv->name); + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) return_0; @@ -556,6 +558,8 @@ if (!activation()) return 0; + log_debug("Checking snapshot percent for LV %s/%s", lv->vg->name, lv->name); + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1))) return_0; @@ -585,6 +589,8 @@ if (!activation()) return 0; + log_debug("Checking mirror percent for LV %s/%s", lv->vg->name, lv->name); + if (!lv_info(cmd, lv, 0, &info, 0, 0)) return_0; @@ -692,7 +698,7 @@ /* * These two functions return the number of visible LVs in the state, - * or -1 on error. + * or -1 on error. FIXME Check this. */ int lvs_in_vg_activated(struct volume_group *vg) { @@ -702,10 +708,11 @@ if (!activation()) return 0; - dm_list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) if (lv_is_visible(lvl->lv)) count += (_lv_active(vg->cmd, lvl->lv) == 1); - } + + log_debug("Counted %d active LVs in VG %s", count, vg->name); return count; } @@ -718,10 +725,11 @@ if (!activation()) return 0; - dm_list_iterate_items(lvl, &vg->lvs) { + dm_list_iterate_items(lvl, &vg->lvs) if (lv_is_visible(lvl->lv)) count += (_lv_open_count(vg->cmd, lvl->lv) > 0); - } + + log_debug("Counted %d open LVs in VG %s", count, vg->name); return count; } @@ -822,12 +830,14 @@ int lv_is_active_exclusive_locally(struct logical_volume *lv) { int l, e; + return _lv_is_active(lv, &l, &e) && l && e; } int lv_is_active_exclusive_remotely(struct logical_volume *lv) { int l, e; + return _lv_is_active(lv, &l, &e) && !l && e; } @@ -1258,6 +1268,10 @@ goto out; } + log_debug("Resuming LV %s/%s%s%s.", lv->vg->name, lv->name, + error_if_not_active ? "" : " if active", + origin_only ? " without snapshots" : ""); + if (!lv_info(cmd, lv, origin_only, &info, 0, 0)) goto_out; @@ -1347,6 +1361,8 @@ goto out; } + log_debug("Deactivating %s/%s.", lv->vg->name, lv->name); + if (!lv_info(cmd, lv, 0, &info, 1, 0)) goto_out; @@ -1454,6 +1470,8 @@ goto out; } + log_debug("Activating %s/%s%s.", lv->vg->name, lv->name, exclusive ? " exclusively" : ""); + if (!lv_info(cmd, lv, 0, &info, 0, 0)) goto_out; --- LVM2/lib/metadata/lv_manip.c 2011/06/11 00:03:07 1.261 +++ LVM2/lib/metadata/lv_manip.c 2011/06/13 22:28:05 1.262 @@ -2677,6 +2677,7 @@ struct lvinfo info; struct logical_volume *origin = NULL; int was_merging = 0; + int reload_required = 0; vg = lv->vg; @@ -2738,6 +2739,7 @@ return_0; } + /* FIXME Review and fix the snapshot error paths! */ if (!deactivate_lv(cmd, lv)) { log_error("Unable to deactivate logical volume \"%s\"", lv->name); @@ -2750,20 +2752,24 @@ return 0; } + /* If no snapshots left, and was not merging, reload without -real. */ + if (origin && (!lv_is_origin(origin) && !was_merging)) + reload_required = 1; + /* store it on disks */ - if (!vg_write(vg) || !vg_commit(vg)) + if (!vg_write(vg)) return_0; - /* If no snapshots left, and was not merging, reload without -real. */ - if (origin && (!lv_is_origin(origin) && !was_merging)) { - if (!suspend_lv(cmd, origin)) { - log_error("Failed to refresh %s without snapshot.", origin->name); - return 0; - } - if (!resume_lv(cmd, origin)) { - log_error("Failed to resume %s.", origin->name); - return 0; - } + if (reload_required && !suspend_lv(cmd, origin)) + log_error("Failed to refresh %s without snapshot.", origin->name); + /* FIXME Falls through because first part of change already in kernel! */ + + if (!vg_commit(vg)) + return_0; + + if (reload_required && !resume_lv(cmd, origin)) { + log_error("Failed to resume %s.", origin->name); + return 0; } backup(vg); From mornfall@sourceware.org Tue Jun 14 02:34:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Tue, 14 Jun 2011 02:34:00 -0000 Subject: LVM2/daemons/common daemon-client.h daemon-ser ... Message-ID: <20110614023419.2122.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-14 02:34:18 Modified files: daemons/common : daemon-client.h daemon-server.c daemon-server.h Added files: daemons/common : daemon-client.c daemon-shared.c daemon-shared.h Log message: Common daemon code: Implement basic socket-based communication infrastructure (both client and server side). The server handles each connection in a separate thread. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.h.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.h.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5 /cvs/lvm2/LVM2/daemons/common/daemon-client.c,v --> standard output revision 1.1 --- LVM2/daemons/common/daemon-client.c +++ - 2011-06-14 02:34:19.031404000 +0000 @@ -0,0 +1,54 @@ +#include "daemon-client.h" +#include "daemon-shared.h" +#include +#include +#include +#include +#include + +daemon_handle daemon_open(daemon_info i) { + daemon_handle h; + struct sockaddr_un sockaddr; + if ((h.socket_fd = socket(PF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) < 0) { + perror("socket"); + goto error; + } + memset(&sockaddr, 0, sizeof(sockaddr)); + fprintf(stderr, "connecting to %s\n", i.socket); + strcpy(sockaddr.sun_path, i.socket); + sockaddr.sun_family = AF_UNIX; + if (connect(h.socket_fd,(struct sockaddr *) &sockaddr, sizeof(sockaddr))) { + perror("connect"); + goto error; + } + h.protocol = 0; + return h; +error: + if (h.socket_fd >= 0) + close(h.socket_fd); + h.socket_fd = -1; + return h; +} + +daemon_reply daemon_send(daemon_handle h, daemon_request rq) +{ + daemon_reply reply; + assert(h.socket_fd >= 0); + + if (!rq.buffer) { + /* TODO: build the buffer from rq.cft */ + } + + assert(rq.buffer); + write_buffer(h.socket_fd, rq.buffer, strlen(rq.buffer)); + + if (read_buffer(h.socket_fd, &reply.buffer)) { + /* TODO: parse reply.buffer into reply.cft */ + } else + reply.error = 1; + + return reply; +} + +void daemon_close(daemon_handle h) { +} /cvs/lvm2/LVM2/daemons/common/daemon-shared.c,v --> standard output revision 1.1 --- LVM2/daemons/common/daemon-shared.c +++ - 2011-06-14 02:34:19.142467000 +0000 @@ -0,0 +1,68 @@ +#include +#include +#include +#include + +/* + * Read a single message from a (socket) filedescriptor. Messages are delimited + * by blank lines. This call will block until all of a message is received. The + * memory will be allocated from heap. Upon error, all memory is freed and the + * buffer pointer is set to NULL. + */ +int read_buffer(int fd, char **buffer) { + int bytes = 0; + int buffersize = 32; + *buffer = malloc(buffersize + 1); + + while (1) { + int result = read(fd, (*buffer) + bytes, buffersize - bytes); + if (result > 0) + bytes += result; + if (result == 0) + goto fail; /* we should never encounter EOF here */ + if (result < 0 && errno != EAGAIN && errno != EWOULDBLOCK) + goto fail; + + if (bytes == buffersize) { + buffersize += 1024; + char *new = realloc(*buffer, buffersize + 1); + if (new) + *buffer = new; + else + goto fail; + } else { + (*buffer)[bytes] = 0; + char *end; + if ((end = strstr((*buffer) + bytes - 2, "\n\n"))) { + *end = 0; + break; /* success, we have the full message now */ + } + /* TODO call select here if we encountered EAGAIN/EWOULDBLOCK */ + } + } + return 1; +fail: + free(*buffer); + *buffer = NULL; + return 0; +} + +/* + * Write a buffer to a filedescriptor. Keep trying. Blocks (even on + * SOCK_NONBLOCK) until all of the write went through. + * + * TODO use select on EWOULDBLOCK/EAGAIN to avoid useless spinning + */ +int write_buffer(int fd, char *buffer, int length) { + int written = 0; + while (1) { + int result = write(fd, buffer + written, length - written); + if (result > 0) + written += result; + if (result < 0 && errno != EWOULDBLOCK && errno != EAGAIN) + break; /* too bad */ + if (written == length) + return 1; /* done */ + } + return 0; +} /cvs/lvm2/LVM2/daemons/common/daemon-shared.h,v --> standard output revision 1.1 --- LVM2/daemons/common/daemon-shared.h +++ - 2011-06-14 02:34:19.240114000 +0000 @@ -0,0 +1,2 @@ +int read_buffer(int fd, char **buffer); +int write_buffer(int fd, char *buffer, int length); --- LVM2/daemons/common/daemon-client.h 2011/05/15 11:02:29 1.2 +++ LVM2/daemons/common/daemon-client.h 2011/06/14 02:34:18 1.3 @@ -12,6 +12,8 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "config.h" // should become part of libdevmapper later + #ifndef _LVM_DAEMON_COMMON_CLIENT_H #define _LVM_DAEMON_COMMON_CLIENT_H @@ -28,13 +30,14 @@ } daemon_info; typedef struct { - char *request; + char *buffer; + struct config_node *cft; } daemon_request; typedef struct { int error; /* 0 for success */ - char *reply; /* textual reply */ - struct config_tree *cft; /* parsed reply, if available */ + char *buffer; /* textual reply */ + struct config_node *cft; /* parsed reply, if available */ } daemon_reply; /* --- LVM2/daemons/common/daemon-server.c 2011/05/15 11:02:29 1.3 +++ LVM2/daemons/common/daemon-server.c 2011/06/14 02:34:18 1.4 @@ -107,8 +107,9 @@ fprintf(stderr, "setting CLOEXEC on socket fd %d failed: %s\n", fd, strerror(errno)); fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); + fprintf(stderr, "creating %s\n", s.socket_path); memset(&sockaddr, 0, sizeof(sockaddr)); - memcpy(sockaddr.sun_path, s.socket_path, strlen(s.socket_path)); + strcpy(sockaddr.sun_path, s.socket_path); sockaddr.sun_family = AF_UNIX; if (bind(fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) { @@ -128,6 +129,7 @@ error: if (fd >= 0) { close(fd); + unlink(s.socket_path); fd = -1; } goto out; @@ -198,6 +200,60 @@ setsid(); } +struct thread_baton { + daemon_state s; + client_handle client; +}; + +void *client_thread(void *baton) +{ + struct thread_baton *b = baton; + request req; + while (1) { + if (!read_buffer(b->client.socket_fd, &req.buffer)) + goto fail; + + /* TODO parse the buffer into req.cft */ + response res = b->s.handler(b->s, b->client, req); + + if (!res.buffer) { + /* TODO fill in the buffer from res.cft */ + } + + write_buffer(b->client.socket_fd, res.buffer, strlen(res.buffer)); + + free(res.buffer); + free(req.buffer); + } +fail: + /* TODO what should we really do here? */ + return NULL; +} + +int handle_connect(daemon_state s) +{ + struct sockaddr_un sockaddr; + client_handle client; + socklen_t sl = sizeof(sockaddr); + int client_fd = accept(s.socket_fd, (struct sockaddr *) &sockaddr, &sl); + if (client_fd < 0) + return 0; + + struct thread_baton *baton = malloc(sizeof(struct thread_baton)); + if (!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; +} + void daemon_start(daemon_state s) { int failed = 0; @@ -230,6 +286,8 @@ signal(SIGINT, &_exit_handler); signal(SIGHUP, &_exit_handler); signal(SIGQUIT, &_exit_handler); + signal(SIGTERM, &_exit_handler); + signal(SIGPIPE, SIG_IGN); #ifdef linux if (s.avoid_oom && !_set_oom_adj(OOM_DISABLE) && !_set_oom_adj(OOM_ADJUST_MIN)) @@ -247,9 +305,20 @@ kill(getppid(), SIGTERM); while (!_shutdown_requested && !failed) { - /* TODO: do work */ + int status; + fd_set in; + FD_ZERO(&in); + FD_SET(s.socket_fd, &in); + if (select(FD_SETSIZE, &in, NULL, NULL, NULL) < 0 && errno != EINTR) + perror("select error"); + if (FD_ISSET(s.socket_fd, &in)) + if (!handle_connect(s)) + syslog(LOG_ERR, "Failed to handle a client connection."); } + if (s.socket_fd >= 0) + unlink(s.socket_path); + syslog(LOG_NOTICE, "%s shutting down", s.name); closelog(); remove_lockfile(s.pidfile); --- LVM2/daemons/common/daemon-server.h 2011/05/15 11:02:29 1.4 +++ LVM2/daemons/common/daemon-server.h 2011/06/14 02:34:18 1.5 @@ -13,6 +13,7 @@ */ #include "daemon-client.h" +#include "config.h" // XXX will be in libdevmapper.h later #ifndef _LVM_DAEMON_COMMON_SERVER_H #define _LVM_DAEMON_COMMON_SERVER_H @@ -25,12 +26,14 @@ } client_handle; typedef struct { - struct config_tree *cft; + struct config_node *cft; + char *buffer; } request; typedef struct { int error; - struct config_tree *cft; + struct config_node *cft; + char *buffer; } response; struct daemon_state; From mornfall@sourceware.org Tue Jun 14 02:36:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Tue, 14 Jun 2011 02:36:00 -0000 Subject: LVM2/daemons/lvmetad lvmetad-client.h Makefile ... Message-ID: <20110614023639.13104.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-14 02:36:38 Modified files: daemons/lvmetad: lvmetad-client.h Added files: daemons/lvmetad: Makefile lvmetad-core.c testclient.c Log message: Add a skeleton for lvmetad, a test client, and a temporary Makefile to build them. These are currently mostly for testing the daemon-common code. LVMetaD functionality is expected to trickle in soon though. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/Makefile.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/testclient.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-client.h.diff?cvsroot=lvm2&r1=1.2&r2=1.3 /cvs/lvm2/LVM2/daemons/lvmetad/Makefile,v --> standard output revision 1.1 --- LVM2/daemons/lvmetad/Makefile +++ - 2011-06-14 02:36:38.688218000 +0000 @@ -0,0 +1,26 @@ +# +# WARNING +# +# This is a temporary Makefile. You need to edit the IPATH/LPATH variables to +# point to build-dir of LVM2. You may then just run "make" to build the lvmetad +# binary and the test client. +# + +SHARED = ../common/daemon-shared.c +CLIENT = ../common/daemon-client.c $(SHARED) +SERVER = ../common/daemon-server.c $(SHARED) +SHARED_H = ../common/daemon-shared.h +CLIENT_H = ../common/daemon-client.h $(SHARED_H) +SERVER_H = ../common/daemon-server.h $(SHARED_H) + +LIBS = -ldevmapper -lpthread +IPATH = -I../common -I/srv/build/lvm2/cvs-lvmetad/default/include +LPATH = -L/srv/build/lvm2/cvs-lvmetad/default/libdm + +all: testclient lvmetad + +testclient: testclient.c $(CLIENT_H) $(CLIENT) + gcc -g testclient.c $(CLIENT) $(IPATH) $(LPATH) $(LIBS) -o testclient + +lvmetad: lvmetad-core.c ../common/daemon-server.c ../common/daemon-server.h ../common/daemon-shared.h ../common/daemon-shared.c + gcc -g lvmetad-core.c $(SERVER) $(IPATH) $(LPATH) $(LIBS) -o lvmetad /cvs/lvm2/LVM2/daemons/lvmetad/lvmetad-core.c,v --> standard output revision 1.1 --- LVM2/daemons/lvmetad/lvmetad-core.c +++ - 2011-06-14 02:36:38.790300000 +0000 @@ -0,0 +1,76 @@ +#include "metadata-exported.h" +#include "../common/daemon-server.h" + +typedef struct { +} lvmetad_state; + +static response handler(daemon_state s, client_handle h, request r) +{ + response res; + fprintf(stderr, "handling client request: %s\n", r.buffer); + res.error = 1; + res.buffer = strdup("hey hey.\n\n"); + return res; +} + +static int setup_post(daemon_state *s) +{ + lvmetad_state *ls = s->private; + + /* if (ls->initial_registrations) + _process_initial_registrations(ds->initial_registrations); */ + + return 1; +} + +static void usage(char *prog, FILE *file) +{ + fprintf(file, "Usage:\n" + "%s [-V] [-h] [-d] [-d] [-d] [-f]\n\n" + " -V Show version of lvmetad\n" + " -h Show this help information\n" + " -d Log debug messages to syslog (-d, -dd, -ddd)\n" + " -R Replace a running lvmetad instance, loading its data\n" + " -f Don't fork, run in the foreground\n\n", prog); +} + +int main(int argc, char *argv[]) +{ + signed char opt; + daemon_state s; + lvmetad_state ls; + int _restart = 0; + + s.private = &ls; + s.setup_post = setup_post; + s.handler = handler; + s.socket_path = "/var/run/lvm/lvmetad.socket"; + s.pidfile = "/var/run/lvm/lvmetad.pid"; + + while ((opt = getopt(argc, argv, "?fhVdR")) != EOF) { + switch (opt) { + case 'h': + usage(argv[0], stdout); + exit(0); + case '?': + usage(argv[0], stderr); + exit(0); + case 'R': + _restart++; + break; + case 'f': + s.foreground = 1; + break; + case 'd': + s.log_level++; + break; + case 'V': + printf("lvmetad version 0\n"); + exit(1); + break; + } + } + + daemon_start(s); + return 0; +} /cvs/lvm2/LVM2/daemons/lvmetad/testclient.c,v --> standard output revision 1.1 --- LVM2/daemons/lvmetad/testclient.c +++ - 2011-06-14 02:36:38.888671000 +0000 @@ -0,0 +1,12 @@ +#include "lvmetad-client.h" + +int main() { + daemon_handle h = lvmetad_open(); + daemon_request rq = { .buffer= "hello worldn\n" }; + int i; + for (i = 0; i < 5; ++i ) { + daemon_reply reply = daemon_send(h, rq); + fprintf(stderr, "daemon says: %s\n", reply.buffer); + } + return 0; +} --- LVM2/daemons/lvmetad/lvmetad-client.h 2011/06/02 08:58:05 1.2 +++ LVM2/daemons/lvmetad/lvmetad-client.h 2011/06/14 02:36:38 1.3 @@ -16,6 +16,7 @@ #define _LVM_LVMETAD_CLIENT_H #include "daemon-client.h" +#include "metadata-exported.h" /* Different types of replies we may get from lvmetad. */ From mbroz@sourceware.org Wed Jun 15 10:56:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Wed, 15 Jun 2011 10:56:00 -0000 Subject: LVM2/tools lvresize.c Message-ID: <20110615105652.23542.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-15 10:56:52 Modified files: tools : lvresize.c Log message: Fix lvreduce stripe rounding up from previous commit. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133 --- LVM2/tools/lvresize.c 2011/06/09 19:38:56 1.132 +++ LVM2/tools/lvresize.c 2011/06/15 10:56:52 1.133 @@ -609,8 +609,10 @@ if (size_rest && lp->resize == LV_REDUCE) { log_print("Rounding size (%d extents) up to stripe " "boundary size for segment (%d extents)", - lp->extents, lp->extents + size_rest); - lp->extents = lp->extents + size_rest; + lp->extents, lp->extents - size_rest + + (lp->stripes * stripesize_extents)); + lp->extents = lp->extents - size_rest + + (lp->stripes * stripesize_extents); } else if (size_rest) { log_print("Rounding size (%d extents) down to stripe " "boundary size for segment (%d extents)", From prajnoha@sourceware.org Wed Jun 15 13:29:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Wed, 15 Jun 2011 13:29:00 -0000 Subject: LVM2 ./WHATS_NEW liblvm/lvm_base.c Message-ID: <20110615132949.30137.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-06-15 13:29:48 Modified files: . : WHATS_NEW liblvm : lvm_base.c Log message: Add proper udev library context initialization and finalization to liblvm. This was missing in liblvm and it caused all udev-related operations to not take effect when using liblvm, e.g. obtaining the list of devices from udev db instead of scanning the whole /dev which also recreated the .cache as a side effect. This was also the case with udisks-lvm-pv-export prober which is run from within udev rules whenever the CHANGE event is fired. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2014&r2=1.2015 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_base.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22 --- LVM2/WHATS_NEW 2011/06/13 22:28:04 1.2014 +++ LVM2/WHATS_NEW 2011/06/15 13:29:48 1.2015 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Add proper udev library context initialization and finalization to liblvm. Fix last snapshot removal to avoid table reload while a device is suspended. Use dm_get_suspended_counter in replacement critical_section logic. Downgrade critical_section errors to debug level until it is moved to libdm. --- LVM2/liblvm/lvm_base.c 2011/05/07 13:50:11 1.21 +++ LVM2/liblvm/lvm_base.c 2011/06/15 13:29:48 1.22 @@ -31,6 +31,9 @@ /* FIXME: logging bound to handle */ + if (!udev_init_library_context()) + stack; + /* create context */ /* FIXME: split create_toolcontext */ /* FIXME: make all globals configurable */ @@ -69,6 +72,7 @@ void lvm_quit(lvm_t libh) { destroy_toolcontext((struct cmd_context *)libh); + udev_fin_library_context(); } int lvm_config_reload(lvm_t libh) From mornfall@sourceware.org Wed Jun 15 17:45:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 15 Jun 2011 17:45:00 -0000 Subject: LVM2 lib/format_text/format-text.c lib/metadat ... Message-ID: <20110615174505.9012.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-15 17:45:04 Modified files: lib/format_text: format-text.c lib/metadata : metadata.c metadata.h test : t-lvconvert-repair-transient-dmeventd.sh Log message: Fix RHBZ 651590 (failure to lock LV results in failure to repair mirror after transient error), stemming from the following sequence of events: 1) devices fail IO, triggering repair 2) dmeventd starts fixing up the mirror 3) during the downconversion, a new metadata version is written --> the devices come back online here 4) the mirror device suspend/resume is called to update DM tables 5) during the suspend/resume cycle, *pre*-commit metadata is read; however, since the failed devices are now back online, we get back inconsistent set of precommit metadata and the whole operation fails The patch relaxes the check that fails in step 5 above, namely by ignoring inconsistencies coming from PVs that are marked MISSING. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.181&r2=1.182 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.457&r2=1.458 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.244&r2=1.245 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-repair-transient-dmeventd.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/lib/format_text/format-text.c 2011/06/01 19:29:33 1.181 +++ LVM2/lib/format_text/format-text.c 2011/06/15 17:45:02 1.182 @@ -127,6 +127,12 @@ return 0; } +static struct device *_mda_get_device_raw(struct metadata_area *mda) +{ + struct mda_context *mdac = (struct mda_context *) mda->metadata_locn; + return mdac->area.dev; +} + /* * For circular region between region_start and region_start + region_size, * back up one SECTOR_SIZE from 'region_ptr' and return the value. @@ -1629,7 +1635,8 @@ .mda_total_sectors = _mda_total_sectors_raw, .mda_in_vg = _mda_in_vg_raw, .pv_analyze_mda = _pv_analyze_mda_raw, - .mda_locns_match = _mda_locns_match_raw + .mda_locns_match = _mda_locns_match_raw, + .mda_get_device = _mda_get_device_raw }; static int _text_pv_setup(const struct format_type *fmt, --- LVM2/lib/metadata/metadata.c 2011/06/01 19:29:33 1.457 +++ LVM2/lib/metadata/metadata.c 2011/06/15 17:45:03 1.458 @@ -2837,6 +2837,7 @@ int inconsistent_pvs = 0; int inconsistent_seqno = 0; int inconsistent_mdas = 0; + int inconsistent_mda_count = 0; unsigned use_precommitted = precommitted; unsigned saved_handles_missing_pvs = cmd->handles_missing_pvs; struct dm_list *pvids; @@ -2913,6 +2914,7 @@ return_NULL; /* Ensure contents of all metadata areas match - else do recovery */ + inconsistent_mda_count=0; dm_list_iterate_items(mda, &fid->metadata_areas_in_use) { if ((use_precommitted && !(vg = mda->ops->vg_read_precommit(fid, vgname, mda))) || @@ -2922,6 +2924,7 @@ free_vg(vg); continue; } + if (!correct_vg) { correct_vg = vg; continue; @@ -2940,6 +2943,9 @@ if (vg->seqno > correct_vg->seqno) { free_vg(correct_vg); correct_vg = vg; + } else { + mda->status |= MDA_INCONSISTENT; + ++inconsistent_mda_count; } } @@ -3067,6 +3073,7 @@ } /* Ensure contents of all metadata areas match - else recover */ + inconsistent_mda_count=0; dm_list_iterate_items(mda, &fid->metadata_areas_in_use) { if ((use_precommitted && !(vg = mda->ops->vg_read_precommit(fid, vgname, @@ -3111,6 +3118,9 @@ if (vg->seqno > correct_vg->seqno) { free_vg(correct_vg); correct_vg = vg; + } else { + mda->status |= MDA_INCONSISTENT; + ++inconsistent_mda_count; } } @@ -3137,13 +3147,26 @@ if (use_precommitted) { log_error("Inconsistent pre-commit metadata copies " "for volume group %s", vgname); - /* FIXME: during repair, there is inconsistent flag set because some metadata areas - * are missing (on missing PVs). Code should create list of missing PVs, compare it - * with PV marked missing in metadata and if equals, use it as consistent vg. - * For now, return precommited metadata if remainng seq match here to allow - * preloading table in suspend call. + + /* + * Check whether all of the inconsistent MDAs were on + * MISSING PVs -- in that case, we should be safe. */ - if (!inconsistent_seqno) { + dm_list_iterate_items(mda, &fid->metadata_areas_in_use) { + if (mda->status & MDA_INCONSISTENT) { + log_debug("Checking inconsistent MDA: %s", dev_name(mda_get_device(mda))); + dm_list_iterate_items(pvl, &correct_vg->pvs) { + if (mda_get_device(mda) == pvl->pv->dev && + (pvl->pv->status & MISSING_PV)) + --inconsistent_mda_count; + } + } + } + + if (inconsistent_mda_count < 0) + log_error(INTERNAL_ERROR "Too many inconsistent MDAs."); + + if (!inconsistent_mda_count) { *consistent = 0; _free_pv_list(&all_pvs); return correct_vg; @@ -4285,6 +4308,13 @@ return mda1->ops->mda_locns_match(mda1, mda2); } +struct device *mda_get_device(struct metadata_area *mda) +{ + if (!mda->ops->mda_get_device) + return NULL; + return mda->ops->mda_get_device(mda); +} + unsigned mda_is_ignored(struct metadata_area *mda) { return (mda->status & MDA_IGNORED); --- LVM2/lib/metadata/metadata.h 2011/06/01 19:29:33 1.244 +++ LVM2/lib/metadata/metadata.h 2011/06/15 17:45:03 1.245 @@ -175,9 +175,12 @@ */ unsigned (*mda_locns_match)(struct metadata_area *mda1, struct metadata_area *mda2); + + struct device *(*mda_get_device)(struct metadata_area *mda); }; -#define MDA_IGNORED 0x00000001 +#define MDA_IGNORED 0x00000001 +#define MDA_INCONSISTENT 0x00000002 struct metadata_area { struct dm_list list; @@ -191,6 +194,7 @@ unsigned mda_is_ignored(struct metadata_area *mda); void mda_set_ignored(struct metadata_area *mda, unsigned ignored); unsigned mda_locns_match(struct metadata_area *mda1, struct metadata_area *mda2); +struct device *mda_get_device(struct metadata_area *mda); struct format_instance_ctx { uint32_t type; --- LVM2/test/t-lvconvert-repair-transient-dmeventd.sh 2011/01/07 14:56:10 1.1 +++ LVM2/test/t-lvconvert-repair-transient-dmeventd.sh 2011/06/15 17:45:03 1.2 @@ -19,9 +19,9 @@ aux disable_dev $dev2 $dev4 mkfs.ext3 $DM_DEV_DIR/$vg/4way aux enable_dev $dev2 $dev4 -sleep 10 +sleep 3 lvs -a -o +devices | not grep unknown check mirror $vg 4way check mirror_legs $vg 4way 2 -lvs -a -o +devices | should not grep mimage_1 -lvs -a -o +devices | should not grep mimage_3 +lvs -a -o +devices | not grep mimage_1 +lvs -a -o +devices | not grep mimage_3 From mornfall@sourceware.org Wed Jun 15 17:48:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 15 Jun 2011 17:48:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20110615174837.12152.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-15 17:48:36 Modified files: . : WHATS_NEW Log message: What's new. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2015&r2=1.2016 --- LVM2/WHATS_NEW 2011/06/15 13:29:48 1.2015 +++ LVM2/WHATS_NEW 2011/06/15 17:48:35 1.2016 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Fix a problem with inconsistent pre-commit metadata on MISSING_PV devices. Add proper udev library context initialization and finalization to liblvm. Fix last snapshot removal to avoid table reload while a device is suspended. Use dm_get_suspended_counter in replacement critical_section logic. From zkabelac@sourceware.org Fri Jun 17 14:14:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 17 Jun 2011 14:14:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ... Message-ID: <20110617141423.32545.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-17 14:14:21 Modified files: . : WHATS_NEW lib/activate : activate.c activate.h dev_manager.c dev_manager.h lib/error : errseg.c lib/metadata : segtype.h lib/mirror : mirrored.c lib/replicator : replicator.c lib/snapshot : snapshot.c lib/striped : striped.c lib/unknown : unknown.c lib/zero : zero.c Log message: Add lv_activate_opts structure To avoid modification of 'read-only' volume group structure add a new structure to pass local data around the code for LV activation. As origin_only is one such flag - replace this parameter with new struct lv_activate_opts. More parameters might eventually become part of lv_activate_opts. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2016&r2=1.2017 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.198&r2=1.199 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.76&r2=1.77 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.217&r2=1.218 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.h.diff?cvsroot=lvm2&r1=1.37&r2=1.38 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/error/errseg.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.34&r2=1.35 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replicator/replicator.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/striped/striped.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/unknown/unknown.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/zero/zero.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25 --- LVM2/WHATS_NEW 2011/06/15 17:48:35 1.2016 +++ LVM2/WHATS_NEW 2011/06/17 14:14:19 1.2017 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Add lv_activate_opts structure for activation (replacing activation flags). Fix a problem with inconsistent pre-commit metadata on MISSING_PV devices. Add proper udev library context initialization and finalization to liblvm. Fix last snapshot removal to avoid table reload while a device is suspended. --- LVM2/lib/activate/activate.c 2011/06/13 22:28:04 1.198 +++ LVM2/lib/activate/activate.c 2011/06/17 14:14:19 1.199 @@ -243,7 +243,7 @@ return 1; } int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv, - unsigned origin_only, int monitor) + struct lv_activate_opts *laopts, int monitor) { return 1; } @@ -632,7 +632,7 @@ return info.open_count; } -static int _lv_activate_lv(struct logical_volume *lv, unsigned origin_only) +static int _lv_activate_lv(struct logical_volume *lv, struct lv_activate_opts *laopts) { int r; struct dev_manager *dm; @@ -640,14 +640,15 @@ if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1))) return_0; - if (!(r = dev_manager_activate(dm, lv, origin_only))) + if (!(r = dev_manager_activate(dm, lv, laopts))) stack; dev_manager_destroy(dm); return r; } -static int _lv_preload(struct logical_volume *lv, unsigned origin_only, int *flush_required) +static int _lv_preload(struct logical_volume *lv, struct lv_activate_opts *laopts, + int *flush_required) { int r; struct dev_manager *dm; @@ -655,7 +656,7 @@ if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1))) return_0; - if (!(r = dev_manager_preload(dm, lv, origin_only, flush_required))) + if (!(r = dev_manager_preload(dm, lv, laopts, flush_required))) stack; dev_manager_destroy(dm); @@ -677,7 +678,8 @@ return r; } -static int _lv_suspend_lv(struct logical_volume *lv, unsigned origin_only, int lockfs, int flush_required) +static int _lv_suspend_lv(struct logical_volume *lv, struct lv_activate_opts *laopts, + int lockfs, int flush_required) { int r; struct dev_manager *dm; @@ -689,7 +691,7 @@ if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, (lv->status & PVMOVE) ? 0 : 1))) return_0; - if (!(r = dev_manager_suspend(dm, lv, origin_only, lockfs, flush_required))) + if (!(r = dev_manager_suspend(dm, lv, laopts, lockfs, flush_required))) stack; dev_manager_destroy(dm); @@ -955,7 +957,7 @@ * Returns 1 otherwise. */ int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv, - unsigned origin_only, int monitor) + const struct lv_activate_opts *laopts, int monitor) { #ifdef DMEVENTD int i, pending = 0, monitored; @@ -965,6 +967,10 @@ struct lv_segment *log_seg; int (*monitor_fn) (struct lv_segment *s, int e); uint32_t s; + static const struct lv_activate_opts zlaopts = { 0 }; + + if (!laopts) + laopts = &zlaopts; /* skip dmeventd code altogether */ if (dmeventd_monitor_mode() == DMEVENTD_MONITOR_IGNORE) @@ -988,10 +994,10 @@ * each of its respective snapshots. The origin itself may * also need to be monitored if it is a mirror, for example. */ - if (!origin_only && lv_is_origin(lv)) + if (!laopts->origin_only && lv_is_origin(lv)) dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) if (!monitor_dev_for_events(cmd, dm_list_struct_base(snh, - struct lv_segment, origin_list)->cow, 0, monitor)) + struct lv_segment, origin_list)->cow, NULL, monitor)) r = 0; /* @@ -1001,7 +1007,7 @@ if ((seg = first_seg(lv)) != NULL && seg->log_lv != NULL && (log_seg = first_seg(seg->log_lv)) != NULL && seg_is_mirrored(log_seg)) - if (!monitor_dev_for_events(cmd, seg->log_lv, 0, monitor)) + if (!monitor_dev_for_events(cmd, seg->log_lv, NULL, monitor)) r = 0; dm_list_iterate(tmp, &lv->segments) { @@ -1011,7 +1017,7 @@ for (s = 0; s < seg->area_count; s++) { if (seg_type(seg, s) != AREA_LV) continue; - if (!monitor_dev_for_events(cmd, seg_lv(seg, s), 0, + if (!monitor_dev_for_events(cmd, seg_lv(seg, s), NULL, monitor)) { log_error("Failed to %smonitor %s", monitor ? "" : "un", @@ -1092,7 +1098,7 @@ } static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, - unsigned origin_only, int error_if_not_suspended) + struct lv_activate_opts *laopts, int error_if_not_suspended) { struct logical_volume *lv = NULL, *lv_pre = NULL, *pvmove_lv = NULL; struct lv_list *lvl_pre; @@ -1112,15 +1118,15 @@ /* Ignore origin_only unless LV is origin in both old and new metadata */ if (!lv_is_origin(lv) || !lv_is_origin(lv_pre)) - origin_only = 0; + laopts->origin_only = 0; if (test_mode()) { - _skip("Suspending %s%s.", lv->name, origin_only ? " origin without snapshots" : ""); + _skip("Suspending %s%s.", lv->name, laopts->origin_only ? " origin without snapshots" : ""); r = 1; goto out; } - if (!lv_info(cmd, lv, origin_only, &info, 0, 0)) + if (!lv_info(cmd, lv, laopts->origin_only, &info, 0, 0)) goto_out; if (!info.exists || info.suspended) { @@ -1155,7 +1161,7 @@ log_error("LV %s missing from preload metadata", sl->seg->lv->name); goto out; } - if (!_lv_preload(lvl_pre->lv, origin_only, &flush_required)) + if (!_lv_preload(lvl_pre->lv, laopts, &flush_required)) goto_out; } /* Now preload the PVMOVE LV itself */ @@ -1164,14 +1170,14 @@ log_error("LV %s missing from preload metadata", pvmove_lv->name); goto out; } - if (!_lv_preload(lvl_pre->lv, origin_only, &flush_required)) + if (!_lv_preload(lvl_pre->lv, laopts, &flush_required)) goto_out; - } else if (!_lv_preload(lv_pre, origin_only, &flush_required)) + } else if (!_lv_preload(lv_pre, laopts, &flush_required)) /* FIXME Revert preloading */ goto_out; } - if (!monitor_dev_for_events(cmd, lv, origin_only, 0)) + if (!monitor_dev_for_events(cmd, lv, laopts, 0)) /* FIXME Consider aborting here */ stack; @@ -1179,7 +1185,7 @@ if (pvmove_lv) critical_section_inc(cmd, "suspending pvmove LV"); - if (!origin_only && + if (!laopts->origin_only && (lv_is_origin(lv_pre) || lv_is_cow(lv_pre))) lockfs = 1; @@ -1193,7 +1199,7 @@ */ if ((lv_pre->vg->status & PRECOMMITTED) && (lv_pre->status & LOCKED) && find_pvmove_lv_in_lv(lv_pre)) { - if (!_lv_suspend_lv(lv_pre, origin_only, lockfs, flush_required)) { + if (!_lv_suspend_lv(lv_pre, laopts, lockfs, flush_required)) { critical_section_dec(cmd, "failed precommitted suspend"); if (pvmove_lv) critical_section_dec(cmd, "failed precommitted suspend (pvmove)"); @@ -1201,7 +1207,7 @@ } } else { /* Normal suspend */ - if (!_lv_suspend_lv(lv, origin_only, lockfs, flush_required)) { + if (!_lv_suspend_lv(lv, laopts, lockfs, flush_required)) { critical_section_dec(cmd, "failed suspend"); if (pvmove_lv) critical_section_dec(cmd, "failed suspend (pvmove)"); @@ -1224,7 +1230,9 @@ /* Returns success if the device is not active */ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only) { - return _lv_suspend(cmd, lvid_s, origin_only, 0); + struct lv_activate_opts laopts = { .origin_only = origin_only }; + + return _lv_suspend(cmd, lvid_s, &laopts, 0); } /* No longer used */ @@ -1246,8 +1254,7 @@ * @error_if_not_active */ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s, - unsigned origin_only, unsigned exclusive, - int error_if_not_active) + struct lv_activate_opts *laopts, int error_if_not_active) { struct logical_volume *lv; struct lvinfo info; @@ -1260,19 +1267,19 @@ goto_out; if (!lv_is_origin(lv)) - origin_only = 0; + laopts->origin_only = 0; if (test_mode()) { - _skip("Resuming %s%s.", lv->name, origin_only ? " without snapshots" : ""); + _skip("Resuming %s%s.", lv->name, laopts->origin_only ? " without snapshots" : ""); r = 1; goto out; } log_debug("Resuming LV %s/%s%s%s.", lv->vg->name, lv->name, error_if_not_active ? "" : " if active", - origin_only ? " without snapshots" : ""); + laopts->origin_only ? " without snapshots" : ""); - if (!lv_info(cmd, lv, origin_only, &info, 0, 0)) + if (!lv_info(cmd, lv, laopts->origin_only, &info, 0, 0)) goto_out; if (!info.exists || !info.suspended) { @@ -1289,15 +1296,15 @@ * non-clustered target should be used. This only happens * if ACTIVATE_EXCL is set in lv->status. */ - if (exclusive) + if (laopts->exclusive) lv->status |= ACTIVATE_EXCL; - if (!_lv_activate_lv(lv, origin_only)) + if (!_lv_activate_lv(lv, laopts)) goto_out; critical_section_dec(cmd, "resumed"); - if (!monitor_dev_for_events(cmd, lv, origin_only, 1)) + if (!monitor_dev_for_events(cmd, lv, laopts, 1)) stack; r = 1; @@ -1312,12 +1319,24 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive) { - return _lv_resume(cmd, lvid_s, origin_only, exclusive, 0); + struct lv_activate_opts laopts = { + .origin_only = origin_only, + /* + * When targets are activated exclusively in a cluster, the + * non-clustered target should be used. This only happens + * if exclusive is set. + */ + .exclusive = exclusive + }; + + return _lv_resume(cmd, lvid_s, &laopts, 0); } int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only) { - return _lv_resume(cmd, lvid_s, origin_only, 0, 1); + struct lv_activate_opts laopts = { .origin_only = origin_only, }; + + return _lv_resume(cmd, lvid_s, &laopts, 1); } static int _lv_has_open_snapshots(struct logical_volume *lv) @@ -1386,7 +1405,7 @@ lv_calculate_readahead(lv, NULL); - if (!monitor_dev_for_events(cmd, lv, 0, 0)) + if (!monitor_dev_for_events(cmd, lv, NULL, 0)) stack; critical_section_inc(cmd, "deactivating"); @@ -1434,7 +1453,7 @@ } static int _lv_activate(struct cmd_context *cmd, const char *lvid_s, - int exclusive, int filter) + struct lv_activate_opts *laopts, int filter) { struct logical_volume *lv; struct lvinfo info; @@ -1470,7 +1489,8 @@ goto out; } - log_debug("Activating %s/%s%s.", lv->vg->name, lv->name, exclusive ? " exclusively" : ""); + log_debug("Activating %s/%s%s.", lv->vg->name, lv->name, + laopts->exclusive ? " exclusively" : ""); if (!lv_info(cmd, lv, 0, &info, 0, 0)) goto_out; @@ -1485,15 +1505,12 @@ lv_calculate_readahead(lv, NULL); - if (exclusive) - lv->status |= ACTIVATE_EXCL; - critical_section_inc(cmd, "activating"); - if (!(r = _lv_activate_lv(lv, 0))) + if (!(r = _lv_activate_lv(lv, laopts))) stack; critical_section_dec(cmd, "activated"); - if (r && !monitor_dev_for_events(cmd, lv, 0, 1)) + if (r && !monitor_dev_for_events(cmd, lv, laopts, 1)) stack; out: @@ -1508,7 +1525,9 @@ /* Activate LV */ int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive) { - if (!_lv_activate(cmd, lvid_s, exclusive, 0)) + struct lv_activate_opts laopts = { .exclusive = exclusive }; + + if (!_lv_activate(cmd, lvid_s, &laopts, 0)) return_0; return 1; @@ -1517,7 +1536,9 @@ /* Activate LV only if it passes filter */ int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s, int exclusive) { - if (!_lv_activate(cmd, lvid_s, exclusive, 1)) + struct lv_activate_opts laopts = { .exclusive = exclusive }; + + if (!_lv_activate(cmd, lvid_s, &laopts, 1)) return_0; return 1; --- LVM2/lib/activate/activate.h 2011/02/18 14:47:29 1.76 +++ LVM2/lib/activate/activate.h 2011/06/17 14:14:19 1.77 @@ -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. * @@ -30,6 +30,12 @@ uint32_t read_ahead; }; +struct lv_activate_opts { + int exclusive; + int origin_only; + int no_merging; +}; + /* target attribute flags */ #define MIRROR_LOG_CLUSTERED 0x00000001U @@ -102,7 +108,7 @@ const char *layer, const char *target_type); int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv, - unsigned origin_only, int do_reg); + const struct lv_activate_opts *laopts, int do_reg); #ifdef DMEVENTD # include "libdevmapper-event.h" --- LVM2/lib/activate/dev_manager.c 2011/06/11 00:03:07 1.217 +++ LVM2/lib/activate/dev_manager.c 2011/06/17 14:14:19 1.218 @@ -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. * @@ -1045,7 +1045,7 @@ /* * Add LV and any known dependencies */ -static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv, unsigned origin_only) +static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv, int origin_only) { struct seg_list *sl; @@ -1077,7 +1077,7 @@ return 1; } -static struct dm_tree *_create_partial_dtree(struct dev_manager *dm, struct logical_volume *lv, unsigned origin_only) +static struct dm_tree *_create_partial_dtree(struct dev_manager *dm, struct logical_volume *lv, int origin_only) { struct dm_tree *dtree; struct dm_list *snh, *snht; @@ -1254,8 +1254,9 @@ } static int _add_snapshot_target_to_dtree(struct dev_manager *dm, - struct dm_tree_node *dnode, - struct logical_volume *lv) + struct dm_tree_node *dnode, + struct logical_volume *lv, + struct lv_activate_opts *laopts) { const char *origin_dlid; const char *cow_dlid; @@ -1288,8 +1289,9 @@ } static int _add_target_to_dtree(struct dev_manager *dm, - struct dm_tree_node *dnode, - struct lv_segment *seg) + struct dm_tree_node *dnode, + struct lv_segment *seg, + struct lv_activate_opts *laopts) { uint64_t extent_size = seg->lv->vg->extent_size; @@ -1301,47 +1303,52 @@ return seg->segtype->ops->add_target_line(dm, dm->mem, dm->cmd, &dm->target_state, seg, - dnode, + laopts, dnode, extent_size * seg->len, &dm-> pvmove_mirror_count); } static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, - struct logical_volume *lv, const char *layer); + struct logical_volume *lv, + struct lv_activate_opts *laopts, + const char *layer); /* Add all replicators' LVs */ static int _add_replicator_dev_target_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, - struct lv_segment *seg) + struct lv_segment *seg, + struct lv_activate_opts *laopts) { struct replicator_device *rdev; struct replicator_site *rsite; /* For inactive replicator add linear mapping */ if (!lv_is_active_replicator_dev(seg->lv)) { - if (!_add_new_lv_to_dtree(dm, dtree, seg->lv->rdevice->lv, NULL)) + if (!_add_new_lv_to_dtree(dm, dtree, seg->lv->rdevice->lv, laopts, NULL)) return_0; return 1; } /* Add rlog and replicator nodes */ if (!seg->replicator || - !first_seg(seg->replicator)->rlog_lv || + !first_seg(seg->replicator)->rlog_lv || !_add_new_lv_to_dtree(dm, dtree, - first_seg(seg->replicator)->rlog_lv, NULL) || - !_add_new_lv_to_dtree(dm, dtree, seg->replicator, NULL)) + first_seg(seg->replicator)->rlog_lv, + laopts, NULL) || + !_add_new_lv_to_dtree(dm, dtree, seg->replicator, laopts, NULL)) return_0; /* Activation of one replicator_dev node activates all other nodes */ dm_list_iterate_items(rsite, &seg->replicator->rsites) { dm_list_iterate_items(rdev, &rsite->rdevices) { if (rdev->lv && - !_add_new_lv_to_dtree(dm, dtree, rdev->lv, NULL)) + !_add_new_lv_to_dtree(dm, dtree, rdev->lv, + laopts, NULL)) return_0; if (rdev->slog && - !_add_new_lv_to_dtree(dm, dtree, - rdev->slog, NULL)) + !_add_new_lv_to_dtree(dm, dtree, rdev->slog, + laopts, NULL)) return_0; } } @@ -1356,7 +1363,7 @@ if (!rdev->replicator_dev->lv || !_add_new_lv_to_dtree(dm, dtree, rdev->replicator_dev->lv, - NULL)) + laopts, NULL)) return_0; } } @@ -1365,10 +1372,11 @@ } static int _add_segment_to_dtree(struct dev_manager *dm, - struct dm_tree *dtree, - struct dm_tree_node *dnode, - struct lv_segment *seg, - const char *layer) + struct dm_tree *dtree, + struct dm_tree_node *dnode, + struct lv_segment *seg, + struct lv_activate_opts *laopts, + const char *layer) { uint32_t s; struct dm_list *snh; @@ -1378,7 +1386,7 @@ /* Ensure required device-mapper targets are loaded */ seg_present = find_cow(seg->lv) ? : seg; target_name = (seg_present->segtype->ops->target_name ? - seg_present->segtype->ops->target_name(seg_present) : + seg_present->segtype->ops->target_name(seg_present, laopts) : seg_present->segtype->name); log_debug("Checking kernel supports %s segment type for %s%s%s", @@ -1395,35 +1403,35 @@ /* Add mirror log */ if (seg->log_lv && - !_add_new_lv_to_dtree(dm, dtree, seg->log_lv, NULL)) + !_add_new_lv_to_dtree(dm, dtree, seg->log_lv, laopts, NULL)) return_0; if (seg_is_replicator_dev(seg)) { - if (!_add_replicator_dev_target_to_dtree(dm, dtree, seg)) + if (!_add_replicator_dev_target_to_dtree(dm, dtree, seg, laopts)) return_0; /* If this is a snapshot origin, add real LV */ /* If this is a snapshot origin + merging snapshot, add cow + real LV */ } else if (lv_is_origin(seg->lv) && !layer) { if (lv_is_merging_origin(seg->lv)) { if (!_add_new_lv_to_dtree(dm, dtree, - find_merging_cow(seg->lv)->cow, "cow")) + find_merging_cow(seg->lv)->cow, laopts, "cow")) return_0; /* * Must also add "real" LV for use when * snapshot-merge target is added */ } - if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, "real")) + if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, laopts, "real")) return_0; } else if (lv_is_cow(seg->lv) && !layer) { - if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, "cow")) + if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, laopts, "cow")) return_0; } else { /* Add any LVs used by this segment */ for (s = 0; s < seg->area_count; s++) if ((seg_type(seg, s) == AREA_LV) && (!_add_new_lv_to_dtree(dm, dtree, seg_lv(seg, s), - NULL))) + laopts, NULL))) return_0; } @@ -1437,22 +1445,24 @@ return_0; } } else if (lv_is_cow(seg->lv) && !layer) { - if (!_add_snapshot_target_to_dtree(dm, dnode, seg->lv)) + if (!_add_snapshot_target_to_dtree(dm, dnode, seg->lv, laopts)) return_0; - } else if (!_add_target_to_dtree(dm, dnode, seg)) + } else if (!_add_target_to_dtree(dm, dnode, seg, laopts)) return_0; if (lv_is_origin(seg->lv) && !layer) /* Add any snapshots of this LV */ dm_list_iterate(snh, &seg->lv->snapshot_segs) - if (!_add_new_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow, NULL)) + if (!_add_new_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow, + laopts, NULL)) return_0; return 1; } static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, - struct logical_volume *lv, const char *layer) + struct logical_volume *lv, struct lv_activate_opts *laopts, + const char *layer) { struct lv_segment *seg; struct lv_layer *lvlayer; @@ -1527,7 +1537,7 @@ /* Create table */ dm->pvmove_mirror_count = 0u; dm_list_iterate_items(seg, &lv->segments) { - if (!_add_segment_to_dtree(dm, dtree, dnode, seg, layer)) + if (!_add_segment_to_dtree(dm, dtree, dnode, seg, laopts, layer)) return_0; /* These aren't real segments in the LVM2 metadata */ if (lv_is_origin(lv) && !layer) @@ -1551,7 +1561,7 @@ /* Add any LVs referencing a PVMOVE LV unless told not to */ if (dm->track_pvmove_deps && (lv->status & PVMOVE)) dm_list_iterate_items(sl, &lv->segs_using_this_lv) - if (!_add_new_lv_to_dtree(dm, dtree, sl->seg->lv, NULL)) + if (!_add_new_lv_to_dtree(dm, dtree, sl->seg->lv, laopts, NULL)) return_0; return 1; @@ -1671,14 +1681,14 @@ } static int _tree_action(struct dev_manager *dm, struct logical_volume *lv, - unsigned origin_only, action_t action) + struct lv_activate_opts *laopts, action_t action) { struct dm_tree *dtree; struct dm_tree_node *root; char *dlid; int r = 0; - if (!(dtree = _create_partial_dtree(dm, lv, origin_only))) + if (!(dtree = _create_partial_dtree(dm, lv, laopts->origin_only))) return_0; if (!(root = dm_tree_find_node(dtree, 0, 0))) { @@ -1689,14 +1699,14 @@ /* Restore fs cookie */ dm_tree_set_cookie(root, fs_get_cookie()); - if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, origin_only ? "real" : NULL))) + if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, laopts->origin_only ? "real" : NULL))) goto_out; /* Only process nodes with uuid of "LVM-" plus VG id. */ switch(action) { case CLEAN: /* Deactivate any unused non-toplevel nodes */ - if (!_clean_tree(dm, root, origin_only ? dlid : NULL)) + if (!_clean_tree(dm, root, laopts->origin_only ? dlid : NULL)) goto_out; break; case DEACTIVATE: @@ -1719,7 +1729,7 @@ case PRELOAD: case ACTIVATE: /* Add all required new devices to tree */ - if (!_add_new_lv_to_dtree(dm, dtree, lv, origin_only ? "real" : NULL)) + if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, laopts->origin_only ? "real" : NULL)) goto_out; /* Preload any devices required before any suspensions */ @@ -1758,19 +1768,24 @@ } /* origin_only may only be set if we are resuming (not activating) an origin LV */ -int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv, unsigned origin_only) +int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv, + struct lv_activate_opts *laopts) { - if (!_tree_action(dm, lv, origin_only, ACTIVATE)) + if (!_tree_action(dm, lv, laopts, ACTIVATE)) return_0; - return _tree_action(dm, lv, origin_only, CLEAN); + return _tree_action(dm, lv, laopts, CLEAN); } /* origin_only may only be set if we are resuming (not activating) an origin LV */ int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv, - unsigned origin_only, int *flush_required) + struct lv_activate_opts *laopts, int *flush_required) { - if (!_tree_action(dm, lv, origin_only, PRELOAD)) + /* FIXME Update the pvmove implementation! */ + if ((lv->status & PVMOVE) || (lv->status & LOCKED)) + return 1; + + if (!_tree_action(dm, lv, laopts, PRELOAD)) return 0; *flush_required = dm->flush_required; @@ -1780,19 +1795,20 @@ int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv) { + struct lv_activate_opts laopts = { 0 }; int r; - r = _tree_action(dm, lv, 0, DEACTIVATE); + r = _tree_action(dm, lv, &laopts, DEACTIVATE); return r; } int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv, - unsigned origin_only, int lockfs, int flush_required) + struct lv_activate_opts *laopts, int lockfs, int flush_required) { dm->flush_required = flush_required; - return _tree_action(dm, lv, origin_only, lockfs ? SUSPEND_WITH_LOCKFS : SUSPEND); + return _tree_action(dm, lv, laopts, lockfs ? SUSPEND_WITH_LOCKFS : SUSPEND); } /* --- LVM2/lib/activate/dev_manager.h 2011/06/11 00:03:07 1.37 +++ LVM2/lib/activate/dev_manager.h 2011/06/17 14:14:19 1.38 @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -19,6 +19,7 @@ #include "metadata-exported.h" struct logical_volume; +struct lv_activate_opts; struct volume_group; struct cmd_context; struct dev_manager; @@ -52,10 +53,11 @@ const struct logical_volume *lv, int wait, percent_t *percent, uint32_t *event_nr); int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv, - unsigned origin_only, int lockfs, int flush_required); -int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv, unsigned origin_only); + struct lv_activate_opts *laopts, int lockfs, int flush_required); +int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv, + struct lv_activate_opts *laopts); int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv, - unsigned origin_only, int *flush_required); + struct lv_activate_opts *laopts, int *flush_required); int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv); int dev_manager_transient(struct dev_manager *dm, struct logical_volume *lv) __attribute__((nonnull(1, 2))); --- LVM2/lib/error/errseg.c 2011/03/25 21:59:42 1.23 +++ LVM2/lib/error/errseg.c 2011/06/17 14:14:19 1.24 @@ -45,6 +45,7 @@ struct cmd_context *cmd __attribute__((unused)), void **target_state __attribute__((unused)), struct lv_segment *seg __attribute__((unused)), + const struct lv_activate_opts *laopts __attribute__((unused)), struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count __attribute__((unused))) { --- LVM2/lib/metadata/segtype.h 2010/12/20 13:32:49 1.34 +++ LVM2/lib/metadata/segtype.h 2011/06/17 14:14:20 1.35 @@ -22,6 +22,7 @@ struct cmd_context; struct config_tree; struct lv_segment; +struct lv_activate_opts; struct formatter; struct config_node; struct dev_manager; @@ -66,7 +67,8 @@ struct segtype_handler { const char *(*name) (const struct lv_segment * seg); - const char *(*target_name) (const struct lv_segment * seg); + const char *(*target_name) (const struct lv_segment *seg, + const struct lv_activate_opts *laopts); void (*display) (const struct lv_segment * seg); int (*text_export) (const struct lv_segment * seg, struct formatter * f); @@ -78,10 +80,11 @@ int (*merge_segments) (struct lv_segment * seg1, struct lv_segment * seg2); int (*add_target_line) (struct dev_manager *dm, struct dm_pool *mem, - struct cmd_context *cmd, void **target_state, - struct lv_segment *seg, - struct dm_tree_node *node, uint64_t len, - uint32_t *pvmove_mirror_count); + struct cmd_context *cmd, void **target_state, + struct lv_segment *seg, + const struct lv_activate_opts *laopts, + struct dm_tree_node *node, uint64_t len, + uint32_t *pvmove_mirror_count); int (*target_status_compatible) (const char *type); int (*check_transient_status) (struct lv_segment *seg, char *params); int (*target_percent) (void **target_state, --- LVM2/lib/mirror/mirrored.c 2011/05/07 13:32:06 1.87 +++ LVM2/lib/mirror/mirrored.c 2011/06/17 14:14:20 1.88 @@ -349,6 +349,7 @@ } static int _add_log(struct dm_pool *mem, struct lv_segment *seg, + const struct lv_activate_opts *laopts, struct dm_tree_node *node, uint32_t area_count, uint32_t region_size) { unsigned clustered = 0; @@ -390,10 +391,11 @@ } static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem, - struct cmd_context *cmd, void **target_state, - struct lv_segment *seg, - struct dm_tree_node *node, uint64_t len, - uint32_t *pvmove_mirror_count) + struct cmd_context *cmd, void **target_state, + struct lv_segment *seg, + const struct lv_activate_opts *laopts, + struct dm_tree_node *node, uint64_t len, + uint32_t *pvmove_mirror_count) { struct mirror_state *mirr_state; uint32_t area_count = seg->area_count; @@ -451,7 +453,7 @@ if (!dm_tree_node_add_mirror_target(node, len)) return_0; - if ((r = _add_log(mem, seg, node, area_count, region_size)) <= 0) { + if ((r = _add_log(mem, seg, laopts, node, area_count, region_size)) <= 0) { stack; return r; } --- LVM2/lib/replicator/replicator.c 2011/03/25 21:59:42 1.6 +++ LVM2/lib/replicator/replicator.c 2011/06/17 14:14:20 1.7 @@ -327,6 +327,7 @@ struct cmd_context *cmd, void **target_state, struct lv_segment *seg, + const struct lv_activate_opts *laopts, struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count) @@ -609,6 +610,7 @@ struct cmd_context *cmd, void **target_state, struct lv_segment *seg, + const struct lv_activate_opts *laopts, struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count) --- LVM2/lib/snapshot/snapshot.c 2011/04/29 00:21:15 1.55 +++ LVM2/lib/snapshot/snapshot.c 2011/06/17 14:14:20 1.56 @@ -28,7 +28,8 @@ return seg->segtype->name; } -static const char *_snap_target_name(const struct lv_segment *seg) +static const char *_snap_target_name(const struct lv_segment *seg, + const struct lv_activate_opts *laopts) { if (seg->status & MERGING) return "snapshot-merge"; --- LVM2/lib/striped/striped.c 2011/03/25 21:59:43 1.36 +++ LVM2/lib/striped/striped.c 2011/06/17 14:14:20 1.37 @@ -164,6 +164,7 @@ 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))) { --- LVM2/lib/unknown/unknown.c 2011/03/25 21:59:43 1.5 +++ LVM2/lib/unknown/unknown.c 2011/06/17 14:14:21 1.6 @@ -67,6 +67,7 @@ struct cmd_context *cmd __attribute__((unused)), void **target_state __attribute__((unused)), struct lv_segment *seg __attribute__((unused)), + const struct lv_activate_opts *laopts __attribute__((unused)), struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count __attribute__((unused))) { --- LVM2/lib/zero/zero.c 2011/03/25 21:59:43 1.24 +++ LVM2/lib/zero/zero.c 2011/06/17 14:14:21 1.25 @@ -44,6 +44,7 @@ struct cmd_context *cmd __attribute__((unused)), void **target_state __attribute__((unused)), struct lv_segment *seg __attribute__((unused)), + const struct lv_activate_opts *laopts __attribute__((unused)), struct dm_tree_node *node,uint64_t len, uint32_t *pvmove_mirror_count __attribute__((unused))) { From zkabelac@sourceware.org Fri Jun 17 14:17:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 17 Jun 2011 14:17:00 -0000 Subject: LVM2 ./WHATS_NEW lib/mirror/mirrored.c Message-ID: <20110617141717.1056.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-17 14:17:17 Modified files: . : WHATS_NEW lib/mirror : mirrored.c Log message: Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2017&r2=1.2018 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89 --- LVM2/WHATS_NEW 2011/06/17 14:14:19 1.2017 +++ LVM2/WHATS_NEW 2011/06/17 14:17:16 1.2018 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag. Add lv_activate_opts structure for activation (replacing activation flags). Fix a problem with inconsistent pre-commit metadata on MISSING_PV devices. Add proper udev library context initialization and finalization to liblvm. --- LVM2/lib/mirror/mirrored.c 2011/06/17 14:14:20 1.88 +++ LVM2/lib/mirror/mirrored.c 2011/06/17 14:17:17 1.89 @@ -360,8 +360,7 @@ * Use clustered mirror log for non-exclusive activation * in clustered VG. */ - if ((!(seg->lv->status & ACTIVATE_EXCL) && - (vg_is_clustered(seg->lv->vg)))) + if (!laopts->exclusive && vg_is_clustered(seg->lv->vg)) clustered = 1; if (seg->log_lv) { From zkabelac@sourceware.org Fri Jun 17 14:22:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 17 Jun 2011 14:22:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ... Message-ID: <20110617142250.2835.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-17 14:22:49 Modified files: . : WHATS_NEW lib/activate : activate.c dev_manager.c lib/snapshot : snapshot.c Log message: Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag Let's hope all conditions has been properly converted. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2018&r2=1.2019 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.199&r2=1.200 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.218&r2=1.219 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/WHATS_NEW 2011/06/17 14:17:16 1.2018 +++ LVM2/WHATS_NEW 2011/06/17 14:22:48 1.2019 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Use lv_activate_opts struct instead of MERGING status flag. Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag. Add lv_activate_opts structure for activation (replacing activation flags). Fix a problem with inconsistent pre-commit metadata on MISSING_PV devices. --- LVM2/lib/activate/activate.c 2011/06/17 14:14:19 1.199 +++ LVM2/lib/activate/activate.c 2011/06/17 14:22:48 1.200 @@ -986,8 +986,8 @@ * In case of a snapshot device, we monitor lv->snapshot->lv, * not the actual LV itself. */ - if (lv_is_cow(lv) && !lv_is_merging_cow(lv)) - return monitor_dev_for_events(cmd, lv->snapshot->lv, 0, monitor); + if (lv_is_cow(lv) && (laopts->no_merging || !lv_is_merging_cow(lv))) + return monitor_dev_for_events(cmd, lv->snapshot->lv, NULL, monitor); /* * In case this LV is a snapshot origin, we instead monitor --- LVM2/lib/activate/dev_manager.c 2011/06/17 14:14:19 1.218 +++ LVM2/lib/activate/dev_manager.c 2011/06/17 14:22:48 1.219 @@ -1276,7 +1276,7 @@ size = (uint64_t) snap_seg->len * snap_seg->origin->vg->extent_size; - if (lv_is_merging_cow(lv)) { + if (!laopts->no_merging && lv_is_merging_cow(lv)) { /* cow is to be merged so load the error target */ if (!dm_tree_node_add_error_target(dnode, size)) return_0; @@ -1412,7 +1412,7 @@ /* If this is a snapshot origin, add real LV */ /* If this is a snapshot origin + merging snapshot, add cow + real LV */ } else if (lv_is_origin(seg->lv) && !layer) { - if (lv_is_merging_origin(seg->lv)) { + if (!laopts->no_merging && lv_is_merging_origin(seg->lv)) { if (!_add_new_lv_to_dtree(dm, dtree, find_merging_cow(seg->lv)->cow, laopts, "cow")) return_0; @@ -1423,7 +1423,7 @@ } if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, laopts, "real")) return_0; - } else if (lv_is_cow(seg->lv) && !layer) { + } else if (!laopts->no_merging && lv_is_cow(seg->lv) && !layer) { if (!_add_new_lv_to_dtree(dm, dtree, seg->lv, laopts, "cow")) return_0; } else { @@ -1437,14 +1437,14 @@ /* Now we've added its dependencies, we can add the target itself */ if (lv_is_origin(seg->lv) && !layer) { - if (!lv_is_merging_origin(seg->lv)) { + if (laopts->no_merging || !lv_is_merging_origin(seg->lv)) { if (!_add_origin_target_to_dtree(dm, dnode, seg->lv)) return_0; } else { if (!_add_snapshot_merge_target_to_dtree(dm, dnode, seg->lv)) return_0; } - } else if (lv_is_cow(seg->lv) && !layer) { + } else if (!laopts->no_merging && lv_is_cow(seg->lv) && !layer) { if (!_add_snapshot_target_to_dtree(dm, dnode, seg->lv, laopts)) return_0; } else if (!_add_target_to_dtree(dm, dnode, seg, laopts)) @@ -1490,7 +1490,7 @@ dtree)) && dinfo->open_count)) { /* FIXME Is there anything simpler to check for instead? */ if (!lv_has_target_type(dm->mem, lv, NULL, "snapshot-merge")) - clear_snapshot_merge(lv); + laopts->no_merging = 1; } } @@ -1542,7 +1542,7 @@ /* These aren't real segments in the LVM2 metadata */ if (lv_is_origin(lv) && !layer) break; - if (lv_is_cow(lv) && !layer) + if (!laopts->no_merging && lv_is_cow(lv) && !layer) break; if (max_stripe_size < seg->stripe_size * seg->area_count) max_stripe_size = seg->stripe_size * seg->area_count; --- LVM2/lib/snapshot/snapshot.c 2011/06/17 14:14:20 1.56 +++ LVM2/lib/snapshot/snapshot.c 2011/06/17 14:22:49 1.57 @@ -31,7 +31,7 @@ static const char *_snap_target_name(const struct lv_segment *seg, const struct lv_activate_opts *laopts) { - if (seg->status & MERGING) + if (!laopts->no_merging && (seg->status & MERGING)) return "snapshot-merge"; return _snap_name(seg); From zkabelac@sourceware.org Fri Jun 17 14:24:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 17 Jun 2011 14:24:00 -0000 Subject: LVM2/lib activate/activate.c metadata/mirror.c Message-ID: <20110617142418.4686.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-17 14:24:18 Modified files: lib/activate : activate.c lib/metadata : mirror.c Log message: Add couple FIXMEs around suspicious code Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.200&r2=1.201 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.152&r2=1.153 --- LVM2/lib/activate/activate.c 2011/06/17 14:22:48 1.200 +++ LVM2/lib/activate/activate.c 2011/06/17 14:24:18 1.201 @@ -795,12 +795,14 @@ goto out; } + /* FIXME: Is this fallback alright? */ if (activate_lv_excl(lv->vg->cmd, lv)) { if (!deactivate_lv(lv->vg->cmd, lv)) stack; + /* FIXME: locally & exclusive are undefined. */ return 0; } - + /* FIXME: Check exclusive value here. */ out: if (locally) *locally = l; --- LVM2/lib/metadata/mirror.c 2011/06/11 00:03:07 1.152 +++ LVM2/lib/metadata/mirror.c 2011/06/17 14:24:18 1.153 @@ -2020,6 +2020,7 @@ } if (vg_is_clustered(lv->vg)) { + /* FIXME: review check of lv_is_active_remotely */ if (!(lv->status & ACTIVATE_EXCL) && !cluster_mirror_is_available(lv)) { log_error("Shared cluster mirrors are not available."); From zkabelac@sourceware.org Fri Jun 17 14:27:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 17 Jun 2011 14:27:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/mirror.c Message-ID: <20110617142735.9185.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-17 14:27:35 Modified files: . : WHATS_NEW lib/metadata : mirror.c Log message: Remove test for status flag As the ACTIVATE_EXCL could be set only in clvmd code - there is no use for this test in lv_add_mirrors() function only called from tools context. FIXME: Add cluster test case for this. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2019&r2=1.2020 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.153&r2=1.154 --- LVM2/WHATS_NEW 2011/06/17 14:22:48 1.2019 +++ LVM2/WHATS_NEW 2011/06/17 14:27:34 1.2020 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Remove useless test of ACTIVATE_EXCL in lv_add_mirrors() clustered code path. Use lv_activate_opts struct instead of MERGING status flag. Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag. Add lv_activate_opts structure for activation (replacing activation flags). --- LVM2/lib/metadata/mirror.c 2011/06/17 14:24:18 1.153 +++ LVM2/lib/metadata/mirror.c 2011/06/17 14:27:35 1.154 @@ -2021,8 +2021,7 @@ if (vg_is_clustered(lv->vg)) { /* FIXME: review check of lv_is_active_remotely */ - if (!(lv->status & ACTIVATE_EXCL) && - !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 Fri Jun 17 14:31:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 17 Jun 2011 14:31:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/f ... Message-ID: <20110617143059.11769.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-17 14:30:58 Modified files: . : WHATS_NEW lib/activate : activate.c lib/format_text: flags.c lib/metadata : metadata-exported.h metadata.h Log message: Remove unused internal flag ACTIVATE_EXCL from the code Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2020&r2=1.2021 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.201&r2=1.202 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.193&r2=1.194 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.245&r2=1.246 --- LVM2/WHATS_NEW 2011/06/17 14:27:34 1.2020 +++ LVM2/WHATS_NEW 2011/06/17 14:30:58 1.2021 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Remove unused internal flag ACTIVATE_EXCL from the code. Remove useless test of ACTIVATE_EXCL in lv_add_mirrors() clustered code path. Use lv_activate_opts struct instead of MERGING status flag. Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag. --- LVM2/lib/activate/activate.c 2011/06/17 14:24:18 1.201 +++ LVM2/lib/activate/activate.c 2011/06/17 14:30:58 1.202 @@ -1293,14 +1293,6 @@ goto out; } - /* - * When targets are activated exclusively in a cluster, the - * non-clustered target should be used. This only happens - * if ACTIVATE_EXCL is set in lv->status. - */ - if (laopts->exclusive) - lv->status |= ACTIVATE_EXCL; - if (!_lv_activate_lv(lv, laopts)) goto_out; --- LVM2/lib/format_text/flags.c 2011/03/29 12:51:57 1.44 +++ LVM2/lib/format_text/flags.c 2011/06/17 14:30:58 1.45 @@ -62,7 +62,6 @@ {VIRTUAL, NULL, 0}, {SNAPSHOT, NULL, 0}, {MERGING, NULL, 0}, - {ACTIVATE_EXCL, NULL, 0}, {CONVERTING, NULL, 0}, {PARTIAL_LV, NULL, 0}, {POSTORDER_FLAG, NULL, 0}, --- LVM2/lib/metadata/metadata-exported.h 2011/06/11 00:03:07 1.193 +++ LVM2/lib/metadata/metadata-exported.h 2011/06/17 14:30:58 1.194 @@ -62,7 +62,6 @@ #define MIRROR_LOG 0x00020000U /* LV */ #define MIRROR_IMAGE 0x00040000U /* LV */ #define LV_NOTSYNCED 0x00080000U /* LV */ -//#define ACTIVATE_EXCL 0x00100000U /* LV - internal use only */ //#define PRECOMMITTED 0x00200000U /* VG - internal use only */ #define CONVERTING 0x00400000U /* LV */ --- LVM2/lib/metadata/metadata.h 2011/06/15 17:45:03 1.245 +++ LVM2/lib/metadata/metadata.h 2011/06/17 14:30:58 1.246 @@ -71,7 +71,6 @@ //#define MIRROR_LOG 0x00020000U /* LV */ //#define MIRROR_IMAGE 0x00040000U /* LV */ //#define MIRROR_NOTSYNCED 0x00080000U /* LV */ -#define ACTIVATE_EXCL 0x00100000U /* LV - internal use only */ #define PRECOMMITTED 0x00200000U /* VG - internal use only */ //#define CONVERTING 0x00400000U /* LV */ From zkabelac@sourceware.org Fri Jun 17 14:39:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 17 Jun 2011 14:39:00 -0000 Subject: LVM2 ./WHATS_NEW lib/format_text/import.c lib/ ... Message-ID: <20110617143911.4873.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-17 14:39:10 Modified files: . : WHATS_NEW lib/format_text: import.c lib/metadata : metadata.c Log message: Code move of vg_mark_partial() up in stack It's useful to keep the partial flag cached - so just move the call for vg_mark_partil_lvs() into import_vg_from_config_tree() so it gets evaluated before it goes through the lvmcache. This patch should not present any functional change. Note: It is rather temporal solution - proper place is probably inside the 'read' call back - but needs some more discussion. For now using this minor hack. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2021&r2=1.2022 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.458&r2=1.459 --- LVM2/WHATS_NEW 2011/06/17 14:30:58 1.2021 +++ LVM2/WHATS_NEW 2011/06/17 14:39:10 1.2022 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Call vg_mark_partial_lvs() before VG structure is returned from the cache. Remove unused internal flag ACTIVATE_EXCL from the code. Remove useless test of ACTIVATE_EXCL in lv_add_mirrors() clustered code path. Use lv_activate_opts struct instead of MERGING status flag. --- LVM2/lib/format_text/import.c 2011/01/10 13:13:42 1.53 +++ LVM2/lib/format_text/import.c 2011/06/17 14:39:10 1.54 @@ -136,6 +136,7 @@ { struct volume_group *vg = NULL; struct text_vg_version_ops **vsn; + int vg_missing; _init_text_import(); @@ -148,6 +149,12 @@ */ if (!(vg = (*vsn)->read_vg(fid, cft, 1))) stack; + else if ((vg_missing = vg_missing_pv_count(vg))) { + log_verbose("There are %d physical volumes missing.", + vg_missing); + vg_mark_partial_lvs(vg, 1); + /* FIXME: move this code inside read_vg() */ + } break; } --- LVM2/lib/metadata/metadata.c 2011/06/15 17:45:03 1.458 +++ LVM2/lib/metadata/metadata.c 2011/06/17 14:39:10 1.459 @@ -2868,11 +2868,6 @@ else /* Inconsistent but we can't repair it */ correct_vg->status &= ~INCONSISTENT_VG; - if (vg_missing_pv_count(correct_vg)) { - log_verbose("There are %d physical volumes missing.", - vg_missing_pv_count(correct_vg)); - vg_mark_partial_lvs(correct_vg, 1); - } return correct_vg; } else { free_vg(correct_vg); From prajnoha@sourceware.org Fri Jun 17 14:50:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Fri, 17 Jun 2011 14:50:00 -0000 Subject: LVM2 ./WHATS_NEW doc/example.conf.in lib/activ ... Message-ID: <20110617145056.10755.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-06-17 14:50:54 Modified files: . : WHATS_NEW doc : example.conf.in lib/activate : dev_manager.c lib/commands : toolcontext.c toolcontext.h lib/config : defaults.h tools : lvmcmdline.c Log message: Disable udev fallback by default and add activation/udev_fallback to lvm.conf. We've used udev fallback code till now to check whether udev created/removed the entries in /dev correctly and if not, a repair was done (giving a warning messagea about that). This patch adds a possibility to enable this additional check and subsequent fallback only when required (debugging purposes mostly) and trust udev completely. So let's disable the fallback code by default and add a new configuration option "activation/udev_fallback". (The original code for creating the nodes will still be used in case the device directory that is set in lvm.conf differs from the one that udev uses and also when activation/udev_rules is set to 0 - otherwise we would end up with no nodes/symlinks at all) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2022&r2=1.2023 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.25&r2=1.26 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.219&r2=1.220 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.43&r2=1.44 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.75&r2=1.76 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143 --- LVM2/WHATS_NEW 2011/06/17 14:39:10 1.2022 +++ LVM2/WHATS_NEW 2011/06/17 14:50:53 1.2023 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Disable udev fallback by default and add activation/udev_fallback to lvm.conf. Call vg_mark_partial_lvs() before VG structure is returned from the cache. Remove unused internal flag ACTIVATE_EXCL from the code. Remove useless test of ACTIVATE_EXCL in lv_add_mirrors() clustered code path. --- LVM2/doc/example.conf.in 2011/04/28 17:33:35 1.25 +++ LVM2/doc/example.conf.in 2011/06/17 14:50:53 1.26 @@ -428,6 +428,13 @@ # while any logical volumes are active. udev_rules = 1 + # Set to 1 to enable udev fallback. This will enable additional checks and + # possible repairs done on entries in the device directory after udev has + # completed processing the events. This is normally not needed if udev + # works correctly but it may be used in some problematic situations or + # for debugging purposes. + udev_fallback = 0 + # 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/06/17 14:22:48 1.219 +++ LVM2/lib/activate/dev_manager.c 2011/06/17 14:50:53 1.220 @@ -874,6 +874,13 @@ uint16_t udev_flags = 0; /* + * Instruct also libdevmapper to disable udev + * fallback in accordance to LVM2 settings. + */ + if (!dm->cmd->current_settings.udev_fallback) + udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK; + + /* * Is this top-level and visible device? * If not, create just the /dev/mapper content. */ @@ -1584,6 +1591,10 @@ const char *name; int r = 1; + /* Nothing to do if udev fallback is disabled. */ + if (!dm->cmd->current_settings.udev_fallback) + return 1; + while ((child = dm_tree_next_child(&handle, root, 0))) { if (!(lvlayer = dm_tree_node_get_context(child))) continue; @@ -1626,6 +1637,10 @@ char *vgname, *lvname, *layer; int r = 1; + /* Nothing to do if udev fallback is disabled. */ + if (!dm->cmd->current_settings.udev_fallback) + return 1; + while ((child = dm_tree_next_child(&handle, root, 0))) { if (!dm_split_lvm_name(dm->mem, dm_tree_node_get_name(child), &vgname, &lvname, &layer)) { r = 0; --- LVM2/lib/commands/toolcontext.c 2011/05/07 13:50:12 1.119 +++ LVM2/lib/commands/toolcontext.c 2011/06/17 14:50:54 1.120 @@ -285,6 +285,21 @@ "activation/udev_sync", DEFAULT_UDEV_SYNC); + #ifdef UDEV_SYNC_SUPPORT + /* + * We need udev rules to be applied, otherwise we would end up with no + * nodes and symlinks! However, we can disable the synchronization itself + * in runtime and still have only udev to create the nodes and symlinks + * without any fallback. + */ + cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ? + find_config_tree_int(cmd, "activation/udev_fallback", + DEFAULT_UDEV_FALLBACK) : 1; + #else + /* We must use old node/symlink creation code if not compiled with udev support at all! */ + cmd->default_settings.udev_fallback = 1; + #endif + cmd->stripe_filler = find_config_tree_str(cmd, "activation/missing_stripe_filler", DEFAULT_STRIPE_FILLER); --- LVM2/lib/commands/toolcontext.h 2011/05/07 13:50:12 1.43 +++ LVM2/lib/commands/toolcontext.h 2011/06/17 14:50:54 1.44 @@ -36,6 +36,7 @@ int read_ahead; /* DM_READ_AHEAD_NONE or _AUTO */ int udev_rules; int udev_sync; + int udev_fallback; int cache_vgmetadata; const char *msg_prefix; const char *fmt_name; --- LVM2/lib/config/defaults.h 2011/04/28 17:33:35 1.75 +++ LVM2/lib/config/defaults.h 2011/06/17 14:50:54 1.76 @@ -78,6 +78,7 @@ #define DEFAULT_READ_AHEAD "auto" #define DEFAULT_UDEV_RULES 1 #define DEFAULT_UDEV_SYNC 0 +#define DEFAULT_UDEV_FALLBACK 0 #define DEFAULT_EXTENT_SIZE 4096 /* In KB */ #define DEFAULT_MAX_PV 0 #define DEFAULT_MAX_LV 0 --- LVM2/tools/lvmcmdline.c 2011/05/07 13:50:11 1.142 +++ LVM2/tools/lvmcmdline.c 2011/06/17 14:50:54 1.143 @@ -952,7 +952,7 @@ cmd->handles_missing_pvs = 0; } -static int _set_udev_checking(struct cmd_context *cmd) +static int _set_udev_fallback(struct cmd_context *cmd) { #ifdef UDEV_SYNC_SUPPORT const char *udev_dev_dir; @@ -984,6 +984,9 @@ cmd->dev_dir, udev_dev_dir); dm_udev_set_checking(0); init_udev_checking(0); + + /* Device directories differ - we must use the fallback code! */ + cmd->current_settings.udev_fallback = 1; } #endif @@ -1088,7 +1091,7 @@ log_debug("O_DIRECT will be used"); #endif - if (!_set_udev_checking(cmd)) + if (!_set_udev_fallback(cmd)) goto_out; if ((ret = _process_common_commands(cmd))) { From prajnoha@sourceware.org Fri Jun 17 14:55:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Fri, 17 Jun 2011 14:55:00 -0000 Subject: LVM2 ./WHATS_NEW_DM tools/dmsetup.c Message-ID: <20110617145552.11785.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-06-17 14:55:51 Modified files: . : WHATS_NEW_DM tools : dmsetup.c Log message: Disable udev fallback and add --udevfallback option to dmsetup. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.472&r2=1.473 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.160&r2=1.161 --- LVM2/WHATS_NEW_DM 2011/06/13 03:32:45 1.472 +++ LVM2/WHATS_NEW_DM 2011/06/17 14:55:51 1.473 @@ -1,5 +1,6 @@ Version 1.02.65 - ================================== + Disable udev fallback by default and add --udevfallback option to dmsetup. Warn if a table is loaded while a device is known to be in suspended state. Add dm_get_suspended_counter() for number of devs in suspended state by lib. Fix "all" report field prefix matching to include label fields with pv_all. --- LVM2/tools/dmsetup.c 2011/04/22 11:56:41 1.160 +++ LVM2/tools/dmsetup.c 2011/06/17 14:55:51 1.161 @@ -135,6 +135,7 @@ UDEVCOOKIE_ARG, NOUDEVRULES_ARG, NOUDEVSYNC_ARG, + UDEVFALLBACK_ARG, OPTIONS_ARG, READAHEAD_ARG, ROWS_ARG, @@ -648,11 +649,11 @@ if (!_set_task_add_node(dmt)) goto out; - if (_udev_cookie) { + if (_udev_cookie) cookie = _udev_cookie; - if (_udev_only) - udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK; - } + + if (_udev_only) + udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK; if (!dm_task_set_cookie(dmt, &cookie, udev_flags) || !dm_task_run(dmt)) @@ -702,11 +703,11 @@ udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG | DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG; - if (_udev_cookie) { + if (_udev_cookie) cookie = _udev_cookie; - if (_udev_only) - udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK; - } + + if (_udev_only) + udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK; if (!dm_task_set_cookie(dmt, &cookie, udev_flags) || !dm_task_run(dmt)) @@ -1006,7 +1007,7 @@ else dirs_diff = strcmp(dev_dir, udev_dev_dir); - _udev_only = _udev_cookie && !dirs_diff; + _udev_only = !dirs_diff && (_udev_cookie || !_switches[UDEVFALLBACK_ARG]); if (dirs_diff) { log_debug("The path %s used for creating device nodes that is " @@ -1225,11 +1226,11 @@ udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG | DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG; - if (_udev_cookie) { + if (_udev_cookie) cookie = _udev_cookie; - if (_udev_only) - udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK; - } + + if (_udev_only) + udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK; if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, udev_flags)) goto out; @@ -2744,8 +2745,8 @@ fprintf(out, "dmsetup [--version] [-h|--help [-c|-C|--columns]]\n" " [-v|--verbose [-v|--verbose ...]]\n" " [-r|--readonly] [--noopencount] [--nolockfs] [--inactive]\n" - " [--udevcookie] [--noudevrules] [--noudevsync] [-y|--yes]\n" - " [--readahead [+]|auto|none]\n" + " [--udevcookie] [--noudevrules] [--noudevsync] [--udevfallback]\n" + " [-y|--yes] [--readahead [+]|auto|none]\n" " [-c|-C|--columns] [-o ] [-O|--sort ]\n" " [--nameprefixes] [--noheadings] [--separator ]\n\n"); for (i = 0; _commands[i].name; i++) @@ -3115,6 +3116,7 @@ {"udevcookie", 1, &ind, UDEVCOOKIE_ARG}, {"noudevrules", 0, &ind, NOUDEVRULES_ARG}, {"noudevsync", 0, &ind, NOUDEVSYNC_ARG}, + {"udevfallback", 0, &ind, UDEVFALLBACK_ARG}, {"options", 1, &ind, OPTIONS_ARG}, {"readahead", 1, &ind, READAHEAD_ARG}, {"rows", 0, &ind, ROWS_ARG}, @@ -3243,6 +3245,8 @@ _switches[NOUDEVRULES_ARG]++; if (ind == NOUDEVSYNC_ARG) _switches[NOUDEVSYNC_ARG]++; + if (ind == UDEVFALLBACK_ARG) + _switches[UDEVFALLBACK_ARG]++; if (c == 'G' || ind == GID_ARG) { _switches[GID_ARG]++; _int_args[GID_ARG] = atoi(optarg); From prajnoha@sourceware.org Wed Jun 22 12:56:00 2011 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Wed, 22 Jun 2011 12:56:00 -0000 Subject: LVM2/libdm libdm-deptree.c Message-ID: <20110622125602.21718.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2011-06-22 12:56:02 Modified files: libdm : libdm-deptree.c Log message: Add check for library fallback in _deactivate_node. This fn calls rm_dev_node directly - an exceptional case. It needs to check the DM_UDEV_DISABLE_LIBRARY_FALLBACK flag directly (it's called in dm_task_run normally where it's checked already). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97 --- LVM2/libdm/libdm-deptree.c 2011/06/13 03:32:46 1.96 +++ LVM2/libdm/libdm-deptree.c 2011/06/22 12:56:02 1.97 @@ -984,8 +984,9 @@ r = dm_task_run(dmt); /* FIXME Until kernel returns actual name so dm-ioctl.c can handle it */ - rm_dev_node(name, dmt->cookie_set && - !(udev_flags & DM_UDEV_DISABLE_DM_RULES_FLAG)); + if (!(udev_flags & DM_UDEV_DISABLE_LIBRARY_FALLBACK)) + rm_dev_node(name, dmt->cookie_set && + !(udev_flags & DM_UDEV_DISABLE_DM_RULES_FLAG)); /* FIXME Remove node from tree or mark invalid? */ From jbrassow@sourceware.org Wed Jun 22 21:31:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Wed, 22 Jun 2011 21:31:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ... Message-ID: <20110622213122.1831.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-06-22 21:31:21 Modified files: . : WHATS_NEW lib/activate : activate.c activate.h lib/metadata : mirror.c Log message: Fix issue preventing cluster mirror creation. Mirrors used to be created by first creating a linear device and then adding the other images plus the log. Now mirrors are created by creating all the images in one go and then adding the log separately. The new way ran into the condition that cluster mirrors cannot change the log type (in the case of creation, from core -> disk) while the mirror is not active. (It isn't active because it is in the process of being created.) The reason this condition is in place is because a remote node may have the mirror active, and we don't want to alter the log underneath it. What we really needed was a way of checking if the mirror was active remotely but not locally, and in that case do not allow a change of the log. I've added this check, and cluster mirrors can now be created again. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2023&r2=1.2024 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.202&r2=1.203 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.77&r2=1.78 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.154&r2=1.155 --- LVM2/WHATS_NEW 2011/06/17 14:50:53 1.2023 +++ LVM2/WHATS_NEW 2011/06/22 21:31:21 1.2024 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Fix issue preventing cluster mirror creation. Disable udev fallback by default and add activation/udev_fallback to lvm.conf. Call vg_mark_partial_lvs() before VG structure is returned from the cache. Remove unused internal flag ACTIVATE_EXCL from the code. --- LVM2/lib/activate/activate.c 2011/06/17 14:30:58 1.202 +++ LVM2/lib/activate/activate.c 2011/06/22 21:31:21 1.203 @@ -823,13 +823,11 @@ return _lv_is_active(lv, NULL, NULL); } -/* -int lv_is_active_locally(struct logical_volume *lv) +int lv_is_active_but_not_locally(struct logical_volume *lv) { int l; - return _lv_is_active(lv, &l, NULL) && l; + return _lv_is_active(lv, &l, NULL) && !l; } -*/ int lv_is_active_exclusive_locally(struct logical_volume *lv) { --- LVM2/lib/activate/activate.h 2011/06/17 14:14:19 1.77 +++ LVM2/lib/activate/activate.h 2011/06/22 21:31:21 1.78 @@ -101,6 +101,7 @@ int lvs_in_vg_opened(const struct volume_group *vg); int lv_is_active(struct logical_volume *lv); +int lv_is_active_but_not_locally(struct logical_volume *lv); int lv_is_active_exclusive_locally(struct logical_volume *lv); int lv_is_active_exclusive_remotely(struct logical_volume *lv); --- LVM2/lib/metadata/mirror.c 2011/06/17 14:27:35 1.154 +++ LVM2/lib/metadata/mirror.c 2011/06/22 21:31:21 1.155 @@ -1857,15 +1857,9 @@ return 0; } - /* - * We are unable to convert the log of inactive cluster mirrors - * due to the inability to detect whether the mirror is active - * on remote nodes (even though it is inactive on this node) - */ - if (vg_is_clustered(lv->vg) && - !(lv_info(cmd, lv, 0, &info, 0, 0) && info.exists)) { - log_error("Unable to convert the log of inactive " - "cluster mirror %s", lv->name); + if (lv_is_active_but_not_locally(lv)) { + log_error("Unable to convert the log of a mirror, %s, that is " + "active remotely but not locally", lv->name); return 0; } From mbroz@sourceware.org Thu Jun 23 10:53:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 23 Jun 2011 10:53:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c test/ ... Message-ID: <20110623105325.12274.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-23 10:53:24 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c test : t-lvconvert-mirror.sh Log message: Fail allocation if number of extents not divisible by area count Allocation should fail early if this condition is not met. Quick fix for https://bugzilla.redhat.com/show_bug.cgi?id=707779 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2024&r2=1.2025 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.262&r2=1.263 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror.sh.diff?cvsroot=lvm2&r1=1.10&r2=1.11 --- LVM2/WHATS_NEW 2011/06/22 21:31:21 1.2024 +++ LVM2/WHATS_NEW 2011/06/23 10:53:24 1.2025 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Reject allocation if number of extents is not divisible by area count. Fix issue preventing cluster mirror creation. Disable udev fallback by default and add activation/udev_fallback to lvm.conf. Call vg_mark_partial_lvs() before VG structure is returned from the cache. --- LVM2/lib/metadata/lv_manip.c 2011/06/13 22:28:05 1.262 +++ LVM2/lib/metadata/lv_manip.c 2011/06/23 10:53:24 1.263 @@ -1716,6 +1716,13 @@ return 1; } + 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; + } + alloc_state.log_area_count_still_needed = ah->log_area_count; if (ah->alloc == ALLOC_CONTIGUOUS) --- LVM2/test/t-lvconvert-mirror.sh 2011/06/09 19:38:56 1.10 +++ LVM2/test/t-lvconvert-mirror.sh 2011/06/23 10:53:24 1.11 @@ -248,3 +248,8 @@ lvreduce -f -l1 $vg/$lv1 lvextend -f -l10 $vg/$lv1 lvremove -ff $vg/$lv1 + +# extents must be divisible +lvcreate -l15 -n $lv1 $vg +not lvconvert -m1 --corelog --stripes 2 $vg/$lv1 +lvremove -ff $vg/$lv1 From jbrassow@sourceware.org Thu Jun 23 14:01:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Thu, 23 Jun 2011 14:01:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c lib/m ... Message-ID: <20110623140100.23242.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-06-23 14:00:59 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c mirror.c Log message: Fix to preserve exclusive activation of mirror while up-converting. When an LVM mirror is up-converted (an additional image added), it creates a temporary mirror stack. The lower-level mirror in the stack that is created was not being activated exclusively - violating the exclusive nature of the original mirror. We now check for exclusive activation of a mirror before converting it, and if found, we ensure that the temporary mirror is also exclusively activated. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2025&r2=1.2026 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.263&r2=1.264 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.155&r2=1.156 --- LVM2/WHATS_NEW 2011/06/23 10:53:24 1.2025 +++ LVM2/WHATS_NEW 2011/06/23 14:00:58 1.2026 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Fix to preserve exclusive activation of mirror while up-converting. Reject allocation if number of extents is not divisible by area count. Fix issue preventing cluster mirror creation. Disable udev fallback by default and add activation/udev_fallback to lvm.conf. --- LVM2/lib/metadata/lv_manip.c 2011/06/23 10:53:24 1.263 +++ LVM2/lib/metadata/lv_manip.c 2011/06/23 14:00:58 1.264 @@ -3103,11 +3103,13 @@ uint64_t status, const char *layer_suffix) { + int r; struct logical_volume *layer_lv; char *name; size_t len; struct segment_type *segtype; struct lv_segment *mapseg; + unsigned exclusive = 0; /* create an empty layer LV */ len = strlen(lv_where->name) + 32; @@ -3129,6 +3131,9 @@ return NULL; } + if (lv_is_active_exclusive_locally(lv_where)) + exclusive = 1; + if (lv_is_active(lv_where) && strstr(name, "_mimagetmp")) { log_very_verbose("Creating transient LV %s for mirror conversion in VG %s.", name, lv_where->vg->name); @@ -3150,8 +3155,15 @@ return NULL; } - if (!activate_lv(cmd, layer_lv)) { - log_error("Failed to resume transient error LV %s for mirror conversion in VG %s.", name, lv_where->vg->name); + if (exclusive) + r = activate_lv_excl(cmd, layer_lv); + else + r = activate_lv(cmd, layer_lv); + + if (!r) { + log_error("Failed to resume transient LV" + " %s for mirror conversion in VG %s.", + name, lv_where->vg->name); return NULL; } } --- LVM2/lib/metadata/mirror.c 2011/06/22 21:31:21 1.155 +++ LVM2/lib/metadata/mirror.c 2011/06/23 14:00:59 1.156 @@ -419,8 +419,13 @@ } } - if (!activate_lv(cmd, lv)) - return_0; + if (lv_is_active_exclusive_locally(lv)) { + if (!activate_lv_excl(cmd, lv)) + return_0; + } else { + if (!activate_lv(cmd, lv)) + return_0; + } if (!deactivate_lv(cmd, lv)) return_0; From agk@sourceware.org Fri Jun 24 19:33:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 24 Jun 2011 19:33:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdm-deptree.c libd ... Message-ID: <20110624193345.20432.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-24 19:33:41 Modified files: . : WHATS_NEW_DM libdm : libdm-deptree.c libdm/ioctl : libdm-iface.c Log message: Return immediately dm_lib_exit() if called more than once. (Avoiding calling it twice would involve some untangling.) Decrement the new suspended_counter if removing a suspended device. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.473&r2=1.474 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107 --- LVM2/WHATS_NEW_DM 2011/06/17 14:55:51 1.473 +++ LVM2/WHATS_NEW_DM 2011/06/24 19:33:41 1.474 @@ -1,5 +1,6 @@ Version 1.02.65 - ================================== + Return immediately dm_lib_exit() if called more than once. Disable udev fallback by default and add --udevfallback option to dmsetup. Warn if a table is loaded while a device is known to be in suspended state. Add dm_get_suspended_counter() for number of devs in suspended state by lib. --- LVM2/libdm/libdm-deptree.c 2011/06/22 12:56:02 1.97 +++ LVM2/libdm/libdm-deptree.c 2011/06/24 19:33:41 1.98 @@ -1188,7 +1188,8 @@ info.minor); r = 0; continue; - } + } else if (info.suspended) + dec_suspended(); if (dm_tree_node_num_children(child, 0)) { if (!_dm_tree_deactivate_children(child, uuid_prefix, uuid_prefix_len, level + 1)) --- LVM2/libdm/ioctl/libdm-iface.c 2011/06/13 03:53:02 1.106 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/06/24 19:33:41 1.107 @@ -2173,6 +2173,15 @@ void dm_lib_exit(void) { + int suspended_counter; + static unsigned _exited = 0; + + if (_exited++) + return; + + if ((suspended_counter = dm_get_suspended_counter())) + log_error("libdevmapper exiting with %d device(s) still suspended.", suspended_counter); + dm_lib_release(); selinux_release(); if (_dm_bitset) From agk@sourceware.org Fri Jun 24 23:39:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 24 Jun 2011 23:39:00 -0000 Subject: LVM2/lib/metadata mirror.c Message-ID: <20110624233909.15553.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-24 23:39:09 Modified files: lib/metadata : mirror.c Log message: remove unused var after recent patch Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.156&r2=1.157 --- LVM2/lib/metadata/mirror.c 2011/06/23 14:00:59 1.156 +++ LVM2/lib/metadata/mirror.c 2011/06/24 23:39:09 1.157 @@ -1853,7 +1853,6 @@ percent_t sync_percent; int in_sync; struct logical_volume *log_lv; - struct lvinfo info; unsigned old_log_count; int r = 0; From mornfall@sourceware.org Mon Jun 27 12:26:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 27 Jun 2011 12:26:00 -0000 Subject: LVM2/daemons/common daemon-client.h Message-ID: <20110627122655.2356.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-27 12:26:54 Modified files: daemons/common : daemon-client.h Log message: Sketch out the actual on-wire format in daemon-client.h documentation, and add a simplified send interface. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.h.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/daemons/common/daemon-client.h 2011/06/14 02:34:18 1.3 +++ LVM2/daemons/common/daemon-client.h 2011/06/27 12:26:54 1.4 @@ -20,7 +20,6 @@ typedef struct { int socket_fd; /* the fd we use to talk to the daemon */ int protocol; /* version of the protocol the daemon uses */ - char *read_buf; } daemon_handle; typedef struct { @@ -31,6 +30,17 @@ typedef struct { char *buffer; + /* + * The request looks like this: + * request = "id" + * arg_foo = "something" + * arg_bar = 3 + * arg_wibble { + * something_special = "here" + * amount = 75 + * knobs = [ "twiddle", "tweak" ] + * } + */ struct config_node *cft; } daemon_request; @@ -53,9 +63,22 @@ * Send a request to the daemon, waiting for the reply. All communication with * the daemon is synchronous. The function handles the IO details and parses the * response, handling common error conditions. See "daemon_reply" for details. + * + * In case the request contains a non-NULL buffer pointer, this buffer is sent + * *verbatim* to the server. In this case, the cft pointer may be NULL (but will + * be ignored even if non-NULL). If the buffer is NULL, the cft is required to + * be a valid pointer, and is used to build up the request. */ daemon_reply daemon_send(daemon_handle h, daemon_request r); +/* + * A simple interface to daemon_send. This function just takes the command id + * and possibly a list of parameters (of the form "name = %?", "value"). The + * type (string, integer) of the value is indicated by a character substituted + * for ? in %?: d for integer, s for string. + */ +daemon_reply daemon_send_simple(daemon_handle h, char *id, ...); + /* Shut down the communication to the daemon. Compulsory. */ void daemon_close(daemon_handle h); From mornfall@sourceware.org Mon Jun 27 12:27:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 27 Jun 2011 12:27:00 -0000 Subject: LVM2/daemons/lvmetad testclient.c Message-ID: <20110627122734.2906.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-27 12:27:34 Modified files: daemons/lvmetad: testclient.c Log message: Call daemon_close before exit in the testclient. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/testclient.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/daemons/lvmetad/testclient.c 2011/06/14 02:36:38 1.1 +++ LVM2/daemons/lvmetad/testclient.c 2011/06/27 12:27:34 1.2 @@ -8,5 +8,6 @@ daemon_reply reply = daemon_send(h, rq); fprintf(stderr, "daemon says: %s\n", reply.buffer); } + daemon_close(h); return 0; } From mornfall@sourceware.org Mon Jun 27 13:14:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 27 Jun 2011 13:14:00 -0000 Subject: LVM2/daemons/common daemon-client.c Message-ID: <20110627131454.10827.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-27 13:14:53 Modified files: daemons/common : daemon-client.c Log message: Do not open the socket with SOCK_NONBLOCK in daemon-client, since we have no use for that behaviour (at least for now). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/daemons/common/daemon-client.c 2011/06/14 02:34:18 1.1 +++ LVM2/daemons/common/daemon-client.c 2011/06/27 13:14:53 1.2 @@ -5,11 +5,12 @@ #include #include #include +#include // ENOMEM daemon_handle daemon_open(daemon_info i) { daemon_handle h; struct sockaddr_un sockaddr; - if ((h.socket_fd = socket(PF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) < 0) { + if ((h.socket_fd = socket(PF_UNIX, SOCK_STREAM /* | SOCK_NONBLOCK */, 0)) < 0) { perror("socket"); goto error; } @@ -50,5 +51,22 @@ return reply; } -void daemon_close(daemon_handle h) { +daemon_reply daemon_send_simple(daemon_handle h, char *id, ...) +{ + va_list ap; + va_start(ap, id); + daemon_request rq = { .buffer = format_buffer(id, ap) }; + + if (!rq.buffer) { + daemon_reply err = { .error = ENOMEM, .buffer = NULL, .cft = NULL }; + return err; + } + + daemon_reply repl = daemon_send(h, rq); + dm_free(rq.buffer); + return repl; +} + +void daemon_close(daemon_handle h) +{ } From mornfall@sourceware.org Mon Jun 27 13:15:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 27 Jun 2011 13:15:00 -0000 Subject: LVM2/daemons common/daemon-shared.c common/dae ... Message-ID: <20110627131550.12647.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-27 13:15:49 Modified files: daemons/common : daemon-shared.c daemon-shared.h daemons/lvmetad: lvmetad-core.c testclient.c Log message: Implement daemon_send_simple and use it in the testclient. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.h.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/testclient.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/daemons/common/daemon-shared.c 2011/06/14 02:34:18 1.1 +++ LVM2/daemons/common/daemon-shared.c 2011/06/27 13:15:49 1.2 @@ -2,12 +2,15 @@ #include #include #include +#include "daemon-shared.h" /* * Read a single message from a (socket) filedescriptor. Messages are delimited * by blank lines. This call will block until all of a message is received. The * memory will be allocated from heap. Upon error, all memory is freed and the * buffer pointer is set to NULL. + * + * See also write_buffer about blocking (read_buffer has identical behaviour). */ int read_buffer(int fd, char **buffer) { int bytes = 0; @@ -66,3 +69,43 @@ } return 0; } + +char *format_buffer(char *id, va_list ap) +{ + char *buffer, *old; + char *next; + char *format; + + dm_asprintf(&buffer, "request = \"%s\"\n", id); + if (!buffer) goto fail; + + while (next = va_arg(ap, char *)) { + old = buffer; + if (strstr(next, "%d") || strstr(next, "%s")) { + dm_asprintf(&format, "%%s%s\n", next); + if (!format) goto fail; + + if (strstr(format, "%d")) + dm_asprintf(&buffer, format, buffer, va_arg(ap, int)); + else + dm_asprintf(&buffer, format, buffer, va_arg(ap, char *)); + + dm_free(format); + dm_free(old); + if (!buffer) goto fail; + } else { + dm_asprintf(&buffer, "%s%s", buffer, next); + dm_free(old); + if (!buffer) goto fail; + } + } + + old = buffer; + dm_asprintf(&buffer, "%s\n", buffer); + dm_free(old); + + return buffer; +fail: + dm_free(buffer); + return NULL; +} --- LVM2/daemons/common/daemon-shared.h 2011/06/14 02:34:18 1.1 +++ LVM2/daemons/common/daemon-shared.h 2011/06/27 13:15:49 1.2 @@ -1,2 +1,6 @@ +#include +#include + int read_buffer(int fd, char **buffer); int write_buffer(int fd, char *buffer, int length); +char *format_buffer(char *id, va_list ap); --- LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/14 02:36:38 1.1 +++ LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 13:15:49 1.2 @@ -7,7 +7,7 @@ static response handler(daemon_state s, client_handle h, request r) { response res; - fprintf(stderr, "handling client request: %s\n", r.buffer); + fprintf(stderr, "---- server obtained:\n%s\n----------------------\n", r.buffer); res.error = 1; res.buffer = strdup("hey hey.\n\n"); return res; --- LVM2/daemons/lvmetad/testclient.c 2011/06/27 12:27:34 1.2 +++ LVM2/daemons/lvmetad/testclient.c 2011/06/27 13:15:49 1.3 @@ -2,10 +2,9 @@ int main() { daemon_handle h = lvmetad_open(); - daemon_request rq = { .buffer= "hello worldn\n" }; int i; for (i = 0; i < 5; ++i ) { - daemon_reply reply = daemon_send(h, rq); + daemon_reply reply = daemon_send_simple(h, "hello world", "param = %d", 3, NULL); fprintf(stderr, "daemon says: %s\n", reply.buffer); } daemon_close(h); From mornfall@sourceware.org Mon Jun 27 13:44:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 27 Jun 2011 13:44:00 -0000 Subject: LVM2/daemons/lvmetad Makefile test.sh Message-ID: <20110627134435.18826.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-27 13:44:34 Modified files: daemons/lvmetad: Makefile Added files: daemons/lvmetad: test.sh Log message: LVMetaD build hack: link to lvm-internal &c. and add a simple test script. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/test.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/Makefile.diff?cvsroot=lvm2&r1=1.1&r2=1.2 /cvs/lvm2/LVM2/daemons/lvmetad/test.sh,v --> standard output revision 1.1 --- LVM2/daemons/lvmetad/test.sh +++ - 2011-06-27 13:44:34.722209000 +0000 @@ -0,0 +1,14 @@ +#!/bin/bash + +export LD_LIBRARY_PATH="$1" + +test -n "$2" && { + ./lvmetad -f & + PID=$! + sleep .1 + ./testclient + kill $PID + exit 0 +} + +sudo ./test.sh "$1" . --- LVM2/daemons/lvmetad/Makefile 2011/06/14 02:36:38 1.1 +++ LVM2/daemons/lvmetad/Makefile 2011/06/27 13:44:33 1.2 @@ -13,9 +13,10 @@ CLIENT_H = ../common/daemon-client.h $(SHARED_H) SERVER_H = ../common/daemon-server.h $(SHARED_H) -LIBS = -ldevmapper -lpthread +LIBS = -ldevmapper -lpthread -ldevmapper-event -llvm-internal -ldl IPATH = -I../common -I/srv/build/lvm2/cvs-lvmetad/default/include -LPATH = -L/srv/build/lvm2/cvs-lvmetad/default/libdm +BUILDDIR = /srv/build/lvm2/cvs-lvmetad/default +LPATH = -L$(BUILDDIR)/libdm -L$(BUILDDIR)/lib -L$(BUILDDIR)/daemons/dmeventd all: testclient lvmetad @@ -24,3 +25,6 @@ lvmetad: lvmetad-core.c ../common/daemon-server.c ../common/daemon-server.h ../common/daemon-shared.h ../common/daemon-shared.c gcc -g lvmetad-core.c $(SERVER) $(IPATH) $(LPATH) $(LIBS) -o lvmetad + +check: testclient lvmetad + ./test.sh "$(BUILDDIR)/libdm:$(BUILDDIR)/daemons/dmeventd" From mornfall@sourceware.org Mon Jun 27 13:46:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 27 Jun 2011 13:46:00 -0000 Subject: LVM2/daemons common/daemon-client.c common/dae ... Message-ID: <20110627134647.21121.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-27 13:46:45 Modified files: daemons/common : daemon-client.c daemon-server.c daemon-server.h daemons/lvmetad: lvmetad-core.c testclient.c Log message: Parse the incoming config tree in daemon-server.c, providing the daemon-specific handler with a struct config_tree pointer to look things up in. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/testclient.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/daemons/common/daemon-client.c 2011/06/27 13:14:53 1.2 +++ LVM2/daemons/common/daemon-client.c 2011/06/27 13:46:45 1.3 @@ -15,7 +15,7 @@ goto error; } memset(&sockaddr, 0, sizeof(sockaddr)); - fprintf(stderr, "connecting to %s\n", i.socket); + fprintf(stderr, "[C] connecting to %s\n", i.socket); strcpy(sockaddr.sun_path, i.socket); sockaddr.sun_family = AF_UNIX; if (connect(h.socket_fd,(struct sockaddr *) &sockaddr, sizeof(sockaddr))) { --- LVM2/daemons/common/daemon-server.c 2011/06/14 02:34:18 1.4 +++ LVM2/daemons/common/daemon-server.c 2011/06/27 13:46:45 1.5 @@ -107,7 +107,7 @@ fprintf(stderr, "setting CLOEXEC on socket fd %d failed: %s\n", fd, strerror(errno)); fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); - fprintf(stderr, "creating %s\n", s.socket_path); + fprintf(stderr, "[D] creating %s\n", s.socket_path); memset(&sockaddr, 0, sizeof(sockaddr)); strcpy(sockaddr.sun_path, s.socket_path); sockaddr.sun_family = AF_UNIX; @@ -213,8 +213,10 @@ if (!read_buffer(b->client.socket_fd, &req.buffer)) goto fail; - /* TODO parse the buffer into req.cft */ + req.cft = create_config_tree_from_string(req.buffer); response res = b->s.handler(b->s, b->client, req); + destroy_config_tree(req.cft); + dm_free(req.buffer); if (!res.buffer) { /* TODO fill in the buffer from res.cft */ @@ -223,7 +225,6 @@ write_buffer(b->client.socket_fd, res.buffer, strlen(res.buffer)); free(res.buffer); - free(req.buffer); } fail: /* TODO what should we really do here? */ --- LVM2/daemons/common/daemon-server.h 2011/06/14 02:34:18 1.5 +++ LVM2/daemons/common/daemon-server.h 2011/06/27 13:46:45 1.6 @@ -26,13 +26,13 @@ } client_handle; typedef struct { - struct config_node *cft; + struct config_tree *cft; char *buffer; } request; typedef struct { int error; - struct config_node *cft; + struct config_tree *cft; char *buffer; } response; --- LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 13:15:49 1.2 +++ LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 13:46:45 1.3 @@ -7,7 +7,7 @@ static response handler(daemon_state s, client_handle h, request r) { response res; - fprintf(stderr, "---- server obtained:\n%s\n----------------------\n", r.buffer); + fprintf(stderr, "[D] REQUEST: %s\n", find_config_str(r.cft->root, "request", "NONE")); res.error = 1; res.buffer = strdup("hey hey.\n\n"); return res; --- LVM2/daemons/lvmetad/testclient.c 2011/06/27 13:15:49 1.3 +++ LVM2/daemons/lvmetad/testclient.c 2011/06/27 13:46:45 1.4 @@ -5,7 +5,7 @@ int i; for (i = 0; i < 5; ++i ) { daemon_reply reply = daemon_send_simple(h, "hello world", "param = %d", 3, NULL); - fprintf(stderr, "daemon says: %s\n", reply.buffer); + fprintf(stderr, "[C] obtained: %s\n", reply.buffer); } daemon_close(h); return 0; From mornfall@sourceware.org Mon Jun 27 13:58:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 27 Jun 2011 13:58:00 -0000 Subject: LVM2/daemons common/daemon-client.c common/dae ... Message-ID: <20110627135812.30006.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-27 13:58:11 Modified files: daemons/common : daemon-client.c daemon-client.h daemon-server.c daemon-server.h daemons/lvmetad: lvmetad-core.c testclient.c Log message: Also parse the config_tree on the client end (daemon-client.c). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/testclient.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 --- LVM2/daemons/common/daemon-client.c 2011/06/27 13:46:45 1.3 +++ LVM2/daemons/common/daemon-client.c 2011/06/27 13:58:11 1.4 @@ -44,13 +44,18 @@ write_buffer(h.socket_fd, rq.buffer, strlen(rq.buffer)); if (read_buffer(h.socket_fd, &reply.buffer)) { - /* TODO: parse reply.buffer into reply.cft */ + reply.cft = create_config_tree_from_string(reply.buffer); } else reply.error = 1; return reply; } +void daemon_reply_destroy(daemon_reply r) { + if (r.cft) + destroy_config_tree(r.cft); +} + daemon_reply daemon_send_simple(daemon_handle h, char *id, ...) { va_list ap; --- LVM2/daemons/common/daemon-client.h 2011/06/27 12:26:54 1.4 +++ LVM2/daemons/common/daemon-client.h 2011/06/27 13:58:11 1.5 @@ -41,13 +41,13 @@ * knobs = [ "twiddle", "tweak" ] * } */ - struct config_node *cft; + struct config_tree *cft; } daemon_request; typedef struct { int error; /* 0 for success */ char *buffer; /* textual reply */ - struct config_node *cft; /* parsed reply, if available */ + struct config_tree *cft; /* parsed reply, if available */ } daemon_reply; /* @@ -79,6 +79,8 @@ */ daemon_reply daemon_send_simple(daemon_handle h, char *id, ...); +void daemon_reply_destroy(daemon_reply r); + /* Shut down the communication to the daemon. Compulsory. */ void daemon_close(daemon_handle h); --- LVM2/daemons/common/daemon-server.c 2011/06/27 13:46:45 1.5 +++ LVM2/daemons/common/daemon-server.c 2011/06/27 13:58:11 1.6 @@ -25,6 +25,7 @@ #include #include "daemon-server.h" +#include "daemon-shared.h" #include "libdevmapper.h" #if 0 @@ -200,6 +201,18 @@ setsid(); } +response daemon_reply_simple(char *id, ...) +{ + va_list ap; + va_start(ap, id); + response res = { .buffer = format_buffer(id, ap), .cft = NULL }; + + if (!res.buffer) + res.error = ENOMEM; + + return res; +} + struct thread_baton { daemon_state s; client_handle client; --- LVM2/daemons/common/daemon-server.h 2011/06/27 13:46:45 1.6 +++ LVM2/daemons/common/daemon-server.h 2011/06/27 13:58:11 1.7 @@ -39,6 +39,12 @@ struct daemon_state; /* + * Craft a simple reply, without the need to construct a config_tree. See + * daemon_send_simple in daemon-client.h for the description of the parameters. + */ +response daemon_reply_simple(char *id, ...); + +/* * The callback. Called once per request issued, in the respective client's * thread. It is presented by a parsed request (in the form of a config tree). * The output is a new config tree that is serialised and sent back to the --- LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 13:46:45 1.3 +++ LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 13:58:11 1.4 @@ -6,11 +6,9 @@ static response handler(daemon_state s, client_handle h, request r) { - response res; - fprintf(stderr, "[D] REQUEST: %s\n", find_config_str(r.cft->root, "request", "NONE")); - res.error = 1; - res.buffer = strdup("hey hey.\n\n"); - return res; + fprintf(stderr, "[D] REQUEST: %s, param = %d\n", find_config_str(r.cft->root, "request", "NONE"), + find_config_int(r.cft->root, "param", -1)); + return daemon_reply_simple("hey there", "param = %d", 42, NULL); } static int setup_post(daemon_state *s) --- LVM2/daemons/lvmetad/testclient.c 2011/06/27 13:46:45 1.4 +++ LVM2/daemons/lvmetad/testclient.c 2011/06/27 13:58:11 1.5 @@ -5,7 +5,9 @@ int i; for (i = 0; i < 5; ++i ) { daemon_reply reply = daemon_send_simple(h, "hello world", "param = %d", 3, NULL); - fprintf(stderr, "[C] obtained: %s\n", reply.buffer); + fprintf(stderr, "[C] REPLY: %s, param = %d\n", find_config_str(reply.cft->root, "request", "NONE"), + find_config_int(reply.cft->root, "param", -1)); + daemon_reply_destroy(reply); } daemon_close(h); return 0; From mornfall@sourceware.org Mon Jun 27 14:04:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 27 Jun 2011 14:04:00 -0000 Subject: LVM2/daemons common/daemon-client.h common/dae ... Message-ID: <20110627140400.2090.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-27 14:03:59 Modified files: daemons/common : daemon-client.h daemon-server.h daemons/lvmetad: lvmetad-core.c testclient.c Log message: Add int/str lookup routines specific to the reply (in client) and request (in server) for nicer-looking code (thin wrapping around find_config_{int,str}). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/testclient.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/daemons/common/daemon-client.h 2011/06/27 13:58:11 1.5 +++ LVM2/daemons/common/daemon-client.h 2011/06/27 14:03:58 1.6 @@ -81,6 +81,15 @@ void daemon_reply_destroy(daemon_reply r); +static inline int daemon_reply_int(daemon_reply r, const char *path, int def) { + return find_config_int(r.cft->root, path, def); +} + +static inline const char *daemon_reply_str(daemon_reply r, const char *path, const char *def) { + return find_config_str(r.cft->root, path, def); +} + + /* Shut down the communication to the daemon. Compulsory. */ void daemon_close(daemon_handle h); --- LVM2/daemons/common/daemon-server.h 2011/06/27 13:58:11 1.7 +++ LVM2/daemons/common/daemon-server.h 2011/06/27 14:03:59 1.8 @@ -44,6 +44,14 @@ */ response daemon_reply_simple(char *id, ...); +static inline int daemon_request_int(request r, const char *path, int def) { + return find_config_int(r.cft->root, path, def); +} + +static inline const char *daemon_request_str(request r, const char *path, const char *def) { + return find_config_str(r.cft->root, path, def); +} + /* * The callback. Called once per request issued, in the respective client's * thread. It is presented by a parsed request (in the form of a config tree). --- LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 13:58:11 1.4 +++ LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 14:03:59 1.5 @@ -6,8 +6,8 @@ static response handler(daemon_state s, client_handle h, request r) { - fprintf(stderr, "[D] REQUEST: %s, param = %d\n", find_config_str(r.cft->root, "request", "NONE"), - find_config_int(r.cft->root, "param", -1)); + fprintf(stderr, "[D] REQUEST: %s, param = %d\n", daemon_request_str(r, "request", "NONE"), + daemon_request_int(r, "param", -1)); return daemon_reply_simple("hey there", "param = %d", 42, NULL); } --- LVM2/daemons/lvmetad/testclient.c 2011/06/27 13:58:11 1.5 +++ LVM2/daemons/lvmetad/testclient.c 2011/06/27 14:03:59 1.6 @@ -5,8 +5,8 @@ int i; for (i = 0; i < 5; ++i ) { daemon_reply reply = daemon_send_simple(h, "hello world", "param = %d", 3, NULL); - fprintf(stderr, "[C] REPLY: %s, param = %d\n", find_config_str(reply.cft->root, "request", "NONE"), - find_config_int(reply.cft->root, "param", -1)); + fprintf(stderr, "[C] REPLY: %s, param = %d\n", daemon_reply_str(reply, "request", "NONE"), + daemon_reply_int(reply, "param", -1)); daemon_reply_destroy(reply); } daemon_close(h); From agk@sourceware.org Mon Jun 27 21:44:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 27 Jun 2011 21:44:00 -0000 Subject: LVM2 ./WHATS_NEW ./WHATS_NEW_DM doc/example.co ... Message-ID: <20110627214401.19396.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-27 21:43:59 Modified files: . : WHATS_NEW WHATS_NEW_DM doc : example.conf.in lib/commands : toolcontext.c lib/config : defaults.h libdm : libdm-common.c libdm-common.h libdm-deptree.c libdm/ioctl : libdm-iface.c man : dmsetup.8.in tools : dmsetup.c Log message: Move udev_only logic inside stacked node op code. (We still need to treat add+readhead+del as a no-op.) Rename udev_fallback to verify_udev_operations. Rename --udevfallback to --verifyudev Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2026&r2=1.2027 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.474&r2=1.475 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.26&r2=1.27 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.76&r2=1.77 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.h.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/dmsetup.8.in.diff?cvsroot=lvm2&r1=1.39&r2=1.40 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.161&r2=1.162 --- LVM2/WHATS_NEW 2011/06/23 14:00:58 1.2026 +++ LVM2/WHATS_NEW 2011/06/27 21:43:58 1.2027 @@ -3,7 +3,7 @@ Fix to preserve exclusive activation of mirror while up-converting. Reject allocation if number of extents is not divisible by area count. Fix issue preventing cluster mirror creation. - Disable udev fallback by default and add activation/udev_fallback to lvm.conf. + Add activation/verify_udev_operations to lvm.conf, disabled by default. Call vg_mark_partial_lvs() before VG structure is returned from the cache. Remove unused internal flag ACTIVATE_EXCL from the code. Remove useless test of ACTIVATE_EXCL in lv_add_mirrors() clustered code path. --- LVM2/WHATS_NEW_DM 2011/06/24 19:33:41 1.474 +++ LVM2/WHATS_NEW_DM 2011/06/27 21:43:58 1.475 @@ -1,7 +1,7 @@ Version 1.02.65 - ================================== - Return immediately dm_lib_exit() if called more than once. - Disable udev fallback by default and add --udevfallback option to dmsetup. + Return immediately from dm_lib_exit() if called more than once. + Disable udev fallback by default and add --verifyudev option to dmsetup. Warn if a table is loaded while a device is known to be in suspended state. Add dm_get_suspended_counter() for number of devs in suspended state by lib. Fix "all" report field prefix matching to include label fields with pv_all. --- LVM2/doc/example.conf.in 2011/06/17 14:50:53 1.26 +++ LVM2/doc/example.conf.in 2011/06/27 21:43:59 1.27 @@ -428,12 +428,11 @@ # while any logical volumes are active. udev_rules = 1 - # Set to 1 to enable udev fallback. This will enable additional checks and - # possible repairs done on entries in the device directory after udev has - # completed processing the events. This is normally not needed if udev - # works correctly but it may be used in some problematic situations or - # for debugging purposes. - udev_fallback = 0 + # Set to 1 for LVM2 to verify operations performed by udev. This turns on + # additional checks (and if necessary, repairs) on entries in the device + # directory after udev has completed processing its events. + # Useful for diagnosing problems with LVM2/udev interactions. + verify_udev_operations = 0 # How to fill in missing stripes if activating an incomplete volume. # Using "error" will make inaccessible parts of the device return --- LVM2/lib/commands/toolcontext.c 2011/06/17 14:50:54 1.120 +++ LVM2/lib/commands/toolcontext.c 2011/06/27 21:43:59 1.121 @@ -293,8 +293,8 @@ * without any fallback. */ cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ? - find_config_tree_int(cmd, "activation/udev_fallback", - DEFAULT_UDEV_FALLBACK) : 1; + find_config_tree_int(cmd, "activation/verify_udev_operations", + DEFAULT_VERIFY_UDEV_OPERATIONS) : 1; #else /* We must use old node/symlink creation code if not compiled with udev support at all! */ cmd->default_settings.udev_fallback = 1; --- LVM2/lib/config/defaults.h 2011/06/17 14:50:54 1.76 +++ LVM2/lib/config/defaults.h 2011/06/27 21:43:59 1.77 @@ -78,7 +78,7 @@ #define DEFAULT_READ_AHEAD "auto" #define DEFAULT_UDEV_RULES 1 #define DEFAULT_UDEV_SYNC 0 -#define DEFAULT_UDEV_FALLBACK 0 +#define DEFAULT_VERIFY_UDEV_OPERATIONS 0 #define DEFAULT_EXTENT_SIZE 4096 /* In KB */ #define DEFAULT_MAX_PV 0 #define DEFAULT_MAX_LV 0 --- LVM2/libdm/libdm-common.c 2011/06/13 03:32:46 1.118 +++ LVM2/libdm/libdm-common.c 2011/06/27 21:43:59 1.119 @@ -501,8 +501,13 @@ #endif } +static int _warn_if_op_needed(int warn_if_udev_failed) +{ + return warn_if_udev_failed && dm_udev_get_sync_support() && dm_udev_get_checking(); +} + static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor, - uid_t uid, gid_t gid, mode_t mode, int check_udev) + uid_t uid, gid_t gid, mode_t mode, int warn_if_udev_failed) { char path[PATH_MAX]; struct stat info; @@ -527,8 +532,7 @@ dev_name); return 0; } - } else if (dm_udev_get_sync_support() && dm_udev_get_checking() && - check_udev) + } else if (_warn_if_op_needed(warn_if_udev_failed)) log_warn("%s not set up by udev: Falling back to direct " "node creation.", path); @@ -553,7 +557,7 @@ return 1; } -static int _rm_dev_node(const char *dev_name, int check_udev) +static int _rm_dev_node(const char *dev_name, int warn_if_udev_failed) { char path[PATH_MAX]; struct stat info; @@ -562,8 +566,7 @@ if (stat(path, &info) < 0) return 1; - else if (dm_udev_get_sync_support() && dm_udev_get_checking() && - check_udev) + else if (_warn_if_op_needed(warn_if_udev_failed)) log_warn("Node %s was not removed by udev. " "Falling back to direct node removal.", path); @@ -578,7 +581,7 @@ } static int _rename_dev_node(const char *old_name, const char *new_name, - int check_udev) + int warn_if_udev_failed) { char oldpath[PATH_MAX]; char newpath[PATH_MAX]; @@ -593,8 +596,7 @@ "is already present", newpath); return 0; } - else if (dm_udev_get_sync_support() && dm_udev_get_checking() && - check_udev) { + else if (_warn_if_op_needed(warn_if_udev_failed)) { if (stat(oldpath, &info) < 0 && errno == ENOENT) /* assume udev already deleted this */ @@ -618,8 +620,7 @@ return 0; } } - else if (dm_udev_get_sync_support() && dm_udev_get_checking() && - check_udev) + else if (_warn_if_op_needed(warn_if_udev_failed)) log_warn("The node %s should have been renamed to %s " "by udev but new node is not present. " "Falling back to direct node rename.", @@ -759,16 +760,16 @@ static int _do_node_op(node_op_t type, const char *dev_name, uint32_t major, uint32_t minor, uid_t uid, gid_t gid, mode_t mode, const char *old_name, uint32_t read_ahead, - uint32_t read_ahead_flags, int check_udev) + uint32_t read_ahead_flags, int warn_if_udev_failed) { switch (type) { case NODE_ADD: return _add_dev_node(dev_name, major, minor, uid, gid, - mode, check_udev); + mode, warn_if_udev_failed); case NODE_DEL: - return _rm_dev_node(dev_name, check_udev); + return _rm_dev_node(dev_name, warn_if_udev_failed); case NODE_RENAME: - return _rename_dev_node(old_name, dev_name, check_udev); + return _rename_dev_node(old_name, dev_name, warn_if_udev_failed); case NODE_READ_AHEAD: return _set_dev_node_read_ahead(dev_name, read_ahead, read_ahead_flags); @@ -794,7 +795,8 @@ uint32_t read_ahead; uint32_t read_ahead_flags; char *old_name; - int check_udev; + int warn_if_udev_failed; + unsigned rely_on_udev; char names[0]; }; @@ -824,16 +826,33 @@ return 0; } -/* Check if udev is supposed to create nodes */ -static int _check_udev(int check_udev) +static void _log_node_op(const char *action_str, struct node_op_parms *nop) { - return check_udev && dm_udev_get_sync_support() && dm_udev_get_checking(); + switch (nop->type) { + case NODE_ADD: + log_debug("%s: %s NODE_ADD (%" PRIu32 ",%" PRIu32 ") %u:%u 0%o", + nop->dev_name, action_str, nop->major, nop->minor, nop->uid, nop->gid, nop->mode); + break; + case NODE_DEL: + log_debug("%s: %s NODE_DEL", nop->dev_name, action_str); + break; + case NODE_RENAME: + log_debug("%s: %s NODE_RENAME to %s", nop->old_name, action_str, nop->dev_name); + break; + case NODE_READ_AHEAD: + log_debug("%s: %s NODE_READ_AHEAD %" PRIu32 " (flags=%" PRIu32 + ")", nop->dev_name, action_str, nop->read_ahead, nop->read_ahead_flags); + break; + default: + ; /* NOTREACHED */ + } } static int _stack_node_op(node_op_t type, const char *dev_name, uint32_t major, uint32_t minor, uid_t uid, gid_t gid, mode_t mode, const char *old_name, uint32_t read_ahead, - uint32_t read_ahead_flags, int check_udev) + uint32_t read_ahead_flags, int warn_if_udev_failed, + unsigned rely_on_udev) { struct node_op_parms *nop; struct dm_list *noph, *nopht; @@ -841,7 +860,7 @@ char *pos; /* - * Note: check_udev must have valid content + * Note: warn_if_udev_failed must have valid content */ if ((type == NODE_DEL) && _other_node_ops(type)) /* @@ -850,27 +869,29 @@ dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); if (!strcmp(dev_name, nop->dev_name)) { + _log_node_op("Unstacking", nop); _del_node_op(nop); if (!_other_node_ops(type)) break; /* no other non DEL ops */ } } - else if ((type == NODE_ADD) && _count_node_ops[NODE_DEL] && _check_udev(check_udev)) + else if ((type == NODE_ADD) && _count_node_ops[NODE_DEL]) /* - * If udev is running ignore previous DEL operation on added node. + * Ignore previous DEL operation on added node. * (No other operations for this device then DEL could be stacked here). */ dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); if ((nop->type == NODE_DEL) && !strcmp(dev_name, nop->dev_name)) { + _log_node_op("Unstacking", nop); _del_node_op(nop); break; /* no other DEL ops */ } } - else if ((type == NODE_RENAME) && _check_udev(check_udev)) + else if ((type == NODE_RENAME)) /* - * If udev is running ignore any outstanding operations if renaming it. + * Ignore any outstanding operations if renaming it. * * Currently RENAME operation happens through 'suspend -> resume'. * On 'resume' device is added with read_ahead settings, so it is @@ -880,6 +901,7 @@ dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); if (!strcmp(old_name, nop->dev_name)) + _log_node_op("Unstacking", nop); _del_node_op(nop); } @@ -897,7 +919,8 @@ nop->mode = mode; nop->read_ahead = read_ahead; nop->read_ahead_flags = read_ahead_flags; - nop->check_udev = check_udev; + nop->warn_if_udev_failed = warn_if_udev_failed; + nop->rely_on_udev = rely_on_udev; _store_str(&pos, &nop->dev_name, dev_name); _store_str(&pos, &nop->old_name, old_name); @@ -905,6 +928,8 @@ _count_node_ops[type]++; dm_list_add(&_node_ops, &nop->list); + _log_node_op("Stacking", nop); + return 1; } @@ -915,38 +940,35 @@ dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); - _do_node_op(nop->type, nop->dev_name, nop->major, nop->minor, - nop->uid, nop->gid, nop->mode, nop->old_name, - nop->read_ahead, nop->read_ahead_flags, - nop->check_udev); + if (!nop->rely_on_udev) { + _log_node_op("Processing", nop); + _do_node_op(nop->type, nop->dev_name, nop->major, nop->minor, + nop->uid, nop->gid, nop->mode, nop->old_name, + nop->read_ahead, nop->read_ahead_flags, + nop->warn_if_udev_failed); + } else + _log_node_op("Skipping (udev)", nop); _del_node_op(nop); } } int add_dev_node(const char *dev_name, uint32_t major, uint32_t minor, - uid_t uid, gid_t gid, mode_t mode, int check_udev) + uid_t uid, gid_t gid, mode_t mode, int check_udev, unsigned rely_on_udev) { - log_debug("%s: Stacking NODE_ADD (%" PRIu32 ",%" PRIu32 ") %u:%u 0%o", - dev_name, major, minor, uid, gid, mode); - return _stack_node_op(NODE_ADD, dev_name, major, minor, uid, - gid, mode, "", 0, 0, check_udev); + gid, mode, "", 0, 0, check_udev, rely_on_udev); } -int rename_dev_node(const char *old_name, const char *new_name, int check_udev) +int rename_dev_node(const char *old_name, const char *new_name, int check_udev, unsigned rely_on_udev) { - log_debug("%s: Stacking NODE_RENAME to %s", old_name, new_name); - return _stack_node_op(NODE_RENAME, new_name, 0, 0, 0, - 0, 0, old_name, 0, 0, check_udev); + 0, 0, old_name, 0, 0, check_udev, rely_on_udev); } -int rm_dev_node(const char *dev_name, int check_udev) +int rm_dev_node(const char *dev_name, int check_udev, unsigned rely_on_udev) { - log_debug("%s: Stacking NODE_DEL (replaces other stacked ops)", dev_name); - return _stack_node_op(NODE_DEL, dev_name, 0, 0, 0, - 0, 0, "", 0, 0, check_udev); + 0, 0, "", 0, 0, check_udev, rely_on_udev); } int set_dev_node_read_ahead(const char *dev_name, uint32_t read_ahead, @@ -955,11 +977,8 @@ if (read_ahead == DM_READ_AHEAD_AUTO) return 1; - log_debug("%s: Stacking NODE_READ_AHEAD %" PRIu32 " (flags=%" PRIu32 - ")", dev_name, read_ahead, read_ahead_flags); - return _stack_node_op(NODE_READ_AHEAD, dev_name, 0, 0, 0, 0, - 0, "", read_ahead, read_ahead_flags, 0); + 0, "", read_ahead, read_ahead_flags, 0, 0); } void update_devs(void) @@ -1428,7 +1447,7 @@ return 0; } - log_debug("Udev cookie 0x%" PRIx32 " (semid %d): Waiting for zero", + log_debug("Udev cookie 0x%" PRIx32 " (semid %d) waiting for zero", cookie, semid); repeat_wait: --- LVM2/libdm/libdm-common.h 2011/06/13 03:32:46 1.8 +++ LVM2/libdm/libdm-common.h 2011/06/27 21:43:59 1.9 @@ -23,10 +23,10 @@ const char *type, const char *params); int add_dev_node(const char *dev_name, uint32_t minor, uint32_t major, - uid_t uid, gid_t gid, mode_t mode, int check_udev); -int rm_dev_node(const char *dev_name, int check_udev); + uid_t uid, gid_t gid, mode_t mode, int check_udev, unsigned rely_on_udev); +int rm_dev_node(const char *dev_name, int check_udev, unsigned rely_on_udev); int rename_dev_node(const char *old_name, const char *new_name, - int check_udev); + int check_udev, unsigned rely_on_udev); int get_dev_node_read_ahead(const char *dev_name, uint32_t *read_ahead); int set_dev_node_read_ahead(const char *dev_name, uint32_t read_ahead, uint32_t read_ahead_flags); --- LVM2/libdm/libdm-deptree.c 2011/06/24 19:33:41 1.98 +++ LVM2/libdm/libdm-deptree.c 2011/06/27 21:43:59 1.99 @@ -983,10 +983,9 @@ r = dm_task_run(dmt); - /* FIXME Until kernel returns actual name so dm-ioctl.c can handle it */ - if (!(udev_flags & DM_UDEV_DISABLE_LIBRARY_FALLBACK)) - rm_dev_node(name, dmt->cookie_set && - !(udev_flags & DM_UDEV_DISABLE_DM_RULES_FLAG)); + /* FIXME Until kernel returns actual name so dm-iface.c can handle it */ + rm_dev_node(name, dmt->cookie_set && !(udev_flags & DM_UDEV_DISABLE_DM_RULES_FLAG), + dmt->cookie_set && !(udev_flags & DM_UDEV_DISABLE_LIBRARY_FALLBACK)); /* FIXME Remove node from tree or mark invalid? */ --- LVM2/libdm/ioctl/libdm-iface.c 2011/06/24 19:33:41 1.107 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/06/27 21:43:59 1.108 @@ -2025,7 +2025,7 @@ struct dm_ioctl *dmi; unsigned command; int check_udev; - int udev_only; + int rely_on_udev; int suspended_counter; #ifdef DM_COMPAT @@ -2097,40 +2097,43 @@ } } + /* + * Are we expecting a udev operation to occur that we need to check for? + */ check_udev = dmt->cookie_set && !(dmt->event_nr >> DM_UDEV_FLAGS_SHIFT & DM_UDEV_DISABLE_DM_RULES_FLAG); - udev_only = dmt->cookie_set ? (dmt->event_nr >> DM_UDEV_FLAGS_SHIFT & - DM_UDEV_DISABLE_LIBRARY_FALLBACK) : 0; + rely_on_udev = dmt->cookie_set ? (dmt->event_nr >> DM_UDEV_FLAGS_SHIFT & + DM_UDEV_DISABLE_LIBRARY_FALLBACK) : 0; switch (dmt->type) { case DM_DEVICE_CREATE: if ((dmt->add_node == DM_ADD_NODE_ON_CREATE) && - dmt->dev_name && *dmt->dev_name && !udev_only) + dmt->dev_name && *dmt->dev_name && !rely_on_udev) add_dev_node(dmt->dev_name, MAJOR(dmi->dev), MINOR(dmi->dev), dmt->uid, dmt->gid, - dmt->mode, check_udev); + dmt->mode, check_udev, rely_on_udev); break; case DM_DEVICE_REMOVE: /* FIXME Kernel needs to fill in dmi->name */ - if (dmt->dev_name && !udev_only) - rm_dev_node(dmt->dev_name, check_udev); + if (dmt->dev_name && !rely_on_udev) + rm_dev_node(dmt->dev_name, check_udev, rely_on_udev); break; case DM_DEVICE_RENAME: /* FIXME Kernel needs to fill in dmi->name */ - if (!dmt->new_uuid && dmt->dev_name && !udev_only) + if (!dmt->new_uuid && dmt->dev_name) rename_dev_node(dmt->dev_name, dmt->newname, - check_udev); + check_udev, rely_on_udev); break; case DM_DEVICE_RESUME: if ((dmt->add_node == DM_ADD_NODE_ON_RESUME) && - dmt->dev_name && *dmt->dev_name && !udev_only) + dmt->dev_name && *dmt->dev_name) add_dev_node(dmt->dev_name, MAJOR(dmi->dev), MINOR(dmi->dev), dmt->uid, dmt->gid, - dmt->mode, check_udev); + dmt->mode, check_udev, rely_on_udev); /* FIXME Kernel needs to fill in dmi->name */ set_dev_node_read_ahead(dmt->dev_name, dmt->read_ahead, dmt->read_ahead_flags); @@ -2140,9 +2143,9 @@ if (dmi->flags & DM_EXISTS_FLAG) add_dev_node(dmi->name, MAJOR(dmi->dev), MINOR(dmi->dev), dmt->uid, - dmt->gid, dmt->mode, 0); + dmt->gid, dmt->mode, 0, rely_on_udev); else if (dmt->dev_name) - rm_dev_node(dmt->dev_name, 0); + rm_dev_node(dmt->dev_name, 0, rely_on_udev); break; case DM_DEVICE_STATUS: --- LVM2/man/dmsetup.8.in 2011/04/29 00:21:16 1.39 +++ LVM2/man/dmsetup.8.in 2011/06/27 21:43:59 1.40 @@ -181,6 +181,10 @@ .IP \fB-v|--verbose\ [-v|--verbose] .br Produce additional output. +.IP \fB--verifyudev +If udev synchronisation is enabled, verify that udev operations get performed +correctly and try to fix up the device nodes afterwards if not. +.br .IP \fB--version .br Display the library and kernel driver version. --- LVM2/tools/dmsetup.c 2011/06/17 14:55:51 1.161 +++ LVM2/tools/dmsetup.c 2011/06/27 21:43:59 1.162 @@ -135,7 +135,6 @@ UDEVCOOKIE_ARG, NOUDEVRULES_ARG, NOUDEVSYNC_ARG, - UDEVFALLBACK_ARG, OPTIONS_ARG, READAHEAD_ARG, ROWS_ARG, @@ -151,6 +150,7 @@ UNQUOTED_ARG, UUID_ARG, VERBOSE_ARG, + VERIFYUDEV_ARG, VERSION_ARG, YES_ARG, ADD_NODE_ON_RESUME_ARG, @@ -1007,7 +1007,7 @@ else dirs_diff = strcmp(dev_dir, udev_dev_dir); - _udev_only = !dirs_diff && (_udev_cookie || !_switches[UDEVFALLBACK_ARG]); + _udev_only = !dirs_diff && (_udev_cookie || !_switches[VERIFYUDEV_ARG]); if (dirs_diff) { log_debug("The path %s used for creating device nodes that is " @@ -2745,7 +2745,7 @@ fprintf(out, "dmsetup [--version] [-h|--help [-c|-C|--columns]]\n" " [-v|--verbose [-v|--verbose ...]]\n" " [-r|--readonly] [--noopencount] [--nolockfs] [--inactive]\n" - " [--udevcookie] [--noudevrules] [--noudevsync] [--udevfallback]\n" + " [--udevcookie] [--noudevrules] [--noudevsync] [--verifyudev]\n" " [-y|--yes] [--readahead [+]|auto|none]\n" " [-c|-C|--columns] [-o ] [-O|--sort ]\n" " [--nameprefixes] [--noheadings] [--separator ]\n\n"); @@ -3116,7 +3116,6 @@ {"udevcookie", 1, &ind, UDEVCOOKIE_ARG}, {"noudevrules", 0, &ind, NOUDEVRULES_ARG}, {"noudevsync", 0, &ind, NOUDEVSYNC_ARG}, - {"udevfallback", 0, &ind, UDEVFALLBACK_ARG}, {"options", 1, &ind, OPTIONS_ARG}, {"readahead", 1, &ind, READAHEAD_ARG}, {"rows", 0, &ind, ROWS_ARG}, @@ -3132,6 +3131,7 @@ {"unbuffered", 0, &ind, UNBUFFERED_ARG}, {"unquoted", 0, &ind, UNQUOTED_ARG}, {"verbose", 1, &ind, VERBOSE_ARG}, + {"verifyudev", 0, &ind, VERIFYUDEV_ARG}, {"version", 0, &ind, VERSION_ARG}, {"yes", 0, &ind, YES_ARG}, {"addnodeonresume", 0, &ind, ADD_NODE_ON_RESUME_ARG}, @@ -3245,8 +3245,8 @@ _switches[NOUDEVRULES_ARG]++; if (ind == NOUDEVSYNC_ARG) _switches[NOUDEVSYNC_ARG]++; - if (ind == UDEVFALLBACK_ARG) - _switches[UDEVFALLBACK_ARG]++; + if (ind == VERIFYUDEV_ARG) + _switches[VERIFYUDEV_ARG]++; if (c == 'G' || ind == GID_ARG) { _switches[GID_ARG]++; _int_args[GID_ARG] = atoi(optarg); From agk@sourceware.org Mon Jun 27 22:38:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 27 Jun 2011 22:38:00 -0000 Subject: LVM2/libdm libdm-common.c libdm-deptree.c Message-ID: <20110627223854.8636.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-27 22:38:54 Modified files: libdm : libdm-common.c libdm-deptree.c Log message: Extend debug log messages to distinguish between the 3 states: trust udev; verify udev; perform dev node operations directly. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100 --- LVM2/libdm/libdm-common.c 2011/06/27 21:43:59 1.119 +++ LVM2/libdm/libdm-common.c 2011/06/27 22:38:53 1.120 @@ -828,20 +828,24 @@ static void _log_node_op(const char *action_str, struct node_op_parms *nop) { + const char *rely = nop->rely_on_udev ? " [trust_udev]" : "" ; + const char *verify = nop->warn_if_udev_failed ? " [verify_udev]" : ""; + switch (nop->type) { case NODE_ADD: - log_debug("%s: %s NODE_ADD (%" PRIu32 ",%" PRIu32 ") %u:%u 0%o", - nop->dev_name, action_str, nop->major, nop->minor, nop->uid, nop->gid, nop->mode); + log_debug("%s: %s NODE_ADD (%" PRIu32 ",%" PRIu32 ") %u:%u 0%o%s%s", + nop->dev_name, action_str, nop->major, nop->minor, nop->uid, nop->gid, nop->mode, + rely, verify); break; case NODE_DEL: - log_debug("%s: %s NODE_DEL", nop->dev_name, action_str); + log_debug("%s: %s NODE_DEL%s%s", nop->dev_name, action_str, rely, verify); break; case NODE_RENAME: - log_debug("%s: %s NODE_RENAME to %s", nop->old_name, action_str, nop->dev_name); + log_debug("%s: %s NODE_RENAME to %s%s%s", nop->old_name, action_str, nop->dev_name, rely, verify); break; case NODE_READ_AHEAD: - log_debug("%s: %s NODE_READ_AHEAD %" PRIu32 " (flags=%" PRIu32 - ")", nop->dev_name, action_str, nop->read_ahead, nop->read_ahead_flags); + log_debug("%s: %s NODE_READ_AHEAD %" PRIu32 " (flags=%" PRIu32 ")%s%s", + nop->dev_name, action_str, nop->read_ahead, nop->read_ahead_flags, rely, verify); break; default: ; /* NOTREACHED */ @@ -860,6 +864,13 @@ char *pos; /* + * Clear warn_if_udev_failed if rely_on_udev is set. It doesn't get + * checked in this case - this just removes the flag from log messages. + */ + if (rely_on_udev) + warn_if_udev_failed = 0; + + /* * Note: warn_if_udev_failed must have valid content */ if ((type == NODE_DEL) && _other_node_ops(type)) @@ -947,7 +958,7 @@ nop->read_ahead, nop->read_ahead_flags, nop->warn_if_udev_failed); } else - _log_node_op("Skipping (udev)", nop); + _log_node_op("Skipping", nop); _del_node_op(nop); } } --- LVM2/libdm/libdm-deptree.c 2011/06/27 21:43:59 1.99 +++ LVM2/libdm/libdm-deptree.c 2011/06/27 22:38:53 1.100 @@ -985,7 +985,7 @@ /* FIXME Until kernel returns actual name so dm-iface.c can handle it */ rm_dev_node(name, dmt->cookie_set && !(udev_flags & DM_UDEV_DISABLE_DM_RULES_FLAG), - dmt->cookie_set && !(udev_flags & DM_UDEV_DISABLE_LIBRARY_FALLBACK)); + dmt->cookie_set && (udev_flags & DM_UDEV_DISABLE_LIBRARY_FALLBACK)); /* FIXME Remove node from tree or mark invalid? */ From agk@sourceware.org Mon Jun 27 23:43:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 27 Jun 2011 23:43:00 -0000 Subject: LVM2 lib/commands/toolcontext.c tools/lvmcmdline.c Message-ID: <20110627234305.26844.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-27 23:43:04 Modified files: lib/commands : toolcontext.c tools : lvmcmdline.c Log message: Move _set_lvm_fallback into toolcontext, fix string comparison (/devtest matched /dev) and note that function should go anyway as it can be overriding a valid config. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.143&r2=1.144 --- LVM2/lib/commands/toolcontext.c 2011/06/27 21:43:59 1.121 +++ LVM2/lib/commands/toolcontext.c 2011/06/27 23:43:04 1.122 @@ -200,6 +200,51 @@ reset_lvm_errno(1); } +/* + * Prevent people disabling udev fallback if using a non-standard dev dir. + * FIXME: Remove this function. lvm.conf provides sufficient control. + */ +static int _enforce_udev_fallback(struct cmd_context *cmd) +{ +#ifdef UDEV_SYNC_SUPPORT + const char *udev_dev_dir; + size_t udev_dev_dir_len; + unsigned dirs_match; + + if (!(udev_dev_dir = udev_get_dev_dir()) || + !*udev_dev_dir) { + log_error("Could not get udev dev path."); + return 0; + } + udev_dev_dir_len = strlen(udev_dev_dir); + + /* There's always a slash at the end of dev_dir. But check udev_dev_dir! */ + if (udev_dev_dir[udev_dev_dir_len - 1] != '/') + dirs_match = (udev_dev_dir_len + 1 == strlen(cmd->dev_dir)) && + !strncmp(cmd->dev_dir, udev_dev_dir, udev_dev_dir_len); + else + dirs_match = !strcmp(cmd->dev_dir, udev_dev_dir); + + if (!dirs_match) { + log_debug("The path %s used for creating device nodes and " + "symlinks that is set in the configuration differs " + "from the path %s that is used by udev. All warnings " + "about udev not working correctly while processing " + "particular nodes and symlinks will be suppressed. " + "These nodes and symlinks will be managed in each " + "directory separately.", + cmd->dev_dir, udev_dev_dir); + dm_udev_set_checking(0); + init_udev_checking(0); + + /* Device directories differ - we must use the fallback code! */ + cmd->default_settings.udev_fallback = 1; + } + +#endif + return 1; +} + static int _process_config(struct cmd_context *cmd) { mode_t old_umask; @@ -285,20 +330,23 @@ "activation/udev_sync", DEFAULT_UDEV_SYNC); - #ifdef UDEV_SYNC_SUPPORT +#ifdef UDEV_SYNC_SUPPORT /* * We need udev rules to be applied, otherwise we would end up with no * nodes and symlinks! However, we can disable the synchronization itself * in runtime and still have only udev to create the nodes and symlinks * without any fallback. */ - cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ? - find_config_tree_int(cmd, "activation/verify_udev_operations", - DEFAULT_VERIFY_UDEV_OPERATIONS) : 1; - #else + if ((cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ? + find_config_tree_int(cmd, "activation/verify_udev_operations", + DEFAULT_VERIFY_UDEV_OPERATIONS) : 1) && + !_enforce_udev_fallback(cmd)) + return_0; + +#else /* We must use old node/symlink creation code if not compiled with udev support at all! */ cmd->default_settings.udev_fallback = 1; - #endif +#endif cmd->stripe_filler = find_config_tree_str(cmd, "activation/missing_stripe_filler", --- LVM2/tools/lvmcmdline.c 2011/06/17 14:50:54 1.143 +++ LVM2/tools/lvmcmdline.c 2011/06/27 23:43:04 1.144 @@ -42,10 +42,6 @@ # define OPTIND_INIT 1 #endif -#ifdef UDEV_SYNC_SUPPORT -# include -#endif - /* * Table of valid switches */ @@ -864,8 +860,10 @@ } else init_trust_cache(0); - if (arg_count(cmd, noudevsync_ARG)) + if (arg_count(cmd, noudevsync_ARG)) { cmd->current_settings.udev_sync = 0; + cmd->current_settings.udev_fallback = 1; + } /* Handle synonyms */ if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) || @@ -952,47 +950,6 @@ cmd->handles_missing_pvs = 0; } -static int _set_udev_fallback(struct cmd_context *cmd) -{ -#ifdef UDEV_SYNC_SUPPORT - const char *udev_dev_dir; - size_t udev_dev_dir_len; - int dirs_diff; - - if (!(udev_dev_dir = udev_get_dev_dir()) || - !*udev_dev_dir) { - log_error("Could not get udev dev path."); - return 0; - } - udev_dev_dir_len = strlen(udev_dev_dir); - - /* There's always a slash at the end of dev_dir. But check udev_dev_dir! */ - if (udev_dev_dir[udev_dev_dir_len - 1] != '/') - dirs_diff = strncmp(cmd->dev_dir, udev_dev_dir, - udev_dev_dir_len); - else - dirs_diff = strcmp(cmd->dev_dir, udev_dev_dir); - - if (dirs_diff) { - log_debug("The path %s used for creating device nodes and " - "symlinks that is set in the configuration differs " - "from the path %s that is used by udev. All warnings " - "about udev not working correctly while processing " - "particular nodes and symlinks will be suppressed. " - "These nodes and symlinks will be managed in each " - "directory separately.", - cmd->dev_dir, udev_dev_dir); - dm_udev_set_checking(0); - init_udev_checking(0); - - /* Device directories differ - we must use the fallback code! */ - cmd->current_settings.udev_fallback = 1; - } - -#endif - return 1; -} - static const char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv) { int i, space; @@ -1091,9 +1048,6 @@ log_debug("O_DIRECT will be used"); #endif - if (!_set_udev_fallback(cmd)) - goto_out; - if ((ret = _process_common_commands(cmd))) { if (ret != ECMD_PROCESSED) stack; From agk@sourceware.org Tue Jun 28 00:11:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 28 Jun 2011 00:11:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110628001148.4134.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-28 00:11:46 Modified files: test/lib : aux.sh Log message: Selectively enable/disable udev rules. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.11&r2=1.12 --- LVM2/test/lib/aux.sh 2011/03/04 14:19:18 1.11 +++ LVM2/test/lib/aux.sh 2011/06/28 00:11:46 1.12 @@ -313,6 +313,11 @@ lvmconf() { if test -z "$LVM_TEST_LOCKING"; then LVM_TEST_LOCKING=1; fi + if test "$DM_DEV_DIR" = "/dev"; then + UDEV_RULES=1; + else + UDEV_RULES=0; + fi test -f CONFIG_VALUES || { cat > CONFIG_VALUES <<-EOF devices/dir = "$DM_DEV_DIR" @@ -336,7 +341,7 @@ global/si_unit_consistency = 1 global/fallback_to_local_locking = 0 activation/udev_sync = 1 -activation/udev_rules = 1 +activation/udev_rules = $UDEV_RULES activation/polling_interval = 0 activation/snapshot_autoextend_percent = 50 activation/snapshot_autoextend_threshold = 50 From agk@sourceware.org Tue Jun 28 00:23:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 28 Jun 2011 00:23:00 -0000 Subject: LVM2 ./WHATS_NEW lib/commands/toolcontext.c Message-ID: <20110628002307.9943.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-28 00:23:07 Modified files: . : WHATS_NEW lib/commands : toolcontext.c Log message: Remove enforcement of udev verification when using non-standard /dev location. If you change the dev dir, it's your responsibility to adjust udev rules or tell lvm not to use udev too. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2027&r2=1.2028 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123 --- LVM2/WHATS_NEW 2011/06/27 21:43:58 1.2027 +++ LVM2/WHATS_NEW 2011/06/28 00:23:06 1.2028 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Remove enforcement of udev verification when using non-standard /dev location. Fix to preserve exclusive activation of mirror while up-converting. Reject allocation if number of extents is not divisible by area count. Fix issue preventing cluster mirror creation. --- LVM2/lib/commands/toolcontext.c 2011/06/27 23:43:04 1.122 +++ LVM2/lib/commands/toolcontext.c 2011/06/28 00:23:06 1.123 @@ -200,51 +200,6 @@ reset_lvm_errno(1); } -/* - * Prevent people disabling udev fallback if using a non-standard dev dir. - * FIXME: Remove this function. lvm.conf provides sufficient control. - */ -static int _enforce_udev_fallback(struct cmd_context *cmd) -{ -#ifdef UDEV_SYNC_SUPPORT - const char *udev_dev_dir; - size_t udev_dev_dir_len; - unsigned dirs_match; - - if (!(udev_dev_dir = udev_get_dev_dir()) || - !*udev_dev_dir) { - log_error("Could not get udev dev path."); - return 0; - } - udev_dev_dir_len = strlen(udev_dev_dir); - - /* There's always a slash at the end of dev_dir. But check udev_dev_dir! */ - if (udev_dev_dir[udev_dev_dir_len - 1] != '/') - dirs_match = (udev_dev_dir_len + 1 == strlen(cmd->dev_dir)) && - !strncmp(cmd->dev_dir, udev_dev_dir, udev_dev_dir_len); - else - dirs_match = !strcmp(cmd->dev_dir, udev_dev_dir); - - if (!dirs_match) { - log_debug("The path %s used for creating device nodes and " - "symlinks that is set in the configuration differs " - "from the path %s that is used by udev. All warnings " - "about udev not working correctly while processing " - "particular nodes and symlinks will be suppressed. " - "These nodes and symlinks will be managed in each " - "directory separately.", - cmd->dev_dir, udev_dev_dir); - dm_udev_set_checking(0); - init_udev_checking(0); - - /* Device directories differ - we must use the fallback code! */ - cmd->default_settings.udev_fallback = 1; - } - -#endif - return 1; -} - static int _process_config(struct cmd_context *cmd) { mode_t old_umask; @@ -337,11 +292,9 @@ * in runtime and still have only udev to create the nodes and symlinks * without any fallback. */ - if ((cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ? + cmd->default_settings.udev_fallback = cmd->default_settings.udev_rules ? find_config_tree_int(cmd, "activation/verify_udev_operations", - DEFAULT_VERIFY_UDEV_OPERATIONS) : 1) && - !_enforce_udev_fallback(cmd)) - return_0; + DEFAULT_VERIFY_UDEV_OPERATIONS) : 1; #else /* We must use old node/symlink creation code if not compiled with udev support at all! */ From agk@sourceware.org Tue Jun 28 00:38:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 28 Jun 2011 00:38:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110628003827.4608.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-28 00:38:26 Modified files: test/lib : aux.sh Log message: Change to still sync with udev (to test waiting for rules) then to verify udev operations like it used to (which will perform them on systems with non-std dev dirs where test udev rules aren't installed). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.12&r2=1.13 --- LVM2/test/lib/aux.sh 2011/06/28 00:11:46 1.12 +++ LVM2/test/lib/aux.sh 2011/06/28 00:38:26 1.13 @@ -314,9 +314,9 @@ lvmconf() { if test -z "$LVM_TEST_LOCKING"; then LVM_TEST_LOCKING=1; fi if test "$DM_DEV_DIR" = "/dev"; then - UDEV_RULES=1; + VERIFY_UDEV=0; else - UDEV_RULES=0; + VERIFY_UDEV=1; fi test -f CONFIG_VALUES || { cat > CONFIG_VALUES <<-EOF @@ -341,7 +341,8 @@ global/si_unit_consistency = 1 global/fallback_to_local_locking = 0 activation/udev_sync = 1 -activation/udev_rules = $UDEV_RULES +activation/udev_rules = 1 +activation/verify_udev_operations = $VERIFY_UDEV activation/polling_interval = 0 activation/snapshot_autoextend_percent = 50 activation/snapshot_autoextend_threshold = 50 From agk@sourceware.org Tue Jun 28 09:24:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 28 Jun 2011 09:24:00 -0000 Subject: LVM2/libdm libdm-common.c Message-ID: <20110628092414.16758.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-28 09:24:14 Modified files: libdm : libdm-common.c Log message: more fixes to readahead etc. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121 --- LVM2/libdm/libdm-common.c 2011/06/27 22:38:53 1.120 +++ LVM2/libdm/libdm-common.c 2011/06/28 09:24:13 1.121 @@ -864,13 +864,6 @@ char *pos; /* - * Clear warn_if_udev_failed if rely_on_udev is set. It doesn't get - * checked in this case - this just removes the flag from log messages. - */ - if (rely_on_udev) - warn_if_udev_failed = 0; - - /* * Note: warn_if_udev_failed must have valid content */ if ((type == NODE_DEL) && _other_node_ops(type)) @@ -911,10 +904,16 @@ */ dm_list_iterate_safe(noph, nopht, &_node_ops) { nop = dm_list_item(noph, struct node_op_parms); - if (!strcmp(old_name, nop->dev_name)) + if (!strcmp(old_name, nop->dev_name)) { _log_node_op("Unstacking", nop); _del_node_op(nop); + } } + else if (type == NODE_READ_AHEAD) { + /* udev doesn't process readahead */ + rely_on_udev = 0; + warn_if_udev_failed = 0; + } if (!(nop = dm_malloc(sizeof(*nop) + len))) { log_error("Insufficient memory to stack mknod operation"); @@ -930,9 +929,14 @@ nop->mode = mode; nop->read_ahead = read_ahead; nop->read_ahead_flags = read_ahead_flags; - nop->warn_if_udev_failed = warn_if_udev_failed; nop->rely_on_udev = rely_on_udev; + /* + * Clear warn_if_udev_failed if rely_on_udev is set. It doesn't get + * checked in this case - this just removes the flag from log messages. + */ + nop->warn_if_udev_failed = rely_on_udev ? 0 : warn_if_udev_failed; + _store_str(&pos, &nop->dev_name, dev_name); _store_str(&pos, &nop->old_name, old_name); From agk@sourceware.org Tue Jun 28 09:43:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 28 Jun 2011 09:43:00 -0000 Subject: LVM2/test t-lvcreate-usage.sh Message-ID: <20110628094328.14597.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-28 09:43:28 Modified files: test : t-lvcreate-usage.sh Log message: More readahead tests. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-usage.sh.diff?cvsroot=lvm2&r1=1.19&r2=1.20 --- LVM2/test/t-lvcreate-usage.sh 2011/01/05 00:16:20 1.19 +++ LVM2/test/t-lvcreate-usage.sh 2011/06/28 09:43:28 1.20 @@ -131,11 +131,22 @@ lvremove -ff $vg lvcreate -L 32m -n $lv --readahead none $vg check lv_field $vg/$lv lv_read_ahead "0" +check lv_field $vg/$lv lv_kernel_read_ahead "0" lvremove -ff $vg lvcreate -L 32m -n $lv --readahead 8k $vg check lv_field $vg/$lv lv_read_ahead "8.00k" +check lv_field $vg/$lv lv_kernel_read_ahead "8.00k" lvremove -ff $vg lvcreate -L 32m -n $lv --readahead auto $vg check lv_field $vg/$lv lv_read_ahead "auto" +check lv_field $vg/$lv lv_kernel_read_ahead "128.00k" +lvremove -ff $vg +lvcreate -L 32m -n $lv -i2 --stripesize 16k --readahead auto $vg +check lv_field $vg/$lv lv_read_ahead "auto" +check lv_field $vg/$lv lv_kernel_read_ahead "128.00k" +lvremove -ff $vg +lvcreate -L 32m -n $lv -i2 --stripesize 128k --readahead auto $vg +check lv_field $vg/$lv lv_read_ahead "auto" +check lv_field $vg/$lv lv_kernel_read_ahead "512.00k" lvremove -ff $vg From zkabelac@sourceware.org Tue Jun 28 13:42:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 28 Jun 2011 13:42:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c Message-ID: <20110628134216.15351.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-28 13:42:15 Modified files: . : WHATS_NEW daemons/clvmd : clvmd.c Log message: Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2028&r2=1.2029 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105 --- LVM2/WHATS_NEW 2011/06/28 00:23:06 1.2028 +++ LVM2/WHATS_NEW 2011/06/28 13:42:15 1.2029 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd. Remove enforcement of udev verification when using non-standard /dev location. Fix to preserve exclusive activation of mirror while up-converting. Reject allocation if number of extents is not divisible by area count. --- LVM2/daemons/clvmd/clvmd.c 2011/04/08 14:40:18 1.104 +++ LVM2/daemons/clvmd/clvmd.c 2011/06/28 13:42:15 1.105 @@ -295,6 +295,9 @@ case CLVMD_CMD_RESTART: command = "RESTART"; break; + case CLVMD_CMD_SYNC_NAMES: + command = "SYNC_NAMES"; + break; default: command = "unknown"; break; From jbrassow@sourceware.org Tue Jun 28 21:28:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Tue, 28 Jun 2011 21:28:00 -0000 Subject: LVM2/tools lvconvert.c Message-ID: <20110628212835.24252.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-06-28 21:28:35 Modified files: tools : lvconvert.c Log message: Remove unnecesary conditional. The conditional is not just unnecessary, it would have been wrong. The code is suppose to be checking if the 'splitmirrors_ARG' is negative, but it instead is checking 'mirrors_ARG'. Rather than changing the argument being checked, I've pulled the check entirely because 'splitmirrors_ARG' is already guarenteed to not be negative by virtue of the fact that it is a 'int_arg'. Negative values will be caught in _process_command_line(). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.163&r2=1.164 --- LVM2/tools/lvconvert.c 2011/06/01 12:24:16 1.163 +++ LVM2/tools/lvconvert.c 2011/06/28 21:28:35 1.164 @@ -169,11 +169,6 @@ return_0; lp->keep_mimages = 1; - if (arg_sign_value(cmd, mirrors_ARG, 0) == SIGN_MINUS) { - log_error("Argument to --splitmirrors" - " cannot be negative"); - return 0; - } lp->mirrors = arg_uint_value(cmd, splitmirrors_ARG, 0); lp->mirrors_sign = SIGN_MINUS; } else if (arg_count(cmd, name_ARG)) { From jbrassow@sourceware.org Wed Jun 29 02:06:00 2011 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Wed, 29 Jun 2011 02:06:00 -0000 Subject: LVM2/tools lvconvert.c Message-ID: <20110629020627.26929.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2011-06-29 02:06:26 Modified files: tools : lvconvert.c Log message: Fix error message - the parameter name is '--mirrorlog' not '--log' Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165 --- LVM2/tools/lvconvert.c 2011/06/28 21:28:35 1.164 +++ LVM2/tools/lvconvert.c 2011/06/29 02:06:26 1.165 @@ -131,7 +131,7 @@ (arg_count(cmd, mirrorlog_ARG) || arg_count(cmd, mirrors_ARG) || arg_count(cmd, repair_ARG))) { log_error("--snapshot or --merge argument cannot be mixed " - "with --mirrors, --repair or --log"); + "with --mirrors, --repair or --mirrorlog"); return 0; } From agk@sourceware.org Wed Jun 29 08:54:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 08:54:00 -0000 Subject: LVM2/libdm/ioctl libdm-iface.c Message-ID: <20110629085414.6309.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 08:54:14 Modified files: libdm/ioctl : libdm-iface.c Log message: Temporary conversion to internal error and failure, to see how many instances of this problem this flushes out. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.108&r2=1.109 --- LVM2/libdm/ioctl/libdm-iface.c 2011/06/27 21:43:59 1.108 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/06/29 08:54:13 1.109 @@ -2059,8 +2059,8 @@ } if ((suspended_counter = dm_get_suspended_counter()) && - dmt->type == DM_DEVICE_RELOAD) - log_error("Performing unsafe table load while %d device(s) " + dmt->type == DM_DEVICE_RELOAD) { + log_error(INTERNAL_ERROR "Performing unsafe table load while %d device(s) " "are known to be suspended: " "%s%s%s %s%.0d%s%.0d%s%s", suspended_counter, @@ -2073,6 +2073,8 @@ dmt->minor > 0 ? dmt->minor : 0, dmt->major > 0 && dmt->minor == 0 ? "0" : "", dmt->major > 0 ? ") " : ""); + return 0; + } /* FIXME Detect and warn if cookie set but should not be. */ repeat_ioctl: From agk@sourceware.org Wed Jun 29 11:36:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 11:36:00 -0000 Subject: LVM2/libdm/ioctl libdm-iface.c Message-ID: <20110629113638.31579.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 11:36:37 Modified files: libdm/ioctl : libdm-iface.c Log message: Remove temporary failures now, but continue to give INTERNAL_ERROR. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110 --- LVM2/libdm/ioctl/libdm-iface.c 2011/06/29 08:54:13 1.109 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/06/29 11:36:37 1.110 @@ -2059,7 +2059,7 @@ } if ((suspended_counter = dm_get_suspended_counter()) && - dmt->type == DM_DEVICE_RELOAD) { + dmt->type == DM_DEVICE_RELOAD) log_error(INTERNAL_ERROR "Performing unsafe table load while %d device(s) " "are known to be suspended: " "%s%s%s %s%.0d%s%.0d%s%s", @@ -2073,8 +2073,6 @@ dmt->minor > 0 ? dmt->minor : 0, dmt->major > 0 && dmt->minor == 0 ? "0" : "", dmt->major > 0 ? ") " : ""); - return 0; - } /* FIXME Detect and warn if cookie set but should not be. */ repeat_ioctl: From agk@sourceware.org Wed Jun 29 12:33:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 12:33:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110629123319.25785.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 12:33:19 Modified files: test/lib : aux.sh Log message: use dmsetup remove -f as a better way of simulating a device "disappearing" Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.13&r2=1.14 --- LVM2/test/lib/aux.sh 2011/06/28 00:38:26 1.13 +++ LVM2/test/lib/aux.sh 2011/06/29 12:33:18 1.14 @@ -260,11 +260,7 @@ init_udev_transaction for dev in "$@"; do - # first we make the device inaccessible - echo 0 10000000 error | dmsetup load $dev - dmsetup resume $dev - # now let's try to get rid of it if it's unused - #dmsetup remove $dev + dmsetup remove -f $dev done finish_udev_transaction From agk@sourceware.org Wed Jun 29 12:37:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 12:37:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110629123751.16458.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 12:37:51 Modified files: test/lib : aux.sh Log message: Add uuids to dmsetup create cmds. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.14&r2=1.15 --- LVM2/test/lib/aux.sh 2011/06/29 12:33:18 1.14 +++ LVM2/test/lib/aux.sh 2011/06/29 12:37:51 1.15 @@ -116,7 +116,7 @@ } make_ioerror() { - echo 0 10000000 error | dmsetup create ioerror + echo 0 10000000 error | dmsetup create -u TEST-ioerror ioerror ln -s $DM_DEV_DIR/mapper/ioerror $DM_DEV_DIR/ioerror } @@ -239,7 +239,7 @@ local dev="$DM_DEV_DIR/mapper/$name" devs="$devs $dev" echo 0 $size linear $LOOP $((($i-1)*$size)) > $name.table - dmsetup create $name $name.table + dmsetup create -u TEST-$name $name $name.table done finish_udev_transaction @@ -271,7 +271,7 @@ init_udev_transaction for dev in "$@"; do local name=`echo "$dev" | sed -e 's,.*/,,'` - dmsetup create $name $name.table || dmsetup load $name $name.table + dmsetup create -u TEST-$name $name $name.table || dmsetup load $name $name.table dmsetup resume $dev done finish_udev_transaction From agk@sourceware.org Wed Jun 29 14:56:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 14:56:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/pv.c man/pvs.8.in Message-ID: <20110629145634.14337.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 14:56:33 Modified files: . : WHATS_NEW lib/metadata : pv.c man : pvs.8.in Log message: Append 'm' attribute to pv_attr for missing PVs. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2029&r2=1.2030 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/pv.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/pvs.8.in.diff?cvsroot=lvm2&r1=1.13&r2=1.14 --- LVM2/WHATS_NEW 2011/06/28 13:42:15 1.2029 +++ LVM2/WHATS_NEW 2011/06/29 14:56:33 1.2030 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Append 'm' attribute to pv_attr for missing PVs. Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd. Remove enforcement of udev verification when using non-standard /dev location. Fix to preserve exclusive activation of mirror while up-converting. --- LVM2/lib/metadata/pv.c 2011/02/21 12:33:16 1.9 +++ LVM2/lib/metadata/pv.c 2011/06/29 14:56:33 1.10 @@ -197,6 +197,7 @@ repstr[0] = (pv->status & ALLOCATABLE_PV) ? 'a' : '-'; repstr[1] = (pv->status & EXPORTED_VG) ? 'x' : '-'; + repstr[2] = (pv->status & MISSING_PV) ? 'm' : '-'; return repstr; } --- LVM2/man/pvs.8.in 2010/06/28 20:34:12 1.13 +++ LVM2/man/pvs.8.in 2011/06/29 14:56:33 1.14 @@ -59,7 +59,7 @@ .IP With --segments, any "pvseg_" prefixes are optional; otherwise any "pv_" prefixes are optional. Columns mentioned in \fBvgs (8)\fP can also -be chosen. The pv_attr bits are: (a)llocatable and e(x)ported. +be chosen. The pv_attr bits are: (a)llocatable, e(x)ported and (m)issing. .TP .I \-\-segments Produces one line of output for each contiguous allocation of space on each From agk@sourceware.org Wed Jun 29 16:08:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 16:08:00 -0000 Subject: LVM2/libdm/ioctl libdm-iface.c Message-ID: <20110629160834.4818.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 16:08:33 Modified files: libdm/ioctl : libdm-iface.c Log message: debug log readonly flag with ioctls Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111 --- LVM2/libdm/ioctl/libdm-iface.c 2011/06/29 11:36:37 1.110 +++ LVM2/libdm/ioctl/libdm-iface.c 2011/06/29 16:08:33 1.111 @@ -1963,7 +1963,7 @@ } log_debug("dm %s %s%s %s%s%s %s%.0d%s%.0d%s" - "%s%c%c%s%s%s %.0" PRIu64 " %s [%u]", + "%s%c%c%s%s%s%s %.0" PRIu64 " %s [%u]", _cmd_data_v4[dmt->type].name, dmt->new_uuid ? "UUID " : "", dmi->name, dmi->uuid, dmt->newname ? " " : "", @@ -1976,6 +1976,7 @@ dmt->major > 0 ? ") " : "", dmt->no_open_count ? 'N' : 'O', dmt->no_flush ? 'N' : 'F', + dmt->read_only ? "R" : "", dmt->skip_lockfs ? "S " : "", dmt->secure_data ? "W " : "", dmt->query_inactive_table ? "I " : "", From agk@sourceware.org Wed Jun 29 17:05:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 17:05:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c Message-ID: <20110629170554.23557.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 17:05:53 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c Log message: Reinstate correct permissions when creating mirrors. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2030&r2=1.2031 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.264&r2=1.265 --- LVM2/WHATS_NEW 2011/06/29 14:56:33 1.2030 +++ LVM2/WHATS_NEW 2011/06/29 17:05:53 1.2031 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Reinstate correct permissions when creating mirrors. [2.02.85] Append 'm' attribute to pv_attr for missing PVs. Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd. Remove enforcement of udev verification when using non-standard /dev location. --- LVM2/lib/metadata/lv_manip.c 2011/06/23 14:00:58 1.264 +++ LVM2/lib/metadata/lv_manip.c 2011/06/29 17:05:53 1.265 @@ -2157,7 +2157,8 @@ for (i = 0; i < devices; i++) { sub_lv = lv_create_empty(img_name, NULL, - MIRROR_IMAGE, lv->alloc, lv->vg); + LVM_READ | LVM_WRITE | MIRROR_IMAGE, + lv->alloc, lv->vg); if (!sub_lv) return_0; if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, status)) From agk@sourceware.org Wed Jun 29 17:33:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 17:33:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110629173340.13063.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 17:33:40 Modified files: test/lib : aux.sh Log message: remove any stray semaphores after tearing down devs Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.15&r2=1.16 --- LVM2/test/lib/aux.sh 2011/06/29 12:37:51 1.15 +++ LVM2/test/lib/aux.sh 2011/06/29 17:33:39 1.16 @@ -86,6 +86,9 @@ fi rm -f DEVICES # devs is set in prepare_devs() rm -f LOOP + + # Delete any remaining dm/udev semaphores + dmsetup udevcomplete_all -y } teardown() { From agk@sourceware.org Wed Jun 29 17:37:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 17:37:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110629173732.16767.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 17:37:30 Modified files: test/lib : aux.sh Log message: print any loop devs that weren't torn down Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/test/lib/aux.sh 2011/06/29 17:33:39 1.16 +++ LVM2/test/lib/aux.sh 2011/06/29 17:37:30 1.17 @@ -89,6 +89,9 @@ # Delete any remaining dm/udev semaphores dmsetup udevcomplete_all -y + + # Display any loop devices that failed to get torn down + losetup -a } teardown() { From agk@sourceware.org Wed Jun 29 18:14:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 18:14:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110629181408.31490.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 18:14:08 Modified files: test/lib : aux.sh Log message: teardown aborts if it hits an error, so better teardown semaphores earlier as we need them later in the teardown process Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.17&r2=1.18 --- LVM2/test/lib/aux.sh 2011/06/29 17:37:30 1.17 +++ LVM2/test/lib/aux.sh 2011/06/29 18:14:08 1.18 @@ -61,6 +61,9 @@ } teardown_devs() { + # Delete any remaining dm/udev semaphores + dmsetup udevcomplete_all -y + test -n "$PREFIX" && { rm -rf $TESTDIR/dev/$PREFIX* @@ -87,9 +90,6 @@ rm -f DEVICES # devs is set in prepare_devs() rm -f LOOP - # Delete any remaining dm/udev semaphores - dmsetup udevcomplete_all -y - # Display any loop devices that failed to get torn down losetup -a } From agk@sourceware.org Wed Jun 29 18:18:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 18:18:00 -0000 Subject: LVM2/test/lib aux.sh utils.sh Message-ID: <20110629181820.775.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 18:18:19 Modified files: test/lib : aux.sh utils.sh Log message: make udev teardown conditional on using udev Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.18&r2=1.19 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/utils.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/test/lib/aux.sh 2011/06/29 18:14:08 1.18 +++ LVM2/test/lib/aux.sh 2011/06/29 18:18:18 1.19 @@ -62,7 +62,7 @@ teardown_devs() { # Delete any remaining dm/udev semaphores - dmsetup udevcomplete_all -y + teardown_udev_cookies test -n "$PREFIX" && { rm -rf $TESTDIR/dev/$PREFIX* --- LVM2/test/lib/utils.sh 2011/06/09 19:48:26 1.6 +++ LVM2/test/lib/utils.sh 2011/06/29 18:18:18 1.7 @@ -147,6 +147,12 @@ fi } +teardown_udev_cookies() { + if test "$DM_UDEV_SYNCHRONISATION" = 1; then + dmsetup udevcomplete_all -y + fi +} + skip() { touch SKIP_THIS_TEST exit 200 From agk@sourceware.org Wed Jun 29 21:56:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 29 Jun 2011 21:56:00 -0000 Subject: LVM2 ./WHATS_NEW_DM man/dmsetup.8.in test/lib/ ... Message-ID: <20110629215647.3712.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-29 21:56:46 Modified files: . : WHATS_NEW_DM man : dmsetup.8.in test/lib : utils.sh tools : dmsetup.c Log message: Add age filter to dmsetup udevcomplete_all to minimise concurrency problems. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.475&r2=1.476 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/dmsetup.8.in.diff?cvsroot=lvm2&r1=1.40&r2=1.41 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/utils.sh.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.162&r2=1.163 --- LVM2/WHATS_NEW_DM 2011/06/27 21:43:58 1.475 +++ LVM2/WHATS_NEW_DM 2011/06/29 21:56:46 1.476 @@ -1,5 +1,6 @@ Version 1.02.65 - ================================== + Add age_in_minutes parameter to dmsetup udevcomplete_all. Return immediately from dm_lib_exit() if called more than once. Disable udev fallback by default and add --verifyudev option to dmsetup. Warn if a table is loaded while a device is known to be in suspended state. --- LVM2/man/dmsetup.8.in 2011/06/27 21:43:59 1.40 +++ LVM2/man/dmsetup.8.in 2011/06/29 21:56:46 1.41 @@ -80,6 +80,7 @@ .I cookie .br .B dmsetup udevcomplete_all +.I [age_in_minutes] .br .B dmsetup udevcookies .br @@ -389,8 +390,10 @@ .br Wake any processes that are waiting for udev to complete processing the specified cookie. .br -.IP \fBudevcomplete_all -Remove all cookies. Any process waiting on a cookie will be resumed immediately. +.IP \fBudevcomplete_all +.I[age_in_minutes] +Remove all cookies older than the specified number of minutes. +Any process waiting on a cookie will be resumed immediately. .br .IP \fBudevcookies List all existing cookies. Cookies are system-wide semaphores with keys --- LVM2/test/lib/utils.sh 2011/06/29 18:18:18 1.7 +++ LVM2/test/lib/utils.sh 2011/06/29 21:56:46 1.8 @@ -149,7 +149,9 @@ teardown_udev_cookies() { if test "$DM_UDEV_SYNCHRONISATION" = 1; then - dmsetup udevcomplete_all -y + # Delete any cookies created more than 10 minutes ago + # and not used in the last 10 minutes. + dmsetup udevcomplete_all -y 10 fi } --- LVM2/tools/dmsetup.c 2011/06/27 21:43:59 1.162 +++ LVM2/tools/dmsetup.c 2011/06/29 21:56:46 1.163 @@ -1085,10 +1085,19 @@ struct seminfo sinfo; struct semid_ds sdata; int counter = 0; + int skipped = 0; + unsigned age = 0; + time_t t; + + if (argc == 2 && (sscanf(argv[1], "%i", &age) != 1)) { + log_error("Failed to read age_in_minutes parameter."); + return 0; + } if (!_switches[YES_ARG]) { - log_warn("This operation will destroy all semaphores with keys " + log_warn("This operation will destroy all semaphores %s%.0d%swith keys " "that have a prefix %" PRIu16 " (0x%" PRIx16 ").", + age ? "older than " : "", age, age ? " minutes " : "", DM_COOKIE_MAGIC, DM_COOKIE_MAGIC); if (_yes_no_prompt("Do you really want to continue? [y/n]: ") == 'n') { @@ -1109,6 +1118,13 @@ continue; if (sdata.sem_perm.__key >> 16 == DM_COOKIE_MAGIC) { + t = time(NULL); + + if (sdata.sem_ctime + age * 60 > t || + sdata.sem_otime + age * 60 > t) { + skipped++; + continue; + } if (semctl(sid, 0, IPC_RMID, 0) < 0) { log_error("Could not cleanup notification semaphore " "with semid %d and cookie value " @@ -1122,8 +1138,8 @@ } log_print("%d semaphores with keys prefixed by " - "%" PRIu16 " (0x%" PRIx16 ") destroyed.", - counter, DM_COOKIE_MAGIC, DM_COOKIE_MAGIC); + "%" PRIu16 " (0x%" PRIx16 ") destroyed. %d skipped.", + counter, DM_COOKIE_MAGIC, DM_COOKIE_MAGIC, skipped); return 1; } @@ -1134,14 +1150,15 @@ struct seminfo sinfo; struct semid_ds sdata; int val; - char *time_str; + char otime_str[26], ctime_str[26]; + char *otimes, *ctimes; if ((max_id = semctl(0, 0, SEM_INFO, &sinfo)) < 0) { log_sys_error("sem_ctl", "SEM_INFO"); return 0; } - printf("cookie semid value last_semop_time\n"); + printf("Cookie Semid Value Last semop time Last change time\n"); for (id = 0; id <= max_id; id++) { if ((sid = semctl(id, 0, SEM_STAT, &sdata)) < 0) @@ -1156,10 +1173,14 @@ continue; } - time_str = ctime((const time_t *) &sdata.sem_otime); - - printf("0x%-10x %-10d %-10d %s", sdata.sem_perm.__key, - sid, val, time_str ? time_str : "unknown\n"); + if ((otimes = ctime_r((const time_t *) &sdata.sem_otime, (char *)&otime_str))) + otime_str[strlen(otimes)-1] = '\0'; + if ((ctimes = ctime_r((const time_t *) &sdata.sem_ctime, (char *)&ctime_str))) + ctime_str[strlen(ctimes)-1] = '\0'; + + printf("0x%-10x %-10d %-10d %s %s\n", sdata.sem_perm.__key, + sid, val, otimes ? : "unknown", + ctimes? : "unknown"); } } @@ -2728,7 +2749,7 @@ {"udevreleasecookie", "[]", 0, 1, 0, _udevreleasecookie}, {"udevflags", "", 1, 1, 0, _udevflags}, {"udevcomplete", "", 1, 1, 0, _udevcomplete}, - {"udevcomplete_all", "", 0, 0, 0, _udevcomplete_all}, + {"udevcomplete_all", "", 0, 1, 0, _udevcomplete_all}, {"udevcookies", "", 0, 0, 0, _udevcookies}, {"targets", "", 0, 0, 0, _targets}, {"version", "", 0, 0, 0, _version}, @@ -2745,7 +2766,7 @@ fprintf(out, "dmsetup [--version] [-h|--help [-c|-C|--columns]]\n" " [-v|--verbose [-v|--verbose ...]]\n" " [-r|--readonly] [--noopencount] [--nolockfs] [--inactive]\n" - " [--udevcookie] [--noudevrules] [--noudevsync] [--verifyudev]\n" + " [--udevcookie [cookie]] [--noudevrules] [--noudevsync] [--verifyudev]\n" " [-y|--yes] [--readahead [+]|auto|none]\n" " [-c|-C|--columns] [-o ] [-O|--sort ]\n" " [--nameprefixes] [--noheadings] [--separator ]\n\n"); From mornfall@sourceware.org Wed Jun 29 22:20:00 2011 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 29 Jun 2011 22:20:00 -0000 Subject: LVM2/daemons/common daemon-client.c daemon-ser ... Message-ID: <20110629222017.14836.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2011-06-29 22:20:14 Modified files: daemons/common : daemon-client.c daemon-server.c daemon-shared.c daemon-shared.h Log message: Differentiate the request and response format, in daemon/common. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.h.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/daemons/common/daemon-client.c 2011/06/27 13:58:11 1.4 +++ LVM2/daemons/common/daemon-client.c 2011/06/29 22:20:14 1.5 @@ -60,7 +60,7 @@ { va_list ap; va_start(ap, id); - daemon_request rq = { .buffer = format_buffer(id, ap) }; + daemon_request rq = { .buffer = format_buffer("request", id, ap) }; if (!rq.buffer) { daemon_reply err = { .error = ENOMEM, .buffer = NULL, .cft = NULL }; --- LVM2/daemons/common/daemon-server.c 2011/06/27 13:58:11 1.6 +++ LVM2/daemons/common/daemon-server.c 2011/06/29 22:20:14 1.7 @@ -205,7 +205,7 @@ { va_list ap; va_start(ap, id); - response res = { .buffer = format_buffer(id, ap), .cft = NULL }; + response res = { .buffer = format_buffer("response", id, ap), .cft = NULL }; if (!res.buffer) res.error = ENOMEM; --- LVM2/daemons/common/daemon-shared.c 2011/06/27 13:15:49 1.2 +++ LVM2/daemons/common/daemon-shared.c 2011/06/29 22:20:14 1.3 @@ -70,13 +70,13 @@ return 0; } -char *format_buffer(char *id, va_list ap) +char *format_buffer(const char *what, const char *id, va_list ap) { char *buffer, *old; char *next; char *format; - dm_asprintf(&buffer, "request = \"%s\"\n", id); + dm_asprintf(&buffer, "%s = \"%s\"\n", what, id); if (!buffer) goto fail; while (next = va_arg(ap, char *)) { --- LVM2/daemons/common/daemon-shared.h 2011/06/27 13:15:49 1.2 +++ LVM2/daemons/common/daemon-shared.h 2011/06/29 22:20:14 1.3 @@ -3,4 +3,4 @@ int read_buffer(int fd, char **buffer); int write_buffer(int fd, char *buffer, int length); -char *format_buffer(char *id, va_list ap); +char *format_buffer(const char *what, const char *id, va_list ap); From agk@sourceware.org Thu Jun 30 00:57:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 30 Jun 2011 00:57:00 -0000 Subject: LVM2/test/lib aux.sh test.sh Message-ID: <20110630005729.21546.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-30 00:57:29 Modified files: test/lib : aux.sh test.sh Log message: test attempt to remove stray loop devs Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.19&r2=1.20 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/test.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/test/lib/aux.sh 2011/06/29 18:18:18 1.19 +++ LVM2/test/lib/aux.sh 2011/06/30 00:57:29 1.20 @@ -90,7 +90,9 @@ rm -f DEVICES # devs is set in prepare_devs() rm -f LOOP - # Display any loop devices that failed to get torn down + # Remove any loop devices that failed to get torn down + losetup -a + echo losetup -d `losetup -a | grep $COMMON_PREFIX | cut -d: -f1` 2>/dev/null || true losetup -a } --- LVM2/test/lib/test.sh 2011/02/09 17:57:14 1.3 +++ LVM2/test/lib/test.sh 2011/06/30 00:57:29 1.4 @@ -19,11 +19,13 @@ . lib/utils OLDPWD="`pwd`" -PREFIX="LVMTEST$$" +COMMON_PREFIX="LVMTEST" +PREFIX="${COMMON_PREFIX}$$" TESTDIR=$(mkdtemp ${LVM_TEST_DIR-$(pwd)} $PREFIX.XXXXXXXXXX) \ || { echo "failed to create temporary directory in ${LVM_TEST_DIR-$(pwd)}"; exit 1; } +export COMMON_PREFIX export PREFIX export TESTDIR From agk@sourceware.org Thu Jun 30 01:17:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 30 Jun 2011 01:17:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110630011738.29368.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-30 01:17:38 Modified files: test/lib : aux.sh Log message: Try to remove any stray loop devices left behind by earlier aborted tests. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.20&r2=1.21 --- LVM2/test/lib/aux.sh 2011/06/30 00:57:29 1.20 +++ LVM2/test/lib/aux.sh 2011/06/30 01:17:37 1.21 @@ -90,10 +90,13 @@ rm -f DEVICES # devs is set in prepare_devs() rm -f LOOP - # Remove any loop devices that failed to get torn down - losetup -a - echo losetup -d `losetup -a | grep $COMMON_PREFIX | cut -d: -f1` 2>/dev/null || true - losetup -a + # Remove any loop devices that failed to get torn down if earlier tests aborted + STRAY_LOOPS=`losetup -a | grep $COMMON_PREFIX | cut -d: -f1` + if test -n "$STRAY_LOOPS"; then + echo "Removing stray loop devices containing $COMMON_PREFIX:" + losetup -a | grep $COMMON_PREFIX + losetup -d $STRAY_LOOPS 2>/dev/null || true + fi } teardown() { From mbroz@sourceware.org Thu Jun 30 08:50:00 2011 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 30 Jun 2011 08:50:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110630085011.8187.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2011-06-30 08:50:10 Modified files: test/lib : aux.sh Log message: Try to force remove dm devices in after test fails. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.21&r2=1.22 --- LVM2/test/lib/aux.sh 2011/06/30 01:17:37 1.21 +++ LVM2/test/lib/aux.sh 2011/06/30 08:50:10 1.22 @@ -90,6 +90,27 @@ rm -f DEVICES # devs is set in prepare_devs() rm -f LOOP + # Try to remove test devices + # resume any linears to be sure we do not deadlock + STRAY_DEVS=$(dmsetup table | grep linear | sed 's/:.*//' | grep $COMMON_PREFIX | cut -d' ' -f 1) + for dm in $STRAY_DEVS ; do + # FIXME: only those really suspended + dmsetup resume $dm 2>/dev/null + done + + # Now try to remove devices + finish=0 + while [ $finish -eq 0 ] ; do + finish=1 + STRAY_DEVS=$(dmsetup table | sed 's/:.*//' | grep $COMMON_PREFIX | cut -d' ' -f 1) + for dm in $STRAY_DEVS ; do + echo "Trying to remove stalled $dm" + dmsetup remove $dm 2>/dev/null + # Sucessful remove means repeat the loop once more + [ $? -eq 0 ] && finish=0 + done + done + # Remove any loop devices that failed to get torn down if earlier tests aborted STRAY_LOOPS=`losetup -a | grep $COMMON_PREFIX | cut -d: -f1` if test -n "$STRAY_LOOPS"; then From zkabelac@sourceware.org Thu Jun 30 09:08:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 30 Jun 2011 09:08:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110630090823.17427.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-30 09:08:22 Modified files: test/lib : aux.sh Log message: Use -f to remove device Since some test may leave devices in suspend mode which would require carefull order of resume operation - use '-f' to replace them with error targets For disable_dev - when 'error' target is used for open count - treat return code as ok (|| true) to avoid breaking futher test processing. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.22&r2=1.23 --- LVM2/test/lib/aux.sh 2011/06/30 08:50:10 1.22 +++ LVM2/test/lib/aux.sh 2011/06/30 09:08:22 1.23 @@ -71,7 +71,7 @@ while dmsetup table | grep -q ^$PREFIX; do for s in `dmsetup info -c -o name --noheading | grep ^$PREFIX`; do umount -fl $DM_DEV_DIR/mapper/$s >& /dev/null || true - dmsetup remove $s >& /dev/null || true + dmsetup remove -f $s >& /dev/null || true done done finish_udev_transaction @@ -292,7 +292,7 @@ init_udev_transaction for dev in "$@"; do - dmsetup remove -f $dev + dmsetup remove -f $dev || true done finish_udev_transaction From agk@sourceware.org Thu Jun 30 09:15:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 30 Jun 2011 09:15:00 -0000 Subject: LVM2 ./WHATS_NEW test/lib/aux.sh Message-ID: <20110630091553.19618.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-30 09:15:53 Modified files: . : WHATS_NEW test/lib : aux.sh Log message: teardown stray filesystems too Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2031&r2=1.2032 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.23&r2=1.24 --- LVM2/WHATS_NEW 2011/06/29 17:05:53 1.2031 +++ LVM2/WHATS_NEW 2011/06/30 09:15:53 1.2032 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Teardown any stray devices with $COMMON_PREFIX during test runs. Reinstate correct permissions when creating mirrors. [2.02.85] Append 'm' attribute to pv_attr for missing PVs. Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd. --- LVM2/test/lib/aux.sh 2011/06/30 09:08:22 1.23 +++ LVM2/test/lib/aux.sh 2011/06/30 09:15:53 1.24 @@ -90,34 +90,47 @@ rm -f DEVICES # devs is set in prepare_devs() rm -f LOOP - # Try to remove test devices - # resume any linears to be sure we do not deadlock - STRAY_DEVS=$(dmsetup table | grep linear | sed 's/:.*//' | grep $COMMON_PREFIX | cut -d' ' -f 1) - for dm in $STRAY_DEVS ; do - # FIXME: only those really suspended - dmsetup resume $dm 2>/dev/null - done - - # Now try to remove devices - finish=0 - while [ $finish -eq 0 ] ; do - finish=1 + # Attempt to remove any loop devices that failed to get torn down if earlier tests aborted + test -n "$COMMON_PREFIX" && { + # Resume any linears to be sure we do not deadlock STRAY_DEVS=$(dmsetup table | sed 's/:.*//' | grep $COMMON_PREFIX | cut -d' ' -f 1) for dm in $STRAY_DEVS ; do - echo "Trying to remove stalled $dm" - dmsetup remove $dm 2>/dev/null - # Sucessful remove means repeat the loop once more - [ $? -eq 0 ] && finish=0 + # FIXME: only those really suspended + echo dmsetup resume $dm + dmsetup resume $dm || true done - done - # Remove any loop devices that failed to get torn down if earlier tests aborted - STRAY_LOOPS=`losetup -a | grep $COMMON_PREFIX | cut -d: -f1` - if test -n "$STRAY_LOOPS"; then - echo "Removing stray loop devices containing $COMMON_PREFIX:" - losetup -a | grep $COMMON_PREFIX - losetup -d $STRAY_LOOPS 2>/dev/null || true - fi + STRAY_MOUNTS=`mount | grep $COMMON_PREFIX | cut -d\ -f1` + if test -n "$STRAY_MOUNTS"; then + echo "Removing stray mounted devices containing $COMMON_PREFIX:" + mount | grep $COMMON_PREFIX + umount -fl $STRAY_MOUNTS || true + sleep 2 + fi + + init_udev_transaction + NUM_REMAINING_DEVS=999 + while NUM_DEVS=`dmsetup table | grep ^$COMMON_PREFIX | wc -l` && \ + test $NUM_DEVS -lt $NUM_REMAINING_DEVS -a $NUM_DEVS -ne 0; do + echo "Removing $NUM_DEVS stray mapped devices with names beginning with $COMMON_PREFIX:" + STRAY_DEVS=$(dmsetup table | sed 's/:.*//' | grep $COMMON_PREFIX | cut -d' ' -f 1) + dmsetup info -c | grep ^$COMMON_PREFIX + for dm in $STRAY_DEVS ; do + echo dmsetup remove $dm + dmsetup remove $dm || true + done + NUM_REMAINING_DEVS=$NUM_DEVS + done + finish_udev_transaction + udev_wait + + STRAY_LOOPS=`losetup -a | grep $COMMON_PREFIX | cut -d: -f1` + if test -n "$STRAY_LOOPS"; then + echo "Removing stray loop devices containing $COMMON_PREFIX:" + losetup -a | grep $COMMON_PREFIX + losetup -d $STRAY_LOOPS || true + fi + } } teardown() { From agk@sourceware.org Thu Jun 30 09:17:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 30 Jun 2011 09:17:00 -0000 Subject: LVM2/test/lib aux.sh Message-ID: <20110630091749.20053.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-30 09:17:49 Modified files: test/lib : aux.sh Log message: use remove -f Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/aux.sh.diff?cvsroot=lvm2&r1=1.24&r2=1.25 --- LVM2/test/lib/aux.sh 2011/06/30 09:15:53 1.24 +++ LVM2/test/lib/aux.sh 2011/06/30 09:17:49 1.25 @@ -117,7 +117,7 @@ dmsetup info -c | grep ^$COMMON_PREFIX for dm in $STRAY_DEVS ; do echo dmsetup remove $dm - dmsetup remove $dm || true + dmsetup remove -f $dm || true done NUM_REMAINING_DEVS=$NUM_DEVS done From zkabelac@sourceware.org Thu Jun 30 09:24:00 2011 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 30 Jun 2011 09:24:00 -0000 Subject: LVM2 ./WHATS_NEW libdm/libdm-deptree.c Message-ID: <20110630092459.21613.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-06-30 09:24:59 Modified files: . : WHATS_NEW libdm : libdm-deptree.c Log message: Report internal error when parameters are missing on table load When some target is passing empty parameters to some dm target, report this as an internal error to better catch some broken table construction (some mirror conversions seem to be doing this for now). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2032&r2=1.2033 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101 --- LVM2/WHATS_NEW 2011/06/30 09:15:53 1.2032 +++ LVM2/WHATS_NEW 2011/06/30 09:24:58 1.2033 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + Report internal error when parameters are missing on table load. Teardown any stray devices with $COMMON_PREFIX during test runs. Reinstate correct permissions when creating mirrors. [2.02.85] Append 'm' attribute to pv_attr for missing PVs. --- LVM2/libdm/libdm-deptree.c 2011/06/27 22:38:53 1.100 +++ LVM2/libdm/libdm-deptree.c 2011/06/30 09:24:58 1.101 @@ -1754,6 +1754,10 @@ stack; return r; } + if (!params[0]) + log_error(INTERNAL_ERROR "Empty parameters for " + "%s %u:%u.", dm_segtypes[seg->type].target, + major, minor); break; } From agk@sourceware.org Thu Jun 30 18:25:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 30 Jun 2011 18:25:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ... Message-ID: <20110630182519.16653.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-30 18:25:19 Modified files: . : WHATS_NEW lib/activate : activate.c dev_manager.c lib/metadata : lv_manip.c metadata.h Log message: When suspending, automatically preload newly-visible existing LVs Let's find out if this makes things better or worse overall... Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2033&r2=1.2034 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.203&r2=1.204 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.220&r2=1.221 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.265&r2=1.266 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.246&r2=1.247 --- LVM2/WHATS_NEW 2011/06/30 09:24:58 1.2033 +++ LVM2/WHATS_NEW 2011/06/30 18:25:18 1.2034 @@ -1,5 +1,6 @@ Version 2.02.86 - ================================= + When suspending, automatically preload newly-visible existing LVs. Report internal error when parameters are missing on table load. Teardown any stray devices with $COMMON_PREFIX during test runs. Reinstate correct permissions when creating mirrors. [2.02.85] --- LVM2/lib/activate/activate.c 2011/06/22 21:31:21 1.203 +++ LVM2/lib/activate/activate.c 2011/06/30 18:25:18 1.204 @@ -1097,6 +1097,26 @@ #endif } +struct detached_lv_data { + struct logical_volume *lv_pre; + struct lv_activate_opts *laopts; + int *flush_required; +}; + +static int _preload_detached_lv(struct cmd_context *cmd, struct logical_volume *lv, void *data) +{ + struct detached_lv_data *detached = data; + struct lv_list *lvl_pre; + + if ((lvl_pre = find_lv_in_vg(detached->lv_pre->vg, lv->name))) { + if (lv_is_visible(lvl_pre->lv) && lv_is_active(lv) && + !_lv_preload(lvl_pre->lv, detached->laopts, detached->flush_required)) + return_0; + } + + return 1; +} + static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, struct lv_activate_opts *laopts, int error_if_not_suspended) { @@ -1105,6 +1125,7 @@ struct seg_list *sl; struct lvinfo info; int r = 0, lockfs = 0, flush_required = 0; + struct detached_lv_data detached; if (!activation()) return 1; @@ -1172,9 +1193,21 @@ } if (!_lv_preload(lvl_pre->lv, laopts, &flush_required)) goto_out; - } else if (!_lv_preload(lv_pre, laopts, &flush_required)) - /* FIXME Revert preloading */ - goto_out; + } else { + if (!_lv_preload(lv_pre, laopts, &flush_required)) + /* FIXME Revert preloading */ + goto_out; + + /* + * Search for existing LVs that have become detached and preload them. + */ + detached.lv_pre = lv_pre; + detached.laopts = laopts; + detached.flush_required = &flush_required; + + if (!for_each_sub_lv(cmd, lv, &_preload_detached_lv, &detached)) + goto_out; + } } if (!monitor_dev_for_events(cmd, lv, laopts, 0)) --- LVM2/lib/activate/dev_manager.c 2011/06/17 14:50:53 1.220 +++ LVM2/lib/activate/dev_manager.c 2011/06/30 18:25:18 1.221 @@ -1096,11 +1096,11 @@ return NULL; } - if (!_add_lv_to_dtree(dm, dtree, lv, origin_only)) + if (!_add_lv_to_dtree(dm, dtree, lv, lv_is_origin(lv) ? origin_only : 0)) goto_bad; /* Add any snapshots of this LV */ - if (!origin_only) + if (!origin_only && lv_is_origin(lv)) dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) if (!_add_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow, 0)) goto_bad; @@ -1714,7 +1714,7 @@ /* Restore fs cookie */ dm_tree_set_cookie(root, fs_get_cookie()); - if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, laopts->origin_only ? "real" : NULL))) + if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, (lv_is_origin(lv) && laopts->origin_only) ? "real" : NULL))) goto_out; /* Only process nodes with uuid of "LVM-" plus VG id. */ @@ -1744,7 +1744,7 @@ case PRELOAD: case ACTIVATE: /* Add all required new devices to tree */ - if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, laopts->origin_only ? "real" : NULL)) + if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, (lv_is_origin(lv) && laopts->origin_only) ? "real" : NULL)) goto_out; /* Preload any devices required before any suspensions */ --- LVM2/lib/metadata/lv_manip.c 2011/06/29 17:05:53 1.265 +++ LVM2/lib/metadata/lv_manip.c 2011/06/30 18:25:18 1.266 @@ -2317,7 +2317,7 @@ return _rename_single_lv(lv, new_name); } -/* Callback for _for_each_sub_lv */ +/* Callback for for_each_sub_lv */ static int _rename_cb(struct cmd_context *cmd, struct logical_volume *lv, void *data) { @@ -2327,32 +2327,31 @@ } /* - * Loop down sub LVs and call "func" for each. - * "func" is responsible to log necessary information on failure. + * Loop down sub LVs and call fn for each. + * fn is responsible to log necessary information on failure. */ -static int _for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv, - int (*func)(struct cmd_context *cmd, - struct logical_volume *lv, - void *data), - void *data) +int for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv, + int (*fn)(struct cmd_context *cmd, + struct logical_volume *lv, void *data), + void *data) { struct logical_volume *org; struct lv_segment *seg; uint32_t s; if (lv_is_cow(lv) && lv_is_virtual_origin(org = origin_from_cow(lv))) - if (!func(cmd, org, data)) + if (!fn(cmd, org, data)) return_0; dm_list_iterate_items(seg, &lv->segments) { - if (seg->log_lv && !func(cmd, seg->log_lv, data)) + if (seg->log_lv && !fn(cmd, seg->log_lv, data)) return_0; for (s = 0; s < seg->area_count; s++) { if (seg_type(seg, s) != AREA_LV) continue; - if (!func(cmd, seg_lv(seg, s), data)) + if (!fn(cmd, seg_lv(seg, s), data)) return_0; - if (!_for_each_sub_lv(cmd, seg_lv(seg, s), func, data)) + if (!for_each_sub_lv(cmd, seg_lv(seg, s), fn, data)) return_0; } } @@ -2397,7 +2396,7 @@ /* rename sub LVs */ lv_names.old = lv->name; lv_names.new = new_name; - if (!_for_each_sub_lv(cmd, lv, _rename_cb, (void *) &lv_names)) + if (!for_each_sub_lv(cmd, lv, _rename_cb, (void *) &lv_names)) return 0; /* rename main LV */ --- LVM2/lib/metadata/metadata.h 2011/06/17 14:30:58 1.246 +++ LVM2/lib/metadata/metadata.h 2011/06/30 18:25:18 1.247 @@ -441,6 +441,11 @@ int remove_seg_from_segs_using_this_lv(struct logical_volume *lv, struct lv_segment *seg); struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv); +int for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv, + int (*fn)(struct cmd_context *cmd, + struct logical_volume *lv, void *data), + void *data); + /* * Calculate readahead from underlying PV devices */ From agk@sourceware.org Thu Jun 30 19:32:00 2011 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 30 Jun 2011 19:32:00 -0000 Subject: LVM2/test t-pvchange-usage.sh Message-ID: <20110630193252.28630.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2011-06-30 19:32:51 Modified files: test : t-pvchange-usage.sh Log message: update pv_attr check for new missing attr Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvchange-usage.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/test/t-pvchange-usage.sh 2011/01/05 00:16:20 1.6 +++ LVM2/test/t-pvchange-usage.sh 2011/06/30 19:32:51 1.7 @@ -30,9 +30,9 @@ # "vgchange disable/enable allocation for pvs with metadatacopies = $mda (bz452982)" pvchange $dev1 -x n - check pv_field $dev1 pv_attr -- + check pv_field $dev1 pv_attr --- pvchange $dev1 -x y - check pv_field $dev1 pv_attr a- + check pv_field $dev1 pv_attr a-- # 'remove pv' vgremove $vg1