mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Add DEV_NAME macro.
Use the DEV_NAME macro to use the mangled form of the name if present, use normal name otherwise (we store both forms - mangled and unmangled in struct dm_task). Mangled form should be always preferred over unmangled with the exception of the situations where we divide one task into several others (like "create and load") - we need to avoid mangling the name twice (because of multiple dm_task_set_name calls)!
This commit is contained in:
parent
55761e14af
commit
2e8c7f2975
@ -664,9 +664,7 @@ uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead)
|
|||||||
|
|
||||||
if (*dmt->dmi.v4->name)
|
if (*dmt->dmi.v4->name)
|
||||||
dev_name = dmt->dmi.v4->name;
|
dev_name = dmt->dmi.v4->name;
|
||||||
else if (dmt->dev_name)
|
else if (!(dev_name = DEV_NAME(dmt))) {
|
||||||
dev_name = dmt->dev_name;
|
|
||||||
else {
|
|
||||||
log_error("Get read ahead request failed: device name unrecorded.");
|
log_error("Get read ahead request failed: device name unrecorded.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1041,7 +1039,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Does driver support device number referencing? */
|
/* Does driver support device number referencing? */
|
||||||
if (_dm_version_minor < 3 && !dmt->dev_name && !dmt->uuid && dmi->dev) {
|
if (_dm_version_minor < 3 && !DEV_NAME(dmt) && !dmt->uuid && dmi->dev) {
|
||||||
if (!_lookup_dev_name(dmi->dev, dmi->name, sizeof(dmi->name))) {
|
if (!_lookup_dev_name(dmi->dev, dmi->name, sizeof(dmi->name))) {
|
||||||
log_error("Unable to find name for device (%" PRIu32
|
log_error("Unable to find name for device (%" PRIu32
|
||||||
":%" PRIu32 ")", dmt->major, dmt->minor);
|
":%" PRIu32 ")", dmt->major, dmt->minor);
|
||||||
@ -1053,9 +1051,9 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME Until resume ioctl supplies name, use dev_name for readahead */
|
/* FIXME Until resume ioctl supplies name, use dev_name for readahead */
|
||||||
if (dmt->dev_name && (dmt->type != DM_DEVICE_RESUME || dmt->minor < 0 ||
|
if (DEV_NAME(dmt) && (dmt->type != DM_DEVICE_RESUME || dmt->minor < 0 ||
|
||||||
dmt->major < 0))
|
dmt->major < 0))
|
||||||
strncpy(dmi->name, dmt->dev_name, sizeof(dmi->name));
|
strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
|
||||||
|
|
||||||
if (dmt->uuid)
|
if (dmt->uuid)
|
||||||
strncpy(dmi->uuid, dmt->uuid, sizeof(dmi->uuid));
|
strncpy(dmi->uuid, dmt->uuid, sizeof(dmi->uuid));
|
||||||
@ -1464,7 +1462,7 @@ static int _check_children_not_suspended_v4(struct dm_task *dmt, uint64_t device
|
|||||||
else
|
else
|
||||||
log_error(INTERNAL_ERROR "Attempt to suspend device %s%s%s%.0d%s%.0d%s%s"
|
log_error(INTERNAL_ERROR "Attempt to suspend device %s%s%s%.0d%s%.0d%s%s"
|
||||||
"that uses already-suspended device (%u:%u)",
|
"that uses already-suspended device (%u:%u)",
|
||||||
dmt->dev_name ? : "", dmt->uuid ? : "",
|
DEV_NAME(dmt) ? : "", dmt->uuid ? : "",
|
||||||
dmt->major > 0 ? "(" : "",
|
dmt->major > 0 ? "(" : "",
|
||||||
dmt->major > 0 ? dmt->major : 0,
|
dmt->major > 0 ? dmt->major : 0,
|
||||||
dmt->major > 0 ? ":" : "",
|
dmt->major > 0 ? ":" : "",
|
||||||
@ -1675,6 +1673,7 @@ int dm_task_run(struct dm_task *dmt)
|
|||||||
int suspended_counter;
|
int suspended_counter;
|
||||||
unsigned ioctl_retry = 1;
|
unsigned ioctl_retry = 1;
|
||||||
int retryable = 0;
|
int retryable = 0;
|
||||||
|
const char *dev_name = DEV_NAME(dmt);
|
||||||
|
|
||||||
if ((unsigned) dmt->type >=
|
if ((unsigned) dmt->type >=
|
||||||
(sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) {
|
(sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) {
|
||||||
@ -1689,7 +1688,7 @@ int dm_task_run(struct dm_task *dmt)
|
|||||||
if (dmt->type == DM_DEVICE_CREATE && dmt->head)
|
if (dmt->type == DM_DEVICE_CREATE && dmt->head)
|
||||||
return _create_and_load_v4(dmt);
|
return _create_and_load_v4(dmt);
|
||||||
|
|
||||||
if (dmt->type == DM_DEVICE_MKNODES && !dmt->dev_name &&
|
if (dmt->type == DM_DEVICE_MKNODES && !dev_name &&
|
||||||
!dmt->uuid && dmt->major <= 0)
|
!dmt->uuid && dmt->major <= 0)
|
||||||
return _mknodes_v4(dmt);
|
return _mknodes_v4(dmt);
|
||||||
|
|
||||||
@ -1710,7 +1709,7 @@ int dm_task_run(struct dm_task *dmt)
|
|||||||
"are known to be suspended: "
|
"are known to be suspended: "
|
||||||
"%s%s%s %s%.0d%s%.0d%s%s",
|
"%s%s%s %s%.0d%s%.0d%s%s",
|
||||||
suspended_counter,
|
suspended_counter,
|
||||||
dmt->dev_name ? : "",
|
dev_name ? : "",
|
||||||
dmt->uuid ? " UUID " : "",
|
dmt->uuid ? " UUID " : "",
|
||||||
dmt->uuid ? : "",
|
dmt->uuid ? : "",
|
||||||
dmt->major > 0 ? "(" : "",
|
dmt->major > 0 ? "(" : "",
|
||||||
@ -1769,32 +1768,32 @@ repeat_ioctl:
|
|||||||
switch (dmt->type) {
|
switch (dmt->type) {
|
||||||
case DM_DEVICE_CREATE:
|
case DM_DEVICE_CREATE:
|
||||||
if ((dmt->add_node == DM_ADD_NODE_ON_CREATE) &&
|
if ((dmt->add_node == DM_ADD_NODE_ON_CREATE) &&
|
||||||
dmt->dev_name && *dmt->dev_name && !rely_on_udev)
|
dev_name && *dev_name && !rely_on_udev)
|
||||||
add_dev_node(dmt->dev_name, MAJOR(dmi->dev),
|
add_dev_node(dev_name, MAJOR(dmi->dev),
|
||||||
MINOR(dmi->dev), dmt->uid, dmt->gid,
|
MINOR(dmi->dev), dmt->uid, dmt->gid,
|
||||||
dmt->mode, check_udev, rely_on_udev);
|
dmt->mode, check_udev, rely_on_udev);
|
||||||
break;
|
break;
|
||||||
case DM_DEVICE_REMOVE:
|
case DM_DEVICE_REMOVE:
|
||||||
/* FIXME Kernel needs to fill in dmi->name */
|
/* FIXME Kernel needs to fill in dmi->name */
|
||||||
if (dmt->dev_name && !rely_on_udev)
|
if (dev_name && !rely_on_udev)
|
||||||
rm_dev_node(dmt->dev_name, check_udev, rely_on_udev);
|
rm_dev_node(dev_name, check_udev, rely_on_udev);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DM_DEVICE_RENAME:
|
case DM_DEVICE_RENAME:
|
||||||
/* FIXME Kernel needs to fill in dmi->name */
|
/* FIXME Kernel needs to fill in dmi->name */
|
||||||
if (!dmt->new_uuid && dmt->dev_name)
|
if (!dmt->new_uuid && dev_name)
|
||||||
rename_dev_node(dmt->dev_name, dmt->newname,
|
rename_dev_node(dev_name, dmt->newname,
|
||||||
check_udev, rely_on_udev);
|
check_udev, rely_on_udev);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DM_DEVICE_RESUME:
|
case DM_DEVICE_RESUME:
|
||||||
if ((dmt->add_node == DM_ADD_NODE_ON_RESUME) &&
|
if ((dmt->add_node == DM_ADD_NODE_ON_RESUME) &&
|
||||||
dmt->dev_name && *dmt->dev_name)
|
dev_name && *dev_name)
|
||||||
add_dev_node(dmt->dev_name, MAJOR(dmi->dev),
|
add_dev_node(dev_name, MAJOR(dmi->dev),
|
||||||
MINOR(dmi->dev), dmt->uid, dmt->gid,
|
MINOR(dmi->dev), dmt->uid, dmt->gid,
|
||||||
dmt->mode, check_udev, rely_on_udev);
|
dmt->mode, check_udev, rely_on_udev);
|
||||||
/* FIXME Kernel needs to fill in dmi->name */
|
/* FIXME Kernel needs to fill in dmi->name */
|
||||||
set_dev_node_read_ahead(dmt->dev_name,
|
set_dev_node_read_ahead(dev_name,
|
||||||
MAJOR(dmi->dev), MINOR(dmi->dev),
|
MAJOR(dmi->dev), MINOR(dmi->dev),
|
||||||
dmt->read_ahead, dmt->read_ahead_flags);
|
dmt->read_ahead, dmt->read_ahead_flags);
|
||||||
break;
|
break;
|
||||||
@ -1804,8 +1803,8 @@ repeat_ioctl:
|
|||||||
add_dev_node(dmi->name, MAJOR(dmi->dev),
|
add_dev_node(dmi->name, MAJOR(dmi->dev),
|
||||||
MINOR(dmi->dev), dmt->uid,
|
MINOR(dmi->dev), dmt->uid,
|
||||||
dmt->gid, dmt->mode, 0, rely_on_udev);
|
dmt->gid, dmt->mode, 0, rely_on_udev);
|
||||||
else if (dmt->dev_name)
|
else if (dev_name)
|
||||||
rm_dev_node(dmt->dev_name, 0, rely_on_udev);
|
rm_dev_node(dev_name, 0, rely_on_udev);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DM_DEVICE_STATUS:
|
case DM_DEVICE_STATUS:
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "libdevmapper.h"
|
#include "libdevmapper.h"
|
||||||
|
|
||||||
|
#define DEV_NAME(dmt) (dmt->mangled_dev_name ? : dmt->dev_name)
|
||||||
|
|
||||||
int mangle_name(const char *str, size_t len, char *buf,
|
int mangle_name(const char *str, size_t len, char *buf,
|
||||||
size_t buf_len, dm_string_mangling_t mode);
|
size_t buf_len, dm_string_mangling_t mode);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user