mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Only do one full device scan during each read of text format metadata.
This commit is contained in:
parent
38220f9fe9
commit
b1f9a2f5d1
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.63 -
|
Version 2.02.63 -
|
||||||
================================
|
================================
|
||||||
|
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.
|
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.
|
Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.
|
||||||
Make find_pv_in_vg_by_uuid() return same type as related functions.
|
Make find_pv_in_vg_by_uuid() return same type as related functions.
|
||||||
|
6
lib/cache/lvmcache.c
vendored
6
lib/cache/lvmcache.c
vendored
@ -703,7 +703,8 @@ struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
|
|||||||
return pvids;
|
return pvids;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
|
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
|
||||||
|
int *scan_done_once)
|
||||||
{
|
{
|
||||||
struct label *label;
|
struct label *label;
|
||||||
struct lvmcache_info *info;
|
struct lvmcache_info *info;
|
||||||
@ -728,10 +729,11 @@ struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memlock())
|
if (memlock() || (scan_done_once && *scan_done_once))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
lvmcache_label_scan(cmd, 2);
|
lvmcache_label_scan(cmd, 2);
|
||||||
|
*scan_done_once = 1;
|
||||||
|
|
||||||
/* Try again */
|
/* Try again */
|
||||||
if ((info = info_from_pvid((char *) pvid, 0))) {
|
if ((info = info_from_pvid((char *) pvid, 0))) {
|
||||||
|
3
lib/cache/lvmcache.h
vendored
3
lib/cache/lvmcache.h
vendored
@ -93,7 +93,8 @@ struct lvmcache_vginfo *vginfo_from_vgname(const char *vgname,
|
|||||||
struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
|
struct lvmcache_vginfo *vginfo_from_vgid(const char *vgid);
|
||||||
struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
|
struct lvmcache_info *info_from_pvid(const char *pvid, int valid_only);
|
||||||
const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
|
const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid);
|
||||||
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid);
|
struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid,
|
||||||
|
int *scan_done_once);
|
||||||
int vgs_locked(void);
|
int vgs_locked(void);
|
||||||
int vgname_is_locked(const char *vgname);
|
int vgname_is_locked(const char *vgname);
|
||||||
|
|
||||||
|
@ -2025,7 +2025,7 @@ static int _get_config_disk_area(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dev_area.dev = device_from_pvid(cmd, &id))) {
|
if (!(dev_area.dev = device_from_pvid(cmd, &id, NULL))) {
|
||||||
char buffer[64] __attribute((aligned(8)));
|
char buffer[64] __attribute((aligned(8)));
|
||||||
|
|
||||||
if (!id_write_format(&id, buffer, sizeof(buffer)))
|
if (!id_write_format(&id, buffer, sizeof(buffer)))
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
typedef int (*section_fn) (struct format_instance * fid, struct dm_pool * mem,
|
typedef int (*section_fn) (struct format_instance * fid, struct dm_pool * mem,
|
||||||
struct volume_group * vg, struct config_node * pvn,
|
struct volume_group * vg, struct config_node * pvn,
|
||||||
struct config_node * vgn,
|
struct config_node * vgn,
|
||||||
struct dm_hash_table * pv_hash);
|
struct dm_hash_table * pv_hash,
|
||||||
|
int *scan_done_once);
|
||||||
|
|
||||||
#define _read_int32(root, path, result) \
|
#define _read_int32(root, path, result) \
|
||||||
get_config_uint32(root, path, (uint32_t *) result)
|
get_config_uint32(root, path, (uint32_t *) result)
|
||||||
@ -153,7 +154,7 @@ 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,
|
static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
||||||
struct volume_group *vg, struct config_node *pvn,
|
struct volume_group *vg, struct config_node *pvn,
|
||||||
struct config_node *vgn __attribute((unused)),
|
struct config_node *vgn __attribute((unused)),
|
||||||
struct dm_hash_table *pv_hash)
|
struct dm_hash_table *pv_hash, int *scan_done_once)
|
||||||
{
|
{
|
||||||
struct physical_volume *pv;
|
struct physical_volume *pv;
|
||||||
struct pv_list *pvl;
|
struct pv_list *pvl;
|
||||||
@ -186,7 +187,7 @@ static int _read_pv(struct format_instance *fid, struct dm_pool *mem,
|
|||||||
/*
|
/*
|
||||||
* Convert the uuid into a device.
|
* Convert the uuid into a device.
|
||||||
*/
|
*/
|
||||||
if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id))) {
|
if (!(pv->dev = device_from_pvid(fid->fmt->cmd, &pv->id, scan_done_once))) {
|
||||||
char buffer[64] __attribute((aligned(8)));
|
char buffer[64] __attribute((aligned(8)));
|
||||||
|
|
||||||
if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
|
if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
|
||||||
@ -490,7 +491,8 @@ static int _read_lvnames(struct format_instance *fid __attribute((unused)),
|
|||||||
struct dm_pool *mem,
|
struct dm_pool *mem,
|
||||||
struct volume_group *vg, struct config_node *lvn,
|
struct volume_group *vg, struct config_node *lvn,
|
||||||
struct config_node *vgn __attribute((unused)),
|
struct config_node *vgn __attribute((unused)),
|
||||||
struct dm_hash_table *pv_hash __attribute((unused)))
|
struct dm_hash_table *pv_hash __attribute((unused)),
|
||||||
|
int *scan_done_once __attribute((unused)))
|
||||||
{
|
{
|
||||||
struct logical_volume *lv;
|
struct logical_volume *lv;
|
||||||
struct config_node *cn;
|
struct config_node *cn;
|
||||||
@ -556,7 +558,8 @@ static int _read_lvsegs(struct format_instance *fid __attribute((unused)),
|
|||||||
struct dm_pool *mem,
|
struct dm_pool *mem,
|
||||||
struct volume_group *vg, struct config_node *lvn,
|
struct volume_group *vg, struct config_node *lvn,
|
||||||
struct config_node *vgn __attribute((unused)),
|
struct config_node *vgn __attribute((unused)),
|
||||||
struct dm_hash_table *pv_hash)
|
struct dm_hash_table *pv_hash,
|
||||||
|
int *scan_done_once __attribute((unused)))
|
||||||
{
|
{
|
||||||
struct logical_volume *lv;
|
struct logical_volume *lv;
|
||||||
struct lv_list *lvl;
|
struct lv_list *lvl;
|
||||||
@ -612,6 +615,7 @@ static int _read_sections(struct format_instance *fid,
|
|||||||
struct dm_hash_table *pv_hash, int optional)
|
struct dm_hash_table *pv_hash, int optional)
|
||||||
{
|
{
|
||||||
struct config_node *n;
|
struct config_node *n;
|
||||||
|
int scan_done_once = 0;
|
||||||
|
|
||||||
if (!(n = find_config_node(vgn, section))) {
|
if (!(n = find_config_node(vgn, section))) {
|
||||||
if (!optional) {
|
if (!optional) {
|
||||||
@ -623,7 +627,7 @@ static int _read_sections(struct format_instance *fid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (n = n->child; n; n = n->sib) {
|
for (n = n->child; n; n = n->sib) {
|
||||||
if (!fn(fid, mem, vg, n, vgn, pv_hash))
|
if (!fn(fid, mem, vg, n, vgn, pv_hash, &scan_done_once))
|
||||||
return_0;
|
return_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,7 +1416,7 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd,
|
|||||||
pp = &default_pp;
|
pp = &default_pp;
|
||||||
|
|
||||||
if (pp->idp) {
|
if (pp->idp) {
|
||||||
if ((dev = device_from_pvid(cmd, pp->idp)) &&
|
if ((dev = device_from_pvid(cmd, pp->idp, NULL)) &&
|
||||||
(dev != dev_cache_get(pv_name, cmd->filter))) {
|
(dev != dev_cache_get(pv_name, cmd->filter))) {
|
||||||
if (!id_write_format((const struct id*)&pp->idp->uuid,
|
if (!id_write_format((const struct id*)&pp->idp->uuid,
|
||||||
buffer, sizeof(buffer)))
|
buffer, sizeof(buffer)))
|
||||||
|
Loading…
Reference in New Issue
Block a user