Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lvcreate: --quiet doesn't suppress overallocation warning. #57

Open
dseomn opened this issue Aug 24, 2021 · 3 comments
Open

lvcreate: --quiet doesn't suppress overallocation warning. #57

dseomn opened this issue Aug 24, 2021 · 3 comments

Comments

@dseomn
Copy link

dseomn commented Aug 24, 2021

Is there any way to suppress the warning below? I only want to see errors.

dseomn@ilus:~$ sudo lvcreate --quiet --quiet -s -n delete-me ilus-vg/data_test
  WARNING: Sum of all thin volume sizes (<2.01 TiB) exceeds the size of thin pool ilus-vg/thin_pool and the size of whole volume group (465.28 GiB).

In case it helps:

dseomn@ilus:~$ sudo lvcreate --version
  LVM version:     2.03.11(2) (2021-01-08)
  Library version: 1.02.175 (2021-01-08)
  Driver version:  4.43.0
  Configuration:   ./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=${prefix}/include --mandir=${prefix}/share/man --infodir=${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir=${prefix}/lib/x86_64-linux-gnu --runstatedir=/run --disable-maintainer-mode --disable-dependency-tracking --libdir=/lib/x86_64-linux-gnu --sbindir=/sbin --with-usrlibdir=/usr/lib/x86_64-linux-gnu --with-optimisation=-O2 --with-cache=internal --with-device-uid=0 --with-device-gid=6 --with-device-mode=0660 --with-default-pid-dir=/run --with-default-run-dir=/run/lvm --with-default-locking-dir=/run/lock/lvm --with-thin=internal --with-thin-check=/usr/sbin/thin_check --with-thin-dump=/usr/sbin/thin_dump --with-thin-repair=/usr/sbin/thin_repair --with-udev-prefix=/ --enable-applib --enable-blkid_wiping --enable-cmdlib --enable-dmeventd --enable-editline --enable-lvmlockd-dlm --enable-lvmlockd-sanlock --enable-lvmpolld --enable-notify-dbus --enable-pkgconfig --enable-udev_rules --enable-udev_sync --disable-readline
@utkonos
Copy link

utkonos commented May 6, 2022

My own use case is that I make a large number of snapshots which eventually trigger all of these warnings even though the actual used space is nowhere near the size that will endanger the pool. When I am done with a particular task, all the snapshots are deleted leaving the base volume. I don't need any of these warnings and I would like them all suppressed. I know of other projects and users who would like to suppress this warning as well along with the other three that you are suppressing via --quiet. Here is the relevant source code:

if (sz != UINT64_C(~0)) {
log_warn("WARNING: Sum of all thin volume sizes (%s) exceeds the "
"size of thin pool%s%s%s (%s).",
display_size(cmd, thinsum),
more_pools ? "" : " ",
more_pools ? "s" : display_lvname(pool_lv),
txt,
(sz > 0) ? display_size(cmd, sz) : "no free space in volume group");
if (max_threshold > 99 || !min_percent)
log_print_unless_silent("WARNING: You have not turned on protection against thin pools running out of space.");
if (max_threshold > 99)
log_print_unless_silent("WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.");
if (!min_percent)
log_print_unless_silent("WARNING: Set activation/thin_pool_autoextend_percent above 0 to specify by how much to extend thin pools reaching the threshold.");
/* FIXME Also warn if there isn't sufficient free space for one pool extension to occur? */
}

As you can see, the first warning is logged using a different method than the other three: log_warn vs log_print_unless_silent. A simple solution would be to make all four of these warnings log_print_unless_silent. However, I think this is a suboptimal solution that may suppress other useful warnings throwing out the baby with the bathwater.

I have read what I think are all of the historical mailing list threads and forum threads on this particular topic. I have found one proposed fix that appears to be optimal for my use case: adding an envvar LVM_SUPPRESS_POOL_WARNINGS. This was proposed by @zkabelac here:
https://listman.redhat.com/archives/linux-lvm/2017-September/024332.html

As stated in that proposal, there are two precedents for this type of suppression that are already implemented in LVM2: LVM_SUPPRESS_FD_WARNINGS and LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES.

Here are two historical threads about this feature request from the mailing list:
https://listman.redhat.com/archives/linux-lvm/2016-April/023529.html
https://listman.redhat.com/archives/linux-lvm/2017-September/024323.html

Here is an issue in the bugtracker at RedHat (unfortunately marked WONTFIX):
https://bugzilla.redhat.com/show_bug.cgi?id=1465974

Here is a forum thread over at Proxmox tracking this issue downstream:
https://forum.proxmox.com/threads/solved-you-have-not-turned-on-protection-against-thin-pools-running-out-of-space.91055/

I posted about this all to the lvm-linux mailing list, and there is interest in this change from the Qubes OS project and @DemiMarie:
https://listman.redhat.com/archives/linux-lvm/2022-May/026169.html

I am now going to suggest that all users and projects that want this change add a 👍 this issue so that there is a measurement of interest.

@utkonos
Copy link

utkonos commented May 8, 2022

I've done a bit more digging. These are the locations where messages/warnings are suppressed elsewhere:

LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES

lvm2/lib/locking/locking.c

Lines 128 to 157 in 8dccc23

int init_locking(struct cmd_context *cmd,
int file_locking_sysinit, int file_locking_readonly, int file_locking_ignorefail)
{
int suppress_messages = 0;
if (file_locking_sysinit || getenv("LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES"))
suppress_messages = 1;
_blocking_supported = find_config_tree_bool(cmd, global_wait_for_locks_CFG, NULL);
_file_locking_readonly = file_locking_readonly;
_file_locking_sysinit = file_locking_sysinit;
_file_locking_ignorefail = file_locking_ignorefail;
log_debug("File locking settings: readonly:%d sysinit:%d ignorelockingfailure:%d global/metadata_read_only:%d global/wait_for_locks:%d.",
_file_locking_readonly, _file_locking_sysinit, _file_locking_ignorefail,
cmd->metadata_read_only, _blocking_supported);
if (!init_file_locking(&_locking, cmd, suppress_messages)) {
log_error_suppress(suppress_messages, "File locking initialisation failed.");
_file_locking_failed = 1;
if (file_locking_sysinit || file_locking_ignorefail)
return 1;
return 0;
}
return 1;
}

LVM_SUPPRESS_FD_WARNINGS

lvm2/tools/lvmcmdline.c

Lines 3550 to 3586 in 8dccc23

if (getenv("LVM_SUPPRESS_FD_WARNINGS"))
suppress_warnings = 1;
if (!(d = opendir(_fd_dir))) {
if (errno != ENOENT) {
log_sys_error("opendir", _fd_dir);
return 0; /* broken system */
}
/* Path does not exist, use the old way */
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
log_sys_error("getrlimit", "RLIMIT_NOFILE");
return 1;
}
for (fd = 3; fd < (int)rlim.rlim_cur; fd++) {
if ((fd != custom_fds->out) &&
(fd != custom_fds->err) &&
(fd != custom_fds->report)) {
_close_descriptor(fd, suppress_warnings, command, ppid,
parent_cmdline);
}
}
return 1;
}
while ((dirent = readdir(d))) {
fd = atoi(dirent->d_name);
if ((fd > 2) &&
(fd != dirfd(d)) &&
(fd != custom_fds->out) &&
(fd != custom_fds->err) &&
(fd != custom_fds->report)) {
_close_descriptor(fd, suppress_warnings,
command, ppid, parent_cmdline);
}
}

@utkonos
Copy link

utkonos commented May 8, 2022

Would this change do the trick?

if (sz != UINT64_C(~0)) { => if (sz != UINT64_C(~0) and !(getenv("LVM_SUPPRESS_POOL_WARNINGS"))) {

Is an envvar available in this way to thin_manip.c?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants