From c3ed3f28a2a13c1f2d3124bf43b73facb8fd02c0 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 7 Nov 2024 18:46:24 +0100 Subject: [PATCH] device_mapper: suppress warns about inactive query When command prints warning about suppressing query for inactive table, because this is not supported by kernel - 1 printed message is just enough, no reason to 'spam' command output all the time, message will remain only in debug log. Also drop 'WARNING:' from real 'error' message. WARNIGS are supposed to be just warning and command then exists with 'success'. --- device_mapper/ioctl/libdm-iface.c | 14 ++++++++------ libdm/ioctl/libdm-iface.c | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c index 3f8a3e4eb..235857426 100644 --- a/device_mapper/ioctl/libdm-iface.c +++ b/device_mapper/ioctl/libdm-iface.c @@ -70,6 +70,7 @@ static unsigned _dm_version_minor = 0; static unsigned _dm_version_patchlevel = 0; static int _log_suppress = 0; static struct dm_timestamp *_dm_ioctl_timestamp = NULL; +static int _dm_warn_inactive_suppress = 0; /* * If the kernel dm driver only supports one major number @@ -1412,22 +1413,23 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count) } if (dmt->query_inactive_table) { if (!_dm_inactive_supported()) - log_warn("WARNING: Inactive table query unsupported " - "by kernel. It will use live table."); + log_warn_suppress(_dm_warn_inactive_suppress++, + "WARNING: Inactive table query unsupported by kernel. " + "It will use live table."); dmi->flags |= DM_QUERY_INACTIVE_TABLE_FLAG; } if (dmt->new_uuid) { if (_dm_version_minor < 19) { - log_error("WARNING: Setting UUID unsupported by " - "kernel. Aborting operation."); + log_error("Setting UUID unsupported by kernel. " + "Aborting operation."); goto bad; } dmi->flags |= DM_UUID_FLAG; } if (dmt->ima_measurement) { if (_dm_version_minor < 45) { - log_error("WARNING: IMA measurement unsupported by " - "kernel. Aborting operation."); + log_error("IMA measurement unsupported by kernel. " + "Aborting operation."); goto bad; } dmi->flags |= DM_IMA_MEASUREMENT_FLAG; diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index d10085881..7e42f2752 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -69,6 +69,7 @@ static unsigned _dm_version_minor = 0; static unsigned _dm_version_patchlevel = 0; static int _log_suppress = 0; static struct dm_timestamp *_dm_ioctl_timestamp = NULL; +static int _dm_warn_inactive_suppress = 0; /* * If the kernel dm driver only supports one major number @@ -1307,22 +1308,23 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count) } if (dmt->query_inactive_table) { if (!_dm_inactive_supported()) - log_warn("WARNING: Inactive table query unsupported " - "by kernel. It will use live table."); + log_warn_suppress(_dm_warn_inactive_suppress++, + "WARNING: Inactive table query unsupported by kernel. " + "It will use live table."); dmi->flags |= DM_QUERY_INACTIVE_TABLE_FLAG; } if (dmt->new_uuid) { if (_dm_version_minor < 19) { - log_error("WARNING: Setting UUID unsupported by " - "kernel. Aborting operation."); + log_error("Setting UUID unsupported by kernel. " + "Aborting operation."); goto bad; } dmi->flags |= DM_UUID_FLAG; } if (dmt->ima_measurement) { if (_dm_version_minor < 45) { - log_error("WARNING: IMA measurement unsupported by " - "kernel. Aborting operation."); + log_error("IMA measurement unsupported by kernel. " + "Aborting operation."); goto bad; } dmi->flags |= DM_IMA_MEASUREMENT_FLAG;