mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
devices: dm uuid related function names
In the context of dm, 'device' refers to a dm device, but in the context of lvm, 'device' refers to struct device. Change some lvm function names to make that difference clearer. dev_manager_get_device_list() -> dev_manager_get_dm_active_devices() get_device_list() -> get_dm_active_devices() device_get_uuid() -> dev_dm_uuid(), devno_dm_uuid()
This commit is contained in:
parent
680f7bd676
commit
990f4f7c4f
@ -672,13 +672,13 @@ int target_present(struct cmd_context *cmd, const char *target_name,
|
|||||||
&maj, &min, &patchlevel);
|
&maj, &min, &patchlevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_device_list(const struct volume_group *vg, struct dm_list **devs,
|
int get_dm_active_devices(const struct volume_group *vg, struct dm_list **devs,
|
||||||
unsigned *devs_features)
|
unsigned *devs_features)
|
||||||
{
|
{
|
||||||
if (!activation())
|
if (!activation())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return dev_manager_get_device_list(NULL, devs, devs_features);
|
return dev_manager_get_dm_active_devices(NULL, devs, devs_features);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -107,10 +107,12 @@ int target_present(struct cmd_context *cmd, const char *target_name,
|
|||||||
int target_version(const char *target_name, uint32_t *maj,
|
int target_version(const char *target_name, uint32_t *maj,
|
||||||
uint32_t *min, uint32_t *patchlevel);
|
uint32_t *min, uint32_t *patchlevel);
|
||||||
|
|
||||||
int get_device_list(const struct volume_group *vg, struct dm_list **devs,
|
int get_dm_active_devices(const struct volume_group *vg, struct dm_list **devs,
|
||||||
unsigned *devs_features);
|
unsigned *devs_features);
|
||||||
int device_get_uuid(struct cmd_context *cmd, int major, int minor,
|
int devno_dm_uuid(struct cmd_context *cmd, int major, int minor,
|
||||||
char *uuid_buf, size_t uuid_buf_size);
|
char *uuid_buf, size_t uuid_buf_size);
|
||||||
|
int dev_dm_uuid(struct cmd_context *cmd, struct device *dev,
|
||||||
|
char *uuid_buf, size_t uuid_buf_size);
|
||||||
|
|
||||||
int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype);
|
int raid4_is_supported(struct cmd_context *cmd, const struct segment_type *segtype);
|
||||||
int lvm_dm_prefix_check(int major, int minor, const char *prefix);
|
int lvm_dm_prefix_check(int major, int minor, const char *prefix);
|
||||||
|
@ -888,8 +888,8 @@ int device_is_usable(struct cmd_context *cmd, struct device *dev, struct dev_usa
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read UUID from a given DM device into buf_uuid */
|
/* Read UUID from a given DM device into buf_uuid */
|
||||||
int device_get_uuid(struct cmd_context *cmd, int major, int minor,
|
int devno_dm_uuid(struct cmd_context *cmd, int major, int minor,
|
||||||
char *uuid_buf, size_t uuid_buf_size)
|
char *uuid_buf, size_t uuid_buf_size)
|
||||||
{
|
{
|
||||||
struct dm_task *dmt;
|
struct dm_task *dmt;
|
||||||
struct dm_info info;
|
struct dm_info info;
|
||||||
@ -918,6 +918,13 @@ int device_get_uuid(struct cmd_context *cmd, int major, int minor,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dev_dm_uuid(struct cmd_context *cmd, struct device *dev,
|
||||||
|
char *uuid_buf, size_t uuid_buf_size)
|
||||||
|
{
|
||||||
|
return devno_dm_uuid(cmd, MAJOR(dev->dev), MINOR(dev->dev),
|
||||||
|
uuid_buf, uuid_buf_size);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If active LVs were activated by a version of LVM2 before 2.02.00 we must
|
* If active LVs were activated by a version of LVM2 before 2.02.00 we must
|
||||||
* perform additional checks to find them because they do not have the LVM-
|
* perform additional checks to find them because they do not have the LVM-
|
||||||
@ -1036,7 +1043,12 @@ int dev_manager_check_prefix_dm_major_minor(uint32_t major, uint32_t minor, cons
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dev_manager_get_device_list(const char *prefix, struct dm_list **devs, unsigned *devs_features)
|
/*
|
||||||
|
* Get a list of active dm devices from the kernel.
|
||||||
|
* The 'devs' list contains a struct dm_active_device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int dev_manager_get_dm_active_devices(const char *prefix, struct dm_list **devs, unsigned *devs_features)
|
||||||
{
|
{
|
||||||
struct dm_task *dmt;
|
struct dm_task *dmt;
|
||||||
int r = 1;
|
int r = 1;
|
||||||
|
@ -108,7 +108,7 @@ int dev_manager_device_uses_vg(struct device *dev,
|
|||||||
int dev_manager_remove_dm_major_minor(uint32_t major, uint32_t minor);
|
int dev_manager_remove_dm_major_minor(uint32_t major, uint32_t minor);
|
||||||
|
|
||||||
int dev_manager_check_prefix_dm_major_minor(uint32_t major, uint32_t minor, const char *prefix);
|
int dev_manager_check_prefix_dm_major_minor(uint32_t major, uint32_t minor, const char *prefix);
|
||||||
int dev_manager_get_device_list(const char *prefix, struct dm_list **devs,
|
int dev_manager_get_dm_active_devices(const char *prefix, struct dm_list **devs,
|
||||||
unsigned *devs_features);
|
unsigned *devs_features);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -593,7 +593,7 @@ static int _get_vgid_and_lvid_for_dev(struct cmd_context *cmd, struct device *de
|
|||||||
char uuid[DM_UUID_LEN];
|
char uuid[DM_UUID_LEN];
|
||||||
size_t uuid_len;
|
size_t uuid_len;
|
||||||
|
|
||||||
if (!device_get_uuid(cmd, MAJOR(dev->dev), MINOR(dev->dev), uuid, sizeof(uuid)))
|
if (!dev_dm_uuid(cmd, dev, uuid, sizeof(uuid)))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
uuid_len = strlen(uuid);
|
uuid_len = strlen(uuid);
|
||||||
@ -1343,7 +1343,7 @@ int dev_cache_update_dm_devs(struct cmd_context *cmd)
|
|||||||
_cache.dm_uuids = NULL;
|
_cache.dm_uuids = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_device_list(NULL, &cmd->cache_dm_devs, &devs_features))
|
if (!get_dm_active_devices(NULL, &cmd->cache_dm_devs, &devs_features))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!(devs_features & DM_DEVICE_LIST_HAS_UUID)) {
|
if (!(devs_features & DM_DEVICE_LIST_HAS_UUID)) {
|
||||||
|
@ -535,7 +535,7 @@ static int _dev_is_mpath_component_sysfs(struct cmd_context *cmd, struct device
|
|||||||
|
|
||||||
/* Check whether holder's UUID uses MPATH prefix */
|
/* Check whether holder's UUID uses MPATH prefix */
|
||||||
/* TODO: reuse/merge with dev_has_mpath_uuid() as this function also recognizes kpartx partition */
|
/* TODO: reuse/merge with dev_has_mpath_uuid() as this function also recognizes kpartx partition */
|
||||||
if (device_get_uuid(cmd, dm_dev_major, dm_dev_minor, uuid, sizeof(uuid)) &&
|
if (devno_dm_uuid(cmd, dm_dev_major, dm_dev_minor, uuid, sizeof(uuid)) &&
|
||||||
!strncmp(uuid, MPATH_PREFIX, sizeof(MPATH_PREFIX) - 1)) {
|
!strncmp(uuid, MPATH_PREFIX, sizeof(MPATH_PREFIX) - 1)) {
|
||||||
log_debug_devs("dev_is_mpath_component %s holder %s %u:%u ignore mpath component",
|
log_debug_devs("dev_is_mpath_component %s holder %s %u:%u ignore mpath component",
|
||||||
dev_name(dev), holder_name, dm_dev_major, dm_dev_minor);
|
dev_name(dev), holder_name, dm_dev_major, dm_dev_minor);
|
||||||
|
@ -55,8 +55,7 @@ int dev_is_lv(struct cmd_context *cmd, struct device *dev)
|
|||||||
{
|
{
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
|
|
||||||
if (device_get_uuid(cmd, MAJOR(dev->dev), MINOR(dev->dev),
|
if (dev_dm_uuid(cmd, dev, buffer, sizeof(buffer)) &&
|
||||||
buffer, sizeof(buffer)) &&
|
|
||||||
!strncmp(buffer, UUID_PREFIX, sizeof(UUID_PREFIX) - 1))
|
!strncmp(buffer, UUID_PREFIX, sizeof(UUID_PREFIX) - 1))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -128,7 +127,7 @@ int dev_is_used_by_active_lv(struct cmd_context *cmd, struct device *dev, int *u
|
|||||||
* by reading DM status and seeing if the uuid begins
|
* by reading DM status and seeing if the uuid begins
|
||||||
* with UUID_PREFIX ("LVM-")
|
* with UUID_PREFIX ("LVM-")
|
||||||
*/
|
*/
|
||||||
if (!device_get_uuid(cmd, dm_dev_major, dm_dev_minor, dm_uuid, sizeof(dm_uuid)))
|
if (!devno_dm_uuid(cmd, dm_dev_major, dm_dev_minor, dm_uuid, sizeof(dm_uuid)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!strncmp(dm_uuid, UUID_PREFIX, lvm_prefix_len))
|
if (!strncmp(dm_uuid, UUID_PREFIX, lvm_prefix_len))
|
||||||
|
@ -512,7 +512,7 @@ int dev_has_mpath_uuid(struct cmd_context *cmd, struct device *dev, char **idnam
|
|||||||
char uuid[DM_UUID_LEN];
|
char uuid[DM_UUID_LEN];
|
||||||
char *idname;
|
char *idname;
|
||||||
|
|
||||||
if (!device_get_uuid(cmd, MAJOR(dev->dev), MINOR(dev->dev), uuid, sizeof(uuid)))
|
if (!dev_dm_uuid(cmd, dev, uuid, sizeof(uuid)))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!_dm_uuid_has_prefix(uuid, "mpath-"))
|
if (!_dm_uuid_has_prefix(uuid, "mpath-"))
|
||||||
@ -531,7 +531,7 @@ static int _dev_has_crypt_uuid(struct cmd_context *cmd, struct device *dev, char
|
|||||||
char uuid[DM_UUID_LEN];
|
char uuid[DM_UUID_LEN];
|
||||||
char *idname;
|
char *idname;
|
||||||
|
|
||||||
if (!device_get_uuid(cmd, MAJOR(dev->dev), MINOR(dev->dev), uuid, sizeof(uuid)))
|
if (!dev_dm_uuid(cmd, dev, uuid, sizeof(uuid)))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!_dm_uuid_has_prefix(uuid, "CRYPT-"))
|
if (!_dm_uuid_has_prefix(uuid, "CRYPT-"))
|
||||||
@ -550,7 +550,7 @@ static int _dev_has_lvmlv_uuid(struct cmd_context *cmd, struct device *dev, char
|
|||||||
char uuid[DM_UUID_LEN];
|
char uuid[DM_UUID_LEN];
|
||||||
char *idname;
|
char *idname;
|
||||||
|
|
||||||
if (!device_get_uuid(cmd, MAJOR(dev->dev), MINOR(dev->dev), uuid, sizeof(uuid)))
|
if (!dev_dm_uuid(cmd, dev, uuid, sizeof(uuid)))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!_dm_uuid_has_prefix(uuid, UUID_PREFIX))
|
if (!_dm_uuid_has_prefix(uuid, UUID_PREFIX))
|
||||||
@ -786,7 +786,7 @@ char *device_id_system_read(struct cmd_context *cmd, struct device *dev, uint16_
|
|||||||
case DEV_ID_TYPE_MPATH_UUID:
|
case DEV_ID_TYPE_MPATH_UUID:
|
||||||
case DEV_ID_TYPE_CRYPT_UUID:
|
case DEV_ID_TYPE_CRYPT_UUID:
|
||||||
case DEV_ID_TYPE_LVMLV_UUID:
|
case DEV_ID_TYPE_LVMLV_UUID:
|
||||||
(void)device_get_uuid(cmd, MAJOR(dev->dev), MINOR(dev->dev), sysbuf, sizeof(sysbuf));
|
(void)dev_dm_uuid(cmd, dev, sysbuf, sizeof(sysbuf));
|
||||||
break;
|
break;
|
||||||
case DEV_ID_TYPE_MD_UUID:
|
case DEV_ID_TYPE_MD_UUID:
|
||||||
read_sys_block(cmd, dev, "md/uuid", sysbuf, sizeof(sysbuf));
|
read_sys_block(cmd, dev, "md/uuid", sysbuf, sizeof(sysbuf));
|
||||||
@ -1005,7 +1005,7 @@ static int _dev_has_stable_id(struct cmd_context *cmd, struct device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((MAJOR(dev->dev) == cmd->dev_types->device_mapper_major)) {
|
if ((MAJOR(dev->dev) == cmd->dev_types->device_mapper_major)) {
|
||||||
if (!device_get_uuid(cmd, MAJOR(dev->dev), MINOR(dev->dev), sysbuf, sizeof(sysbuf)))
|
if (!dev_dm_uuid(cmd, dev, sysbuf, sizeof(sysbuf)))
|
||||||
goto_out;
|
goto_out;
|
||||||
|
|
||||||
if (_dm_uuid_has_prefix(sysbuf, "mpath-"))
|
if (_dm_uuid_has_prefix(sysbuf, "mpath-"))
|
||||||
|
@ -1257,8 +1257,12 @@ int label_scan(struct cmd_context *cmd)
|
|||||||
if (!label_scan_setup_bcache())
|
if (!label_scan_setup_bcache())
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
/* Initialize dm device cache early so
|
/*
|
||||||
* 'Hints' file processing can also use it */
|
* Initialize cache of dm device uuids, which uses a special dm kernel
|
||||||
|
* feature for efficiently querying many dm devs together. (It's done
|
||||||
|
* here, before processing the hints file, so that the dm uuid checks
|
||||||
|
* in hint processing can benefit from the dm uuid cache.)
|
||||||
|
*/
|
||||||
if (!dev_cache_update_dm_devs(cmd))
|
if (!dev_cache_update_dm_devs(cmd))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
|
@ -6066,7 +6066,7 @@ int get_rootvg_dev_uuid(struct cmd_context *cmd, char **dm_uuid_out)
|
|||||||
if (stat(me->mnt_dir, &info) < 0)
|
if (stat(me->mnt_dir, &info) < 0)
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!device_get_uuid(cmd, MAJOR(info.st_dev), MINOR(info.st_dev), dm_uuid, sizeof(dm_uuid)))
|
if (!devno_dm_uuid(cmd, MAJOR(info.st_dev), MINOR(info.st_dev), dm_uuid, sizeof(dm_uuid)))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
log_debug("Found root dm_uuid %s", dm_uuid);
|
log_debug("Found root dm_uuid %s", dm_uuid);
|
||||||
|
Loading…
Reference in New Issue
Block a user