master - mirror: fix flushing for mirror target
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d4c03cf7b21279...
Commit: d4c03cf7b21279ad28b8b9944d0281a55692efcc
Parent: 76fc41fb9d06519d7410f0054c279ea3a8dccc37
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Apr 5 21:34:42 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 6 11:31:02 2016 +0200
mirror: fix flushing for mirror target
Fix regression caused by commit ba41ee1dc94264f7ac8e61f8b1d56b10225b0d2f.
The idea was to use no_flush for changed device only for thin volumes
and thin pools but also to merge this with change made in commit
844b00958492224c448b30f89ae5532bb6591fd2.
However the resulting condition has caused misbehavior for the mirror
suspend - as that has been before the ONLY allowed target type
that could have been suspended with noflush.
Result was badly working repair for --type mirror that has been
passing 'flush' to the repaired mirror target whenever preload
wrongly set flush_required.
The origin code has required the flush_required to be set whenever
deivce size is changed.
Now it first detects if device size got smaller
'dm_tree_node_size_changed(root) < 0' - this requires flush.
Otherwise it checks device is not thin volume nor thin pool and its
size has changed (got bigger) and requires flush.
This mean upsize of thin-pool or thin volume will not require flush.
---
lib/activate/dev_manager.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 3563d5a..22331c3 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -3044,12 +3044,11 @@ static int _tree_action(struct dev_manager *dm, const struct logical_volume *lv,
if ((dm_tree_node_size_changed(root) < 0))
dm->flush_required = 1;
-
/* Currently keep the code require flush for any
- * non 'thin pool/volume, mirror' or with any size change */
- if (!lv_is_thin_volume(lv) &&
- !lv_is_thin_pool(lv) &&
- (!lv_is_mirror(lv) || dm_tree_node_size_changed(root)))
+ * non 'thin pool/volume' and size increase */
+ else if (!lv_is_thin_volume(lv) &&
+ !lv_is_thin_pool(lv) &&
+ dm_tree_node_size_changed(root))
dm->flush_required = 1;
if (action == ACTIVATE) {
8 years
v2_02_149 annotated tag has been created
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7a02139d225514...
Commit: 7a02139d22551405d4317671a312ef5cc20c2db0
Parent: 0000000000000000000000000000000000000000
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: 2016-04-01 19:30 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: 2016-04-01 19:30 +0000
annotated tag: v2_02_149 has been created
at 7a02139d22551405d4317671a312ef5cc20c2db0 (tag)
tagging 2d0d58b8679f0d071c194db34660a112ae0f3204 (commit)
replaces v2_02_148
Release 2.02.149.
A small development release including fixes for some recent changes.
21 files changed, 265 insertions(+), 77 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAlb+zK8ACgkQIoGRwVZ+LBc/SQCfVsGYacni96Ps6N01aXCdqgFU
EHUAn25BkfYNAAbt5Ob6PIEVIaGjmzD+
=DzKi
-----END PGP SIGNATURE-----
Alasdair G Kergon (3):
post-commit
Revert "thin: display highest mapped sector"
pre-release
Marian Csontos (1):
test: Add missing directory
Peter Rajnoha (13):
dev-cache: handle situation where device is referenced in sysfs, but the node is not yet in dev dir
dev-cache: also index VGIDs and LVIDs if using persistent .cache file
dev-cache: remove spurious error msg if no value found in /sys/dev/block/<major>:<minor>/dm/uuid during dev scan
dev-cache: dev_cache_index_devs fn is available unconditionally
doc: describe lvmlockd/lvmpolld features as available if LVM compiled with lockd/polld support
dev-cache: fix check for already indexed dev in _index_dev_by_vgid_and_lvid
tests: vg-check-devs-used requires driver version 4.15 at least
refactor: dev-cache: use btree instead of hash table for sysfs-only devices
refactor: dev-cache: move code adding sysfs-only device into separate fn
dev-cache: also add dev name for device found in sysfs only
dev-cache: iterate devices in sysfs for VGID/LVID index if obtain_device_list_from_udev=0
fix: make udev_get_library_context available also for non-udev compilations
dev-cache: skip VGID/LVID indexing if /sys/dev/block is not present
Zdenek Kabelac (7):
thin: no thin-pool flush when reading metadata status
thin: display highest mapped sector
cleanup: debug message fix
cleanup: use TARGET define
cleanup: use local var to read struct
tests: do not test settings when MQ is emulated by SMQ
tests: fixed cache target reacts faster
8 years
master - post-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=76fc41fb9d0651...
Commit: 76fc41fb9d06519d7410f0054c279ea3a8dccc37
Parent: 2d0d58b8679f0d071c194db34660a112ae0f3204
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Apr 1 20:36:40 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Apr 1 20:36:40 2016 +0100
post-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 3 +++
WHATS_NEW_DM | 3 +++
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/VERSION b/VERSION
index 084a9cd..3a2d7d1 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.149(2)-git (2016-04-01)
+2.02.150(2)-git (2016-04-01)
diff --git a/VERSION_DM b/VERSION_DM
index 7fab3bb..77d3356 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.121-git (2016-04-01)
+1.02.122-git (2016-04-01)
diff --git a/WHATS_NEW b/WHATS_NEW
index 32bb212..98168a1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,6 @@
+Version 2.02.150 -
+=================================
+
Version 2.02.149 - 1st April 2016
=================================
Do not flush thin-pool when checking metadata fullness.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 3f044da..d84f8cf 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,6 @@
+Version 1.02.122 -
+==================================
+
Version 1.02.121 - 26th March 2016
==================================
Adjust raid status function.
8 years
master - pre-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2d0d58b8679f0d...
Commit: 2d0d58b8679f0d071c194db34660a112ae0f3204
Parent: 60befab7732d33bc29f796b6ff3743969b328240
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Apr 1 20:29:52 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Apr 1 20:29:52 2016 +0100
pre-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 4 ++--
WHATS_NEW_DM | 3 ---
man/vgcreate.8.in | 2 +-
5 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/VERSION b/VERSION
index 48f77ed..084a9cd 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.149(2)-git (2016-03-26)
+2.02.149(2)-git (2016-04-01)
diff --git a/VERSION_DM b/VERSION_DM
index defda54..7fab3bb 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.122-git (2016-03-26)
+1.02.121-git (2016-04-01)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3237e0a..32bb212 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,5 @@
-Version 2.02.149 -
-==================================
+Version 2.02.149 - 1st April 2016
+=================================
Do not flush thin-pool when checking metadata fullness.
Remove spurious error about no value in /sys/dev/block/major:minor/dm/uuid.
Fix device mismatch detection for LV if persistent .cache file is used.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index d84f8cf..3f044da 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,6 +1,3 @@
-Version 1.02.122 -
-==================================
-
Version 1.02.121 - 26th March 2016
==================================
Adjust raid status function.
diff --git a/man/vgcreate.8.in b/man/vgcreate.8.in
index b0b01e4..764d76e 100644
--- a/man/vgcreate.8.in
+++ b/man/vgcreate.8.in
@@ -130,7 +130,7 @@ The 2.4 kernel has a limitation of 2TiB per block device.
.TP
.B \-\-shared
-Create a shared VG using lvmlockd if LVM is copiled with lockd support.
+Create a shared VG using lvmlockd if LVM is compiled with lockd support.
lvmlockd will select lock type sanlock or dlm depending on which lock
manager is running. This allows multiple hosts to share a VG on shared
devices. lvmlockd and a lock manager must be configured and running. See
8 years
master - Revert "thin: display highest mapped sector"
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=60befab7732d33...
Commit: 60befab7732d33bc29f796b6ff3743969b328240
Parent: 42f04a0f77ee94b01d652d6c11d10e85aa46a897
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Apr 1 20:09:38 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Apr 1 20:09:38 2016 +0100
Revert "thin: display highest mapped sector"
This reverts commit fc7dacaa4c6bf0af4c5a457c098da26d7cc71f9c.
Let's put this information into a separate field. It doesn't meet the
definition of the existing field.
---
WHATS_NEW | 1 -
lib/activate/dev_manager.c | 4 ----
lib/thin/thin.c | 15 ++++++---------
3 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2ad2d69..3237e0a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,6 +1,5 @@
Version 2.02.149 -
==================================
- Report highest mapping for thin volume as Meta%.
Do not flush thin-pool when checking metadata fullness.
Remove spurious error about no value in /sys/dev/block/major:minor/dm/uuid.
Fix device mismatch detection for LV if persistent .cache file is used.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 5341b54..3563d5a 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -938,10 +938,6 @@ static int _percent_run(struct dev_manager *dm, const char *name,
if (!segtype->ops->target_percent)
continue;
- /* For thin volume pass device size via 'total_numerator' */
- if (!seg && segtype_is_thin_volume(segtype))
- total_numerator = length - 1; /* highest mapped is 0 .. (length - 1) */
-
if (!segtype->ops->target_percent(&dm->target_state,
&percent, dm->mem,
dm->cmd, seg, params,
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index c07859a..a850757 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -613,7 +613,7 @@ static int _thin_add_target_line(struct dev_manager *dm,
static int _thin_target_percent(void **target_state __attribute__((unused)),
dm_percent_t *percent,
struct dm_pool *mem,
- struct cmd_context *cmd,
+ struct cmd_context *cmd __attribute__((unused)),
struct lv_segment *seg,
char *params,
uint64_t *total_numerator,
@@ -643,18 +643,15 @@ static int _thin_target_percent(void **target_state __attribute__((unused)),
*percent = dm_make_percent(s->mapped_sectors, csize);
*total_denominator += csize;
- *total_numerator += s->mapped_sectors;
} else {
- /* Using denominator to pass the mapped info upward? */
- if (s->highest_mapped_sector > *total_numerator) {
- log_warn("WARNING: highest mapped sector %s is above device size.",
- display_size(cmd, s->highest_mapped_sector));
- s->highest_mapped_sector = *total_numerator;
- }
- *percent = dm_make_percent(s->highest_mapped_sector, *total_numerator);
+ /* No lv_segment info here */
+ *percent = DM_PERCENT_INVALID;
+ /* FIXME: Using denominator to pass the mapped info upward? */
*total_denominator += s->highest_mapped_sector;
}
+ *total_numerator += s->mapped_sectors;
+
return 1;
}
8 years
master - dev-cache: skip VGID/LVID indexing if /sys/dev/block is not present
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=42f04a0f77ee94...
Commit: 42f04a0f77ee94b01d652d6c11d10e85aa46a897
Parent: 9f28eb4c20ecb772f1b8a912c43f243d63a7e5f3
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Apr 1 17:04:11 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Apr 1 17:09:15 2016 +0200
dev-cache: skip VGID/LVID indexing if /sys/dev/block is not present
/sys/dev/block is available since kernel version 2.2.26 (~ 2008):
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-dev
The VGID/LVID indexing code relies on this feature so skip indexing
if it's not available to avoid error messages about inability to open
/sys/dev/block directory.
We're not going to provide fallback code to read the /sys/block/
instead in this case as that's not that efficient - it needs extra
reads for getting major:minor and reading partitions would also
pose further reads and that's not worth it.
---
lib/device/dev-cache.c | 35 +++++++++++++++++++++++++++--------
1 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 84bd85b..8461f40 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -818,9 +818,8 @@ static int _dev_cache_iterate_devs_for_index(void)
return r;
}
-static int _dev_cache_iterate_sysfs_for_index(void)
+static int _dev_cache_iterate_sysfs_for_index(const char *path)
{
- char path[PATH_MAX];
char devname[PATH_MAX];
DIR *d;
struct dirent *dirent;
@@ -830,11 +829,6 @@ static int _dev_cache_iterate_sysfs_for_index(void)
int partial_failure = 0;
int r = 0;
- if (dm_snprintf(path, sizeof(path), "%sdev/block", dm_sysfs_dir()) < 0) {
- log_error("_dev_cache_iterate_sysfs_for_index: dm_snprintf failed.");
- return 0;
- }
-
if (!(d = opendir(path))) {
log_sys_error("opendir", path);
return 0;
@@ -876,11 +870,36 @@ static int _dev_cache_iterate_sysfs_for_index(void)
int dev_cache_index_devs(void)
{
+ static int sysfs_has_dev_block = -1;
+ char path[PATH_MAX];
+
+ if (dm_snprintf(path, sizeof(path), "%sdev/block", dm_sysfs_dir()) < 0) {
+ log_error("dev_cache_index_devs: dm_snprintf failed.");
+ return 0;
+ }
+
+ /* Skip indexing if /sys/dev/block is not available.*/
+ if (sysfs_has_dev_block == -1) {
+ struct stat info;
+ if (stat(path, &info) == 0)
+ sysfs_has_dev_block = 1;
+ else {
+ if (errno == ENOENT) {
+ sysfs_has_dev_block = 0;
+ return 1;
+ } else {
+ log_sys_error("stat", path);
+ return 0;
+ }
+ }
+ } else if (!sysfs_has_dev_block)
+ return 1;
+
int with_udev = obtain_device_list_from_udev() &&
udev_get_library_context();
return with_udev ? _dev_cache_iterate_devs_for_index()
- : _dev_cache_iterate_sysfs_for_index();
+ : _dev_cache_iterate_sysfs_for_index(path);
}
#ifdef UDEV_SYNC_SUPPORT
8 years
master - fix: make udev_get_library_context available also for non-udev compilations
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9f28eb4c20ecb7...
Commit: 9f28eb4c20ecb772f1b8a912c43f243d63a7e5f3
Parent: 15d1824facce1ac38c2669b17c8c0965b8c18f3e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Apr 1 15:35:13 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Apr 1 15:35:22 2016 +0200
fix: make udev_get_library_context available also for non-udev compilations
If compiling without udev_sync support, udev_get_library_context simply
returns NULL so we don't need to remember putting ifdef UDEV_SYNC_SUPPORT
in the code all the time we just need to check whether there's any udev
context initialized or not.
---
lib/misc/lvm-wrappers.c | 7 ++++++-
lib/misc/lvm-wrappers.h | 6 +-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/misc/lvm-wrappers.c b/lib/misc/lvm-wrappers.c
index e8e2e92..e2b14aa 100644
--- a/lib/misc/lvm-wrappers.c
+++ b/lib/misc/lvm-wrappers.c
@@ -66,7 +66,7 @@ bad:
return 0;
}
-struct udev* udev_get_library_context(void)
+void *udev_get_library_context(void)
{
return _udev;
}
@@ -78,6 +78,11 @@ int udev_init_library_context(void)
return 1;
}
+void *udev_get_library_context(void)
+{
+ return NULL;
+}
+
void udev_fin_library_context(void)
{
}
diff --git a/lib/misc/lvm-wrappers.h b/lib/misc/lvm-wrappers.h
index c2d5123..3c45aff 100644
--- a/lib/misc/lvm-wrappers.h
+++ b/lib/misc/lvm-wrappers.h
@@ -16,12 +16,8 @@
#ifndef _LVM_WRAPPERS_H
#define _LVM_WRAPPERS_H
-#ifdef UDEV_SYNC_SUPPORT
-struct udev;
-struct udev *udev_get_library_context(void);
-#endif
-
int udev_init_library_context(void);
+void *udev_get_library_context(void);
void udev_fin_library_context(void);
int udev_is_running(void);
8 years
master - dev-cache: iterate devices in sysfs for VGID/LVID index if obtain_device_list_from_udev=0
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=15d1824facce1a...
Commit: 15d1824facce1ac38c2669b17c8c0965b8c18f3e
Parent: 7ed5a65ee5ccb92de388977cff0dc697045ffc09
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Apr 1 11:34:09 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Apr 1 14:49:39 2016 +0200
dev-cache: iterate devices in sysfs for VGID/LVID index if obtain_device_list_from_udev=0
If obtain_device_list_from_udev=0, LVM can make use of persistent .cache
file. This cache file contains only devices which underwent filters in
previous LVM command run. But we need to iterate over all block devices
to create the VGID/LVID index completely for the device mismatch check
to be complete as well.
This patch iterates over block devices found in sysfs to generate the
VGID/LVID index in dev cache if obtain_device_list_from_udev=0
(if obtain_device_list_from_udev=1, we always read complete list of
block devices from udev and we ignore .cache file so we don't need
to look in sysfs for the complete list).
---
lib/device/dev-cache.c | 82 +++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 74 insertions(+), 8 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 27540d9..84bd85b 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -684,14 +684,15 @@ static int _insert_dev(const char *path, dev_t d)
}
/* is this device already registered ? */
- if (!(dev = (struct device *) btree_lookup(_cache.devices,
- (uint32_t) d))) {
- /* create new device */
- if (loopfile) {
- if (!(dev = dev_create_file(path, NULL, NULL, 0)))
+ if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) d))) {
+ if (!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) d))) {
+ /* create new device */
+ if (loopfile) {
+ if (!(dev = dev_create_file(path, NULL, NULL, 0)))
+ return_0;
+ } else if (!(dev = _dev_create(d)))
return_0;
- } else if (!(dev = _dev_create(d)))
- return_0;
+ }
if (!(btree_insert(_cache.devices, (uint32_t) d, dev))) {
log_error("Couldn't insert device into binary tree.");
@@ -799,7 +800,7 @@ static int _insert_file(const char *path)
return 1;
}
-int dev_cache_index_devs(void)
+static int _dev_cache_iterate_devs_for_index(void)
{
struct btree_iter *iter = btree_first(_cache.devices);
struct device *dev;
@@ -817,6 +818,71 @@ int dev_cache_index_devs(void)
return r;
}
+static int _dev_cache_iterate_sysfs_for_index(void)
+{
+ char path[PATH_MAX];
+ char devname[PATH_MAX];
+ DIR *d;
+ struct dirent *dirent;
+ int major, minor;
+ dev_t devno;
+ struct device *dev;
+ int partial_failure = 0;
+ int r = 0;
+
+ if (dm_snprintf(path, sizeof(path), "%sdev/block", dm_sysfs_dir()) < 0) {
+ log_error("_dev_cache_iterate_sysfs_for_index: dm_snprintf failed.");
+ return 0;
+ }
+
+ if (!(d = opendir(path))) {
+ log_sys_error("opendir", path);
+ return 0;
+ }
+
+ while ((dirent = readdir(d))) {
+ if (!strcmp(".", dirent->d_name) ||
+ !strcmp("..", dirent->d_name))
+ continue;
+
+ if (sscanf(dirent->d_name, "%d:%d", &major, &minor) != 2) {
+ log_error("_dev_cache_iterate_sysfs_for_index: %s: failed "
+ "to get major and minor number", dirent->d_name);
+ partial_failure = 1;
+ continue;
+ }
+
+ devno = MKDEV(major, minor);
+ if (!(dev = (struct device *) btree_lookup(_cache.devices, (uint32_t) devno)) &&
+ !(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) devno))) {
+ if (!dm_device_get_name(major, minor, 1, devname, sizeof(devname)) ||
+ !(dev = _insert_sysfs_dev(devno, devname))) {
+ partial_failure = 1;
+ continue;
+ }
+ }
+
+ if (!_index_dev_by_vgid_and_lvid(dev))
+ partial_failure = 1;
+ }
+
+ r = !partial_failure;
+
+ if (closedir(d))
+ log_sys_error("closedir", path);
+
+ return r;
+}
+
+int dev_cache_index_devs(void)
+{
+ int with_udev = obtain_device_list_from_udev() &&
+ udev_get_library_context();
+
+ return with_udev ? _dev_cache_iterate_devs_for_index()
+ : _dev_cache_iterate_sysfs_for_index();
+}
+
#ifdef UDEV_SYNC_SUPPORT
static int _device_in_udev_db(const dev_t d)
8 years
master - dev-cache: also add dev name for device found in sysfs only
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7ed5a65ee5ccb9...
Commit: 7ed5a65ee5ccb92de388977cff0dc697045ffc09
Parent: 91d32f9d1ba1ff3bed0f47104721e97960df3878
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Apr 1 10:09:03 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Apr 1 14:48:56 2016 +0200
dev-cache: also add dev name for device found in sysfs only
For the case when we print device name associated with struct device
that was not found in /dev, but in sysfs, for example when printing
devices where LV device mismatch is found.
---
lib/device/dev-cache.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 12dcceb..27540d9 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -433,11 +433,29 @@ static struct dm_list *_get_or_add_list_by_index_key(struct dm_hash_table *idx,
static struct device *_insert_sysfs_dev(dev_t devno, const char *devname)
{
+ char path[PATH_MAX];
+ char *path_copy;
struct device *dev;
+ if (dm_snprintf(path, sizeof(path), "%s%s", _cache.dev_dir, devname) < 0) {
+ log_error("_insert_sysfs_dev: %s: dm_snprintf failed", devname);
+ return NULL;
+ }
+
if (!(dev = _dev_create(devno)))
return_NULL;
+ if (!(path_copy = dm_pool_strdup(_cache.mem, path))) {
+ log_error("_insert_sysfs_dev: %s: dm_pool_strdup failed", devname);
+ return NULL;
+ }
+
+ if (!_add_alias(dev, path_copy)) {
+ log_error("Couldn't add alias to dev cache.");
+ _free(dev);
+ return NULL;
+ }
+
if (!btree_insert(_cache.sysfs_only_devices, (uint32_t) devno, dev)) {
log_error("Couldn't add device to binary tree of sysfs-only devices in dev cache.");
_free(dev);
8 years
master - refactor: dev-cache: move code adding sysfs-only device into separate fn
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=91d32f9d1ba1ff...
Commit: 91d32f9d1ba1ff3bed0f47104721e97960df3878
Parent: 0e774d5ae77fb67c7a015d9bb8e4c289dd8fa2e4
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Apr 1 09:41:41 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Apr 1 11:47:06 2016 +0200
refactor: dev-cache: move code adding sysfs-only device into separate fn
---
lib/device/dev-cache.c | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index d99352b..12dcceb 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -431,6 +431,22 @@ static struct dm_list *_get_or_add_list_by_index_key(struct dm_hash_table *idx,
return list;
}
+static struct device *_insert_sysfs_dev(dev_t devno, const char *devname)
+{
+ struct device *dev;
+
+ if (!(dev = _dev_create(devno)))
+ return_NULL;
+
+ if (!btree_insert(_cache.sysfs_only_devices, (uint32_t) devno, dev)) {
+ log_error("Couldn't add device to binary tree of sysfs-only devices in dev cache.");
+ _free(dev);
+ return NULL;
+ }
+
+ return dev;
+}
+
static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *devname)
{
char path[PATH_MAX];
@@ -440,7 +456,7 @@ static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev
struct device *dev;
if (dm_snprintf(path, sizeof(path), "%sblock/%s/dev", dm_sysfs_dir(), devname) < 0) {
- log_error("_get_device_for_non_dm_dev: %s: dm_snprintf failed", devname);
+ log_error("_get_device_for_sysfs_dev_name_using_devno: %s: dm_snprintf failed", devname);
return NULL;
}
@@ -448,7 +464,7 @@ static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev
return_NULL;
if (sscanf(buf, "%d:%d", &major, &minor) != 2) {
- log_error("_get_device_for_non_dm_dev: %s: failed to get major and minor number", devname);
+ log_error("_get_device_for_sysfs_dev_name_using_devno: %s: failed to get major and minor number", devname);
return NULL;
}
@@ -465,14 +481,9 @@ static struct device *_get_device_for_sysfs_dev_name_using_devno(const char *dev
* where different directory for dev nodes is used (e.g. our test suite). So track
* such devices in _cache.sysfs_only_devices hash for the vgid/lvid check to work still.
*/
- if (!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) devno))) {
- if (!(dev = _dev_create(devno)))
- return_NULL;
- if (!btree_insert(_cache.sysfs_only_devices, (uint32_t) devno, dev)) {
- log_error("Couldn't add device to binary tree of sysfs-only devices in dev cache.");
- return NULL;
- }
- }
+ if (!(dev = (struct device *) btree_lookup(_cache.sysfs_only_devices, (uint32_t) devno)) &&
+ !(dev = _insert_sysfs_dev(devno, devname)))
+ return_NULL;
}
return dev;
8 years