catch (const LvmCacheException& e)
{
y2war("lvm cache failed");
+ y2deb(cache);
}
}
catch (const LvmCacheException& e)
{
y2war("lvm cache failed");
+ y2deb(cache);
}
SDir info_dir = openInfoDir(num);
catch(const LvmCacheException& e)
{
y2err("Lvm cache failure");
+ y2deb(cache);
return false;
}
catch(const LvmCacheException& e)
{
y2err("Couldn't activate snapshot " << vg_name << "/" << lv_name);
+ y2deb(cache);
throw LvmActivationException();
}
}
catch(const LvmCacheException& e)
{
y2war("lvm cache failure");
+ y2deb(cache);
throw LvmDeactivatationException();
}
}
}
+ void
+ LogicalVolume::debug(std::ostream& out) const
+ {
+ out << attrs;
+ }
+
+
VolumeGroup::VolumeGroup(vg_content_raw& input, const string& vg_name, const string& add_lv_name)
: vg_name(vg_name)
{
}
+ void
+ VolumeGroup::debug(std::ostream& out) const
+ {
+ // do not allow any modifications in a whole VG
+ boost::unique_lock<boost::upgrade_mutex> unique_lock(vg_mutex);
+
+ for (const_iterator cit = lv_info_map.begin(); cit != lv_info_map.end(); cit++)
+ out << "\tLV:'" << cit->first << "':" << std::endl << "\t\t" << cit->second;
+ }
+
+
LvmCache*
LvmCache::get_lvm_cache()
{
{
const_iterator cit = vgroups.find(vg_name);
if (cit == vgroups.end())
+ {
add_vg(vg_name, lv_name);
+ y2deb("lvm cache: added new vg: " << vg_name << ", including lv: " << lv_name);
+ }
else
{
cit->second->add_or_update(lv_name);
+ y2deb("lvm cache: updated lv details for " << lv_name);
}
}
y2err(vg_name << "/" << lv_name << " already in cache!");
throw;
}
+
+ y2deb("lvm cache: added new lv: " << lv_name << " in vg: " << vg_name);
}
if (cit != vgroups.end())
cit->second->remove(lv_name);
+
+ y2deb("lvm cache: removed lv " << lv_name << " from vg " << vg_name);
}
y2err("lvm cache failed to rename " << vg_name << "/" << old_name << " -> " << vg_name << "/" << new_name);
throw;
}
+
+ y2deb("lvm cache: in vg " << vg_name << " " << old_name << " was renamed to " << new_name);
+ }
+
+
+ std::ostream&
+ operator<<(std::ostream& out, const LvmCache* cache)
+ {
+ out << "LvmCache:" << std::endl;
+ for (LvmCache::const_iterator cit = cache->vgroups.begin(); cit != cache->vgroups.end(); cit++)
+ out << "Volume Group:'" << cit->first << "':" << std::endl << cit->second;
+
+ return out;
+ }
+
+
+ std::ostream&
+ operator<<(std::ostream& out, const VolumeGroup* vg)
+ {
+ vg->debug(out);
+
+ return out;
+ }
+
+
+ std::ostream&
+ operator<<(std::ostream& out, const LogicalVolume* lv)
+ {
+ lv->debug(out);
+
+ return out;
+ }
+
+
+ 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;
+
+ return out;
}
}
bool readonly(); // shared
bool thin(); // shared
+ friend std::ostream& operator<<(std::ostream& out, const LogicalVolume* cache);
+
private:
+ void debug(std::ostream& out) const;
+
const VolumeGroup* vg;
const string lv_name;
const LvmCapabilities* caps;
void remove(const string& lv_name); // excl lock
void rename(const string& old_name, const string& new_name); // upg lock -> excl
+ friend std::ostream& operator<<(std::ostream& out, const VolumeGroup* vg);
+
private:
+ void debug(std::ostream& out) const;
+
const string vg_name;
mutable boost::upgrade_mutex vg_mutex;
// 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() {}
map<string, VolumeGroup*> vgroups;
};
+
+ std::ostream& operator<<(std::ostream& out, const LvAttrs& a);
}
#endif // SNAPPER_LVM_CACHE_H