master - report: revert lvs origin_size sort order change
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=538acd56f1a3cd...
Commit: 538acd56f1a3cd439028e0b9c9d6106cb820228c
Parent: 53b405093b7c13235589b2778f9236e2aabcae61
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Jun 15 01:24:16 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Jun 15 01:24:16 2013 +0100
report: revert lvs origin_size sort order change
Reinstate the previous sort order for origin_size, so that LVs with
an empty origin_size continue to appear at the start of the list
not the end.
Ref. 9d445f371c7658969d6580748233dc33c3ba0453
---
lib/report/report.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 2459ad0..47b3a33 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -35,6 +35,7 @@ struct lvm_report_object {
static const uint64_t _minusone64 = UINT64_C(-1);
static const int32_t _minusone32 = INT32_C(-1);
+static const uint64_t _zero64 = UINT64_C(0);
/*
* Data-munging functions to prepare each data type for display and sorting
@@ -608,7 +609,7 @@ static int _originsize_disp(struct dm_report *rh, struct dm_pool *mem,
uint64_t size;
if (!(size = lv_origin_size(lv))) {
- dm_report_field_set_value(field, "", NULL);
+ dm_report_field_set_value(field, "", &_zero64);
return 1;
}
9 years, 9 months
master - conf: refine lvm.conf documentation for autoactivation feature even more
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=53b405093b7c13...
Commit: 53b405093b7c13235589b2778f9236e2aabcae61
Parent: 19369cf7f33ffc4da43b7809e4bcc1a989a9d406
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jun 14 12:35:06 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jun 14 12:35:06 2013 +0200
conf: refine lvm.conf documentation for autoactivation feature even more
---
doc/example.conf.in | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/doc/example.conf.in b/doc/example.conf.in
index 5b7ed5b..94c32d5 100644
--- a/doc/example.conf.in
+++ b/doc/example.conf.in
@@ -662,13 +662,20 @@ activation {
# In this case, the user calls "vgchange --activate ay/-a ay" or
# "lvchange --activate ay/-a ay" directly.
#
- # If the VG/LV being processed does not match the list, the VG/LV is not
- # activated. If auto_activation_volume_list is not set, then all volumes
- # are activated by default.
+ # By default, the auto_activation_volume_list is not defined and all
+ # volumes will be activated either automatically or by using --activate ay/-a ay.
#
# N.B. The "activation/volume_list" is still honoured in all cases so even
# if the VG/LV passes the auto_activation_volume_list, it still needs to
# pass the volume_list for it to be activated in the end.
+
+ # If auto_activation_volume_list is defined but empty, no volumes will be
+ # activated automatically and --activate ay/-a ay will do nothing.
+ #
+ # auto_activation_volume_list = []
+
+ # If auto_activation_volume_list is defined and it's not empty, only matching
+ # volumes will be activated either automatically or by using --activate ay/-a ay.
#
# "vgname" and "vgname/lvname" are matched exactly.
# "@tag" matches any tag set in the LV or VG.
9 years, 9 months
master - typo: lvm.conf: auto_activation_list -> auto_activation_volume_list
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=19369cf7f33ffc...
Commit: 19369cf7f33ffc4da43b7809e4bcc1a989a9d406
Parent: dba53681a5d31c7f9510cf64637e2fbc707fb899
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jun 14 10:07:07 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jun 14 10:07:07 2013 +0200
typo: lvm.conf: auto_activation_list -> auto_activation_volume_list
---
doc/example.conf.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/doc/example.conf.in b/doc/example.conf.in
index 7800d15..5b7ed5b 100644
--- a/doc/example.conf.in
+++ b/doc/example.conf.in
@@ -655,7 +655,7 @@ activation {
# is triggered. This requires lvmetad (global/use_lvmetad=1) and udev
# to be running. In this case, "pvscan --cache -aay" is called
# automatically without any user intervention while processing
- # udev events. Please, make sure you define auto_activation_list
+ # udev events. Please, make sure you define auto_activation_volume_list
# properly so only the volumes you want and expect are autoactivated.
#
# - direct activation on command line with the autoactivation option.
9 years, 9 months
master - man: refine lvm.conf and man page documentation for autoactivation feature
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dba53681a5d31c...
Commit: dba53681a5d31c7f9510cf64637e2fbc707fb899
Parent: fa5d4bc7807c8ab84e65304e52532ee05ee4e172
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jun 14 09:36:56 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jun 14 10:02:56 2013 +0200
man: refine lvm.conf and man page documentation for autoactivation feature
---
WHATS_NEW | 1 +
doc/example.conf.in | 26 +++++++++++++++++++++++---
man/lvchange.8.in | 5 +++--
man/pvscan.8.in | 5 +++--
man/vgchange.8.in | 5 +++--
5 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 86b1f03..a061467 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Refine lvm.conf and man page documentation for autoactivation feature.
Add support for thin volumes in vgsplit.
Also filter partitions on mpath components if multipath_component_detection=1.
Add lvresize support for online thin pool metadata volume resize.
diff --git a/doc/example.conf.in b/doc/example.conf.in
index 9670b92..7800d15 100644
--- a/doc/example.conf.in
+++ b/doc/example.conf.in
@@ -646,9 +646,29 @@ activation {
# volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
# If auto_activation_volume_list is defined, each LV that is to be
- # activated with the autoactivation option (--activate ay/-a ay)
- # is first checked against the list. If it does not match, the LV
- # is not activated. This list is checked as well as volume_list.
+ # activated with the autoactivation option (--activate ay/-a ay) is
+ # first checked against the list. There are two scenarios in which
+ # the autoactivation option is used:
+ #
+ # - automatic activation of volumes based on incoming PVs. If all the
+ # PVs making up a VG are present in the system, the autoactivation
+ # is triggered. This requires lvmetad (global/use_lvmetad=1) and udev
+ # to be running. In this case, "pvscan --cache -aay" is called
+ # automatically without any user intervention while processing
+ # udev events. Please, make sure you define auto_activation_list
+ # properly so only the volumes you want and expect are autoactivated.
+ #
+ # - direct activation on command line with the autoactivation option.
+ # In this case, the user calls "vgchange --activate ay/-a ay" or
+ # "lvchange --activate ay/-a ay" directly.
+ #
+ # If the VG/LV being processed does not match the list, the VG/LV is not
+ # activated. If auto_activation_volume_list is not set, then all volumes
+ # are activated by default.
+ #
+ # N.B. The "activation/volume_list" is still honoured in all cases so even
+ # if the VG/LV passes the auto_activation_volume_list, it still needs to
+ # pass the volume_list for it to be activated in the end.
#
# "vgname" and "vgname/lvname" are matched exactly.
# "@tag" matches any tag set in the LV or VG.
diff --git a/man/lvchange.8.in b/man/lvchange.8.in
index 2271d4c..d5041f3 100644
--- a/man/lvchange.8.in
+++ b/man/lvchange.8.in
@@ -65,8 +65,9 @@ libdevmapper to activate (\-ay) or deactivate (\-an) the
logical volumes. If autoactivation option is used (\-aay),
the logical volume is activated only if it matches an item in
the activation/auto_activation_volume_list set in lvm.conf.
-Autoactivation is not yet supported for logical volumes that
-are part of partial or clustered volume groups.
+If this list is not set, then all volumes are considered for
+autoactivation. The autoactivation is not yet supported for
+logical volumes that are part of partial or clustered volume groups.
.IP
If clustered locking is enabled, -aey will activate exclusively
on one node and -aly will activate only on the local node.
diff --git a/man/pvscan.8.in b/man/pvscan.8.in
index 1be3109..2246744 100644
--- a/man/pvscan.8.in
+++ b/man/pvscan.8.in
@@ -47,8 +47,9 @@ Show UUIDs (Uniform Unique Identifiers) in addition to device special names.
Together with the information already cached in lvmetad, automatically activate
any logical volumes that become activatable after the scan done on one or more devices.
The logical volume to autoactivate is matched against the
-activation/auto_activation_volume_list set in lvm.conf. Autoactivation is not yet
-supported on logical volumes that are part of partial or clustered volume groups.
+activation/auto_activation_volume_list set in lvm.conf. If this list is not set, then
+all volumes are considered for autoactivation. The autoactivation is not yet
+supported for logical volumes that are part of partial or clustered volume groups.
.TP
.BR \-\-cache " [" \-\-major " " \fImajor " " \-\-minor " " \fIminor " | " \fIDevicePath " ]..."
Scan one or more devices and instruct the lvmetad daemon to update its cached
diff --git a/man/vgchange.8.in b/man/vgchange.8.in
index 0f5fc58..bc4ef32 100644
--- a/man/vgchange.8.in
+++ b/man/vgchange.8.in
@@ -70,8 +70,9 @@ group for input/output.
In other words, makes the logical volumes known/unknown to the kernel.
If autoactivation option is used (\-aay), each logical volume in
the volume group is activated only if it matches an item in the
-activation/auto_activation_volume_list set in lvm.conf.
-Autoactivation is not yet supported for partial or clustered
+activation/auto_activation_volume_list set in lvm.conf. If this
+list is not set, then all volumes are considered for autoactivation.
+The autoactivation is not yet supported for partial or clustered
volume groups.
.IP
If clustered locking is enabled, add 'e' to activate/deactivate
9 years, 9 months
master - tests: harness updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fa5d4bc7807c8a...
Commit: fa5d4bc7807c8ab84e65304e52532ee05ee4e172
Parent: 036d4f2982e8b1c34a7594307c6d2ae98cd36237
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 12 14:16:25 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 13 14:51:02 2013 +0200
tests: harness updates
---
test/lib/harness.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/test/lib/harness.c b/test/lib/harness.c
index 696d011..cea9a15 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -93,9 +93,11 @@ static int outline(FILE *out, char *buf, int start, int force) {
if (!strncmp(from, "@TESTDIR=", 9)) {
subst[0].key = "@TESTDIR@";
+ free(subst[0].value);
subst[0].value = strndup(from + 9, next - from - 9 - 1);
} else if (!strncmp(from, "@PREFIX=", 8)) {
subst[1].key = "@PREFIX@";
+ free(subst[1].value);
subst[1].value = strndup(from + 8, next - from - 8 - 1);
} else {
char *line = strndup(from, next - from);
@@ -150,6 +152,7 @@ static void trickle(FILE *out, int *last, int *counter) {
static void clear(void) {
readbuf_used = 0;
+ fullbuffer = 0;
}
static int64_t _get_time_us(void)
@@ -389,13 +392,14 @@ static void run(int i, char *f) {
failed(i, f, st);
} else
failed(i, f, st);
- clear();
+
if (outfile)
fclose(outfile);
if (fullbuffer)
printf("\nTest was interrupted, output has got too large (>%u) (loop:%u)\n"
"Set LVM_TEST_UNLIMITED=1 for unlimited log.\n",
(unsigned) readbuf_sz, fullbuffer);
+ clear();
}
}
@@ -433,16 +437,21 @@ int main(int argc, char **argv) {
}
/* set up signal handlers */
- for (i = 0; i <= 32; ++i) {
- if (i == SIGCHLD || i == SIGWINCH || i == SIGURG)
- continue;
- signal(i, handler);
- }
+ for (i = 0; i <= 32; ++i)
+ switch (i) {
+ case SIGCHLD: case SIGWINCH: case SIGURG:
+ case SIGKILL: case SIGSTOP: break;
+ default: signal(i, handler);
+ }
/* run the tests */
for (i = 1; !die && i < argc; ++i)
run(i, argv[i]);
+ free(subst[0].value);
+ free(subst[1].value);
+ free(readbuf);
+
printf("\n## %d tests %s : %d OK, %d warnings, %d failures, %d known failures; "
"%d skipped, %d interrupted\n",
s.nwarned + s.npassed + s.nfailed + s.nskipped + s.ninterrupted,
@@ -490,7 +499,5 @@ int main(int argc, char **argv) {
return (s.nfailed > 0) || (s.ninterrupted > 0) || die;
}
- free(readbuf);
-
return die;
}
9 years, 9 months
master - cleanup: tab
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=036d4f2982e8b1...
Commit: 036d4f2982e8b1c34a7594307c6d2ae98cd36237
Parent: fe22089edff17158e6d9264cd671395b2ad6e060
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 13 14:10:49 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 13 14:51:02 2013 +0200
cleanup: tab
---
tools/vgsplit.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index de41df7..6beaf34 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -181,7 +181,7 @@ static int _move_mirrors(struct volume_group *vg_from,
seg_in = 0;
for (s = 0; s < seg->area_count; s++)
if (_lv_is_in_vg(vg_to, seg_lv(seg, s)))
- seg_in++;
+ seg_in++;
log_in = !seg->log_lv;
if (seg->log_lv) {
9 years, 9 months
master - thin: vgsplit support for thins
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fe22089edff171...
Commit: fe22089edff17158e6d9264cd671395b2ad6e060
Parent: ebf0898d69f53664fa5c1f88207aa8bc970b84fc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 13 12:05:53 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 13 14:51:00 2013 +0200
thin: vgsplit support for thins
Support vgsplit for VGs with thin pools and thin volumes.
In case the thin data and thin metadata volumes are moved to a new VG,
move there also all related thin volumes and check that external origins
are also present in this new VG.
---
WHATS_NEW | 1 +
test/shell/vgsplit-thin.sh | 39 +++++++++++++++++++++++++++++++
tools/vgsplit.c | 55 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 36ad365..86b1f03 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Add support for thin volumes in vgsplit.
Also filter partitions on mpath components if multipath_component_detection=1.
Add lvresize support for online thin pool metadata volume resize.
Add helper functions find_pool_lv() and pool_can_resize_metadata().
diff --git a/test/shell/vgsplit-thin.sh b/test/shell/vgsplit-thin.sh
new file mode 100644
index 0000000..8fed1af
--- /dev/null
+++ b/test/shell/vgsplit-thin.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Test vgsplit command options for validity
+
+. lib/test
+
+aux have_thin 1 0 0 || skip
+
+aux prepare_devs 5
+
+vgcreate $vg1 $(cat DEVICES)
+lvcreate -T -L8M $vg1/pool1 -V10M -n $lv1 "$dev1" "$dev2"
+lvcreate -T -L8M $vg1/pool2 -V10M -n $lv2 "$dev3" "$dev4"
+
+# Test with external origin if available
+lvcreate -l1 -an -pr --zero n -n eorigin $vg1 "$dev5"
+aux have_thin 1 5 0 && lvcreate -an -s $vg1/eorigin -n $lv3 --thinpool $vg1/pool1
+
+# Cannot move active thin
+not vgsplit $vg1 $vg2 "$dev1" "$dev2" "$dev5"
+
+vgchange -an $vg1
+not vgsplit $vg1 $vg2 "$dev1"
+not vgsplit $vg1 $vg2 "$dev2" "$dev3"
+vgsplit $vg1 $vg2 "$dev1" "$dev2" "$dev5"
+lvs -a -o+devices $vg1 $vg2
+
+vgmerge $vg1 $vg2
+
+vgremove -ff $vg1
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index b52c2f8..de41df7 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -62,6 +62,10 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
if ((lv->status & MIRRORED))
continue;
+ if (lv_is_thin_pool(lv) ||
+ lv_is_thin_volume(lv))
+ continue;
+
/* Ensure all the PVs used by this LV remain in the same */
/* VG as each other */
vg_with = NULL;
@@ -211,6 +215,53 @@ static int _move_mirrors(struct volume_group *vg_from,
return 1;
}
+static int _move_thins(struct volume_group *vg_from,
+ struct volume_group *vg_to)
+{
+ struct dm_list *lvh, *lvht;
+ struct logical_volume *lv, *data_lv;
+ struct lv_segment *seg;
+
+ dm_list_iterate_safe(lvh, lvht, &vg_from->lvs) {
+ lv = dm_list_item(lvh, struct lv_list)->lv;
+
+ if (lv_is_thin_volume(lv)) {
+ seg = first_seg(lv);
+ data_lv = seg_lv(first_seg(seg->pool_lv), 0);
+ if ((_lv_is_in_vg(vg_to, data_lv) ||
+ _lv_is_in_vg(vg_to, seg->external_lv))) {
+ if (_lv_is_in_vg(vg_from, seg->external_lv) ||
+ _lv_is_in_vg(vg_from, data_lv)) {
+ log_error("Can't split external origin %s "
+ "and pool %s between two Volume Groups.",
+ seg->external_lv->name,
+ seg->pool_lv->name);
+ return 0;
+ }
+ if (!_move_one_lv(vg_from, vg_to, lvh))
+ return_0;
+ }
+ } else if (lv_is_thin_pool(lv)) {
+ seg = first_seg(lv);
+ data_lv = seg_lv(seg, 0);
+ if (_lv_is_in_vg(vg_to, data_lv) ||
+ _lv_is_in_vg(vg_to, seg->metadata_lv)) {
+ if (_lv_is_in_vg(vg_from, seg->metadata_lv) ||
+ _lv_is_in_vg(vg_from, data_lv)) {
+ log_error("Can't split pool data and metadata %s "
+ "between two Volume Groups.",
+ lv->name);
+ return 0;
+ }
+ if (!_move_one_lv(vg_from, vg_to, lvh))
+ return_0;
+ }
+ }
+ }
+
+ return 1;
+}
+
/*
* Create or open the destination of the vgsplit operation.
* Returns
@@ -430,6 +481,10 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (!(_move_snapshots(vg_from, vg_to)))
goto_bad;
+ /* Move required pools across */
+ if (!(_move_thins(vg_from, vg_to)))
+ goto_bad;
+
/* Split metadata areas and check if both vgs have at least one area */
if (!(vg_split_mdas(cmd, vg_from, vg_to)) && vg_from->pv_count) {
log_error("Cannot split: Nowhere to store metadata for new Volume Group");
9 years, 9 months
master - dev-type: refine dev_get_primary_dev return codes and add more comments
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ebf0898d69f536...
Commit: ebf0898d69f53664fa5c1f88207aa8bc970b84fc
Parent: 56ee1de7e4509aff264d2c682e7690101248b73d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 12 14:33:28 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jun 12 14:33:28 2013 +0200
dev-type: refine dev_get_primary_dev return codes and add more comments
---
lib/device/dev-md.c | 2 +-
lib/device/dev-type.c | 30 ++++++++++++++++++++++--------
lib/filters/filter-mpath.c | 6 +++---
3 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/lib/device/dev-md.c b/lib/device/dev-md.c
index 84d9ce3..a8bbe81 100644
--- a/lib/device/dev-md.c
+++ b/lib/device/dev-md.c
@@ -141,7 +141,7 @@ static int _md_sysfs_attribute_snprintf(char *path, size_t size,
if (MAJOR(dev) == dt->blkext_major) {
/* lookup parent MD device from blkext partition */
- if (dev_get_primary_dev(dt, blkdev, &dev) < 1)
+ if (!dev_get_primary_dev(dt, blkdev, &dev))
return ret;
}
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index b28fe75..39777f1 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -203,7 +203,7 @@ int dev_subsystem_part_major(struct dev_types *dt, struct device *dev)
return 1;
if ((MAJOR(dev->dev) == dt->blkext_major) &&
- (dev_get_primary_dev(dt, dev, &primary_dev) > 0) &&
+ dev_get_primary_dev(dt, dev, &primary_dev) &&
(MAJOR(primary_dev) == dt->md_major))
return 1;
@@ -320,10 +320,24 @@ int dev_is_partitioned(struct dev_types *dt, struct device *dev)
/*
* Get primary dev for the dev supplied.
+ *
+ * We can get a primary device for a partition either by:
+ * A: knowing the number of partitions allowed for the dev and also
+ * which major:minor number represents the primary and partition device
+ * (by using the dev_types->dev_type_array)
+ * B: by the existence of the 'partition' sysfs attribute
+ * (/dev/block/<major>:<minor>/partition)
+ *
+ * Method A is tried first, then method B as a fallback if A fails.
+ *
+ * N.B. Method B can only do the decision based on the pure existence of
+ * the 'partition' sysfs item. There's no direct scan for partition
+ * tables whatsoever!
+ *
* Returns:
- * 0 if the dev is already a primary dev
- * 1 if the dev is a partition, primary dev in result
- * -1 on error
+ * 0 on error
+ * 1 if the dev is already a primary dev, primary dev in 'result'
+ * 2 if the dev is a partition, primary dev in 'result'
*/
int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
{
@@ -344,10 +358,10 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
if ((parts = dt->dev_type_array[major].max_partitions) > 1) {
if ((residue = minor % parts)) {
*result = MKDEV((dev_t)major, (minor - residue));
- ret = 1;
+ ret = 2;
} else {
*result = dev->dev;
- ret = 0; /* dev is not a partition! */
+ ret = 1; /* dev is not a partition! */
}
goto out;
}
@@ -370,7 +384,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
if (errno != ENOENT)
log_sys_error("stat", path);
*result = dev->dev;
- ret = 0; goto out; /* dev is not a partition! */
+ ret = 1; goto out; /* dev is not a partition! */
}
@@ -465,7 +479,7 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
log_sys_error("stat", path);
return 0;
}
- if (dev_get_primary_dev(dt, dev, &primary) < 0)
+ if (!dev_get_primary_dev(dt, dev, &primary))
return 0;
/* get attribute from partition's primary device */
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
index 16e2105..76d8a2d 100644
--- a/lib/filters/filter-mpath.c
+++ b/lib/filters/filter-mpath.c
@@ -130,14 +130,14 @@ static int dev_is_mpath(struct dev_filter *f, struct device *dev)
return 0;
switch (dev_get_primary_dev(dt, dev, &primary_dev)) {
- case -1:
+ case 0:
/* Error. */
log_error("Failed to get primary device for %d:%d.", major, minor);
return 0;
- case 0:
+ case 1:
/* The dev is already a primary dev. Just continue with the dev. */
break;
- case 1:
+ case 2:
/* The dev is partition. */
name = dev_name(dev); /* name of original dev for log_debug msg */
9 years, 9 months
master - distclean: add missing items
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=56ee1de7e4509a...
Commit: 56ee1de7e4509aff264d2c682e7690101248b73d
Parent: 8bade9bfeae9b4205472d70232676d70412eefa8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 12 12:51:38 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jun 12 13:14:49 2013 +0200
distclean: add missing items
These were missing in distclean target under scripts dir:
blk_availability_init_red_hat
blk_availability_systemd_red_hat.service
blkdeactivate.sh
---
scripts/Makefile.in | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 91e2e94..a658903 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -118,4 +118,6 @@ DISTCLEAN_TARGETS += clvmd_init_red_hat cmirrord_init_red_hat \
dm_event_systemd_red_hat.socket dm_event_systemd_red_hat.service \
lvm2_monitoring_systemd_red_hat.service \
lvm2_lvmetad_systemd_red_hat.socket lvm2_lvmetad_systemd_red_hat.service \
- lvm2_tmpfiles_red_hat.conf
+ lvm2_tmpfiles_red_hat.conf blk_availability_init_red_hat \
+ blk_availability_systemd_red_hat.service \
+ blkdeactivate.sh
9 years, 9 months
master - cleanup: remove old and unused code to detect partition types
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8bade9bfeae9b4...
Commit: 8bade9bfeae9b4205472d70232676d70412eefa8
Parent: 966d4f36d7fb29734c6176e21a139375c431eeac
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 12 12:46:46 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jun 12 13:14:49 2013 +0200
cleanup: remove old and unused code to detect partition types
This part of the code has not been used for ages, if ever.
If needed anytime in future, we should use some library
instead - libblkid?
---
lib/device/dev-type.c | 181 -------------------------------------------------
1 files changed, 0 insertions(+), 181 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 92120e8..b28fe75 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -428,187 +428,6 @@ out:
return ret;
}
-#if 0
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <linux/fs.h>
-#include <linux/major.h>
-#include <linux/genhd.h>
-
-int _get_partition_type(struct dev_filter *filter, struct device *d);
-
-#define MINOR_PART(dev) (MINOR((dev)->dev) % max_partitions(MINOR((dev)->dev)))
-
-int is_extended_partition(struct device *d)
-{
- return (MINOR_PART(d) > 4) ? 1 : 0;
-}
-
-struct device *dev_primary(struct dev_mgr *dm, struct device *d)
-{
- struct device *ret;
-
- ret = dev_by_dev(dm, d->dev - MINOR_PART(dm, d));
- /* FIXME: Needs replacing with a 'refresh' */
- if (!ret) {
- init_dev_scan(dm);
- ret = dev_by_dev(dm, d->dev - MINOR_PART(dm, d));
- }
-
- return ret;
-
-}
-
-int partition_type_is_lvm(struct dev_mgr *dm, struct device *d)
-{
- int pt;
-
- pt = _get_partition_type(dm, d);
-
- if (!pt) {
- if (is_whole_disk(dm, d))
- /* FIXME: Overloaded pt=0 in error cases */
- return 1;
- else {
- log_error
- ("%s: missing partition table "
- "on partitioned device", d->name);
- return 0;
- }
- }
-
- if (is_whole_disk(dm, d)) {
- log_error("%s: looks to possess partition table", d->name);
- return 0;
- }
-
- /* check part type */
- if (pt != LVM_PARTITION && pt != LVM_NEW_PARTITION) {
- log_error("%s: invalid partition type 0x%x "
- "(must be 0x%x)", d->name, pt, LVM_NEW_PARTITION);
- return 0;
- }
-
- if (pt == LVM_PARTITION) {
- log_error
- ("%s: old LVM partition type found - please change to 0x%x",
- d->name, LVM_NEW_PARTITION);
- return 0;
- }
-
- return 1;
-}
-
-int _get_partition_type(struct dev_mgr *dm, struct device *d)
-{
- int pv_handle = -1;
- struct device *primary;
- ssize_t read_ret;
- ssize_t bytes_read = 0;
- char *buffer;
- unsigned short *s_buffer;
- struct partition *part;
- loff_t offset = 0;
- loff_t extended_offset = 0;
- int part_sought;
- int part_found = 0;
- int first_partition = 1;
- int extended_partition = 0;
- int p;
-
- if (!(primary = dev_primary(dm, d))) {
- log_error
- ("Failed to find main device containing partition %s",
- d->name);
- return 0;
- }
-
- if (!(buffer = dm_malloc(SECTOR_SIZE))) {
- log_error("Failed to allocate partition table buffer");
- return 0;
- }
-
- /* Get partition table */
- if ((pv_handle = open(primary->name, O_RDONLY)) < 0) {
- log_error("%s: open failed: %s", primary->name,
- strerror(errno));
- return 0;
- }
-
- s_buffer = (unsigned short *) buffer;
- part = (struct partition *) (buffer + 0x1be);
- part_sought = MINOR_PART(dm, d);
-
- do {
- bytes_read = 0;
-
- if (llseek(pv_handle, offset * SECTOR_SIZE, SEEK_SET) == -1) {
- log_error("%s: llseek failed: %s",
- primary->name, strerror(errno));
- return 0;
- }
-
- while ((bytes_read < SECTOR_SIZE) &&
- (read_ret =
- read(pv_handle, buffer + bytes_read,
- SECTOR_SIZE - bytes_read)) != -1)
- bytes_read += read_ret;
-
- if (read_ret == -1) {
- log_error("%s: read failed: %s", primary->name,
- strerror(errno));
- return 0;
- }
-
- if (s_buffer[255] == 0xAA55) {
- if (is_whole_disk(dm, d))
- return -1;
- } else
- return 0;
-
- extended_partition = 0;
-
- /* Loop through primary partitions */
- for (p = 0; p < 4; p++) {
- if (part[p].sys_ind == DOS_EXTENDED_PARTITION ||
- part[p].sys_ind == LINUX_EXTENDED_PARTITION
- || part[p].sys_ind == WIN98_EXTENDED_PARTITION) {
- extended_partition = 1;
- offset = extended_offset + part[p].start_sect;
- if (extended_offset == 0)
- extended_offset = part[p].start_sect;
- if (first_partition == 1)
- part_found++;
- } else if (first_partition == 1) {
- if (p == part_sought) {
- if (part[p].sys_ind == 0) {
- /* missing primary? */
- return 0;
- }
- } else
- part_found++;
- } else if (!part[p].sys_ind)
- part_found++;
-
- if (part_sought == part_found)
- return part[p].sys_ind;
-
- }
- first_partition = 0;
- }
- while (extended_partition == 1);
-
- return 0;
-}
-#endif
-
#ifdef linux
static unsigned long _dev_topology_attribute(struct dev_types *dt,
9 years, 9 months