Author: aschnell
Date: Thu Apr 23 11:27:48 2009
New Revision: 56928
URL: http://svn.opensuse.org/viewcvs/yast?rev=56928&view=rev
Log:
- some cleanup
Modified:
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/Storage.h
trunk/storage/libstorage/src/StorageTmpl.h
trunk/storage/libstorage/src/Volume.cc
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=56928&r1=56927&r2=56928&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Thu Apr 23 11:27:48 2009
@@ -2437,7 +2437,7 @@
if( ignoreFs )
vol->setIgnoreFs();
ret = cont->resizeVolume( &(*vol), newSizeMb*1024 );
- eraseFreeInfo( vol->device() );
+ eraseCachedFreeInfo(vol->device());
y2mil( "vol:" << *vol );
}
else
@@ -5352,10 +5352,10 @@
bool
-Storage::getFreeInfo( const string& device, unsigned long long& resize_free,
- unsigned long long& df_free,
- unsigned long long& used, bool& win, bool& efi,
- bool use_cache )
+Storage::getFreeInfo(const string& device, unsigned long long& resize_free,
+ unsigned long long& df_free,
+ unsigned long long& used, bool& win, bool& efi,
+ bool use_cache)
{
bool ret = false;
assertInit();
@@ -5364,8 +5364,8 @@
VolIterator vol;
if( findVolume( device, vol ) )
{
- if( use_cache && getFreeInf( vol->device(), df_free, resize_free,
- used, win, efi, ret ))
+ if (use_cache && getCachedFreeInfo(vol->device(), df_free, resize_free,
+ used, win, efi, ret))
{
}
else
@@ -5472,8 +5472,7 @@
if( !ret )
vol->crUnsetup();
}
- setFreeInfo( vol->device(), df_free, resize_free, used, win, efi,
- ret );
+ setCachedFreeInfo(vol->device(), df_free, resize_free, used, win, efi, ret);
}
}
if( ret )
@@ -5482,25 +5481,27 @@
return( ret );
}
-void Storage::setFreeInfo( const string& device, unsigned long long df_free,
- unsigned long long resize_free,
+
+void
+Storage::setCachedFreeInfo(const string& device, unsigned long long df_free,
+ unsigned long long resize_free,
unsigned long long used, bool win, bool efi,
- bool resize_ok )
- {
+ bool resize_ok)
+{
y2mil("device:" << device << " df_free:" << df_free << " resize_free:" << resize_free << " used:" << used <<
" win:" << win << " efi:" << efi);
- FreeInfo inf( df_free, resize_free, used, win, efi, resize_ok );
- freeInfo[device] = inf;
- }
+ mapInsertOrReplace(freeInfo, device, FreeInfo(df_free, resize_free, used, win, efi, resize_ok));
+}
+
bool
-Storage::getFreeInf( const string& device, unsigned long long& df_free,
- unsigned long long& resize_free,
- unsigned long long& used, bool& win, bool& efi,
- bool& resize_ok )
- {
- map::iterator i = freeInfo.find( device );
+Storage::getCachedFreeInfo(const string& device, unsigned long long& df_free,
+ unsigned long long& resize_free,
+ unsigned long long& used, bool& win, bool& efi,
+ bool& resize_ok) const
+{
+ map::const_iterator i = freeInfo.find(device);
bool ret = i!=freeInfo.end();
if( ret )
{
@@ -5515,16 +5516,18 @@
if( ret )
y2mil("df_free:" << df_free << " resize_free:" << resize_free << " used:" << used <<
" win:" << win << " efi:" << efi << " resize_ok:" << resize_ok);
- return( ret );
- }
+ return ret;
+}
+
void
-Storage::eraseFreeInfo( const string& device )
- {
+Storage::eraseCachedFreeInfo(const string& device)
+{
map::iterator i = freeInfo.find( device );
if( i!=freeInfo.end() )
freeInfo.erase(i);
- }
+}
+
int
Storage::createBackupState( const string& name )
Modified: trunk/storage/libstorage/src/Storage.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.h?rev=56928&r1=56927&r2=56928&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.h (original)
+++ trunk/storage/libstorage/src/Storage.h Thu Apr 23 11:27:48 2009
@@ -183,6 +183,7 @@
{ return( d.type()==storage::NFSC ); }
static bool isDm( const Container&d )
{ return( d.type()==storage::DM ); }
+
struct FreeInfo
{
unsigned long long resize_free;
@@ -191,7 +192,6 @@
bool win;
bool efi;
bool rok;
- FreeInfo() { resize_free=df_free=used=0; efi=win=rok=false; }
FreeInfo( unsigned long long df,
unsigned long long resize,
unsigned long long usd, bool w=false, bool e=false,
@@ -444,7 +444,7 @@
void getCommitInfos(list<CommitInfo>& infos) const;
const string& getLastAction() const { return lastAction; }
const string& getExtendedErrorMessage() const { return extendedError; }
- void eraseFreeInfo( const string& device );
+ void eraseCachedFreeInfo(const string& device);
static void waitForDevice();
static int waitForDevice(const string& device);
@@ -1694,14 +1694,14 @@
string backupStates() const;
void detectObjects();
void deleteBackups();
- void setFreeInfo( const string& device, unsigned long long df_free,
- unsigned long long resize_free,
- unsigned long long used, bool win, bool efi,
- bool resize_ok );
- bool getFreeInf( const string& device, unsigned long long& df_free,
- unsigned long long& resize_free,
- unsigned long long& used, bool& win, bool& efi,
- bool& resize_ok );
+ void setCachedFreeInfo(const string& device, unsigned long long df_free,
+ unsigned long long resize_free,
+ unsigned long long used, bool win, bool efi,
+ bool resize_ok);
+ bool getCachedFreeInfo(const string& device, unsigned long long& df_free,
+ unsigned long long& resize_free,
+ unsigned long long& used, bool& win, bool& efi,
+ bool& resize_ok) const;
// protected internal member variables
Lock lock;
Modified: trunk/storage/libstorage/src/StorageTmpl.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageTmpl.h?rev=56928&r1=56927&r2=56928&view=diff
==============================================================================
--- trunk/storage/libstorage/src/StorageTmpl.h (original)
+++ trunk/storage/libstorage/src/StorageTmpl.h Thu Apr 23 11:27:48 2009
@@ -213,6 +213,17 @@
}
+ template
+ typename Map::iterator mapInsertOrReplace(Map& m, const Key& k, const Value& v)
+ {
+ typename Map::iterator pos = m.lower_bound(k);
+ if (pos != m.end() && !typename Map::key_compare()(k, pos->first))
+ pos->second = v;
+ else
+ pos = m.insert(pos, typename Map::value_type(k, v));
+ return pos;
+ }
+
template
inline unsigned int lengthof (T (&)[sz]) { return sz; }
Modified: trunk/storage/libstorage/src/Volume.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Volume.cc?rev=56928&r1=56927&r2=56928&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Volume.cc (original)
+++ trunk/storage/libstorage/src/Volume.cc Thu Apr 23 11:27:48 2009
@@ -2186,7 +2186,7 @@
{
crUnsetup();
}
- cont->getStorage()->eraseFreeInfo(dev);
+ cont->getStorage()->eraseCachedFreeInfo(dev);
cont->getStorage()->removeDmTableTo(*this);
y2mil("ret:" << ret);
return( ret );
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org