]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- async cleanup of stale btrfs qgroups (bsc#1222847) 899/head
authorArvin Schnell <aschnell@suse.de>
Thu, 18 Apr 2024 13:10:47 +0000 (15:10 +0200)
committerArvin Schnell <aschnell@suse.de>
Thu, 18 Apr 2024 13:10:47 +0000 (15:10 +0200)
client/systemd-helper.cc
package/snapper.changes
snapper/Btrfs.cc
snapper/SnapperDefines.h

index 88d7b07b2755360ea475042ea7084adafdbcab45..12751c94e891efc5b6c8a3e41e8e0e478fc0629f 100644 (file)
@@ -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 <cstdlib>
 #include <iostream>
 
+#include <snapper/SystemCmd.h>
+#include <snapper/SnapperDefines.h>
+
 #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;
index 05c4e0b3470a610d2a0ea0af082befd962ff67e1..28b47f94644f180079e48fd117e6e2f3ebcee2ec 100644 (file)
@@ -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
 
index 7659e4ec49c8bcad6c54350f51fd1180775dd619..32511adf74d2068a23a682efc9989bd61724a1f9 100644 (file)
@@ -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)
index 154f069b4a85a680c1cbd35dc513e7ce94f1bfcd..fe2d3ee859ecd9601a9ded69b9d02b527f807003 100644 (file)
@@ -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"