]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- deal with CaaSP btrfs setup where certain subvolumes are read-only (bsc#1018302... 323/head
authorArvin Schnell <aschnell@suse.de>
Fri, 3 Feb 2017 10:30:31 +0000 (11:30 +0100)
committerArvin Schnell <aschnell@suse.de>
Fri, 3 Feb 2017 10:30:31 +0000 (11:30 +0100)
VERSION
package/snapper.changes
snapper/Btrfs.cc
snapper/Btrfs.h
snapper/Snapper.cc

diff --git a/VERSION b/VERSION
index 2b7c5ae01848a77d95e2792eb83ab605c9aed91a..17b2ccd9bf9050efdf57d7800677e87919b9b5b9 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.4.2
+0.4.3
index e9e3bab29cece451aedc8c96a829c635ba63822f..34ea4dfd390455ab3c85789ce26e9227395c11fe 100644 (file)
@@ -1,3 +1,10 @@
+-------------------------------------------------------------------
+Thu Feb 02 19:07:40 CET 2017 - aschnell@suse.com
+
+- deal with CaaSP btrfs setup where certain subvolumes are
+  read-only (bsc#1018302 and bsc#1018095)
+- version 0.4.3
+
 -------------------------------------------------------------------
 Thu Feb 02 14:49:59 CET 2017 - aschnell@suse.com
 
index efc6363ae7e1a52c9b43f31d26be9689e0d9b7b8..6be6e868d3433f9a92c06f4a3cb3f01760dd9aa2 100644 (file)
@@ -296,6 +296,13 @@ namespace snapper
     }
 
 
+    SDir
+    Btrfs::openGeneralDir() const
+    {
+       return openInfosDir();
+    }
+
+
     void
     Btrfs::createSnapshot(unsigned int num, unsigned int num_parent, bool read_only,
                          bool quota) const
@@ -1446,19 +1453,19 @@ namespace snapper
     {
        try
        {
+           SDir general_dir = openGeneralDir();
+
            if (num == 0)
            {
                SDir subvolume_dir = openSubvolumeDir();
                subvolid_t id = get_id(subvolume_dir.fd());
-               set_default_id(subvolume_dir.fd(), id);
+               set_default_id(general_dir.fd(), id);
            }
            else
            {
                SDir snapshot_dir = openSnapshotDir(num);
                subvolid_t id = get_id(snapshot_dir.fd());
-
-               SDir subvolume_dir = openSubvolumeDir();
-               set_default_id(subvolume_dir.fd(), id);
+               set_default_id(general_dir.fd(), id);
            }
        }
        catch (const runtime_error& e)
index 6636b718797eda052d03648bba0d5b748ccea707..7b427828b03f1c42b2ad84ceb3cecc8b56cca270 100644 (file)
@@ -60,6 +60,13 @@ namespace snapper
        virtual SDir openInfosDir() const;
        virtual SDir openSnapshotDir(unsigned int num) const;
 
+       /**
+        * A general read-write directory that can be used for ioctls. The
+        * exact directory can change to adapt to the system changes,
+        * e.g. which subvolumes are read-only.
+        */
+       SDir openGeneralDir() const;
+
        virtual void createSnapshot(unsigned int num, unsigned int num_parent, bool read_only,
                                    bool quota) const;
        virtual void createSnapshotOfDefault(unsigned int num, bool read_only, bool quota) const;
index d6ee38023213a28a7204f586d12582cf08c0624d..9159e11fefb230f05494e74189aa0adcc9f2f2f0 100644 (file)
@@ -661,15 +661,15 @@ namespace snapper
        if (btrfs->getQGroup() != no_qgroup)
            SN_THROW(QuotaException("qgroup already set"));
 
-       SDir subvolume_dir = openSubvolumeDir();
+       SDir general_dir = btrfs->openGeneralDir();
 
-       quota_enable(subvolume_dir.fd());
+       quota_enable(general_dir.fd());
 
-       qgroup_t qgroup = qgroup_find_free(subvolume_dir.fd(), 1);
+       qgroup_t qgroup = qgroup_find_free(general_dir.fd(), 1);
 
        y2mil("free qgroup:" << format_qgroup(qgroup));
 
-       qgroup_create(subvolume_dir.fd(), qgroup);
+       qgroup_create(general_dir.fd(), qgroup);
 
        setConfigInfo({ { "QGROUP", format_qgroup(qgroup) } });
 
@@ -694,15 +694,15 @@ namespace snapper
        if (btrfs->getQGroup() == no_qgroup)
            SN_THROW(QuotaException("qgroup not set"));
 
-       SDir subvolume_dir = openSubvolumeDir();
+       SDir general_dir = btrfs->openGeneralDir();
 
        try
        {
-           vector<qgroup_t> children = qgroup_query_children(subvolume_dir.fd(), btrfs->getQGroup());
+           vector<qgroup_t> children = qgroup_query_children(general_dir.fd(), btrfs->getQGroup());
            sort(children.begin(), children.end());
 
-           // Iterate all snapshot and ensure that those and only those with a
-           // cleanup algorithm are included in the high level qgroup.
+           // Iterate all snapshots and ensure that those and only those with
+           // cleanup algorithm are included in the high level qgroup.
 
            for (const Snapshot& snapshot : snapshots)
            {
@@ -716,11 +716,11 @@ namespace snapper
 
                if (!snapshot.getCleanup().empty() && !included)
                {
-                   qgroup_assign(subvolume_dir.fd(), qgroup, btrfs->getQGroup());
+                   qgroup_assign(general_dir.fd(), qgroup, btrfs->getQGroup());
                }
                else if (snapshot.getCleanup().empty() && included)
                {
-                   qgroup_remove(subvolume_dir.fd(), qgroup, btrfs->getQGroup());
+                   qgroup_remove(general_dir.fd(), qgroup, btrfs->getQGroup());
                }
            }
        }
@@ -750,23 +750,23 @@ namespace snapper
        if (btrfs->getQGroup() == no_qgroup)
            SN_THROW(QuotaException("qgroup not set"));
 
-       SDir subvolume_dir = openSubvolumeDir();
+       SDir general_dir = btrfs->openGeneralDir();
 
        // Tests have shown that without a rescan and sync here the quota data
        // is incorrect.
 
-       quota_rescan(subvolume_dir.fd());
-       sync(subvolume_dir.fd());
+       quota_rescan(general_dir.fd());
+       sync(general_dir.fd());
 
        struct statvfs64 fsbuf;
-       if (fstatvfs64(subvolume_dir.fd(), &fsbuf) != 0)
+       if (fstatvfs64(general_dir.fd(), &fsbuf) != 0)
            SN_THROW(QuotaException("statvfs64 failed"));
 
        QuotaData quota_data;
 
        quota_data.size = fsbuf.f_blocks * fsbuf.f_bsize;
 
-       QGroupUsage qgroup_usage = qgroup_query_usage(subvolume_dir.fd(), btrfs->getQGroup());
+       QGroupUsage qgroup_usage = qgroup_query_usage(general_dir.fd(), btrfs->getQGroup());
        quota_data.used = qgroup_usage.exclusive;
 
        y2mil("size:" << quota_data.size << " used:" << quota_data.used);