Author: fehr
Date: Wed Jan 25 13:36:34 2012
New Revision: 67288
URL: http://svn.opensuse.org/viewcvs/yast?rev=67288&view=rev
Log:
allow resize and move of simple btrfs volumes if they are formatted anyway (bnc#742491)
Modified:
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
branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp
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=67288&r1=67287&r2=67288&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 Wed Jan 25 13:36:34 2012
@@ -1795,16 +1795,24 @@
Storage::updatePartitionArea( const string& partition, unsigned long start,
unsigned long size )
{
+ return( updatePartitionArea( partition, start, size, false ));
+ }
+
+int
+Storage::updatePartitionArea( const string& partition, unsigned long start,
+ unsigned long size, bool noBtrfs )
+ {
int ret = 0;
assertInit();
- y2mil("partition:" << partition << " start:" << start << " size:" << size);
+ y2mil("partition:" << partition << " start:" << start << " size:" << size <<
+ " noBtrfs:" << noBtrfs);
VolIterator vol;
ContIterator cont;
if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
- else if( findVolume( partition, cont, vol ) )
+ else if( findVolume( partition, cont, vol, noBtrfs ) )
{
if( cont->type()==DISK )
{
@@ -1831,17 +1839,42 @@
}
}
else if( cont->type() == MDPART )
- {
- MdPartCo* disk = dynamic_cast(&(*cont));
- if( disk!=NULL )
{
- ret = disk->changePartitionArea(vol->nr(), Region(start, size));
+ MdPartCo* disk = dynamic_cast(&(*cont));
+ if( disk!=NULL )
+ {
+ ret = disk->changePartitionArea(vol->nr(), Region(start, size));
+ }
+ else
+ {
+ ret = STORAGE_CHANGE_AREA_INVALID_CONTAINER;
+ }
}
- else
+ else if( cont->type()==BTRFSC )
{
- ret = STORAGE_CHANGE_AREA_INVALID_CONTAINER;
+ BtrfsCo* bco = dynamic_cast(&(*cont));
+ Btrfs* b = dynamic_cast(&(*vol));
+ if( bco!=NULL && b!=NULL )
+ {
+ list<string> devs = b->getDevices();
+ if( devs.size()==1 )
+ {
+ ret = updatePartitionArea( devs.front(), start, size, true );
+ if( ret==0 && findVolume( devs.front(), vol, false, true ) )
+ {
+ b->setSize( vol->sizeK() );
+ y2mil( "vol:" << *vol );
+ y2mil( "b:" << *b );
+ }
+ }
+ else
+ ret = VOLUME_ALREADY_IN_USE;
+ }
+ else
+ {
+ ret = STORAGE_CHANGE_AREA_INVALID_CONTAINER;
+ }
}
- }
else
{
ret = STORAGE_CHANGE_AREA_INVALID_CONTAINER;
@@ -1869,7 +1902,7 @@
y2mil("partition:" << partition);
ConstVolIterator vol;
ConstContIterator cont;
- if( findVolume( partition, cont, vol ) )
+ if( findVolume( partition, cont, vol, true ) )
{
if( cont->type()==DISK )
{
@@ -2007,16 +2040,24 @@
Storage::resizePartition( const string& partition, unsigned long sizeCyl,
bool ignoreFs )
{
+ return( resizePartition( partition, sizeCyl, ignoreFs, false ));
+ }
+
+int
+Storage::resizePartition( const string& partition, unsigned long sizeCyl,
+ bool ignoreFs, bool noBtrfs )
+ {
int ret = 0;
assertInit();
- y2mil("partition:" << partition << " newCyl:" << sizeCyl << " ignoreFs:" << ignoreFs);
+ y2mil("partition:" << partition << " newCyl:" << sizeCyl << " ignoreFs:" << ignoreFs <<
+ "noBtrfs:" << noBtrfs );
VolIterator vol;
ContIterator cont;
if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
- else if( findVolume( partition, cont, vol ) )
+ else if( findVolume( partition, cont, vol, noBtrfs ) )
{
if( cont->type()==DISK )
{
@@ -2048,21 +2089,46 @@
ret = STORAGE_RESIZE_INVALID_CONTAINER;
}
}
- else if( cont->type()== MDPART )
- {
- MdPartCo* disk = dynamic_cast(&(*cont));
- MdPart* p = dynamic_cast(&(*vol));
- if( disk!=NULL && p!=NULL )
- {
- if( ignoreFs )
- p->setIgnoreFs();
- ret = disk->resizePartition( p, sizeCyl );
- }
- else
- {
- ret = STORAGE_RESIZE_INVALID_CONTAINER;
- }
- }
+ else if( cont->type()==MDPART )
+ {
+ MdPartCo* disk = dynamic_cast(&(*cont));
+ MdPart* p = dynamic_cast(&(*vol));
+ if( disk!=NULL && p!=NULL )
+ {
+ if( ignoreFs )
+ p->setIgnoreFs();
+ ret = disk->resizePartition( p, sizeCyl );
+ }
+ else
+ {
+ ret = STORAGE_RESIZE_INVALID_CONTAINER;
+ }
+ }
+ else if( cont->type()==BTRFSC )
+ {
+ BtrfsCo* bco = dynamic_cast(&(*cont));
+ Btrfs* b = dynamic_cast(&(*vol));
+ if( bco!=NULL && b!=NULL )
+ {
+ list<string> devs = b->getDevices();
+ if( devs.size()==1 )
+ {
+ ret = resizePartition( devs.front(), sizeCyl, ignoreFs, true );
+ if( ret==0 && findVolume( devs.front(), vol, false, true ) )
+ {
+ b->setSize( vol->sizeK() );
+ y2mil( "vol:" << *vol );
+ y2mil( "b:" << *b );
+ }
+ }
+ else
+ ret = VOLUME_ALREADY_IN_USE;
+ }
+ else
+ {
+ ret = STORAGE_RESIZE_INVALID_CONTAINER;
+ }
+ }
else
{
ret = STORAGE_RESIZE_INVALID_CONTAINER;
@@ -3193,23 +3259,59 @@
Storage::resizeVolume(const string& device, unsigned long long newSizeK,
bool ignoreFs)
{
+ return( resizeVolume( device, newSizeK, ignoreFs, false ));
+ }
+
+int
+Storage::resizeVolume(const string& device, unsigned long long newSizeK,
+ bool ignoreFs, bool noBtrfs )
+ {
int ret = 0;
assertInit();
- y2mil("device:" << device << " newSizeK:" << newSizeK << " ignoreFs:" << ignoreFs);
+ y2mil("device:" << device << " newSizeK:" << newSizeK <<
+ " ignoreFs:" << ignoreFs << " noBtrfs:" << noBtrfs );
VolIterator vol;
ContIterator cont;
if (readonly())
{
ret = STORAGE_CHANGE_READONLY;
}
- else if( findVolume( device, cont, vol ) )
+ else if( findVolume( device, cont, vol, noBtrfs ) )
{
- y2mil( "vol:" << *vol );
- if( ignoreFs )
- vol->setIgnoreFs();
- ret = cont->resizeVolume(&(*vol), newSizeK);
- eraseCachedFreeInfo(vol->device());
- y2mil( "vol:" << *vol );
+ if( cont->type()!=BTRFSC )
+ {
+ y2mil( "vol:" << *vol );
+ if( ignoreFs )
+ vol->setIgnoreFs();
+ ret = cont->resizeVolume(&(*vol), newSizeK);
+ eraseCachedFreeInfo(vol->device());
+ y2mil( "vol:" << *vol );
+ }
+ else
+ {
+ BtrfsCo* bco = dynamic_cast(&(*cont));
+ Btrfs* b = dynamic_cast(&(*vol));
+ if( bco!=NULL && b!=NULL )
+ {
+ list<string> devs = b->getDevices();
+ if( devs.size()==1 )
+ {
+ ret = resizeVolume( devs.front(), newSizeK, ignoreFs, true );
+ if( ret==0 && findVolume( devs.front(), vol, false, true ) )
+ {
+ b->setSize( vol->sizeK() );
+ y2mil( "vol:" << *vol );
+ y2mil( "b:" << *b );
+ }
+ }
+ else
+ ret = VOLUME_ALREADY_IN_USE;
+ }
+ else
+ {
+ ret = STORAGE_RESIZE_INVALID_CONTAINER;
+ }
+ }
}
else
{
@@ -6164,6 +6266,12 @@
bool
Storage::isUsedBySingleBtrfs( const Volume& vol ) const
{
+ return( isUsedBySingleBtrfs( vol, NULL ));
+ }
+
+bool
+Storage::isUsedBySingleBtrfs( const Volume& vol, const Volume** btrfs ) const
+ {
const list<UsedBy>& ub = vol.getUsedBy();
bool ret = ub.size()==1 && ub.front().type()==UB_BTRFS;
if( ret )
@@ -6173,6 +6281,8 @@
while( i!=p.end() && i->getUuid()!=ub.front().device() )
++i;
ret = i!=p.end() && i->getDevices(true).size()<=1;
+ if( btrfs!=NULL )
+ *btrfs = &(*i);
}
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=67288&r1=67287&r2=67288&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 Wed Jan 25 13:36:34 2012
@@ -283,6 +283,7 @@
bool isUsedBy(const string& dev);
bool isUsedBy(const string& dev, UsedByType type);
bool isUsedBySingleBtrfs( const Volume& vol ) const;
+ bool isUsedBySingleBtrfs( const Volume& vol, const Volume** btrfs ) const;
bool canRemove( const Volume& vol ) const;
void fetchDanglingUsedBy(const string& dev, list<UsedBy>& uby);
@@ -2040,11 +2041,18 @@
void detectDmmultipath(SystemInfo& systeminfo);
void detectDm(SystemInfo& systeminfo, bool only_crypt);
void initDisk( list<DiskData>& dl, SystemInfo& systeminfo);
- void detectFsData(const VolIterator& begin, const VolIterator& end, SystemInfo& systeminfo);
+ void detectFsData(const VolIterator& begin, const VolIterator& end,
+ SystemInfo& systeminfo);
+ int updatePartitionArea(const string& device, unsigned long start,
+ unsigned long size, bool noBtrfs );
int resizeVolume(const string& device, unsigned long long newSizeK,
bool ignore_fs);
+ int resizeVolume(const string& device, unsigned long long newSizeK,
+ bool ignore_fs, bool noBtrfs );
int resizePartition( const string& device, unsigned long sizeCyl,
bool ignore_fs );
+ int resizePartition( const string& device, unsigned long sizeCyl,
+ bool ignoreFs, bool noBtrfs );
void addToList(Container* e);
DiskIterator findDisk( const string& disk );
DiskIterator findDiskId( const string& id );
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=67288&r1=67287&r2=67288&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 Wed Jan 25 13:36:34 2012
@@ -1451,9 +1451,16 @@
{
int ret=0;
y2mil("val:" << newSizeK);
- if (isUsedBy() && !getStorage()->isUsedBySingleBtrfs(*this))
+ if( isUsedBy() )
{
- ret = VOLUME_ALREADY_IN_USE;
+ const Volume* btrfs = NULL;
+ if( getStorage()->isUsedBySingleBtrfs(*this, &btrfs) )
+ {
+ y2mil( "btrfs:" << btrfs );
+ ret = btrfs->canResize( newSizeK );
+ }
+ else
+ ret = VOLUME_ALREADY_IN_USE;
}
else
{
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=67288&r1=67287&r2=67288&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 Wed Jan 25 13:36:34 2012
@@ -1,6 +1,8 @@
-------------------------------------------------------------------
Wed Jan 25 12:20:53 CET 2012 - fehr@suse.de
+- allow resize and move of simple btrfs volumes if they are
+ formatted anyway (bnc#742491)
- fix bug handling used devices of simple btrfs volumes in resize
-------------------------------------------------------------------
Modified: branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp?rev=67288&r1=67287&r2=67288&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/storage/storage/src/include/ep-dialogs.ycp Wed Jan 25 13:36:34 2012
@@ -636,6 +636,7 @@
map possible = Storage::IsResizable(data);
+ y2milestone( "DlgResize data: %1", data );
if (!data["format"]:false && !possible["shrink"]:false && !possible["extend"]:false)
{
// popup text
@@ -833,7 +834,8 @@
boolean lvm = data["type"]:`unknown == `lvm;
//1 - ask & be interactive, 2 - we are on lvm, 3 - cyl.diff, 4 - filesystem, 5 - mountpoint
- if (!CheckResizePossible(false, lvm, size_k - old_size_k, used_fs, mountpoint))
+ if (!data["format"]:false &&
+ !CheckResizePossible(false, lvm, size_k - old_size_k, used_fs, mountpoint))
{
//FIXME: To check whether the part. can be resized only
//after user tries to do that is stupid - in some cases
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org