From ed440367b94d9a132782ca3b21be7e9d48b57cb5 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 7 Jun 2024 15:57:42 +0200 Subject: [PATCH] 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. --- lib/activate/dev_manager.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 31ceae45d..b0e87097e 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -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;