]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- remove unused code and lvs output parameters 23/head
authorOndrej Kozina <okozina@redhat.com>
Mon, 30 Sep 2013 07:48:05 +0000 (09:48 +0200)
committerOndrej Kozina <okozina@redhat.com>
Mon, 30 Sep 2013 07:48:05 +0000 (09:48 +0200)
snapper/Lvm.cc
snapper/Lvm.h
snapper/LvmCache.cc
snapper/LvmCache.h

index ca49fcc88449daed7840425963e2a0910ee5622e..3a0af36dc29d6a7039ffcabd189cc1e244e4126f 100644 (file)
@@ -250,7 +250,7 @@ namespace snapper
 
        try
        {
-           activateSnapshot(vg_name, snapshotLvName(num), true);
+           activateSnapshot(vg_name, snapshotLvName(num));
        }
        catch (const LvmActivationException& e)
        {
@@ -278,7 +278,7 @@ namespace snapper
 
        try
        {
-           deactivateSnapshot(vg_name, snapshotLvName(num), true);
+           deactivateSnapshot(vg_name, snapshotLvName(num));
        }
        catch (const LvmDeactivatationException& e)
        {
@@ -290,7 +290,7 @@ namespace snapper
     bool
     Lvm::checkSnapshot(unsigned int num) const
     {
-       return detectInactiveSnapshot(vg_name, snapshotLvName(num), true);
+       return detectInactiveSnapshot(vg_name, snapshotLvName(num));
     }
 
 
@@ -329,68 +329,39 @@ namespace snapper
 
 
     void
-    Lvm::activateSnapshot(const string& vg_name, const string& lv_name, bool use_cache) const
+    Lvm::activateSnapshot(const string& vg_name, const string& lv_name) const
     {
-       if (use_cache)
+       try
        {
-           try
-           {
-               cache->activate(vg_name, lv_name);
-           }
-           catch(const LvmCacheException& e)
-           {
-               y2deb(cache);
-               throw LvmActivationException();
-           }
+           cache->activate(vg_name, lv_name);
        }
-       else
+       catch(const LvmCacheException& e)
        {
-           SystemCmd cmd(LVCHANGEBIN + caps->get_ignoreactivationskip() + " -ay " + quote(vg_name + "/" + lv_name));
-           if (cmd.retcode() != 0)
-           {
-               y2err("Couldn't activate snapshot " << vg_name << "/" << lv_name);
-               throw LvmActivationException();
-           }
+           y2deb(cache);
+           throw LvmActivationException();
        }
     }
 
 
     void
-    Lvm::deactivateSnapshot(const string& vg_name, const string& lv_name, bool use_cache) const
+    Lvm::deactivateSnapshot(const string& vg_name, const string& lv_name) const
     {
-       if (use_cache)
+       try
        {
-           try
-           {
-               cache->deactivate(vg_name, lv_name);
-           }
-           catch(const LvmCacheException& e)
-           {
-               y2deb(cache);
-               throw LvmDeactivatationException();
-           }
+           cache->deactivate(vg_name, lv_name);
        }
-       else
+       catch(const LvmCacheException& e)
        {
-           SystemCmd cmd(LVCHANGEBIN " -an " + quote(vg_name + "/" + lv_name));
-           if (cmd.retcode())
-               throw LvmDeactivatationException();
+           y2deb(cache);
+           throw LvmDeactivatationException();
        }
     }
 
 
     bool
-    Lvm::detectInactiveSnapshot(const string& vg_name, const string& lv_name, bool use_cache) const
+    Lvm::detectInactiveSnapshot(const string& vg_name, const string& lv_name) const
     {
-       if (use_cache)
-       {
-           return cache->contains(vg_name, lv_name);
-       }
-       else
-       {
-           SystemCmd cmd(LVSBIN " " + quote(vg_name + "/" + lv_name));
-           return cmd.retcode() == 0;
-       }
+       return cache->contains(vg_name, lv_name);
     }
 
 
index 2e0936c1e12c6141c41375a99dbaecca15d7ef24..fbca2f5ef904f178116d4b0be1dcd9f915798e09 100644 (file)
@@ -109,9 +109,9 @@ namespace snapper
        LvmCache* cache;
 
        bool detectThinVolumeNames(const MtabData& mtab_data);
-       void activateSnapshot(const string& vg_name, const string& lv_name, bool use_cache) const;
-       void deactivateSnapshot(const string& vg_name, const string& lv_name, bool use_cache) const;
-       bool detectInactiveSnapshot(const string& vg_name, const string& lv_name, bool use_cache) const;
+       void activateSnapshot(const string& vg_name, const string& lv_name) const;
+       void deactivateSnapshot(const string& vg_name, const string& lv_name) const;
+       bool detectInactiveSnapshot(const string& vg_name, const string& lv_name) const;
 
        string getDevice(unsigned int num) const;
 
index 0201e1e2f9b1e39112c2463169a9ac884495b992..9bcabb9c805de19ae4bf3e6e98f46a192016ba9f 100644 (file)
@@ -40,31 +40,22 @@ namespace snapper
     }
 
 
-    bool
-    LvAttrs::extract_readonly(const string& raw)
-    {
-       return (raw.size() > 1 && raw[1] == 'r');
-    }
-
-
     LvAttrs::LvAttrs(const vector<string>& raw)
        : active(raw.size() > 0 && extract_active(raw.front())),
-       readonly(raw.size() > 0 && extract_readonly(raw.front())),
-       thin(raw.size() > 1 && raw[1] == "thin"),
-       pool(raw.size() > 2 ? raw[2] : "")
+       thin(raw.size() > 1 && raw[1] == "thin")
     {
     }
 
 
-    LvAttrs::LvAttrs(bool active, bool readonly, bool thin, string pool)
-       : active(active), readonly(readonly), thin(thin), pool(pool)
+    LvAttrs::LvAttrs(bool active, bool thin)
+       : active(active), thin(thin)
     {
     }
 
 
     LogicalVolume::LogicalVolume(const VolumeGroup* vg, const string& lv_name)
        : vg(vg), lv_name(lv_name), caps(LvmCapabilities::get_lvm_capabilities()),
-       attrs(caps->get_ignoreactivationskip().empty(), true, true, "")
+       attrs(caps->get_ignoreactivationskip().empty(), true)
     {
     }
 
@@ -150,7 +141,7 @@ namespace snapper
     {
        boost::unique_lock<boost::shared_mutex> unique_lock(lv_mutex);
 
-       SystemCmd cmd(LVSBIN " --noheadings -o lv_attr,segtype,pool_lv " + quote(vg->get_vg_name() + "/" + lv_name));
+       SystemCmd cmd(LVSBIN " --noheadings -o lv_attr,segtype " + quote(vg->get_vg_name() + "/" + lv_name));
 
        if (cmd.retcode() != 0 || cmd.numLines() < 1)
        {
@@ -170,15 +161,6 @@ namespace snapper
     }
 
 
-    bool
-    LogicalVolume::readonly()
-    {
-       boost::shared_lock<boost::shared_mutex> shared_lock(lv_mutex);
-
-       return attrs.readonly;
-    }
-
-
     bool
     LogicalVolume::thin()
     {
@@ -263,17 +245,6 @@ namespace snapper
     }
 
 
-    bool
-    VolumeGroup::constains_read_only(const string& lv_name) const
-    {
-       boost::shared_lock<boost::shared_mutex> shared_lock(vg_mutex);
-
-       const_iterator cit = lv_info_map.find(lv_name);
-
-       return cit != lv_info_map.end() && cit->second->readonly();
-    }
-
-
     void
     VolumeGroup::create_snapshot(const string& lv_origin_name, const string& lv_snapshot_name)
     {
@@ -310,7 +281,7 @@ namespace snapper
        }
        else
        {
-           SystemCmd cmd(LVSBIN " --noheadings -o lv_attr,segtype,pool_lv " + quote(vg_name + "/" + lv_name));
+           SystemCmd cmd(LVSBIN " --noheadings -o lv_attr,segtype " + quote(vg_name + "/" + lv_name));
            if (cmd.retcode() != 0 || cmd.numLines() < 1)
            {
                y2err("lvm cache: failed to get info about " << vg_name << "/" << lv_name);
@@ -356,41 +327,6 @@ namespace snapper
     }
 
 
-    void
-    VolumeGroup::rename(const string& old_name, const string& new_name)
-    {
-       boost::upgrade_lock<boost::shared_mutex> upg_lock(vg_mutex);
-
-       const_iterator cit = lv_info_map.find(old_name);
-
-       if (cit == lv_info_map.end() || lv_info_map.find(new_name) != lv_info_map.end())
-       {
-           y2err("lvm cache: " << vg_name << "/" << old_name <<
-                 " is missing or " << vg_name << "/" << new_name <<
-                 " already in cache!");
-           throw LvmCacheException();
-       }
-
-       // wait for all invidual lv cache operations under shared vg lock to finish
-       boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(upg_lock);
-
-       SystemCmd cmd(LVRENAMEBIN " " + quote(vg_name) + " " + quote(old_name) +
-                     " " + quote(new_name));
-
-       if (cmd.retcode() != 0)
-       {
-           y2err("lvm cache: " << vg_name <<  "/" << old_name << " -> " <<
-                 vg_name << "/" << new_name << " rename command failed!");
-           throw LvmCacheException();
-       }
-
-       lv_info_map.insert(make_pair(new_name, new LogicalVolume(this, new_name, cit->second->attrs)));
-
-       delete cit->second;
-       lv_info_map.erase(cit);
-    }
-
-
     void
     VolumeGroup::debug(std::ostream& out) const
     {
@@ -447,15 +383,6 @@ namespace snapper
     }
 
 
-    bool
-    LvmCache::contains_read_only(const string& vg_name, const string& lv_name) const
-    {
-       const_iterator cit = vgroups.find(vg_name);
-
-       return cit != vgroups.end() && cit->second->constains_read_only(lv_name);
-    }
-
-
     bool
     LvmCache::contains(const string& vg_name, const string& lv_name) const
     {
@@ -510,7 +437,7 @@ namespace snapper
     void
     LvmCache::add_vg(const string& vg_name, const string& include_lv_name)
     {
-       SystemCmd cmd(LVSBIN " --noheadings -o lv_name,lv_attr,segtype,pool_lv " + quote(vg_name));
+       SystemCmd cmd(LVSBIN " --noheadings -o lv_name,lv_attr,segtype " + quote(vg_name));
        if (cmd.retcode() != 0)
        {
            y2err("lvm cache: failed to get info about VG " << vg_name);
@@ -554,23 +481,6 @@ namespace snapper
     }
 
 
-    void
-    LvmCache::rename(const string& vg_name, const string& old_name, const string& new_name) const
-    {
-       const_iterator cit = vgroups.find(vg_name);
-
-       if (cit == vgroups.end())
-       {
-           y2err("lvm cache: VG " << vg_name << " is not in cache!");
-           throw LvmCacheException();
-       }
-
-       cit->second->rename(old_name, new_name);
-
-       y2deb("lvm cache: " << vg_name << "/" << old_name << " renamed to " << vg_name << "/" << new_name);
-    }
-
-
     std::ostream&
     operator<<(std::ostream& out, const LvmCache* cache)
     {
@@ -603,10 +513,8 @@ namespace snapper
     std::ostream&
     operator<<(std::ostream& out, const LvAttrs& a)
     {
-       out << "active='" << (a.active ? "true" : "false") << "',readonly='"
-           << (a.readonly ? "true" : "false") << "',thin='"
-           << (a.thin ? "true" : "false") << ",pool='" << a.pool << "'"
-           << std::endl;
+       out << "active='" << (a.active ? "true" : "false") << "',thin='"
+           << (a.thin ? "true" : "false") << "'" << std::endl;
 
        return out;
     }
index 6cdcc9902d0012898e2e5ccc6c96ba4031a7c11a..5d5e3e3b51f22838e28d61fd357994ce107d7034 100644 (file)
@@ -55,13 +55,10 @@ namespace snapper
        static bool extract_readonly(const string& raw);
 
        LvAttrs(const vector<string>& raw);
-       LvAttrs(bool active, bool readonly, bool thin, string pool);
-       //LvAttrs() : active(false), readonly(false), thin(false), pool() {}
+       LvAttrs(bool active, bool thin);
 
        bool active;
-       bool readonly;
        bool thin;
-       string pool;
     };
 
 
@@ -79,7 +76,6 @@ namespace snapper
 
        void update(); // shared, unique_lock
 
-       bool readonly(); // shared
        bool thin(); // shared
 
        friend std::ostream& operator<<(std::ostream& out, const LogicalVolume* cache);
@@ -117,13 +113,10 @@ namespace snapper
        bool contains(const string& lv_name) const; // shared lock
        bool contains_thin(const string& lv_name) const; // shared lock
 
-       bool constains_read_only(const string& lv_name) const; // shared lock
-
        void create_snapshot(const string& lv_origin_name, const string& lv_snapshot_name); // upg lock -> excl
        void add_or_update(const string& lv_name); // upg lock -> excl
 
        void remove_lv(const string& lv_name); // upg lock -> excl
-       void rename(const string& old_name, const string& new_name); // upg lock -> excl
 
        friend std::ostream& operator<<(std::ostream& out, const VolumeGroup* vg);
 
@@ -154,7 +147,6 @@ namespace snapper
 
        bool contains(const string& vg_name, const string& lv_name) const;
        bool contains_thin(const string& vg_name, const string& lv_name) const;
-       bool contains_read_only(const string& vg_name, const string& lv_name) const;
 
        // create snapper owned snapshot
        void create_snapshot(const string& vg_name, const string&lv_origin_name, const string& lv_snapshot_name);
@@ -164,9 +156,6 @@ namespace snapper
        // remove snapshot owned by snapper
        void delete_snapshot(const string& vg_name, const string& lv_name) const;
 
-       // rename snapshots (used during import)
-       void rename(const string& vg_name, const string& old_name, const string& new_name) const;
-
        friend std::ostream& operator<<(std::ostream& out, const LvmCache* cache);
     private:
        LvmCache() {}