mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
libdm: print params only for ioctls using them
When preparing ioctl buffer and flatting all parameters,
add table parameters only to ioctl that do process them.
Note: list of ioctl should be kept in sync with kernel code.
(cherry picked from commit 43f8da7699
)
This commit is contained in:
parent
15d51bd6d0
commit
c8ca03d5b7
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.155 -
|
Version 1.02.155 -
|
||||||
====================================
|
====================================
|
||||||
|
Enhance ioctl flattening and add parameters only when needed.
|
||||||
Add DM_DEVICE_ARM_POLL for API completness matching kernel.
|
Add DM_DEVICE_ARM_POLL for API completness matching kernel.
|
||||||
Do not add parameters for RESUME with DM_DEVICE_CREATE dm task.
|
Do not add parameters for RESUME with DM_DEVICE_CREATE dm task.
|
||||||
|
|
||||||
|
@ -1087,6 +1087,22 @@ static int _lookup_dev_name(uint64_t dev, char *buf, size_t len)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _add_params(int type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case DM_DEVICE_REMOVE_ALL:
|
||||||
|
case DM_DEVICE_CREATE:
|
||||||
|
case DM_DEVICE_REMOVE:
|
||||||
|
case DM_DEVICE_SUSPEND:
|
||||||
|
case DM_DEVICE_STATUS:
|
||||||
|
case DM_DEVICE_CLEAR:
|
||||||
|
case DM_DEVICE_ARM_POLL:
|
||||||
|
return 0; /* IOCTL_FLAGS_NO_PARAMS in drivers/md/dm-ioctl.c */
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||||
{
|
{
|
||||||
const size_t min_size = 16 * 1024;
|
const size_t min_size = 16 * 1024;
|
||||||
@ -1099,11 +1115,15 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
|||||||
char *b, *e;
|
char *b, *e;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (t = dmt->head; t; t = t->next) {
|
if (_add_params(dmt->type))
|
||||||
len += sizeof(struct dm_target_spec);
|
for (t = dmt->head; t; t = t->next) {
|
||||||
len += strlen(t->params) + 1 + ALIGNMENT;
|
len += sizeof(struct dm_target_spec);
|
||||||
count++;
|
len += strlen(t->params) + 1 + ALIGNMENT;
|
||||||
}
|
count++;
|
||||||
|
}
|
||||||
|
else if (dmt->head)
|
||||||
|
log_debug_activation(INTERNAL_ERROR "dm '%s' ioctl should not define parameters.",
|
||||||
|
_cmd_data_v4[dmt->type].name);
|
||||||
|
|
||||||
if (count && (dmt->sector || dmt->message)) {
|
if (count && (dmt->sector || dmt->message)) {
|
||||||
log_error("targets and message are incompatible");
|
log_error("targets and message are incompatible");
|
||||||
@ -1253,9 +1273,10 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
|||||||
b = (char *) (dmi + 1);
|
b = (char *) (dmi + 1);
|
||||||
e = (char *) dmi + len;
|
e = (char *) dmi + len;
|
||||||
|
|
||||||
for (t = dmt->head; t; t = t->next)
|
if (_add_params(dmt->type))
|
||||||
if (!(b = _add_target(t, b, e)))
|
for (t = dmt->head; t; t = t->next)
|
||||||
goto_bad;
|
if (!(b = _add_target(t, b, e)))
|
||||||
|
goto_bad;
|
||||||
|
|
||||||
if (dmt->newname)
|
if (dmt->newname)
|
||||||
strcpy(b, dmt->newname);
|
strcpy(b, dmt->newname);
|
||||||
|
@ -1099,6 +1099,22 @@ static int _lookup_dev_name(uint64_t dev, char *buf, size_t len)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _add_params(int type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case DM_DEVICE_REMOVE_ALL:
|
||||||
|
case DM_DEVICE_CREATE:
|
||||||
|
case DM_DEVICE_REMOVE:
|
||||||
|
case DM_DEVICE_SUSPEND:
|
||||||
|
case DM_DEVICE_STATUS:
|
||||||
|
case DM_DEVICE_CLEAR:
|
||||||
|
case DM_DEVICE_ARM_POLL:
|
||||||
|
return 0; /* IOCTL_FLAGS_NO_PARAMS in drivers/md/dm-ioctl.c */
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||||
{
|
{
|
||||||
const size_t min_size = 16 * 1024;
|
const size_t min_size = 16 * 1024;
|
||||||
@ -1111,11 +1127,15 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
|||||||
char *b, *e;
|
char *b, *e;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (t = dmt->head; t; t = t->next) {
|
if (_add_params(dmt->type))
|
||||||
len += sizeof(struct dm_target_spec);
|
for (t = dmt->head; t; t = t->next) {
|
||||||
len += strlen(t->params) + 1 + ALIGNMENT;
|
len += sizeof(struct dm_target_spec);
|
||||||
count++;
|
len += strlen(t->params) + 1 + ALIGNMENT;
|
||||||
}
|
count++;
|
||||||
|
}
|
||||||
|
else if (dmt->head)
|
||||||
|
log_debug_activation(INTERNAL_ERROR "dm '%s' ioctl should not define parameters.",
|
||||||
|
_cmd_data_v4[dmt->type].name);
|
||||||
|
|
||||||
if (count && (dmt->sector || dmt->message)) {
|
if (count && (dmt->sector || dmt->message)) {
|
||||||
log_error("targets and message are incompatible");
|
log_error("targets and message are incompatible");
|
||||||
@ -1265,9 +1285,10 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
|||||||
b = (char *) (dmi + 1);
|
b = (char *) (dmi + 1);
|
||||||
e = (char *) dmi + len;
|
e = (char *) dmi + len;
|
||||||
|
|
||||||
for (t = dmt->head; t; t = t->next)
|
if (_add_params(dmt->type))
|
||||||
if (!(b = _add_target(t, b, e)))
|
for (t = dmt->head; t; t = t->next)
|
||||||
goto_bad;
|
if (!(b = _add_target(t, b, e)))
|
||||||
|
goto_bad;
|
||||||
|
|
||||||
if (dmt->newname)
|
if (dmt->newname)
|
||||||
strcpy(b, dmt->newname);
|
strcpy(b, dmt->newname);
|
||||||
|
Loading…
Reference in New Issue
Block a user