From 67790d7e3bcfb202eb42d23ab36dfdfe31713996 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 27 Feb 2021 21:22:41 +0100 Subject: [PATCH] device_mapper: reduce min_size for flatten For most ioctl() we do not need to pass so big buffers and we can reduce amount of zeroed memory blocks. --- device_mapper/ioctl/libdm-iface.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c index 116fa3dc1..906d84b4e 100644 --- a/device_mapper/ioctl/libdm-iface.c +++ b/device_mapper/ioctl/libdm-iface.c @@ -1118,7 +1118,7 @@ static int _add_params(int type) static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count) { - const size_t min_size = 16 * 1024; + size_t min_size; const int (*version)[3]; struct dm_ioctl *dmi; @@ -1137,6 +1137,18 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count) else if (dmt->head) log_debug_activation(INTERNAL_ERROR "dm '%s' ioctl should not define parameters.", _cmd_data_v4[dmt->type].name); + switch (dmt->type) { + case DM_DEVICE_CREATE: + case DM_DEVICE_DEPS: + case DM_DEVICE_INFO: + case DM_DEVICE_LIST: + case DM_DEVICE_STATUS: + case DM_DEVICE_TABLE: + case DM_DEVICE_TARGET_MSG: + min_size = 16 * 1024; + default: + min_size = 2 * 1024; + } if (count && (dmt->sector || dmt->message)) { log_error("targets and message are incompatible"); -- 2.43.5