Author: aschnell
Date: Fri Aug 15 12:20:44 2008
New Revision: 50105
URL: http://svn.opensuse.org/viewcvs/yast?rev=50105&view=rev
Log:
- backup commit
Modified:
branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.cc
branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.h
branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.cc
branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.h
branches/tmp/aschnell/snapshots/libstorage/src/StorageInterface.h
Modified: branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.cc?rev=50105&r1=50104&r2=50105&view=diff
==============================================================================
--- branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.cc (original)
+++ branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.cc Fri Aug 15 12:20:44 2008
@@ -55,6 +55,12 @@
}
+const LvmVg* LvmLv::vg() const
+{
+ return(dynamic_cast(cont));
+}
+
+
void LvmLv::init( const string& name )
{
nm = name;
@@ -65,20 +71,40 @@
void LvmLv::calcSize()
{
- if (origin.empty())
+ if (!isSnapshot())
{
Dm::calcSize();
}
else
{
- const Container* cont = getContainer();
-
- // TODO: take size from origin
- Dm::calcSize();
+ LvmVg::ConstLvmLvPair p = vg()->LvmVg::lvmLvPair(LvmVg::lvNotDeleted);
+ LvmVg::ConstLvmLvIter i = p.begin();
+ while( i!=p.end() && i->name()!=origin )
+ ++i;
+ if (i != p.end())
+ {
+ setSize(i->sizeK());
+ }
+ else
+ {
+ setSize(0);
+ y2err("not found " << origin);
+ }
}
}
+bool
+LvmLv::hasSnapshots() const
+{
+ LvmVg::ConstLvmLvPair p = vg()->LvmVg::lvmLvPair(LvmVg::lvNotDeleted);
+ LvmVg::ConstLvmLvIter i = p.begin();
+ while( i!=p.end() && i->getOrigin()!=name() )
+ ++i;
+ return i != p.end();
+}
+
+
void
LvmLv::getState(LvmLvSnapshotStateInfo& info)
{
Modified: branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.h?rev=50105&r1=50104&r2=50105&view=diff
==============================================================================
--- branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.h (original)
+++ branches/tmp/aschnell/snapshots/libstorage/src/LvmLv.h Fri Aug 15 12:20:44 2008
@@ -21,6 +21,8 @@
virtual ~LvmLv();
+ const LvmVg* vg() const;
+
void calcSize();
void getState(LvmLvSnapshotStateInfo& info);
@@ -28,6 +30,9 @@
void setOrigin( const string& o ) { origin=o; }
string getOrigin() const { return origin; }
+ bool isSnapshot() const { return !origin.empty(); }
+ bool hasSnapshots() const;
+
void setUuid( const string& uuid ) { vol_uuid=uuid; }
void setStatus( const string& s ) { status=s; }
void setAlloc( const string& a ) { allocation=a; }
Modified: branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.cc?rev=50105&r1=50104&r2=50105&view=diff
==============================================================================
--- branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.cc (original)
+++ branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.cc Fri Aug 15 12:20:44 2008
@@ -292,19 +292,29 @@
return( ret );
}
-// TODO: disallow for lv with snapshots and for snapshots
int LvmVg::resizeVolume( Volume* v, unsigned long long newSize )
{
int ret = 0;
y2milestone( "newSizeK:%llu vol:%s", newSize, v->name().c_str() );
checkConsistency();
- if( readonly() )
- {
+
+ LvmLv * l = dynamic_cast(v);
+
+ if (readonly())
+ {
ret = LVM_CHANGE_READONLY;
- }
- else
- {
- LvmLv * l = dynamic_cast(v);
+ }
+ else if (l->isSnapshot())
+ {
+ ret = LVM_LV_IS_SNAPSHOT;
+ }
+ else if (l->hasSnapshots())
+ {
+ ret = LVM_LV_HAS_SNAPSHOTS;
+ }
+
+ if (ret == 0)
+ {
unsigned long new_le = sizeToLe(newSize);
if( l->stripes()>1 )
new_le = ((new_le+l->stripes()-1)/l->stripes())*l->stripes();
@@ -348,7 +358,7 @@
{
ret = LVM_CHECK_RESIZE_INVALID_VOLUME;
}
- }
+ }
if( ret==0 )
checkConsistency();
y2milestone( "ret:%d", ret );
@@ -360,7 +370,6 @@
return( removeLv( v->name() ));
}
-// TODO: disallow for lv with snapshots
int
LvmVg::removeLv( const string& name )
{
@@ -380,6 +389,8 @@
++i;
if( i==p.end() )
ret = LVM_LV_UNKNOWN_NAME;
+ else if (i->hasSnapshots())
+ ret = LVM_LV_HAS_SNAPSHOTS;
}
if( ret==0 && i->getUsedByType() != UB_NONE )
{
@@ -563,8 +574,25 @@
int
LvmVg::removeLvSnapshot(const string& name)
{
- // TODO: check if it is a snapshot
- return removeLv(name);
+ int ret = 0;
+ y2mil("name:" << name);
+ if( ret==0 )
+ {
+ LvmLvPair p=lvmLvPair(lvNotDeleted);
+ LvmLvIter i=p.begin();
+ while( i!=p.end() && i->name()!=name )
+ ++i;
+ if (i==p.end())
+ ret = LVM_LV_UNKNOWN_NAME;
+ else if (!i->isSnapshot())
+ ret = LVM_LV_NOT_SNAPSHOT;
+ }
+ if (ret == 0)
+ {
+ ret = removeLv(name);
+ }
+ y2mil("ret:" << ret);
+ return ret;
}
@@ -581,17 +609,15 @@
i=p.begin();
while( i!=p.end() && i->name()!=name )
++i;
- if( i==p.end() )
+ if (i == p.end())
ret = LVM_LV_UNKNOWN_NAME;
+ else if (!i->isSnapshot())
+ ret = LVM_LV_NOT_SNAPSHOT;
}
if (ret == 0 && i->created())
{
ret = LVM_LV_NOT_ON_DISK;
}
- if (ret == 0 && i->getOrigin().empty())
- {
- ret = LVM_LV_NOT_SNAPSHOT;
- }
if (ret == 0)
{
i->getState(info);
@@ -696,6 +722,9 @@
if (line.find("destination for") != string::npos)
{
origin = extractNthWord(6, line, true);
+ string::size_type pos = origin.find("/", 5);
+ if (pos != string::npos)
+ origin.erase(0, pos + 1);
}
}
else if( line.find( "LV Status" ) == 0 )
Modified: branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.h?rev=50105&r1=50104&r2=50105&view=diff
==============================================================================
--- branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.h (original)
+++ branches/tmp/aschnell/snapshots/libstorage/src/LvmVg.h Fri Aug 15 12:20:44 2008
@@ -10,6 +10,7 @@
class LvmVg : public PeContainer
{
friend class Storage;
+ friend class LvmLv;
public:
LvmVg( Storage * const s, const string& Name );
Modified: branches/tmp/aschnell/snapshots/libstorage/src/StorageInterface.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/snapshots/libstorage/src/StorageInterface.h?rev=50105&r1=50104&r2=50105&view=diff
==============================================================================
--- branches/tmp/aschnell/snapshots/libstorage/src/StorageInterface.h (original)
+++ branches/tmp/aschnell/snapshots/libstorage/src/StorageInterface.h Fri Aug 15 12:20:44 2008
@@ -569,6 +569,8 @@
LVM_LV_UNKNOWN_ORIGIN = -4028,
LVM_LV_NOT_ON_DISK = -4029,
LVM_LV_NOT_SNAPSHOT = -4030,
+ LVM_LV_HAS_SNAPSHOTS = -4031,
+ LVM_LV_IS_SNAPSHOT = -4032,
FSTAB_ENTRY_NOT_FOUND = -5000,
FSTAB_CHANGE_PREFIX_IMPOSSIBLE = -5001,
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org