1
0
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:
Alasdair Kergon 2005-03-08 13:46:17 +00:00
parent 8f5d81cbc8
commit b9565b406a
11 changed files with 20 additions and 18 deletions

View File

@ -1 +1 @@
2.01.07-cvs (2005-03-01) 2.01.07-cvs (2005-03-08)

View File

@ -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. Remove DESTDIR from LVM_SHARED_PATH.
clvmd fixes: make FDs close-on-exec clvmd fixes: make FDs close-on-exec
gulm unlocks VG & orphan locks at startup in case they are stale gulm unlocks VG & orphan locks at startup in case they are stale

View File

@ -188,7 +188,7 @@ int lvmcache_label_scan(struct cmd_context *cmd, int full_scan)
goto out; 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"); log_error("dev_iter creation failed");
goto out; goto out;
} }
@ -266,7 +266,7 @@ struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
if (memlock()) if (memlock())
return NULL; return NULL;
lvmcache_label_scan(cmd, 1); lvmcache_label_scan(cmd, 2);
/* Try again */ /* Try again */
if ((info = info_from_pvid((char *) pvid))) { if ((info = info_from_pvid((char *) pvid))) {

View File

@ -56,7 +56,8 @@ struct lvmcache_info {
int lvmcache_init(void); int lvmcache_init(void);
void lvmcache_destroy(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); int lvmcache_label_scan(struct cmd_context *cmd, int full_scan);
/* Add/delete a device */ /* Add/delete a device */

View File

@ -355,11 +355,11 @@ static int _insert(const char *path, int rec)
return r; return r;
} }
static void _full_scan(void) static void _full_scan(int dev_scan)
{ {
struct list *dh; struct list *dh;
if (_cache.has_scanned) if (_cache.has_scanned && !dev_scan)
return; return;
list_iterate(dh, &_cache.dirs) { list_iterate(dh, &_cache.dirs) {
@ -381,7 +381,7 @@ void dev_cache_scan(int do_scan)
_cache.has_scanned = 1; _cache.has_scanned = 1;
else { else {
_cache.has_scanned = 0; _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; 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)); struct dev_iter *di = dbg_malloc(sizeof(*di));
@ -549,7 +549,7 @@ struct dev_iter *dev_iter_create(struct dev_filter *f)
return NULL; return NULL;
} }
_full_scan(); _full_scan(dev_scan);
di->current = btree_first(_cache.devices); di->current = btree_first(_cache.devices);
di->filter = f; di->filter = f;

View File

@ -45,7 +45,7 @@ struct device *dev_cache_get(const char *name, struct dev_filter *f);
* Object for iterating through the cache. * Object for iterating through the cache.
*/ */
struct dev_iter; 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); void dev_iter_destroy(struct dev_iter *iter);
struct device *dev_iter_get(struct dev_iter *iter); struct device *dev_iter_get(struct dev_iter *iter);

View File

@ -482,7 +482,7 @@ int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
/* vgcache_del(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"); log_error("read_pvs_in_vg: dev_iter_create failed");
return 0; return 0;
} }

View File

@ -1185,7 +1185,7 @@ static int _pv_read(const struct format_type *fmt, const char *pv_name,
/* Perform full scan and try again */ /* Perform full scan and try again */
if (!memlock()) { if (!memlock()) {
lvmcache_label_scan(fmt->cmd, 1); lvmcache_label_scan(fmt->cmd, 2);
if (info->vginfo && info->vginfo->vgname && if (info->vginfo && info->vginfo->vgname &&
*info->vginfo->vgname && *info->vginfo->vgname &&

View File

@ -654,7 +654,7 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vgname,
stack; stack;
return NULL; return NULL;
} }
lvmcache_label_scan(cmd, 1); lvmcache_label_scan(cmd, 2);
if (!(fmt = fmt_from_vgname(vgname))) { if (!(fmt = fmt_from_vgname(vgname))) {
stack; stack;
return NULL; 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. */ * allowed to do a full scan here any more. */
// The slow way - full scan required to cope with vgrename // 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"); log_error("vg_read_by_vgid: get_vgs failed");
return NULL; return NULL;
} }

View File

@ -34,7 +34,7 @@ static int _get_max_dev_name_len(struct dev_filter *filter)
struct dev_iter *iter; struct dev_iter *iter;
struct device *dev; struct device *dev;
if (!(iter = dev_iter_create(filter))) { if (!(iter = dev_iter_create(filter, 1))) {
log_error("dev_iter_create failed"); log_error("dev_iter_create failed");
return 0; 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); 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"); log_error("dev_iter_create failed");
return ECMD_FAILED; return ECMD_FAILED;
} }

View File

@ -463,7 +463,7 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
int ret_max = 0; int ret_max = 0;
int ret = 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"); log_error("dev_iter creation failed");
return ECMD_FAILED; return ECMD_FAILED;
} }