mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
devices: isolate fake dev use for mirror checks
Freeing dev-cache from dumb fake device usage.
This commit is contained in:
parent
82d145a372
commit
92fd2cb498
@ -448,8 +448,9 @@ static int _ignore_blocked_mirror_devices(struct cmd_context *cmd,
|
|||||||
void *next = NULL;
|
void *next = NULL;
|
||||||
struct dm_task *dmt = NULL;
|
struct dm_task *dmt = NULL;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
struct device *tmp_dev;
|
char fake_dev_name[16];
|
||||||
char buf[16];
|
struct device fake_dev = { 0 };
|
||||||
|
struct dm_str_list *alias;
|
||||||
|
|
||||||
if (!(mem = dm_pool_create("blocked_mirrors", 128)))
|
if (!(mem = dm_pool_create("blocked_mirrors", 128)))
|
||||||
return_0;
|
return_0;
|
||||||
@ -470,16 +471,20 @@ static int _ignore_blocked_mirror_devices(struct cmd_context *cmd,
|
|||||||
dev_name(dev));
|
dev_name(dev));
|
||||||
check_for_blocking = 1;
|
check_for_blocking = 1;
|
||||||
} else {
|
} else {
|
||||||
|
dev_init(&fake_dev);
|
||||||
if (dm_snprintf(buf, sizeof(buf), "%u:%u",
|
if (dm_snprintf(fake_dev_name, sizeof(fake_dev_name), "%u:%u",
|
||||||
sm->logs[0].major, sm->logs[0].minor) < 0)
|
sm->logs[0].major, sm->logs[0].minor) < 0)
|
||||||
goto_out;
|
goto_out;
|
||||||
|
|
||||||
if (!(tmp_dev = dev_create_file(buf, NULL, NULL, 0)))
|
if (!(alias = dm_pool_zalloc(mem, sizeof(*alias))))
|
||||||
goto_out;
|
goto_out;
|
||||||
|
if (!(alias->str = dm_pool_strdup(mem, fake_dev_name)))
|
||||||
|
goto_out;
|
||||||
|
dm_list_add(&fake_dev.aliases, &alias->list);
|
||||||
|
fake_dev.flags = DEV_REGULAR;
|
||||||
|
fake_dev.dev = MKDEV(sm->logs[0].major, sm->logs[0].minor);
|
||||||
|
|
||||||
tmp_dev->dev = MKDEV(sm->logs[0].major, sm->logs[0].minor);
|
if (dm_device_is_usable(cmd, &fake_dev, (struct dev_usable_check_params)
|
||||||
if (dm_device_is_usable(cmd, tmp_dev, (struct dev_usable_check_params)
|
|
||||||
{ .check_empty = 1,
|
{ .check_empty = 1,
|
||||||
.check_blocked = 1,
|
.check_blocked = 1,
|
||||||
.check_suspended = ignore_suspended_devices(),
|
.check_suspended = ignore_suspended_devices(),
|
||||||
|
@ -78,7 +78,7 @@ static int _insert(const char *path, const struct stat *info,
|
|||||||
int rec, int check_with_udev_db);
|
int rec, int check_with_udev_db);
|
||||||
|
|
||||||
/* Setup non-zero members of passed zeroed 'struct device' */
|
/* Setup non-zero members of passed zeroed 'struct device' */
|
||||||
static void _dev_init(struct device *dev)
|
void dev_init(struct device *dev)
|
||||||
{
|
{
|
||||||
dev->fd = -1;
|
dev->fd = -1;
|
||||||
dev->bcache_fd = -1;
|
dev->bcache_fd = -1;
|
||||||
@ -147,7 +147,7 @@ struct device *dev_create_file(const char *filename, struct device *dev,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_dev_init(dev);
|
dev_init(dev);
|
||||||
dev->flags = DEV_REGULAR | ((use_malloc) ? DEV_ALLOCED : 0);
|
dev->flags = DEV_REGULAR | ((use_malloc) ? DEV_ALLOCED : 0);
|
||||||
dm_list_add(&dev->aliases, &alias->list);
|
dm_list_add(&dev->aliases, &alias->list);
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ static struct device *_dev_create(dev_t d)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_dev_init(dev);
|
dev_init(dev);
|
||||||
dev->dev = d;
|
dev->dev = d;
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
|
Loading…
Reference in New Issue
Block a user