1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Suppress repeated errors about the same missing PV uuids.

Bypass full device scans when using internally-cached VG metadata.
This commit is contained in:
Alasdair Kergon 2010-03-17 02:11:18 +00:00
parent f168869702
commit 0a5182fc97
6 changed files with 35 additions and 19 deletions

View File

@ -1,5 +1,7 @@
Version 2.02.63 -
================================
Suppress repeated errors about the same missing PV uuids.
Bypass full device scans when using internally-cached VG metadata.
Only do one full device scan during each read of text format metadata.
Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls.
Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.

View File

@ -704,7 +704,7 @@ struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
}
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
int *scan_done_once)
unsigned *scan_done_once)
{
struct label *label;
struct lvmcache_info *info;

View File

@ -94,7 +94,7 @@ struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
int *scan_done_once);
unsigned *scan_done_once);
int vgs_locked(void);
int vgname_is_locked(const char *vgname);

View File

@ -46,7 +46,8 @@ enum {
struct text_vg_version_ops {
int (*check_version) (struct config_tree * cf);
struct volume_group *(*read_vg) (struct format_instance * fid,
struct config_tree * cf);
struct config_tree * cf,
unsigned use_cached_pvs);
void (*read_desc) (struct dm_pool * mem, struct config_tree * cf,
time_t *when, char **desc);
const char *(*read_vgname) (const struct format_type *fmt,

View File

@ -111,7 +111,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
if (!(*vsn)->check_version(cft))
continue;
if (!(vg = (*vsn)->read_vg(fid, cft)))
if (!(vg = (*vsn)->read_vg(fid, cft, 0)))
goto_out;
(*vsn)->read_desc(fid->fmt->cmd->mem, cft, when, desc);
@ -146,7 +146,11 @@ struct volume_group *import_vg_from_buffer(char *buf,
for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
if (!(*vsn)->check_version(cft))
continue;
if (!(vg = (*vsn)->read_vg(fid, cft)))
/*
* The only path to this point uses cached vgmetadata,
* so it can use cached PV state too.
*/
if (!(vg = (*vsn)->read_vg(fid, cft, 1)))
stack;
break;
}

View File

@ -28,7 +28,8 @@ typedef int (*section_fn) (struct format_instance * fid, struct dm_pool * mem,
struct volume_group * vg, struct config_node * pvn,
struct config_node * vgn,
struct dm_hash_table * pv_hash,
int *scan_done_once);
unsigned *scan_done_once,
unsigned report_missing_devices);
#define _read_int32(root, path, result) \
get_config_uint32(root, path, (uint32_t *) result)
@ -154,7 +155,8 @@ static int _read_flag_config(struct config_node *n, uint64_t *status, int type)
static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
struct volume_group *vg, struct config_node *pvn,
struct config_node *vgn __attribute((unused)),
struct dm_hash_table *pv_hash, int *scan_done_once)
struct dm_hash_table *pv_hash, unsigned *scan_done_once,
unsigned report_missing_devices)
{
struct physical_volume *pv;
struct pv_list *pvl;
@ -191,10 +193,11 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
char buffer[64] __attribute((aligned(8)));
if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
log_error("Couldn't find device.");
buffer[0] = '\0';
if (report_missing_devices)
log_error("Couldn't find device with uuid %s.", buffer);
else
log_error("Couldn't find device with uuid '%s'.",
buffer);
log_very_verbose("Couldn't find device with uuid %s.", buffer);
}
if (!(pv->vg_name = dm_pool_strdup(mem, vg->name)))
@ -492,7 +495,8 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)),
struct volume_group *vg, struct config_node *lvn,
struct config_node *vgn __attribute((unused)),
struct dm_hash_table *pv_hash __attribute((unused)),
int *scan_done_once __attribute((unused)))
unsigned *scan_done_once __attribute((unused)),
unsigned report_missing_devices __attribute((unused)))
{
struct logical_volume *lv;
struct config_node *cn;
@ -559,7 +563,8 @@ static int _read_lvsegs(struct format_instance *fid __attribute((unused)),
struct volume_group *vg, struct config_node *lvn,
struct config_node *vgn __attribute((unused)),
struct dm_hash_table *pv_hash,
int *scan_done_once __attribute((unused)))
unsigned *scan_done_once __attribute((unused)),
unsigned report_missing_devices __attribute((unused)))
{
struct logical_volume *lv;
struct lv_list *lvl;
@ -612,10 +617,12 @@ static int _read_sections(struct format_instance *fid,
const char *section, section_fn fn,
struct dm_pool *mem,
struct volume_group *vg, struct config_node *vgn,
struct dm_hash_table *pv_hash, int optional)
struct dm_hash_table *pv_hash, int optional,
unsigned *scan_done_once)
{
struct config_node *n;
int scan_done_once = 0;
/* Only report missing devices when doing a scan */
unsigned report_missing_devices = scan_done_once ? !*scan_done_once : 1;
if (!(n = find_config_node(vgn, section))) {
if (!optional) {
@ -627,7 +634,7 @@ static int _read_sections(struct format_instance *fid,
}
for (n = n->child; n; n = n->sib) {
if (!fn(fid, mem, vg, n, vgn, pv_hash, &scan_done_once))
if (!fn(fid, mem, vg, n, vgn, pv_hash, scan_done_once, report_missing_devices))
return_0;
}
@ -635,12 +642,14 @@ static int _read_sections(struct format_instance *fid,
}
static struct volume_group *_read_vg(struct format_instance *fid,
struct config_tree *cft)
struct config_tree *cft,
unsigned use_cached_pvs)
{
struct config_node *vgn, *cn;
struct volume_group *vg;
struct dm_hash_table *pv_hash = NULL;
struct dm_pool *mem = dm_pool_create("lvm2 vg_read", VG_MEMPOOL_CHUNK);
unsigned scan_done_once = use_cached_pvs;
if (!mem)
return_NULL;
@ -743,7 +752,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
dm_list_init(&vg->pvs);
if (!_read_sections(fid, "physical_volumes", _read_pv, mem, vg,
vgn, pv_hash, 0)) {
vgn, pv_hash, 0, &scan_done_once)) {
log_error("Couldn't find all physical volumes for volume "
"group %s.", vg->name);
goto bad;
@ -761,14 +770,14 @@ static struct volume_group *_read_vg(struct format_instance *fid,
}
if (!_read_sections(fid, "logical_volumes", _read_lvnames, mem, vg,
vgn, pv_hash, 1)) {
vgn, pv_hash, 1, NULL)) {
log_error("Couldn't read all logical volume names for volume "
"group %s.", vg->name);
goto bad;
}
if (!_read_sections(fid, "logical_volumes", _read_lvsegs, mem, vg,
vgn, pv_hash, 1)) {
vgn, pv_hash, 1, NULL)) {
log_error("Couldn't read all logical volumes for "
"volume group %s.", vg->name);
goto bad;