Author: fehr
Date: Thu Jan 12 12:07:14 2012
New Revision: 67156
URL: http://svn.opensuse.org/viewcvs/yast?rev=67156&view=rev
Log:
- fix bug when resizing a btrfs fs that had format set (bnc#732988)
- fix problem handling used by for btrfs during resize
--This linee and those below, will be ignored--
M libstorage/src/BtrfsCo.cc
M libstorage/src/Storage.h
M libstorage/src/BtrfsCo.h
M libstorage/src/Storage.cc
M libstorage/src/Btrfs.h
M libstorage/src/Volume.cc
M libstorage/src/Btrfs.cc
M package/yast2-storage.changes
Modified:
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h
branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc
branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc?rev=67156&r1=67155&r2=67156&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.cc Thu Jan 12 12:07:14 2012
@@ -104,6 +104,37 @@
y2deb("destructed Btrfs " << dev);
}
+BtrfsCo* Btrfs::co()
+ {
+ Container* con = const_cast(cont);
+ return(dynamic_caststorage::BtrfsCo*(con));
+ }
+
+list<string>
+Btrfs::getDevices( bool add_del ) const
+ {
+ list<string> ret;
+ getDevices( ret, add_del );
+ return( ret );
+ }
+
+void
+Btrfs::getDevices( list<string>& devs, bool add_del ) const
+ {
+ y2mil( "add_del:" << add_del );
+ devs = devices;
+ if( add_del )
+ {
+ if( !dev_add.empty() )
+ devs.insert( devs.end(), dev_add.begin(), dev_add.end() );
+ if( !dev_rem.empty() )
+ for( list<string>::const_iterator s=dev_rem.begin(); s!=dev_rem.end(); ++s )
+ devs.remove( *s );
+ }
+ y2mil( "devs:" << devs );
+ }
+
+
void Btrfs::addSubvol( const string& path )
{
y2mil( "path:\"" << path << "\"" );
@@ -222,11 +253,14 @@
}
else
{
- dev_add.push_back( d );
+ if( format )
+ devices.push_back( d );
+ else
+ dev_add.push_back( d );
if( !getStorage()->isDisk(d))
getStorage()->changeFormatVolume( d, false, FSNONE );
}
- getStorage()->setUsedBy(d, UB_BTRFS, device());
+ getStorage()->setUsedByBtrfs(d, getUuid());
setSize( size_k+getStorage()->deviceSize( d ) );
++i;
}
@@ -267,6 +301,11 @@
string d = normalizeDevice( *i );
if( (p=find( dev_add.begin(), dev_add.end(), d ))!=dev_add.end())
dev_add.erase(p);
+ else if( format )
+ {
+ if( (p=find( devices.begin(), devices.end(), d ))!=devices.end())
+ devices.erase(p);
+ }
else
dev_rem.push_back(d);
getStorage()->clearUsedBy(d);
@@ -465,6 +504,24 @@
return( ret );
}
+int Btrfs::setFormat( bool val, storage::FsType new_fs )
+ {
+ int ret = 0;
+ y2mil("device:" << dev << " val:" << val << " fs:" << toString(new_fs));
+ ret = Volume::setFormat( val, new_fs );
+ if( ret==0 )
+ {
+ if( val )
+ {
+ orig_uuid = uuid;
+ uuid = co()->fakeUuid();
+ }
+ getStorage()->setBtrfsUsedBy( this );
+ }
+ y2mil("ret:" << ret);
+ return( ret );
+ }
+
void Btrfs::unuseDev() const
{
for( list<string>::const_iterator s=devices.begin(); s!=devices.end(); ++s )
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h?rev=67156&r1=67155&r2=67156&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Btrfs.h Thu Jan 12 12:07:14 2012
@@ -44,8 +44,8 @@
void clearSubvol() { subvol.clear(); }
void addSubvol( const string& path );
- const list<string>& getDevices() const { return devices; }
- void getDevices( list<string>& devs ) const { devs=devices; }
+ list<string> getDevices( bool add_del=false ) const;
+ void getDevices( list<string>& devs, bool add_del=false ) const;
void getSubvolumes( list<Subvolume>& sv ) const { sv = subvol; }
bool existSubvolume( const string& name );
@@ -67,6 +67,7 @@
Text reduceText(bool doing, const string& device) const;
Text removeText( bool doing ) const;
Text formatText( bool doing ) const;
+ int setFormat( bool format, storage::FsType fs );
virtual string udevPath() const;
virtual list<string> udevId() const;
@@ -93,6 +94,7 @@
static bool needExtend( const Btrfs& v );
protected:
+ BtrfsCo* co();
string subvolNames( bool added ) const;
list<string> devices;
list<string> dev_add;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc?rev=67156&r1=67155&r2=67156&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.cc Thu Jan 12 12:07:14 2012
@@ -187,16 +187,23 @@
y2mil("end");
}
+string BtrfsCo::fakeUuid()
+ {
+ string ret;
+ unsigned long long uuid = 12345;
+ BtrfsIter i;
+ while( findBtrfs(decString(uuid),i) )
+ ++uuid;
+ ret = decString(uuid);
+ y2mil( "ret:" << ret );
+ return(ret);
+ }
+
void
BtrfsCo::addFromVolume( const Volume& v, string &uuid )
{
Btrfs* b = new Btrfs( *this, v );
- unsigned long long uid = 12345;
- BtrfsIter i;
- while( findBtrfs(decString(uid),i) )
- ++uid;
- uuid = decString(uid);
- b->initUuid( uuid );
+ b->initUuid( fakeUuid() );
vols.push_back(b);
}
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h?rev=67156&r1=67155&r2=67156&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/BtrfsCo.h Thu Jan 12 12:07:14 2012
@@ -71,6 +71,7 @@
int removeUuid( const string& uuid );
bool equalContent( const Container& rhs ) const;
void saveData(xmlNode* node) const;
+ string fakeUuid();
virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
virtual void logData(const string& Dir) const;
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc?rev=67156&r1=67155&r2=67156&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.cc Thu Jan 12 12:07:14 2012
@@ -583,15 +583,7 @@
BtrfsCo::ConstBtrfsPair p(v->btrfsPair());
for( BtrfsCo::ConstBtrfsIter i=p.begin(); i!=p.end(); ++i )
{
- const list<string>& devs = i->getDevices();
- for( list<string>::const_iterator d=devs.begin(); d!=devs.end(); ++d )
- {
- VolIterator v;
- if( findVolume( *d, v ))
- {
- v->setUsedByUuid( UB_BTRFS, i->getUuid() );
- }
- }
+ setBtrfsUsedBy( &(*i) );
}
addToList( v );
}
@@ -600,6 +592,20 @@
}
}
+void Storage::setBtrfsUsedBy( const Btrfs* bt )
+ {
+ const list<string>& devs = bt->getDevices(true);
+ y2mil( "devs:" << devs << " to uuid:" << bt->getUuid() );
+ for( list<string>::const_iterator d=devs.begin(); d!=devs.end(); ++d )
+ {
+ VolIterator v;
+ if( findVolume( *d, v, false, true ))
+ {
+ v->setUsedByUuid( UB_BTRFS, bt->getUuid() );
+ }
+ }
+ }
+
void
Storage::detectLoops(SystemInfo& systeminfo)
{
@@ -4542,7 +4548,7 @@
{
int ret = 0;
assertInit();
- y2mil("device:" << device << "devices:" << devs );
+ y2mil("device:" << device << " devices:" << devs );
BtrfsCo* co;
if (readonly())
{
@@ -5185,7 +5191,7 @@
if( c->type()==BTRFSC )
{
const Btrfs * b = dynamic_cast(&(*v));
- if( b!=NULL && b->getDevices().size()==1 )
+ if( b!=NULL && b->getDevices(true).size()==1 )
{
findVolume(b->device(), c, v, true);
}
@@ -6156,7 +6162,7 @@
ConstBtrfsIterator i = p.begin();
while( i!=p.end() && i->getUuid()!=ub.front().device() )
++i;
- ret = i!=p.end() && i->getDevices().size()<=1;
+ ret = i!=p.end() && i->getDevices(true).size()<=1;
}
y2mil( "dev:" << vol.device() << " ret:" << ret );
return( ret );
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h?rev=67156&r1=67155&r2=67156&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Storage.h Thu Jan 12 12:07:14 2012
@@ -550,6 +550,8 @@
int extendBtrfsVolume( const string& device, const deque<string>& devs );
int shrinkBtrfsVolume( const string& device, const string& dev );
int shrinkBtrfsVolume( const string& device, const deque<string>& devs );
+ void setBtrfsUsedBy( const Btrfs* bt );
+
int addTmpfsMount( const string& mp, const string& opts );
int removeTmpfsMount( const string& mp );
Modified: branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc?rev=67156&r1=67155&r2=67156&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/libstorage/src/Volume.cc Thu Jan 12 12:07:14 2012
@@ -844,7 +844,7 @@
if( ret==0 && cType()==BTRFSC && getEncryption()==ENC_NONE )
{
const Btrfs* l = static_cast(this);
- list<string> li = l->getDevices();
+ list<string> li = l->getDevices(true);
y2mil( "devices:" << li );
if( li.size()>1 )
{
@@ -1148,6 +1148,7 @@
void Volume::setUsedByUuid( UsedByType ubt, const string& uuid )
{
+ y2mil( "device:" << device() << " to uuid:" << uuid );
eraseUuid();
eraseLabel();
setMount( "" );
Modified: branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes?rev=67156&r1=67155&r2=67156&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/package/yast2-storage.changes Thu Jan 12 12:07:14 2012
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Wed Jan 11 16:10:33 CET 2012 - fehr@suse.de
+
+- fix bug when resizing a btrfs fs that had format set (bnc#732988)
+- fix problem handling used by for btrfs during resize
+
+-------------------------------------------------------------------
Tue Jan 10 18:59:52 CET 2012 - fehr@suse.de
- fix parsing problem with old style size values (e.g. 10G instead
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org