]> sourceware.org Git - lvm2.git/commitdiff
dev_manager: check if uuid isn't already in cache
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 7 Jun 2024 13:57:42 +0000 (15:57 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 21 Jun 2024 09:28:54 +0000 (11:28 +0200)
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

index 31ceae45d82f4798b916291e4a8c57bb69fc3dfa..b0e87097e3df2f918238def8fa92faa3168fa6e7 100644 (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;
This page took 0.045001 seconds and 5 git commands to generate.