mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Add is_dm_major() for use in duplicate device detection in lvmcache_add().
This commit is contained in:
parent
72a16423d2
commit
68366c99b2
@ -1,5 +1,8 @@
|
||||
Version 2.01.15 -
|
||||
=================================
|
||||
Add is_dm_major() for use in duplicate device detection in lvmcache_add().
|
||||
Really switch device number in lvmcache when it says it is doing so.
|
||||
Option for bitset memory allocation using malloc as well as pool.
|
||||
Don't assume exactly two mirrors when parsing mirror status.
|
||||
Suppress fsync() error message on filesystems that don't support it.
|
||||
Fix yes_no_prompt() error handling.
|
||||
|
13
lib/cache/lvmcache.c
vendored
13
lib/cache/lvmcache.c
vendored
@ -495,12 +495,25 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
|
||||
pvid, dev_name(dev),
|
||||
dev_name(existing->dev));
|
||||
return NULL;
|
||||
} else if (is_dm_major(MAJOR(existing->dev->dev)) &&
|
||||
!is_dm_major(MAJOR(dev->dev))) {
|
||||
log_very_verbose("Ignoring duplicate PV %s on "
|
||||
"%s - using dm %s",
|
||||
pvid, dev_name(dev),
|
||||
dev_name(existing->dev));
|
||||
return NULL;
|
||||
} else if (MAJOR(existing->dev->dev) != md_major() &&
|
||||
MAJOR(dev->dev) == md_major())
|
||||
log_very_verbose("Duplicate PV %s on %s - "
|
||||
"using md %s", pvid,
|
||||
dev_name(existing->dev),
|
||||
dev_name(dev));
|
||||
else if (!is_dm_major(MAJOR(existing->dev->dev)) &&
|
||||
is_dm_major(MAJOR(dev->dev)))
|
||||
log_very_verbose("Duplicate PV %s on %s - "
|
||||
"using dm %s", pvid,
|
||||
dev_name(existing->dev),
|
||||
dev_name(dev));
|
||||
else
|
||||
log_error("Found duplicate PV %s: using %s not "
|
||||
"%s", pvid, dev_name(dev),
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "lvm-string.h"
|
||||
#include "config.h"
|
||||
#include "metadata.h"
|
||||
#include "bitset.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
@ -38,12 +39,18 @@ typedef struct {
|
||||
} device_info_t;
|
||||
|
||||
static int _md_major = -1;
|
||||
static bitset_t _dm_bitset;
|
||||
|
||||
int md_major(void)
|
||||
{
|
||||
return _md_major;
|
||||
}
|
||||
|
||||
int is_dm_major(int major)
|
||||
{
|
||||
return bit(_dm_bitset, major) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Devices are only checked for partition tables if their minor number
|
||||
* is a multiple of the number corresponding to their type below
|
||||
@ -181,6 +188,11 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
|
||||
if (!strncmp("md", line + i, 2) && isspace(*(line + i + 2)))
|
||||
_md_major = line_maj;
|
||||
|
||||
/* Look for dm devices */
|
||||
if (!strncmp("device-mapper", line + i, 13) &&
|
||||
isspace(*(line + i + 13)))
|
||||
bit_set(_dm_bitset, line_maj);
|
||||
|
||||
/* Go through the valid device names and if there is a
|
||||
match store max number of partitions */
|
||||
for (j = 0; device_info[j].name != NULL; j++) {
|
||||
@ -251,6 +263,12 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
f->destroy = lvm_type_filter_destroy;
|
||||
f->private = NULL;
|
||||
|
||||
if (!(_dm_bitset = bitset_create(NULL, NUMBER_OF_MAJORS))) {
|
||||
stack;
|
||||
dbg_free(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_scan_proc_dev(proc, cn)) {
|
||||
stack;
|
||||
return NULL;
|
||||
@ -261,6 +279,7 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
|
||||
void lvm_type_filter_destroy(struct dev_filter *f)
|
||||
{
|
||||
bitset_destroy(_dm_bitset);
|
||||
dbg_free(f);
|
||||
return;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
void lvm_type_filter_destroy(struct dev_filter *f);
|
||||
|
||||
int md_major(void);
|
||||
|
||||
int is_dm_major(int major);
|
||||
int max_partitions(int major);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user