mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Cope with new devices appearing by rescanning /dev if a uuid can't be found.
This commit is contained in:
parent
8f5d81cbc8
commit
b9565b406a
@ -1,5 +1,6 @@
|
||||
Version 2.01.07 -
|
||||
Version 2.01.07 - 8th March 2005
|
||||
================================
|
||||
Cope with new devices appearing by rescanning /dev if a uuid can't be found.
|
||||
Remove DESTDIR from LVM_SHARED_PATH.
|
||||
clvmd fixes: make FDs close-on-exec
|
||||
gulm unlocks VG & orphan locks at startup in case they are stale
|
||||
|
4
lib/cache/lvmcache.c
vendored
4
lib/cache/lvmcache.c
vendored
@ -188,7 +188,7 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(cmd->filter))) {
|
||||
if (!(iter = dev_iter_create(cmd->filter, (full_scan == 2) ? 1: 0))) {
|
||||
log_error("dev_iter creation failed");
|
||||
goto out;
|
||||
}
|
||||
@ -266,7 +266,7 @@ struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
|
||||
if (memlock())
|
||||
return NULL;
|
||||
|
||||
lvmcache_label_scan(cmd, 1);
|
||||
lvmcache_label_scan(cmd, 2);
|
||||
|
||||
/* Try again */
|
||||
if ((info = info_from_pvid((char *) pvid))) {
|
||||
|
3
lib/cache/lvmcache.h
vendored
3
lib/cache/lvmcache.h
vendored
@ -56,7 +56,8 @@ struct lvmcache_info {
|
||||
int lvmcache_init(void);
|
||||
void lvmcache_destroy(void);
|
||||
|
||||
/* Set full_scan to 1 to reread every filtered device label */
|
||||
/* Set full_scan to 1 to reread every filtered device label or
|
||||
* 2 to rescan /dev for new devices */
|
||||
int lvmcache_label_scan(struct cmd_context *cmd, int full_scan);
|
||||
|
||||
/* Add/delete a device */
|
||||
|
@ -355,11 +355,11 @@ static int _insert(const char *path, int rec)
|
||||
return r;
|
||||
}
|
||||
|
||||
static void _full_scan(void)
|
||||
static void _full_scan(int dev_scan)
|
||||
{
|
||||
struct list *dh;
|
||||
|
||||
if (_cache.has_scanned)
|
||||
if (_cache.has_scanned && !dev_scan)
|
||||
return;
|
||||
|
||||
list_iterate(dh, &_cache.dirs) {
|
||||
@ -381,7 +381,7 @@ void dev_cache_scan(int do_scan)
|
||||
_cache.has_scanned = 1;
|
||||
else {
|
||||
_cache.has_scanned = 0;
|
||||
_full_scan();
|
||||
_full_scan(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -540,7 +540,7 @@ struct device *dev_cache_get(const char *name, struct dev_filter *f)
|
||||
return (d && (!f || f->passes_filter(f, d))) ? d : NULL;
|
||||
}
|
||||
|
||||
struct dev_iter *dev_iter_create(struct dev_filter *f)
|
||||
struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan)
|
||||
{
|
||||
struct dev_iter *di = dbg_malloc(sizeof(*di));
|
||||
|
||||
@ -549,7 +549,7 @@ struct dev_iter *dev_iter_create(struct dev_filter *f)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_full_scan();
|
||||
_full_scan(dev_scan);
|
||||
di->current = btree_first(_cache.devices);
|
||||
di->filter = f;
|
||||
|
||||
|
@ -45,7 +45,7 @@ struct device *dev_cache_get(const char *name, struct dev_filter *f);
|
||||
* Object for iterating through the cache.
|
||||
*/
|
||||
struct dev_iter;
|
||||
struct dev_iter *dev_iter_create(struct dev_filter *f);
|
||||
struct dev_iter *dev_iter_create(struct dev_filter *f, int dev_scan);
|
||||
void dev_iter_destroy(struct dev_iter *iter);
|
||||
struct device *dev_iter_get(struct dev_iter *iter);
|
||||
|
||||
|
@ -482,7 +482,7 @@ int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
|
||||
/* vgcache_del(vg_name); */
|
||||
}
|
||||
|
||||
if (!(iter = dev_iter_create(filter))) {
|
||||
if (!(iter = dev_iter_create(filter, 1))) {
|
||||
log_error("read_pvs_in_vg: dev_iter_create failed");
|
||||
return 0;
|
||||
}
|
||||
|
@ -1185,7 +1185,7 @@ static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
|
||||
/* Perform full scan and try again */
|
||||
if (!memlock()) {
|
||||
lvmcache_label_scan(fmt->cmd, 1);
|
||||
lvmcache_label_scan(fmt->cmd, 2);
|
||||
|
||||
if (info->vginfo && info->vginfo->vgname &&
|
||||
*info->vginfo->vgname &&
|
||||
|
@ -654,7 +654,7 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vgname,
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
lvmcache_label_scan(cmd, 1);
|
||||
lvmcache_label_scan(cmd, 2);
|
||||
if (!(fmt = fmt_from_vgname(vgname))) {
|
||||
stack;
|
||||
return NULL;
|
||||
@ -768,7 +768,7 @@ struct volume_group *vg_read_by_vgid(struct cmd_context *cmd, const char *vgid)
|
||||
* allowed to do a full scan here any more. */
|
||||
|
||||
// The slow way - full scan required to cope with vgrename
|
||||
if (!(vgnames = get_vgs(cmd, 1))) {
|
||||
if (!(vgnames = get_vgs(cmd, 2))) {
|
||||
log_error("vg_read_by_vgid: get_vgs failed");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ static int _get_max_dev_name_len(struct dev_filter *filter)
|
||||
struct dev_iter *iter;
|
||||
struct device *dev;
|
||||
|
||||
if (!(iter = dev_iter_create(filter))) {
|
||||
if (!(iter = dev_iter_create(filter, 1))) {
|
||||
log_error("dev_iter_create failed");
|
||||
return 0;
|
||||
}
|
||||
@ -103,7 +103,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
max_len = _get_max_dev_name_len(cmd->filter);
|
||||
|
||||
if (!(iter = dev_iter_create(cmd->filter))) {
|
||||
if (!(iter = dev_iter_create(cmd->filter, 0))) {
|
||||
log_error("dev_iter_create failed");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
|
||||
int ret_max = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (!(iter = dev_iter_create(cmd->filter))) {
|
||||
if (!(iter = dev_iter_create(cmd->filter, 1))) {
|
||||
log_error("dev_iter creation failed");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user