[yast-commit] r52526 - in /trunk/storage: libstorage/src/ package/
Author: aschnell Date: Fri Oct 24 15:29:31 2008 New Revision: 52526 URL: http://svn.opensuse.org/viewcvs/yast?rev=52526&view=rev Log: - started work on start/stop of multipath (bnc #438055) - some cursory cleanup Modified: trunk/storage/libstorage/src/DmmultipathCo.cc trunk/storage/libstorage/src/DmmultipathCo.h trunk/storage/libstorage/src/LvmVg.cc trunk/storage/libstorage/src/LvmVg.h trunk/storage/libstorage/src/Storage.cc trunk/storage/libstorage/src/Storage.h trunk/storage/libstorage/src/StorageInterface.h trunk/storage/package/yast2-storage.changes Modified: trunk/storage/libstorage/src/DmmultipathCo.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmmultipathCo.cc?rev=52526&r1=52525&r2=52526&view=diff ============================================================================== --- trunk/storage/libstorage/src/DmmultipathCo.cc (original) +++ trunk/storage/libstorage/src/DmmultipathCo.cc Fri Oct 24 15:29:31 2008 @@ -124,50 +124,79 @@ void -DmmultipathCo::getMultipaths( list<string>& l ) +DmmultipathCo::activate(bool val) { - l.clear(); + y2mil("old active:" << active << " val:" << val); - string line; - unsigned i=0; - SystemCmd c(MULTIPATHBIN " -d -v 2+ -ll"); - if( i<c.numLines() ) - line = *c.getLine(i); - while( i<c.numLines() ) + if (active != val) { - while( i<c.numLines() && (line.empty() || !isalnum(line[0]))) - if( ++i<c.numLines() ) - line = *c.getLine(i); + SystemCmd c; + if (val) + { + Dm::activate(true); + c.execute(MODPROBEBIN " dm-multipath"); + c.execute(MULTIPATHBIN); + } + else + { + c.execute(MULTIPATHBIN " -F"); + } + active = val; + } +} - y2mil("mp line:" << line); - string unit = extractNthWord(0, line); - y2mil("mp name:" << unit); +void +DmmultipathCo::getMultipaths(list<string>& l) +{ + l.clear(); + + SystemCmd c(MULTIPATHBIN " -d -v 2+ -ll"); + if (c.numLines() > 0) + { + active = true; - list<string> mp_list; + string line; + unsigned i=0; - if( ++i<c.numLines() ) + if( i<c.numLines() ) line = *c.getLine(i); - while( i<c.numLines() && (line.empty() || !isalnum(line[0]))) + while( i<c.numLines() ) { - if (boost::starts_with(line, " \\_")) - { - y2mil( "mp element:" << line ); - string dev = extractNthWord(3,line); - if( find( mp_list.begin(), mp_list.end(), dev )== mp_list.end() ) - mp_list.push_back(dev); - } + while( i<c.numLines() && (line.empty() || !isalnum(line[0]))) + if( ++i<c.numLines() ) + line = *c.getLine(i); + + y2mil("mp line:" << line); + + string unit = extractNthWord(0, line); + y2mil("mp name:" << unit); + + list<string> mp_list; + if( ++i<c.numLines() ) line = *c.getLine(i); - } - y2mil( "mp_list:" << mp_list ); - if (mp_list.size() >= 1) - { - l.push_back(unit); + while( i<c.numLines() && (line.empty() || !isalnum(line[0]))) + { + if (boost::starts_with(line, " \\_")) + { + y2mil( "mp element:" << line ); + string dev = extractNthWord(3,line); + if( find( mp_list.begin(), mp_list.end(), dev )== mp_list.end() ) + mp_list.push_back(dev); + } + if( ++i<c.numLines() ) + line = *c.getLine(i); + } + y2mil( "mp_list:" << mp_list ); + if (mp_list.size() >= 1) + { + l.push_back(unit); + } } } - y2mil("ret:" << l); + y2mil("detected multipaths " << l); } @@ -247,3 +276,6 @@ } void DmmultipathCo::logData( const string& Dir ) {} + +bool DmmultipathCo::active = false; + Modified: trunk/storage/libstorage/src/DmmultipathCo.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmmultipathCo.h?rev=52526&r1=52525&r2=52526&view=diff ============================================================================== --- trunk/storage/libstorage/src/DmmultipathCo.h (original) +++ trunk/storage/libstorage/src/DmmultipathCo.h Fri Oct 24 15:29:31 2008 @@ -95,6 +95,7 @@ static string undevName( const string& name ); + static void activate( bool val=true ); static void getMultipaths( std::list<string>& l ); static bool multipathNotDeleted( const Dmmultipath&d ) { return( !d.deleted() ); } @@ -102,6 +103,8 @@ string vendor; string model; + + static bool active; }; } Modified: trunk/storage/libstorage/src/LvmVg.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/LvmVg.cc?rev=52526&r1=52525&r2=52526&view=diff ============================================================================== --- trunk/storage/libstorage/src/LvmVg.cc (original) +++ trunk/storage/libstorage/src/LvmVg.cc Fri Oct 24 15:29:31 2008 @@ -2,8 +2,8 @@ Textdomain "storage" */ -#include <iostream> -#include <sstream> +#include <iostream> +#include <sstream> #include "y2storage/LvmVg.h" #include "y2storage/LvmLv.h" @@ -114,10 +114,10 @@ while( ret==0 && i!=devs.end() ) { string d = normalizeDevice( *i ); - if( (p=find( pv.begin(), pv.end(), d ))!=pv.end() || + if( (p=find( pv.begin(), pv.end(), d ))!=pv.end() || (p=find( pv_add.begin(), pv_add.end(), d ))!=pv_add.end()) ret = LVM_PV_ALREADY_CONTAINED; - else if( (p=find( pv_remove.begin(), pv_remove.end(), d )) != + else if( (p=find( pv_remove.begin(), pv_remove.end(), d )) != pv_remove.end() && !getStorage()->deletedDevice( d ) ) { } @@ -136,7 +136,7 @@ { string d = normalizeDevice( *i ); unsigned long pe = 0; - if( (p=find( pv_remove.begin(), pv_remove.end(), d )) != + if( (p=find( pv_remove.begin(), pv_remove.end(), d )) != pv_remove.end() && !getStorage()->deletedDevice( d ) ) { pv.push_back( *p ); @@ -219,7 +219,7 @@ } -int +int LvmVg::setPeSize( long long unsigned peSizeK ) { int ret = 0; @@ -243,7 +243,7 @@ return( ret ); } -int +int LvmVg::createLv( const string& name, unsigned long long sizeK, unsigned stripe, string& device ) { @@ -370,7 +370,7 @@ return( removeLv( v->name() )); } -int +int LvmVg::removeLv( const string& name ) { int ret = 0; @@ -419,7 +419,7 @@ return( ret ); } -int +int LvmVg::changeStripe( const string& name, unsigned long stripe ) { int ret = 0; @@ -463,7 +463,7 @@ free_pe -= num_le; i->setStripes( stripe ); } - else + else free_pe -= i->getLe(); } } @@ -471,7 +471,7 @@ return( ret ); } -int +int LvmVg::changeStripeSize( const string& name, unsigned long long stripeSize ) { int ret = 0; @@ -590,7 +590,7 @@ if (ret == 0) { ret = removeLv(name); - } + } y2mil("ret:" << ret); return ret; } @@ -652,7 +652,7 @@ { bool lv1 = extractNthWord( 1, line )=="lvm1"; if( exists && lv1 != lvm1 ) - y2warning( "inconsistent lvm1 my:%d lvm:%d", + y2warning( "inconsistent lvm1 my:%d lvm:%d", lvm1, lv1 ); lvm1 = lv1; } @@ -665,7 +665,7 @@ tmp.erase( pos ); tmp >> pes; if( exists && pes != pe_size ) - y2warning( "inconsistent pe_size my:%llu lvm:%llu", + y2warning( "inconsistent pe_size my:%llu lvm:%llu", pe_size, pes ); pe_size = pes; } @@ -801,7 +801,7 @@ num_lv++; //cout << "Created:" << *i << endl; map<string,unsigned long> pe_map; - if( addLvPeDistribution( i->getLe(), i->stripes(), pv, pv_add, + if( addLvPeDistribution( i->getLe(), i->stripes(), pv, pv_add, pe_map ) == 0 ) i->setPeMap( pe_map ); free_pe -= i->getLe(); @@ -814,7 +814,7 @@ long size_diff = i->getLe() - sizeToLe(i->origSizeK()); if( size_diff>0 ) { - if( addLvPeDistribution( size_diff, i->stripes(), pv, pv_add, + if( addLvPeDistribution( size_diff, i->stripes(), pv, pv_add, pe_map ) == 0 ) i->setPeMap( pe_map ); } @@ -832,7 +832,7 @@ } } -void LvmVg::addLv(unsigned long& le, string& name, string& origin, string& uuid, +void LvmVg::addLv(unsigned long& le, string& name, string& origin, string& uuid, string& status, string& alloc, bool& ro) { y2milestone( "addLv:%s", name.c_str() ); @@ -885,7 +885,7 @@ } } name = origin = uuid = status = alloc = ""; - le = 0; + le = 0; ro = false; } @@ -903,12 +903,12 @@ list<Volume*>& vol ) { int ret = 0; - unsigned long oco = col.size(); - unsigned long ovo = vol.size(); + unsigned long oco = col.size(); + unsigned long ovo = vol.size(); Container::getToCommit( stage, col, vol ); if( stage==DECREASE ) { - if( !pv_remove.empty() && + if( !pv_remove.empty() && find( col.begin(), col.end(), this )==col.end() ) { col.push_back( this ); @@ -916,7 +916,7 @@ } else if( stage==INCREASE ) { - if( !pv_add.empty() && + if( !pv_add.empty() && find( col.begin(), col.end(), this )==col.end() ) { col.push_back( this ); @@ -942,7 +942,7 @@ { ret = doReduceVg(); } - else + else ret = LVM_COMMIT_NOTHING_TODO; break; case INCREASE: @@ -971,32 +971,32 @@ y2mil( "Container::getCommitActions:" << l ); if( deleted() ) { - l.push_back( new commitAction( DECREASE, staticType(), + l.push_back( new commitAction( DECREASE, staticType(), removeVgText(false), this, true )); } else if( created() ) { - l.push_front( new commitAction( INCREASE, staticType(), + l.push_front( new commitAction( INCREASE, staticType(), createVgText(false), this, true )); } - else + else { if( !pv_add.empty() ) - for( list<Pv>::const_iterator i=pv_add.begin(); i!=pv_add.end(); + for( list<Pv>::const_iterator i=pv_add.begin(); i!=pv_add.end(); ++i ) l.push_back( new commitAction( INCREASE, staticType(), - extendVgText(false,i->device), + extendVgText(false,i->device), this, true )); if( !pv_remove.empty() ) - for( list<Pv>::const_iterator i=pv_remove.begin(); + for( list<Pv>::const_iterator i=pv_remove.begin(); i!=pv_remove.end(); ++i ) l.push_back( new commitAction( DECREASE, staticType(), - reduceVgText(false,i->device), + reduceVgText(false,i->device), this, false )); } } -string +string LvmVg::removeVgText( bool doing ) const { string txt; @@ -1013,7 +1013,7 @@ return( txt ); } -string +string LvmVg::createVgText( bool doing ) const { string txt; @@ -1034,7 +1034,7 @@ return( txt ); } -string +string LvmVg::extendVgText( bool doing, const string& dev ) const { string txt; @@ -1055,7 +1055,7 @@ return( txt ); } -string +string LvmVg::reduceVgText( bool doing, const string& dev ) const { string txt; @@ -1076,7 +1076,7 @@ return( txt ); } -void +void LvmVg::init() { PeContainer::init(); @@ -1086,48 +1086,57 @@ inactiv = lvm1 = false; } -void LvmVg::activate( bool val ) + +void +LvmVg::activate(bool val) +{ + y2mil("old active:" << active << " val:" << val); + + if (active != val) { - y2milestone( "old active:%d val:%d", active, val ); - if( active!=val ) - { SystemCmd c; - if( val ) - { + if (val) + { Dm::activate(true); c.execute(VGSCANBIN " --mknodes"); c.execute(VGCHANGEBIN " -a y"); - } + } else - { + { c.execute(VGCHANGEBIN " -a n"); - } - active = val; } + active = val; } +} -void LvmVg::getVgs( list<string>& l ) - { + +void +LvmVg::getVgs(list<string>& l) +{ l.clear(); - string vgname; - string::size_type pos; + SystemCmd c(VGDISPLAYBIN " -s"); - if( !active && c.numLines()>0 ) + if (c.numLines() > 0) + { active = true; - for( unsigned i=0; i<c.numLines(); ++i ) + + for( unsigned i=0; i<c.numLines(); ++i ) { - vgname = *c.getLine(i); - pos=vgname.find_first_not_of( app_ws+"\"" ); - if( pos>0 ) - vgname.erase( 0, pos ); - pos=vgname.find_first_of( app_ws+"\"" ); - if( pos>0 ) - vgname.erase( pos ); - l.push_back(vgname); + string vgname = *c.getLine(i); + string::size_type pos=vgname.find_first_not_of( app_ws+"\"" ); + if( pos>0 ) + vgname.erase( 0, pos ); + pos=vgname.find_first_of( app_ws+"\"" ); + if( pos>0 ) + vgname.erase( pos ); + l.push_back(vgname); } - y2mil( "detected Vgs " << l ); } + y2mil("detected vgs " << l); +} + + int LvmVg::doCreateVg() { @@ -1160,7 +1169,7 @@ SystemCmd c( "find " + ddir + " -type l | xargs -r rm" ); rmdir( ddir.c_str() ); } - string cmd = VGCREATEBIN " " + instSysString() + metaString() + + string cmd = VGCREATEBIN " " + instSysString() + metaString() + "-s " + decString(pe_size) + "k " + quote(name()) + " " + devices; SystemCmd c( cmd ); if( c.retcode()!=0 ) @@ -1312,8 +1321,8 @@ return( ret ); } -int -LvmVg::doCreate( Volume* v ) +int +LvmVg::doCreate( Volume* v ) { y2milestone( "Vg:%s name:%s", name().c_str(), v->name().c_str() ); LvmLv * l = dynamic_cast<LvmLv *>(v); @@ -1409,7 +1418,7 @@ return( ret ); } -int LvmVg::doResize( Volume* v ) +int LvmVg::doResize( Volume* v ) { y2milestone( "Vg:%s name:%s", name().c_str(), v->name().c_str() ); LvmLv * l = dynamic_cast<LvmLv *>(v); @@ -1428,7 +1437,7 @@ getStorage()->showInfoCb( l->resizeText(true) ); } checkConsistency(); - if( v->isMounted() && + if( v->isMounted() && ((old_le>new_le&&!caps.isReduceableWhileMounted)|| (old_le<new_le&&!caps.isExtendableWhileMounted))) { @@ -1590,7 +1599,7 @@ s << " lvm1"; if( d.inactiv ) s << " inactive"; - s << " UUID:" << d.uuid + s << " UUID:" << d.uuid << " lv:" << d.num_lv; return( s ); } @@ -1621,7 +1630,7 @@ { ConstLvmLvPair pc=p->lvmLvPair(); ConstLvmLvIter j = pc.begin(); - while( j!=pc.end() && + while( j!=pc.end() && (i->device()!=j->device() || i->created()!=j->created()) ) ++j; if( j!=pc.end() ) @@ -1639,7 +1648,7 @@ { ConstLvmLvPair pc=lvmLvPair(); ConstLvmLvIter j = pc.begin(); - while( j!=pc.end() && + while( j!=pc.end() && (i->device()!=j->device() || i->created()!=j->created()) ) ++j; if( j==pc.end() ) @@ -1667,7 +1676,7 @@ ConstLvmLvPair pc = p->lvmLvPair(); ConstLvmLvIter i = pp.begin(); ConstLvmLvIter j = pc.begin(); - while( ret && i!=pp.end() && j!=pc.end() ) + while( ret && i!=pp.end() && j!=pc.end() ) { ret = ret && i->equalContent( *j ); ++i; Modified: trunk/storage/libstorage/src/LvmVg.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/LvmVg.h?rev=52526&r1=52525&r2=52526&view=diff ============================================================================== --- trunk/storage/libstorage/src/LvmVg.h (original) +++ trunk/storage/libstorage/src/LvmVg.h Fri Oct 24 15:29:31 2008 @@ -28,11 +28,11 @@ int extendVg( const string& device ); int reduceVg( const std::list<string>& dl ); int reduceVg( const string& device ); - int createLv( const string& name, unsigned long long sizeK, + int createLv( const string& name, unsigned long long sizeK, unsigned stripe, string& device ); int removeLv( const string& name ); int changeStripe( const string& name, unsigned long stripe ); - int changeStripeSize( const string& name, + int changeStripeSize( const string& name, unsigned long long stripeSize ); int createLvSnapshot(const string& origin, const string& name, @@ -56,7 +56,7 @@ static void getVgs( std::list<string>& l ); static bool lvNotDeleted( const LvmLv& l ) { return( !l.deleted() ); } - + protected: // iterators over LVM LVs // protected typedefs for iterators over LVMLVs @@ -130,7 +130,7 @@ string instSysString(); void logData( const string& Dir ); - void addLv(unsigned long& le, string& name, string& origin, string& uuid, + void addLv(unsigned long& le, string& name, string& origin, string& uuid, string& status, string& alloc, bool& ro); void addPv( Pv*& p ); Modified: trunk/storage/libstorage/src/Storage.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=52526&r1=52525&r2=52526&view=diff ============================================================================== --- trunk/storage/libstorage/src/Storage.cc (original) +++ trunk/storage/libstorage/src/Storage.cc Fri Oct 24 15:29:31 2008 @@ -5657,22 +5657,32 @@ return( ret ); } + void -Storage::activateHld( bool val ) +Storage::activateHld(bool val) +{ + y2mil("val:" << val); + if (val) { - y2milestone( "val:%d", val ); - if( val ) - { Dm::activate(val); - MdCo::activate(val,tmpDir()); - } + MdCo::activate(val, tmpDir()); + } LvmVg::activate(val); - if( !val ) - { + if (!val) + { Dm::activate(val); - MdCo::activate(val,tmpDir()); - } + MdCo::activate(val, tmpDir()); } +} + + +void +Storage::activateMultipath(bool val) +{ + y2mil("val:" << val); + DmmultipathCo::activate(val); +} + int Storage::addFstabEntry( const string& device, const string& mount, const string& vfs, const string& options, Modified: trunk/storage/libstorage/src/Storage.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.h?rev=52526&r1=52525&r2=52526&view=diff ============================================================================== --- trunk/storage/libstorage/src/Storage.h (original) +++ trunk/storage/libstorage/src/Storage.h Fri Oct 24 15:29:31 2008 @@ -462,6 +462,7 @@ int commit(); void handleHald( bool stop ); void activateHld( bool val=true ); + void activateMultipath( bool val=true ); void removeDmTableTo( const Volume& vol ); void removeDmTableTo( const string& device ); bool removeDmTable( const string& table ); Modified: trunk/storage/libstorage/src/StorageInterface.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageInterface.h?rev=52526&r1=52525&r2=52526&view=diff ============================================================================== --- trunk/storage/libstorage/src/StorageInterface.h (original) +++ trunk/storage/libstorage/src/StorageInterface.h Fri Oct 24 15:29:31 2008 @@ -2076,6 +2076,14 @@ virtual void activateHld( bool val ) = 0; /** + * Activate or deactivate multipath + * + * @param val flag if multipath should be activated or deactivated + * @return bool if values could be successfully determined + */ + virtual void activateMultipath( bool val ) = 0; + + /** * Rescan all disks. * All currently detected objects are forgotten and a new scan * for all type of objects (disks, LVM, MD) is initiated. Modified: trunk/storage/package/yast2-storage.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/package/yast2-storage.changes?rev=52526&r1=52525&r2=52526&view=diff ============================================================================== --- trunk/storage/package/yast2-storage.changes (original) +++ trunk/storage/package/yast2-storage.changes Fri Oct 24 15:29:31 2008 @@ -3,6 +3,7 @@ - encrypt crypt files per default (bnc #438047) - fixed raid detection (bnc #438644) +- started work on start/stop of multipath (bnc #438055) - 2.17.44 ------------------------------------------------------------------- -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn.opensuse.org