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

dev_manager: check if uuid isn't already in cache

When DM uuid cache is available, we can possibly avoid unnecessary
status ioctl() when we check the device for 'usable' uuid.

If this test passes the existing code will got through the full check.
This commit is contained in:
Zdenek Kabelac 2024-06-07 15:57:42 +02:00
parent e30bc9b179
commit ed440367b9

View File

@ -758,6 +758,7 @@ int device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_usa
struct dm_task *dmt;
struct dm_info info;
const char *name, *uuid;
const struct dm_active_device *dm_dev;
uint64_t start, length;
char *target_type = NULL;
char *params;
@ -765,6 +766,12 @@ int device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_usa
int only_error_or_zero_target = 1;
int r = 0;
if (cmd->cache_dm_devs &&
/* With cache we can avoid status calls for unusable UUIDs */
(dm_dev = dev_cache_get_dm_dev_by_devno(cmd, dev->dev)) &&
!_is_usable_uuid(dev, dm_dev->name, dm_dev->uuid, check.check_reserved, check.check_lv, is_lv))
return 0;
if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, NULL, NULL,
MAJOR(dev->dev), MINOR(dev->dev), 0, 0, 0)))
return_0;