From: Arvin Schnell Date: Thu, 18 Apr 2024 13:10:47 +0000 (+0200) Subject: - async cleanup of stale btrfs qgroups (bsc#1222847) X-Git-Tag: v0.11.0~3^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F899%2Fhead;p=thirdparty%2Fsnapper.git - async cleanup of stale btrfs qgroups (bsc#1222847) --- diff --git a/client/systemd-helper.cc b/client/systemd-helper.cc index 88d7b07b..12751c94 100644 --- a/client/systemd-helper.cc +++ b/client/systemd-helper.cc @@ -1,6 +1,6 @@ /* * Copyright (c) [2014-2015] Novell, Inc. - * Copyright (c) [2016-2023] SUSE LLC + * Copyright (c) [2016-2024] SUSE LLC * * All Rights Reserved. * @@ -26,6 +26,9 @@ #include #include +#include +#include + #include "utils/text.h" #include "utils/GetOpts.h" @@ -169,6 +172,20 @@ cleanup(ProxySnappers* snappers) ok = false; } } + + string fstype; + if (proxy_config.getValue(KEY_FSTYPE, fstype) && fstype == "btrfs") + { + string subvolume; + if (proxy_config.getValue(KEY_SUBVOLUME, subvolume)) + { + cout << "Running 'btrfs qgroup clear-stale " << subvolume << "'." << endl; + + SystemCmd cmd({ BTRFS_BIN, "qgroup", "clear-stale", subvolume }); + if (cmd.retcode() != 0) + cerr << "'btrfs qgroup clear-stale " << subvolume << "' failed." << endl; + } + } } return ok; diff --git a/package/snapper.changes b/package/snapper.changes index 05c4e0b3..28b47f94 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Apr 18 15:03:31 CEST 2024 - aschnell@suse.com + +- async cleanup of stale btrfs qgroups (bsc#1222847) + ------------------------------------------------------------------- Wed Apr 17 17:03:40 CEST 2024 - aschnell@suse.com diff --git a/snapper/Btrfs.cc b/snapper/Btrfs.cc index 7659e4ec..32511adf 100644 --- a/snapper/Btrfs.cc +++ b/snapper/Btrfs.cc @@ -423,25 +423,6 @@ namespace snapper #if defined(HAVE_LIBBTRFS) || defined(HAVE_LIBBTRFSUTIL) deleted_subvolids.push_back(subvolid); -#endif - -#ifdef ENABLE_BTRFS_QUOTA - - // workaround for the kernel not deleting the qgroup of a - // subvolume when deleting the subvolume, see - // https://bugzilla.suse.com/show_bug.cgi?id=972511 - - try - { - SDir general_dir = openGeneralDir(); - qgroup_destroy(general_dir.fd(), calc_qgroup(0, subvolid)); - } - catch (const runtime_error& e) - { - // Ignore that the qgroup could not be destroyed. Should not - // cause problems except of having stale qgroups. - } - #endif } catch (const runtime_error& e) diff --git a/snapper/SnapperDefines.h b/snapper/SnapperDefines.h index 154f069b..fe2d3ee8 100644 --- a/snapper/SnapperDefines.h +++ b/snapper/SnapperDefines.h @@ -1,6 +1,6 @@ /* * Copyright (c) [2004-2014] Novell, Inc. - * Copyright (c) [2020-2023] SUSE LLC + * Copyright (c) [2020-2024] SUSE LLC * * All Rights Reserved. * @@ -47,6 +47,8 @@ #define SH_BIN "/bin/sh" +#define BTRFS_BIN "/usr/sbin/btrfs" + #define SYSTEMCTL_BIN "/usr/bin/systemctl"