public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/device/dev-cache.c
@ 2011-12-21 13:14 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-12-21 13:14 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-12-21 13:14:54
Modified files:
. : WHATS_NEW
lib/device : dev-cache.c
Log message:
Always zalloc device structure
Since there is zalloc behind the macro, put 'z' into the name.
Make the 'use_malloc' code path also using zalloc() call,
so it also give zeroed area.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2209&r2=1.2210
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67
--- LVM2/WHATS_NEW 2011/12/21 13:03:06 1.2209
+++ LVM2/WHATS_NEW 2011/12/21 13:14:54 1.2210
@@ -1,5 +1,6 @@
Version 2.02.89 -
==================================
+ Always zalloc device structure during initialization.
Fix missing thread list manipulation protection in dmeventd.
Do not derefence lv pointer in _percent_run() function before NULL check.
Allow empty strings for description and creation_host config fields.
--- LVM2/lib/device/dev-cache.c 2011/08/30 14:55:16 1.66
+++ LVM2/lib/device/dev-cache.c 2011/12/21 13:14:54 1.67
@@ -48,7 +48,7 @@
} _cache;
-#define _alloc(x) dm_pool_zalloc(_cache.mem, (x))
+#define _zalloc(x) dm_pool_zalloc(_cache.mem, (x))
#define _free(x) dm_pool_free(_cache.mem, (x))
#define _strdup(x) dm_pool_strdup(_cache.mem, (x))
@@ -61,11 +61,11 @@
if (allocate) {
if (use_malloc) {
- if (!(dev = dm_malloc(sizeof(*dev)))) {
+ if (!(dev = dm_zalloc(sizeof(*dev)))) {
log_error("struct device allocation failed");
return NULL;
}
- if (!(alias = dm_malloc(sizeof(*alias)))) {
+ if (!(alias = dm_zalloc(sizeof(*alias)))) {
log_error("struct str_list allocation failed");
dm_free(dev);
return NULL;
@@ -78,11 +78,11 @@
}
dev->flags = DEV_ALLOCED;
} else {
- if (!(dev = _alloc(sizeof(*dev)))) {
+ if (!(dev = _zalloc(sizeof(*dev)))) {
log_error("struct device allocation failed");
return NULL;
}
- if (!(alias = _alloc(sizeof(*alias)))) {
+ if (!(alias = _zalloc(sizeof(*alias)))) {
log_error("struct str_list allocation failed");
_free(dev);
return NULL;
@@ -118,7 +118,7 @@
{
struct device *dev;
- if (!(dev = _alloc(sizeof(*dev)))) {
+ if (!(dev = _zalloc(sizeof(*dev)))) {
log_error("struct device allocation failed");
return NULL;
}
@@ -303,7 +303,7 @@
static int _add_alias(struct device *dev, const char *path)
{
- struct str_list *sl = _alloc(sizeof(*sl));
+ struct str_list *sl = _zalloc(sizeof(*sl));
struct str_list *strl;
const char *oldpath;
int prefer_old = 1;
@@ -788,7 +788,7 @@
return 1;
}
- if (!(dl = _alloc(sizeof(*dl) + strlen(path) + 1))) {
+ if (!(dl = _zalloc(sizeof(*dl) + strlen(path) + 1))) {
log_error("dir_list allocation failed");
return 0;
}
@@ -814,7 +814,7 @@
return 1;
}
- if (!(dl = _alloc(sizeof(*dl) + strlen(path) + 1))) {
+ if (!(dl = _zalloc(sizeof(*dl) + strlen(path) + 1))) {
log_error("dir_list allocation failed for file");
return 0;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW lib/device/dev-cache.c
@ 2012-04-11 9:12 prajnoha
0 siblings, 0 replies; 7+ messages in thread
From: prajnoha @ 2012-04-11 9:12 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha@sourceware.org 2012-04-11 09:12:03
Modified files:
. : WHATS_NEW
lib/device : dev-cache.c
Log message:
Change message severity to log_very_verbose for missing dev info in udev db.
Libudev does not provide transactions when querying udev database - once we
get the list of block devices (devices/obtain_device_list_from_udev=1) and
we iterate over the list to get more detailed information about device node
and symlink names used etc., the device could be removed just in between we
get the list and put a query for more info. In this case, libudev returns
NULL value as the device does not exist anymore.
Recently, we've added a warning message to reveal such situations. However,
this could be misleading if the device is not related to the LVM action
we're just processing - the non-related block device could be removed in
parallel and this is not an error but a possible and normal operation.
(N.B. This "missing info" should not happen when devices are related to
the LVM action we're just processing since all such processing should be
synchronized with udev and the udev db must always be in consistent state
after the sync point. But we can't filter this situation out from others,
non-related devices, so we have to lower the message verbosity here for a
general solution.)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2377&r2=1.2378
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
--- LVM2/WHATS_NEW 2012/04/11 01:23:29 1.2377
+++ LVM2/WHATS_NEW 2012/04/11 09:12:02 1.2378
@@ -1,5 +1,6 @@
Version 2.02.96 -
================================
+ Change message severity to log_very_verbose for missing dev info in udev db.
Fix problems when specifying PVs during RAID down-converts.
Fix ability to handle failures in mirrored log (regression intro 2.02.89).
Fix unlocking volume group in vgreduce in error path.
--- LVM2/lib/device/dev-cache.c 2012/03/06 02:39:25 1.74
+++ LVM2/lib/device/dev-cache.c 2012/04/11 09:12:03 1.75
@@ -497,7 +497,7 @@
{
struct udev_enumerate *udev_enum = NULL;
struct udev_list_entry *device_entry, *symlink_entry;
- const char *node_name, *symlink_name;
+ const char *entry_name, *node_name, *symlink_name;
struct udev_device *device;
int r = 1;
@@ -508,20 +508,34 @@
udev_enumerate_scan_devices(udev_enum))
goto bad;
+ /*
+ * Report any missing information as "log_very_verbose" only, do not
+ * report it as a "warning" or "error" - the record could be removed
+ * by the time we ask for more info (node name, symlink name...).
+ * Whatever removes *any* block device in the system (even unrelated
+ * to our operation), we would have a warning/error on output then.
+ * That could be misleading. If there's really any problem with missing
+ * information from udev db, we can still have a look at the verbose log.
+ */
udev_list_entry_foreach(device_entry, udev_enumerate_get_list_entry(udev_enum)) {
- if (!(device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(device_entry)))) {
- log_warn("WARNING: udev failed to return a device entry.");
+ entry_name = udev_list_entry_get_name(device_entry);
+
+ if (!(device = udev_device_new_from_syspath(udev, entry_name))) {
+ log_very_verbose("udev failed to return a device for entry %s.",
+ entry_name);
continue;
}
if (!(node_name = udev_device_get_devnode(device)))
- log_warn("WARNING: udev failed to return a device node.");
+ log_very_verbose("udev failed to return a device node for entry %s.",
+ entry_name);
else
r &= _insert(node_name, 0, 0);
udev_list_entry_foreach(symlink_entry, udev_device_get_devlinks_list_entry(device)) {
if (!(symlink_name = udev_list_entry_get_name(symlink_entry)))
- log_warn("WARNING: udev failed to return a symlink name.");
+ log_very_verbose("udev failed to return a symlink name for entry %s.",
+ entry_name);
else
r &= _insert(symlink_name, 0, 0);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW lib/device/dev-cache.c
@ 2011-12-21 13:21 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-12-21 13:21 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-12-21 13:21:09
Modified files:
. : WHATS_NEW
lib/device : dev-cache.c
Log message:
Do not lstat common path prefix
When both path have identical prefix i.e. /dev/disk/by-id
skip 2 x lstat() for /dev /dev/disk /dev/disk/by-id
and directly lstat() only different part of the path.
Reduces amount of lstat calls on system with lots of devices.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2211&r2=1.2212
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69
--- LVM2/WHATS_NEW 2011/12/21 13:17:54 1.2211
+++ LVM2/WHATS_NEW 2011/12/21 13:21:09 1.2212
@@ -1,5 +1,6 @@
Version 2.02.89 -
==================================
+ Reduce number of lstat calls when selecting device alias.
Add function to inialize common structure device members.
Always zalloc device structure during initialization.
Fix missing thread list manipulation protection in dmeventd.
--- LVM2/lib/device/dev-cache.c 2011/12/21 13:17:54 1.68
+++ LVM2/lib/device/dev-cache.c 2011/12/21 13:21:09 1.69
@@ -259,6 +259,13 @@
s0 = &p0[0] + 1;
s1 = &p1[0] + 1;
+ /*
+ * If we reach here, both paths are the same length.
+ * Now skip past identical path components.
+ */
+ while (*s0 && *s0 == *s1)
+ s0++, s1++;
+
/* We prefer symlinks - they exist for a reason!
* So we prefer a shorter path before the first symlink in the name.
* FIXME Configuration option to invert this? */
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW lib/device/dev-cache.c
@ 2011-12-21 13:17 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-12-21 13:17 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-12-21 13:17:54
Modified files:
. : WHATS_NEW
lib/device : dev-cache.c
Log message:
Add common initialization code for struct device
Avoid duplicate code and add _dev_init() where all common
member values are initialized.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2210&r2=1.2211
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68
--- LVM2/WHATS_NEW 2011/12/21 13:14:54 1.2210
+++ LVM2/WHATS_NEW 2011/12/21 13:17:54 1.2211
@@ -1,5 +1,6 @@
Version 2.02.89 -
==================================
+ Add function to inialize common structure device members.
Always zalloc device structure during initialization.
Fix missing thread list manipulation protection in dmeventd.
Do not derefence lv pointer in _percent_run() function before NULL check.
--- LVM2/lib/device/dev-cache.c 2011/12/21 13:14:54 1.67
+++ LVM2/lib/device/dev-cache.c 2011/12/21 13:17:54 1.68
@@ -54,6 +54,18 @@
static int _insert(const char *path, int rec, int check_with_udev_db);
+/* Setup non-zero members of passed zeroed 'struct device' */
+static void _dev_init(struct device *dev, int max_error_count)
+{
+ dev->block_size = -1;
+ dev->fd = -1;
+ dev->read_ahead = -1;
+ dev->max_error_count = max_error_count;
+
+ dm_list_init(&dev->aliases);
+ dm_list_init(&dev->open_list);
+}
+
struct device *dev_create_file(const char *filename, struct device *dev,
struct str_list *alias, int use_malloc)
{
@@ -76,7 +88,6 @@
dm_free(alias);
return NULL;
}
- dev->flags = DEV_ALLOCED;
} else {
if (!(dev = _zalloc(sizeof(*dev)))) {
log_error("struct device allocation failed");
@@ -97,19 +108,9 @@
return NULL;
}
- dev->flags |= DEV_REGULAR;
- dm_list_init(&dev->aliases);
+ _dev_init(dev, NO_DEV_ERROR_COUNT_LIMIT);
+ dev->flags = DEV_REGULAR | ((use_malloc) ? DEV_ALLOCED : 0);
dm_list_add(&dev->aliases, &alias->list);
- dev->end = UINT64_C(0);
- dev->dev = 0;
- dev->fd = -1;
- dev->open_count = 0;
- dev->error_count = 0;
- dev->max_error_count = NO_DEV_ERROR_COUNT_LIMIT;
- dev->block_size = -1;
- dev->read_ahead = -1;
- memset(dev->pvid, 0, sizeof(dev->pvid));
- dm_list_init(&dev->open_list);
return dev;
}
@@ -122,17 +123,9 @@
log_error("struct device allocation failed");
return NULL;
}
- dev->flags = 0;
- dm_list_init(&dev->aliases);
+
+ _dev_init(dev, dev_disable_after_error_count());
dev->dev = d;
- dev->fd = -1;
- dev->open_count = 0;
- dev->max_error_count = dev_disable_after_error_count();
- dev->block_size = -1;
- dev->read_ahead = -1;
- dev->end = UINT64_C(0);
- memset(dev->pvid, 0, sizeof(dev->pvid));
- dm_list_init(&dev->open_list);
return dev;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW lib/device/dev-cache.c
@ 2011-01-17 15:16 zkabelac
0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2011-01-17 15:16 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac@sourceware.org 2011-01-17 15:16:56
Modified files:
. : WHATS_NEW
lib/device : dev-cache.c
Log message:
Do not scan devices unnecessarily for reseting error counter
For reseting error counter use directly btree cached elements and do not
create whole dev_iterator.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1880&r2=1.1881
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63
--- LVM2/WHATS_NEW 2011/01/13 14:56:17 1.1880
+++ LVM2/WHATS_NEW 2011/01/17 15:16:55 1.1881
@@ -1,5 +1,6 @@
Version 2.02.81 -
===================================
+ Do not scan devices unnecessarily in dev_reset_error_count().
Skip unnecessary lock_vol() call after volume deactivation.
Extend exec_cmd params to specify, when device sync is needed.
Replace fs_unlock by sync_local_dev_names to notify local clvmd. (2.02.80)
--- LVM2/lib/device/dev-cache.c 2010/12/20 13:23:11 1.62
+++ LVM2/lib/device/dev-cache.c 2011/01/17 15:16:55 1.63
@@ -850,18 +850,14 @@
void dev_reset_error_count(struct cmd_context *cmd)
{
- struct dev_iter *iter;
- struct device *dev;
+ struct dev_iter iter;
- if (!(iter = dev_iter_create(cmd->filter, 0))) {
- log_error("Resetting device error count failed");
+ if (!_cache.devices)
return;
- }
- for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter))
- dev->error_count = 0;
-
- dev_iter_destroy(iter);
+ iter.current = btree_first(_cache.devices);
+ while (iter.current)
+ _iter_next(&iter)->error_count = 0;
}
int dev_fd(struct device *dev)
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW lib/device/dev-cache.c
@ 2010-05-24 22:53 agk
0 siblings, 0 replies; 7+ messages in thread
From: agk @ 2010-05-24 22:53 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-05-24 22:53:49
Modified files:
. : WHATS_NEW
lib/device : dev-cache.c
Log message:
Avoid selecting names under /dev/block if there is an alternative.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1596&r2=1.1597
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57
--- LVM2/WHATS_NEW 2010/05/24 17:46:47 1.1596
+++ LVM2/WHATS_NEW 2010/05/24 22:53:48 1.1597
@@ -1,5 +1,6 @@
Version 2.02.67 -
===============================
+ Avoid selecting names under /dev/block if there is an alternative.
Update clustered log kernel module name to log-userspace for 2.6.31 onwards.
Activate only first head of Replicator for vgchange -ay.
Add Replicators' LVs to dtree for activation.
--- LVM2/lib/device/dev-cache.c 2009/07/15 20:02:46 1.56
+++ LVM2/lib/device/dev-cache.c 2010/05/24 22:53:49 1.57
@@ -40,6 +40,7 @@
struct dm_hash_table *names;
struct btree *devices;
struct dm_regex *preferred_names_matcher;
+ const char *dev_dir;
int has_scanned;
struct dm_list dirs;
@@ -155,6 +156,7 @@
char p0[PATH_MAX], p1[PATH_MAX];
char *s0, *s1;
struct stat stat0, stat1;
+ size_t devdir_len;
/*
* FIXME Better to compare patterns one-at-a-time against all names.
@@ -179,6 +181,19 @@
* Built-in rules.
*/
+ /*
+ * Anything beats /dev/block.
+ */
+ devdir_len = strlen(_cache.dev_dir);
+ if (!strncmp(path0, _cache.dev_dir, devdir_len) &&
+ !strncmp(path1, _cache.dev_dir, devdir_len)) {
+ if (!strncmp(path0 + devdir_len, "block/", 6)) {
+ if (strncmp(path1 + devdir_len, "block/", 6))
+ return 1;
+ } else if (!strncmp(path1 + devdir_len, "block/", 6))
+ return 0;
+ }
+
/* Return the path with fewer slashes */
for (p = path0; p++; p = (const char *) strchr(p, '/'))
slash0++;
@@ -545,6 +560,11 @@
goto bad;
}
+ if (!(_cache.dev_dir = _strdup(cmd->dev_dir))) {
+ log_error("strdup dev_dir failed.");
+ goto bad;
+ }
+
dm_list_init(&_cache.dirs);
dm_list_init(&_cache.files);
^ permalink raw reply [flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW lib/device/dev-cache.c
@ 2005-03-21 14:51 agk
0 siblings, 0 replies; 7+ messages in thread
From: agk @ 2005-03-21 14:51 UTC (permalink / raw)
To: lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2005-03-21 14:51:50
Modified files:
. : WHATS_NEW
lib/device : dev-cache.c
Log message:
Add 'already in device cache' debug message.
Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.208&r2=1.209
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-04-11 9:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-21 13:14 LVM2 ./WHATS_NEW lib/device/dev-cache.c zkabelac
-- strict thread matches above, loose matches on Subject: below --
2012-04-11 9:12 prajnoha
2011-12-21 13:21 zkabelac
2011-12-21 13:17 zkabelac
2011-01-17 15:16 zkabelac
2010-05-24 22:53 agk
2005-03-21 14:51 agk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).