master - dmstats: use better interval estimate for usleep() timer
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=886b4f755d7f33...
Commit: 886b4f755d7f33194f92dafbf2c22517db4de374
Parent: 68ec42ebaf288911b1cb95882678ca778b795953
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 12:39:26 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 13:03:44 2016 +0000
dmstats: use better interval estimate for usleep() timer
Although the usleep() interval timer is not used if the Linux
TIMERFD interface is available it should still provide reasonably
good timing.
Instead of trying to estimate the error from the duration of the
last sleep, peg it to the start time of the program, and use the
value of ((start_time - now) % interval) to correct the current
interval duration.
This always pulls us back into sync at the end of each interval,
rather than relying on trying to incrementally adjust the time
duration at each interval start.
This greatly reduces drift when the usleep() clock is used.
---
tools/dmsetup.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 1be19d5..17c5742 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -282,6 +282,7 @@ const char *_stats_types[] = {
/* report timekeeping */
static struct dm_timestamp *_cycle_timestamp = NULL;
+static struct dm_timestamp *_start_timestamp = NULL;
static uint64_t _interval = 0; /* configured interval in nsecs */
static uint64_t _new_interval = 0; /* flag top-of-interval */
static uint64_t _last_interval = 0; /* approx. measured interval in nsecs */
@@ -650,12 +651,14 @@ static int _do_timer_wait(void)
static int _start_usleep_timer(void)
{
log_debug("Using usleep for interval timekeeping.");
+ _start_timestamp = dm_timestamp_alloc();
+ dm_timestamp_get(_start_timestamp);
return 1;
}
static int _do_usleep_wait(void)
{
- static struct dm_timestamp *_last_sleep, *_now = NULL;
+ static struct dm_timestamp *_now = NULL;
uint64_t this_interval;
int64_t delta_t;
@@ -664,9 +667,7 @@ static int _do_usleep_wait(void)
* message ioctls by keeping track of the last wake time and
* adjusting the sleep interval accordingly.
*/
- if (!_last_sleep && !_now) {
- if (!(_last_sleep = dm_timestamp_alloc()))
- return_0;
+ if (!_now) {
if (!(_now = dm_timestamp_alloc()))
return_0;
dm_timestamp_get(_now);
@@ -674,19 +675,19 @@ static int _do_usleep_wait(void)
log_error("Using "FMTu64" as first interval.", this_interval);
} else {
dm_timestamp_get(_now);
- delta_t = dm_timestamp_delta(_now, _last_sleep);
- log_debug("Interval timer delta_t: "FMTi64, delta_t);
+ delta_t = dm_timestamp_delta(_now, _start_timestamp);
+ log_debug("Interval timer drift: "FMTi64,
+ (delta_t % _interval));
/* FIXME: usleep timer drift over large counts. */
/* adjust for time spent populating and reporting */
- this_interval = 2 * _interval - delta_t;
+ this_interval = _interval - (delta_t % _interval);
log_debug("Using "FMTu64" as interval.", this_interval);
}
/* Signal that a new interval has begun. */
_new_interval = 1;
- dm_timestamp_copy(_last_sleep, _now);
if (usleep(this_interval / NSEC_PER_USEC)) {
if (errno == EINTR)
@@ -699,8 +700,9 @@ static int _do_usleep_wait(void)
}
if (_count == 2) {
- dm_timestamp_destroy(_last_sleep);
+ dm_timestamp_destroy(_start_timestamp);
dm_timestamp_destroy(_now);
+ _start_timestamp = _now = NULL;
}
return 1;
7 years, 4 months
master - dmstats: improve tool help output and option coverage
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=68ec42ebaf2889...
Commit: 68ec42ebaf288911b1cb95882678ca778b795953
Parent: 4f9d901c7142a0f2a73eb0353db992407187a144
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 10:53:27 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 11:51:13 2016 +0000
dmstats: improve tool help output and option coverage
---
tools/dmsetup.c | 104 +++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 78 insertions(+), 26 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index f068293..1be19d5 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -5608,48 +5608,100 @@ static int _stats_help(CMD_ARGS);
* dmsetup stats <cmd> [options] [device_name]
* dmstats <cmd> [options] [device_name]
*
- * clear [--regionid id] <device_name>
- * create [--areas nr_areas] [--areasize size]
- * [ [--start start] [--length len] | [--segments]]
- * [--userdata data] [--programid id] [<device_name>]
- * delete [--regionid] <device_name>
- * delete_all [--programid id]
- * group [--alias name] [--alldevices] [--regions <regions>] [<device_name>]
- * list [--programid id] [<device_name>]
- * print [--clear] [--programid id] [--regionid id] [<device_name>]
- * report [--interval seconds] [--count count] [--units units] [--regionid id]
- * [--programid id] [<device>]
- * ungroup [--alldevices] [--groupid id] [<device_name>]
+ * clear [--allregions|--regionid id] [--alldevices|<device...>]
+ * create [--start <start> [--length <len>]
+ * [--areas <nr_areas>] [--areasize <size>]
+ * [--programid <id>] [--userdata <data> ]
+ * [--bounds histogram_boundaries] [--precise]
+ * [--alldevices|<device...>]
+ * create --filemap [--nogroup]
+ * [--programid <id>] [--userdata <data> ]
+ * [--bounds histogram_boundaries] [--precise] [<file_path>]
+ * delete [--allprograms|--programid id]
+ * [--allregions|--regionid id]
+ * [--alldevices|<device...>]
+ * group [--alias NAME] --regions <regions>
+ * [--allprograms|--programid id] [--alldevices|<device...>]
+ * list [--allprograms|--programid id] [--allregions|--regionid id]
+ * print [--clear] [--allprograms|--programid id]
+ * [--allregions|--regionid id]
+ * [--alldevices|<device...>]
+ * report [--interval <seconds>] [--count <cnt>]
+ * [--units <u>] [--programid <id>] [--regionid <id>]
+ * [-o <fields>] [-O|--sort <sort_fields>]
+ * [-S|--select <selection>] [--nameprefixes]
+ * [--noheadings] [--separator <separator>]
+ * [--allprograms|--programid id] [<device...>]
+ * ungroup --groupid <id> [--allprograms|--programid id]
+ * [--alldevices|<device...>]
*/
+#define INDENT "\n\t "
+/* groups of commonly used options */
#define AREA_OPTS "[--areas <nr_areas>] [--areasize <size>] "
-#define CREATE_OPTS "[--start <start> [--length <len>]]\n\t\t" AREA_OPTS
+#define REGION_OPTS "[--start <start> [--length <len>]" INDENT AREA_OPTS
#define ID_OPTS "[--programid <id>] [--userdata <data> ] "
#define SELECT_OPTS "[--programid <id>] [--regionid <id>] "
-#define PRINT_OPTS "[--clear] " SELECT_OPTS
-#define REPORT_OPTS "[--interval <seconds>] [--count <cnt>]\n\t\t[--units <u>]" SELECT_OPTS
-#define GROUP_OPTS "[--alias NAME] --regions <regions>"
+#define HIST_OPTS "[--bounds histogram_boundaries] "
+#define PRECISE_OPTS "[--precise] "
+#define SEGMENTS_OPT "[--segments] "
+#define EXTRA_OPTS HIST_OPTS PRECISE_OPTS
+#define ALL_PROGS_OPT "[--allprograms|--programid id] "
+#define ALL_REGIONS_OPT "[--allregions|--regionid id] "
+#define ALL_DEVICES_OPT "[--alldevices|<device...>] "
+#define ALL_PROGS_REGIONS_DEVICES ALL_PROGS_OPT INDENT ALL_REGIONS_OPT INDENT ALL_DEVICES_OPT
+#define FIELD_OPTS "[-o <fields>] [-O|--sort <sort_fields>]"
+#define DM_REPORT_OPTS FIELD_OPTS INDENT "[-S|--select <selection>] [--nameprefixes]" INDENT \
+"[--noheadings] [--separator <separator>]"
+
+/* command options */
+#define CREATE_OPTS REGION_OPTS INDENT ID_OPTS INDENT EXTRA_OPTS INDENT SEGMENTS_OPT
+#define FILEMAP_OPTS "--filemap [--nogroup]" INDENT ID_OPTS INDENT EXTRA_OPTS
+#define PRINT_OPTS "[--clear] " ALL_PROGS_REGIONS_DEVICES
+#define REPORT_OPTS "[--interval <seconds>] [--count <cnt>]" INDENT \
+"[--units <u>] " SELECT_OPTS INDENT DM_REPORT_OPTS INDENT ALL_PROGS_OPT
+#define GROUP_OPTS "[--alias NAME] --regions <regions>" INDENT ALL_PROGS_OPT ALL_DEVICES_OPT
+#define UNGROUP_OPTS ALL_PROGS_OPT INDENT ALL_DEVICES_OPT
+/*
+ * The 'create' command has two entries in the table, to allow for the
+ * the fact that 'create' and 'create --filemap' have largely disjoint
+ * sets of options.
+ */
static struct command _stats_subcommands[] = {
{"help", "", 0, 0, 0, 0, _stats_help},
- {"clear", "--regionid <id> [<device>]", 0, -1, 1, 0, _stats_clear},
- {"create", CREATE_OPTS "\n\t\t" ID_OPTS "[<device>]", 0, -1, 1, 0, _stats_create},
- {"delete", "--regionid <id> <device>", 1, -1, 1, 0, _stats_delete},
+ {"clear", ALL_REGIONS_OPT ALL_DEVICES_OPT, 0, -1, 1, 0, _stats_clear},
+ {"create", CREATE_OPTS ALL_DEVICES_OPT, 0, -1, 1, 0, _stats_create},
+ {"create", FILEMAP_OPTS "[<file_path>]", 0, -1, 1, 0, _stats_create},
+ {"delete", ALL_PROGS_REGIONS_DEVICES, 1, -1, 1, 0, _stats_delete},
{"group", GROUP_OPTS, 1, -1, 1, 0, _stats_group},
- {"list", "[--programid <id>] [<device>]", 0, -1, 1, 0, _stats_report},
- {"print", PRINT_OPTS "[<device>]", 0, -1, 1, 0, _stats_print},
- {"report", REPORT_OPTS "[<device>]", 0, -1, 1, 0, _stats_report},
- {"ungroup", "--groupid <id> [device]", 1, -1, 1, 0, _stats_ungroup},
+ {"list", ALL_PROGS_OPT ALL_REGIONS_OPT, 0, -1, 1, 0, _stats_report},
+ {"print", PRINT_OPTS, 0, -1, 1, 0, _stats_print},
+ {"report", REPORT_OPTS "[<device...>]", 0, -1, 1, 0, _stats_report},
+ {"ungroup", "--groupid <id> " UNGROUP_OPTS, 1, -1, 1, 0, _stats_ungroup},
{"version", "", 0, -1, 1, 0, _version},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
#undef AREA_OPTS
-#undef CREATE_OPTS
+#undef REGION_OPTS
#undef ID_OPTS
+#undef SELECT_OPTS
+#undef HIST_OPTS
+#undef PRECISE_OPTS
+#undef EXTRA_OPTS
+#undef ALL_PROGS_OPT
+#undef ALL_REGIONS_OPT
+#undef ALL_DEVICES_OPT
+#undef ALL_PROGS_REGIONS_DEVICES
+#undef FIELD_OPTS
+#undef DM_REPORT_OPTS
+#undef CREATE_OPTS
+#undef FILEMAP_OPTS
#undef PRINT_OPTS
#undef REPORT_OPTS
-#undef SELECT_OPTS
+#undef GROUP_OPTS
+#undef UNGROUP_OPTS
static int _dmsetup_help(CMD_ARGS);
@@ -5723,7 +5775,7 @@ static void _stats_usage(FILE *out)
for (i = 0; _stats_subcommands[i].name; i++)
fprintf(out, "\t%s %s\n", _stats_subcommands[i].name, _stats_subcommands[i].help);
- fprintf(out, "<device> may be device name or -u <uuid> or "
+ fprintf(out, "\n<device> may be device name or -u <uuid> or "
"-j <major> -m <minor>\n");
fprintf(out, "<fields> are comma-separated. Use 'help -c' for list.\n");
fprintf(out, "\n");
7 years, 4 months
master - man: fix 'dmstats create' formatting in dmstats.8.in
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4f9d901c7142a0...
Commit: 4f9d901c7142a0f2a73eb0353db992407187a144
Parent: 14be8c4fad7cd50cbd0006b6824552733f40bafd
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 10:23:12 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 10:23:12 2016 +0000
man: fix 'dmstats create' formatting in dmstats.8.in
---
man/dmstats.8.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/man/dmstats.8.in b/man/dmstats.8.in
index 5ee02a9..fbc7811 100644
--- a/man/dmstats.8.in
+++ b/man/dmstats.8.in
@@ -83,8 +83,8 @@ dmstats \(em device-mapper statistics management
. ad l
. BR create
. RB [ device_name...
-. RB | file_path... ]
-. RB [ \-\-alldevices ]
+. RB | file_path...
+. RB | [ \-\-alldevices ]]
. RB [ \-\-areas
. IR nr_areas | \fB\-\-areasize
. IR area_size ]
7 years, 4 months
master - man: fix 'dmstats list' option formatting in dmstats.8.in
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=14be8c4fad7cd5...
Commit: 14be8c4fad7cd50cbd0006b6824552733f40bafd
Parent: 25dd3988c3a5bed78f8f5c76ca2b24a7c95866a2
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 10:12:56 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 10:12:56 2016 +0000
man: fix 'dmstats list' option formatting in dmstats.8.in
---
man/dmstats.8.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/man/dmstats.8.in b/man/dmstats.8.in
index 7f451fd..5ee02a9 100644
--- a/man/dmstats.8.in
+++ b/man/dmstats.8.in
@@ -155,7 +155,7 @@ dmstats \(em device-mapper statistics management
. OPT_OBJECTS
. RB \%[ \-\-nosuffix ]
. RB [ \-\-notimesuffix ]
-. RB \%[ \-v | \-\-verbose [ \-v | \-\-verbose ]]
+. RB \%[ \-v | \-\-verbose]
. ad b
..
.CMD_LIST
7 years, 4 months
master - man: fix 'dmstats <command>' formatting in dmstats.8.in
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=25dd3988c3a5be...
Commit: 25dd3988c3a5bed78f8f5c76ca2b24a7c95866a2
Parent: 35791689ba5ef95da45290fd12ce9cff55c86258
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Sun Dec 18 10:11:02 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Sun Dec 18 10:12:45 2016 +0000
man: fix 'dmstats <command>' formatting in dmstats.8.in
---
man/dmstats.8.in | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/man/dmstats.8.in b/man/dmstats.8.in
index 2367b8b0..7f451fd 100644
--- a/man/dmstats.8.in
+++ b/man/dmstats.8.in
@@ -53,12 +53,14 @@ dmstats \(em device-mapper statistics management
.de CMD_COMMAND
. ad l
. IR command
-. RI [ device_name
-. RB | \-\-uuid
-. IR uuid | \fB\-\-major
+. RI [ device_name |
+. RB [ \-u | \-\-uuid
+. IR uuid ]
+. RB | [ \-\-major
. IR major
. BR \-\-minor
. IR minor ]
+. RB \%[ \-v | \-\-verbose]
. ad b
..
.CMD_COMMAND
7 years, 4 months
master - libdm: use destination size as limit in dm_bit_copy()
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=35791689ba5ef9...
Commit: 35791689ba5ef95da45290fd12ce9cff55c86258
Parent: 0f98d5c2e6d103a46bb5eca75ac496622933c475
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Dec 12 20:28:29 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Wed Dec 14 11:28:11 2016 +0000
libdm: use destination size as limit in dm_bit_copy()
The dm_bit_copy() macro uses the source (bs1) bitset size as the
limit for memcpy:
memcpy((bs1) + 1, (bs2) + 1, ((*(bs1) / DM_BITS_PER_INT) + 1)..)
This is safe if the destination bitset is smaller than the source,
or if the two bitsets are of the same size.
With a destination that is larger (e.g. when resizing a bitmap to
add more capacity), the memcpy will overrun the source bitset and
set garbage bits in the destination.
There are nine uses of the macro currently (8 in libdm/regex, and
1 in daemons/cmirrord): in each case the two bitsets are always of
equal size so the behaviour is unchanged.
Fix the macro to use bs2's size to simplify resizing bitsets and
avoid the need for another copy macro.
---
libdm/libdevmapper.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index bcf784b..ed46795 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -2090,7 +2090,7 @@ int dm_bit_get_prev(dm_bitset_t bs, int last_bit);
memset((bs) + 1, 0, ((*(bs) / DM_BITS_PER_INT) + 1) * sizeof(int))
#define dm_bit_copy(bs1, bs2) \
- memcpy((bs1) + 1, (bs2) + 1, ((*(bs1) / DM_BITS_PER_INT) + 1) * sizeof(int))
+ memcpy((bs1) + 1, (bs2) + 1, ((*(bs2) / DM_BITS_PER_INT) + 1) * sizeof(int))
/*
* Parse a string representation of a bitset into a dm_bitset_t. The
7 years, 4 months
master - cleanup: use exiting function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0f98d5c2e6d103...
Commit: 0f98d5c2e6d103a46bb5eca75ac496622933c475
Parent: fecd043cca4b5f4d5a244d715c60ce35ff1b62d7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Dec 14 11:34:28 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 14 11:41:42 2016 +0100
cleanup: use exiting function
Reuse existing code and some indent change.
---
lib/metadata/lv_manip.c | 4 ++--
lib/metadata/raid_manip.c | 9 ++-------
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 211b190..1889998 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6258,12 +6258,12 @@ static int _lv_update_and_reload(struct logical_volume *lv, int origin_only)
int lv_update_and_reload(struct logical_volume *lv)
{
- return _lv_update_and_reload(lv, 0);
+ return _lv_update_and_reload(lv, 0);
}
int lv_update_and_reload_origin(struct logical_volume *lv)
{
- return _lv_update_and_reload(lv, 1);
+ return _lv_update_and_reload(lv, 1);
}
/*
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index b48b959..5ec86a3 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1464,13 +1464,8 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
/*
* Eliminate the residual LVs
*/
- dm_list_iterate_items(lvl, &removal_lvs) {
- if (!deactivate_lv(cmd, lvl->lv))
- return_0;
-
- if (!lv_remove(lvl->lv))
- return_0;
- }
+ if (!_deactivate_and_remove_lvs(lv->vg, &removal_lvs))
+ return_0;
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
7 years, 4 months
master - raid: split preserves local exlusive activation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fecd043cca4b5f...
Commit: fecd043cca4b5f4d5a244d715c60ce35ff1b62d7
Parent: 77e09c3fb4d019ab3a0472059481ef990c64b415
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Dec 14 10:19:25 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 14 11:40:01 2016 +0100
raid: split preserves local exlusive activation
---
WHATS_NEW | 1 +
lib/metadata/raid_manip.c | 19 ++-----------------
2 files changed, 3 insertions(+), 17 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 60e8fa5..4ac3377 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Always active splitted RAID LV exclusively locally.
Do not use LV RAID status bit for segment status.
Check segtype directly instead of checking RAID in segment status.
Reusing exiting code for raid image removal.
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index ed48239..b48b959 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -163,22 +163,6 @@ uint32_t lv_raid_image_count(const struct logical_volume *lv)
return seg->area_count;
}
-static int _activate_sublv_preserving_excl(struct logical_volume *top_lv,
- struct logical_volume *sub_lv)
-{
- struct cmd_context *cmd = top_lv->vg->cmd;
-
- /* If top RAID was EX, use EX */
- if (lv_is_active_exclusive_locally(top_lv)) {
- if (!activate_lv_excl_local(cmd, sub_lv))
- return_0;
- } else {
- if (!activate_lv(cmd, sub_lv))
- return_0;
- }
- return 1;
-}
-
/* HM Helper: prohibit allocation on @pv if @lv already has segments allocated on it */
static int _avoid_pv_of_lv(struct logical_volume *lv, struct physical_volume *pv)
{
@@ -1553,7 +1537,8 @@ int lv_raid_split_and_track(struct logical_volume *lv,
display_lvname(lv));
/* Activate the split (and tracking) LV */
- if (!_activate_sublv_preserving_excl(lv, seg_lv(seg, s)))
+ /* Preserving exclusive local activation also for tracked LV */
+ if (!activate_lv_excl_local(lv->vg->cmd, seg_lv(seg, s)))
return_0;
log_print_unless_silent("Use 'lvconvert --merge %s' to merge back into %s.",
7 years, 4 months
master - raid: activation with list
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=77e09c3fb4d019...
Commit: 77e09c3fb4d019ab3a0472059481ef990c64b415
Parent: 4a05f83278a1b1967b91d8f47fa1f7ce18341439
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Dec 14 11:16:47 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 14 11:37:02 2016 +0100
raid: activation with list
Commit 069039204002e5c8514050fe541bbd378c383a02 revealed a problem
in raid metadata manipulation.
We do two operations in one table reload:
- raid leg/image extraction
- rename remaining raid legs
This should be made in separate steps. Otherwise we do an
uncorrectable table change on error path (leaving tables
for admin and dmsetup).
As a hotfix - restore the previous logic and use a single
new function _lv_update_and_reload_list which activates exclusively
extracted LVs on the list before resuming suspended raid LV.
This restore 'rename' functionality upon resume.
Also still preserve the 'origin_only' logic - although we know
it's not working properly for cluster and LV stacking.
Further fixes are needed.
---
lib/metadata/raid_manip.c | 67 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 049102a..ed48239 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -233,11 +233,6 @@ static int _deactivate_and_remove_lvs(struct volume_group *vg, struct dm_list *r
{
struct lv_list *lvl;
- /* Need to take lock/resume for proper deactivation */
- dm_list_iterate_items(lvl, removal_lvs)
- if (!activate_lv_excl_local(vg->cmd, lvl->lv))
- return_0;
-
dm_list_iterate_items(lvl, removal_lvs) {
if (!deactivate_lv(vg->cmd, lvl->lv))
return_0;
@@ -363,6 +358,62 @@ static int _raid_remove_top_layer(struct logical_volume *lv,
return 1;
}
+/*
+ * Assisted excl_local activation of lvl listed LVs before resume
+ *
+ * FIXME: code which needs to use this function is usually unsafe
+ * againt crashes as it's doing more then 1 operation per commit
+ * and as such is currently irreversible on error path.
+ *
+ * Function is not making backup as this is usually not the last
+ * metadata changing operation.
+ *
+ * Also we should take 'struct lv_list'...
+ */
+static int _lv_update_and_reload_list(struct logical_volume *lv, int origin_only, struct dm_list *lv_list)
+{
+ struct volume_group *vg = lv->vg;
+ const struct logical_volume *lock_lv = lv_lock_holder(lv);
+ struct lv_list *lvl;
+ int r;
+
+ log_very_verbose("Updating logical volume %s on disk(s)%s.",
+ display_lvname(lock_lv), origin_only ? " (origin only)": "");
+
+ if (!vg_write(vg))
+ return_0;
+
+ if (!(r = (origin_only ? suspend_lv_origin(vg->cmd, lock_lv) : suspend_lv(vg->cmd, lock_lv)))) {
+ log_error("Failed to lock logical volume %s.",
+ display_lvname(lock_lv));
+ vg_revert(vg);
+ } else if (!(r = vg_commit(vg)))
+ stack; /* !vg_commit() has implict vg_revert() */
+
+ if (r && lv_list) {
+ dm_list_iterate_items(lvl, lv_list) {
+ log_very_verbose("Activating logical volume %s before %s in kernel.",
+ display_lvname(lvl->lv), display_lvname(lock_lv));
+ if (!activate_lv_excl_local(vg->cmd, lvl->lv)) {
+ log_error("Failed to activate %s before resuming %s.",
+ display_lvname(lvl->lv), display_lvname(lock_lv));
+ r = 0; /* But lets try with the rest */
+ }
+ }
+ }
+
+ log_very_verbose("Updating logical volume %s in kernel.",
+ display_lvname(lock_lv));
+
+ if (!(origin_only ? resume_lv_origin(vg->cmd, lock_lv) : resume_lv(vg->cmd, lock_lv))) {
+ log_error("Problem reactivating logical volume %s.",
+ display_lvname(lock_lv));
+ r = 0;
+ }
+
+ return r;
+}
+
/* Makes on-disk metadata changes
* If LV is active:
* clear first block of device
@@ -1233,7 +1284,7 @@ static int _raid_remove_images(struct logical_volume *lv,
if (!commit)
return 1;
- if (!lv_update_and_reload(lv))
+ if (!_lv_update_and_reload_list(lv, 0, removal_lvs))
return_0;
/*
@@ -1927,7 +1978,7 @@ static int _raid0_add_or_remove_metadata_lvs(struct logical_volume *lv,
return_0;
if (update_and_reload) {
- if (!lv_update_and_reload_origin(lv))
+ if (!_lv_update_and_reload_list(lv, 1, removal_lvs))
return_0;
/* If any residual LVs, eliminate them, write VG, commit it and take a backup */
@@ -1977,7 +2028,7 @@ static int _lv_update_reload_fns_reset_eliminate_lvs(struct logical_volume *lv,
{
int flags_were_cleared = 0, r = 0;
- if (!lv_update_and_reload_origin(lv))
+ if (!_lv_update_and_reload_list(lv, 1, removal_lvs))
return_0;
/* Eliminate any residual LV and don't commit the metadata */
7 years, 4 months
master - configure: just move new macro to right file
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a05f83278a1b1...
Commit: 4a05f83278a1b1967b91d8f47fa1f7ce18341439
Parent: f4401fe351f63679ae8f4bab448a9283fb631a4a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Dec 13 22:48:56 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Dec 13 22:49:59 2016 +0100
configure: just move new macro to right file
aclocal is regenerated while acinclude is permanent.
Move new macro to permanent file.
---
acinclude.m4 | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
aclocal.m4 | 170 ---------------------------------------------------------
2 files changed, 171 insertions(+), 170 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index b6c9b18..cd02300 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -61,3 +61,174 @@ AC_DEFUN([AC_TRY_LDFLAGS],
ifelse([$4], [], [:], [$4])
fi
])
+
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_gcc_builtin.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_GCC_BUILTIN(BUILTIN)
+#
+# DESCRIPTION
+#
+# This macro checks if the compiler supports one of GCC's built-in
+# functions; many other compilers also provide those same built-ins.
+#
+# The BUILTIN parameter is the name of the built-in function.
+#
+# If BUILTIN is supported define HAVE_<BUILTIN>. Keep in mind that since
+# builtins usually start with two underscores they will be copied over
+# into the HAVE_<BUILTIN> definition (e.g. HAVE___BUILTIN_EXPECT for
+# __builtin_expect()).
+#
+# The macro caches its result in the ax_cv_have_<BUILTIN> variable (e.g.
+# ax_cv_have___builtin_expect).
+#
+# The macro currently supports the following built-in functions:
+#
+# __builtin_assume_aligned
+# __builtin_bswap16
+# __builtin_bswap32
+# __builtin_bswap64
+# __builtin_choose_expr
+# __builtin___clear_cache
+# __builtin_clrsb
+# __builtin_clrsbl
+# __builtin_clrsbll
+# __builtin_clz
+# __builtin_clzl
+# __builtin_clzll
+# __builtin_complex
+# __builtin_constant_p
+# __builtin_ctz
+# __builtin_ctzl
+# __builtin_ctzll
+# __builtin_expect
+# __builtin_ffs
+# __builtin_ffsl
+# __builtin_ffsll
+# __builtin_fpclassify
+# __builtin_huge_val
+# __builtin_huge_valf
+# __builtin_huge_vall
+# __builtin_inf
+# __builtin_infd128
+# __builtin_infd32
+# __builtin_infd64
+# __builtin_inff
+# __builtin_infl
+# __builtin_isinf_sign
+# __builtin_nan
+# __builtin_nand128
+# __builtin_nand32
+# __builtin_nand64
+# __builtin_nanf
+# __builtin_nanl
+# __builtin_nans
+# __builtin_nansf
+# __builtin_nansl
+# __builtin_object_size
+# __builtin_parity
+# __builtin_parityl
+# __builtin_parityll
+# __builtin_popcount
+# __builtin_popcountl
+# __builtin_popcountll
+# __builtin_powi
+# __builtin_powif
+# __builtin_powil
+# __builtin_prefetch
+# __builtin_trap
+# __builtin_types_compatible_p
+# __builtin_unreachable
+#
+# Unsuppored built-ins will be tested with an empty parameter set and the
+# result of the check might be wrong or meaningless so use with care.
+#
+# LICENSE
+#
+# Copyright (c) 2013 Gabriele Svelto <gabriele.svelto(a)gmail.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 3
+
+AC_DEFUN([AX_GCC_BUILTIN], [
+ AS_VAR_PUSHDEF([ac_var], [ax_cv_have_$1])
+
+ AC_CACHE_CHECK([for $1], [ac_var], [
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [
+ m4_case([$1],
+ [__builtin_assume_aligned], [$1("", 0)],
+ [__builtin_bswap16], [$1(0)],
+ [__builtin_bswap32], [$1(0)],
+ [__builtin_bswap64], [$1(0)],
+ [__builtin_choose_expr], [$1(0, 0, 0)],
+ [__builtin___clear_cache], [$1("", "")],
+ [__builtin_clrsb], [$1(0)],
+ [__builtin_clrsbl], [$1(0)],
+ [__builtin_clrsbll], [$1(0)],
+ [__builtin_clz], [$1(0)],
+ [__builtin_clzl], [$1(0)],
+ [__builtin_clzll], [$1(0)],
+ [__builtin_complex], [$1(0.0, 0.0)],
+ [__builtin_constant_p], [$1(0)],
+ [__builtin_ctz], [$1(0)],
+ [__builtin_ctzl], [$1(0)],
+ [__builtin_ctzll], [$1(0)],
+ [__builtin_expect], [$1(0, 0)],
+ [__builtin_ffs], [$1(0)],
+ [__builtin_ffsl], [$1(0)],
+ [__builtin_ffsll], [$1(0)],
+ [__builtin_fpclassify], [$1(0, 1, 2, 3, 4, 0.0)],
+ [__builtin_huge_val], [$1()],
+ [__builtin_huge_valf], [$1()],
+ [__builtin_huge_vall], [$1()],
+ [__builtin_inf], [$1()],
+ [__builtin_infd128], [$1()],
+ [__builtin_infd32], [$1()],
+ [__builtin_infd64], [$1()],
+ [__builtin_inff], [$1()],
+ [__builtin_infl], [$1()],
+ [__builtin_isinf_sign], [$1(0.0)],
+ [__builtin_nan], [$1("")],
+ [__builtin_nand128], [$1("")],
+ [__builtin_nand32], [$1("")],
+ [__builtin_nand64], [$1("")],
+ [__builtin_nanf], [$1("")],
+ [__builtin_nanl], [$1("")],
+ [__builtin_nans], [$1("")],
+ [__builtin_nansf], [$1("")],
+ [__builtin_nansl], [$1("")],
+ [__builtin_object_size], [$1("", 0)],
+ [__builtin_parity], [$1(0)],
+ [__builtin_parityl], [$1(0)],
+ [__builtin_parityll], [$1(0)],
+ [__builtin_popcount], [$1(0)],
+ [__builtin_popcountl], [$1(0)],
+ [__builtin_popcountll], [$1(0)],
+ [__builtin_powi], [$1(0, 0)],
+ [__builtin_powif], [$1(0, 0)],
+ [__builtin_powil], [$1(0, 0)],
+ [__builtin_prefetch], [$1("")],
+ [__builtin_trap], [$1()],
+ [__builtin_types_compatible_p], [$1(int, int)],
+ [__builtin_unreachable], [$1()],
+ [m4_warn([syntax], [Unsupported built-in $1, the test may fail])
+ $1()]
+ )
+ ])],
+ [AS_VAR_SET([ac_var], [yes])],
+ [AS_VAR_SET([ac_var], [no])])
+ ])
+
+ AS_IF([test yes = AS_VAR_GET([ac_var])],
+ [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
+ [Define to 1 if the system has the `$1' built-in function])], [])
+
+ AS_VAR_POPDEF([ac_var])
+])
diff --git a/aclocal.m4 b/aclocal.m4
index 1f02c2b..4ab64a8 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -536,175 +536,5 @@ AC_DEFUN([AM_RUN_LOG],
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
(exit $ac_status); }])
-# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_gcc_builtin.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_GCC_BUILTIN(BUILTIN)
-#
-# DESCRIPTION
-#
-# This macro checks if the compiler supports one of GCC's built-in
-# functions; many other compilers also provide those same built-ins.
-#
-# The BUILTIN parameter is the name of the built-in function.
-#
-# If BUILTIN is supported define HAVE_<BUILTIN>. Keep in mind that since
-# builtins usually start with two underscores they will be copied over
-# into the HAVE_<BUILTIN> definition (e.g. HAVE___BUILTIN_EXPECT for
-# __builtin_expect()).
-#
-# The macro caches its result in the ax_cv_have_<BUILTIN> variable (e.g.
-# ax_cv_have___builtin_expect).
-#
-# The macro currently supports the following built-in functions:
-#
-# __builtin_assume_aligned
-# __builtin_bswap16
-# __builtin_bswap32
-# __builtin_bswap64
-# __builtin_choose_expr
-# __builtin___clear_cache
-# __builtin_clrsb
-# __builtin_clrsbl
-# __builtin_clrsbll
-# __builtin_clz
-# __builtin_clzl
-# __builtin_clzll
-# __builtin_complex
-# __builtin_constant_p
-# __builtin_ctz
-# __builtin_ctzl
-# __builtin_ctzll
-# __builtin_expect
-# __builtin_ffs
-# __builtin_ffsl
-# __builtin_ffsll
-# __builtin_fpclassify
-# __builtin_huge_val
-# __builtin_huge_valf
-# __builtin_huge_vall
-# __builtin_inf
-# __builtin_infd128
-# __builtin_infd32
-# __builtin_infd64
-# __builtin_inff
-# __builtin_infl
-# __builtin_isinf_sign
-# __builtin_nan
-# __builtin_nand128
-# __builtin_nand32
-# __builtin_nand64
-# __builtin_nanf
-# __builtin_nanl
-# __builtin_nans
-# __builtin_nansf
-# __builtin_nansl
-# __builtin_object_size
-# __builtin_parity
-# __builtin_parityl
-# __builtin_parityll
-# __builtin_popcount
-# __builtin_popcountl
-# __builtin_popcountll
-# __builtin_powi
-# __builtin_powif
-# __builtin_powil
-# __builtin_prefetch
-# __builtin_trap
-# __builtin_types_compatible_p
-# __builtin_unreachable
-#
-# Unsuppored built-ins will be tested with an empty parameter set and the
-# result of the check might be wrong or meaningless so use with care.
-#
-# LICENSE
-#
-# Copyright (c) 2013 Gabriele Svelto <gabriele.svelto(a)gmail.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 3
-
-AC_DEFUN([AX_GCC_BUILTIN], [
- AS_VAR_PUSHDEF([ac_var], [ax_cv_have_$1])
-
- AC_CACHE_CHECK([for $1], [ac_var], [
- AC_LINK_IFELSE([AC_LANG_PROGRAM([], [
- m4_case([$1],
- [__builtin_assume_aligned], [$1("", 0)],
- [__builtin_bswap16], [$1(0)],
- [__builtin_bswap32], [$1(0)],
- [__builtin_bswap64], [$1(0)],
- [__builtin_choose_expr], [$1(0, 0, 0)],
- [__builtin___clear_cache], [$1("", "")],
- [__builtin_clrsb], [$1(0)],
- [__builtin_clrsbl], [$1(0)],
- [__builtin_clrsbll], [$1(0)],
- [__builtin_clz], [$1(0)],
- [__builtin_clzl], [$1(0)],
- [__builtin_clzll], [$1(0)],
- [__builtin_complex], [$1(0.0, 0.0)],
- [__builtin_constant_p], [$1(0)],
- [__builtin_ctz], [$1(0)],
- [__builtin_ctzl], [$1(0)],
- [__builtin_ctzll], [$1(0)],
- [__builtin_expect], [$1(0, 0)],
- [__builtin_ffs], [$1(0)],
- [__builtin_ffsl], [$1(0)],
- [__builtin_ffsll], [$1(0)],
- [__builtin_fpclassify], [$1(0, 1, 2, 3, 4, 0.0)],
- [__builtin_huge_val], [$1()],
- [__builtin_huge_valf], [$1()],
- [__builtin_huge_vall], [$1()],
- [__builtin_inf], [$1()],
- [__builtin_infd128], [$1()],
- [__builtin_infd32], [$1()],
- [__builtin_infd64], [$1()],
- [__builtin_inff], [$1()],
- [__builtin_infl], [$1()],
- [__builtin_isinf_sign], [$1(0.0)],
- [__builtin_nan], [$1("")],
- [__builtin_nand128], [$1("")],
- [__builtin_nand32], [$1("")],
- [__builtin_nand64], [$1("")],
- [__builtin_nanf], [$1("")],
- [__builtin_nanl], [$1("")],
- [__builtin_nans], [$1("")],
- [__builtin_nansf], [$1("")],
- [__builtin_nansl], [$1("")],
- [__builtin_object_size], [$1("", 0)],
- [__builtin_parity], [$1(0)],
- [__builtin_parityl], [$1(0)],
- [__builtin_parityll], [$1(0)],
- [__builtin_popcount], [$1(0)],
- [__builtin_popcountl], [$1(0)],
- [__builtin_popcountll], [$1(0)],
- [__builtin_powi], [$1(0, 0)],
- [__builtin_powif], [$1(0, 0)],
- [__builtin_powil], [$1(0, 0)],
- [__builtin_prefetch], [$1("")],
- [__builtin_trap], [$1()],
- [__builtin_types_compatible_p], [$1(int, int)],
- [__builtin_unreachable], [$1()],
- [m4_warn([syntax], [Unsupported built-in $1, the test may fail])
- $1()]
- )
- ])],
- [AS_VAR_SET([ac_var], [yes])],
- [AS_VAR_SET([ac_var], [no])])
- ])
-
- AS_IF([test yes = AS_VAR_GET([ac_var])],
- [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
- [Define to 1 if the system has the `$1' built-in function])], [])
-
- AS_VAR_POPDEF([ac_var])
-])
m4_include([acinclude.m4])
7 years, 4 months