Skip to content

Commit

Permalink
fix LVM encryption when btrfs fs is present (bnc#808020)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fehr committed Mar 11, 2013
1 parent e9fb753 commit 7876642
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libstorage/src/LvmVg.cc
Expand Up @@ -223,7 +223,7 @@ LvmVg::extendVg( const list<string>& devs )
pvn.device = d;

const Volume* v;
if (getStorage()->findVolume(d, v) && v->dmcrypt())
if (getStorage()->findVolume(d, v, true) && v->dmcrypt())
pvn.dmcryptDevice = v->dmcryptDevice();

pv_add.push_back( pvn );
Expand Down Expand Up @@ -944,7 +944,7 @@ void LvmVg::getVgData( const string& name, bool exists )
p->device = extractNthWord( 2, line );

const Volume* v;
if (getStorage()->findVolume(p->device, v))
if (getStorage()->findVolume(p->device, v, true))
{
p->device = v->device();
p->dmcryptDevice = v->dmcryptDevice();
Expand Down
10 changes: 5 additions & 5 deletions libstorage/src/Storage.cc
Expand Up @@ -2992,7 +2992,7 @@ Storage::setCryptType( const string& device, bool val, EncryptType typ )
{
ret = STORAGE_CHANGE_READONLY;
}
else if( findVolume( device, cont, vol ) )
else if( findVolume( device, cont, vol, true ) )
{
ret = vol->setEncryption( val, typ );
}
Expand All @@ -3018,7 +3018,7 @@ Storage::getCrypt( const string& device, bool& val )
y2mil("device:" << device);
ConstVolIterator vol;
ConstContIterator cont;
if( findVolume( device, cont, vol ) )
if( findVolume( device, cont, vol, true ) )
{
val = vol->getEncryption();
}
Expand Down Expand Up @@ -3046,7 +3046,7 @@ Storage::verifyCryptPassword( const string& device, const string& pwd,
{
ret = STORAGE_CHANGE_READONLY;
}
else if( findVolume( device, vol ) )
else if( findVolume( device, vol, false, true ) )
{
ret = vol->setCryptPwd( pwd );
if( ret==0 && vol->detectEncryption()==ENC_UNKNOWN )
Expand Down Expand Up @@ -3110,7 +3110,7 @@ Storage::setCryptPassword( const string& device, const string& pwd )
{
ret = STORAGE_CHANGE_READONLY;
}
else if( findVolume( device, vol ) )
else if( findVolume( device, vol, false, true ) )
{
ret = vol->setCryptPwd( pwd );
if( i!=pwdBuf.end() )
Expand Down Expand Up @@ -6386,7 +6386,7 @@ Storage::findDevice( const string& dev, const Device* &vol,
void
Storage::setUsedBy(const string& dev, UsedByType type, const string& device)
{
Device* tmp = findDevice(dev);
Device* tmp = findDevice(dev,true);
if (tmp)
{
tmp->setUsedBy(type, device);
Expand Down
4 changes: 3 additions & 1 deletion libstorage/src/Volume.cc
Expand Up @@ -1714,7 +1714,9 @@ Volume::setEncryption(bool val, EncryptType typ )
y2mil("val:" << val << " typ:" << toString(typ));
if (isUsedBy())
{
ret = VOLUME_ALREADY_IN_USE;
const Volume* btrfs = NULL;
if( !getStorage()->isUsedBySingleBtrfs(*this, &btrfs) )
ret = VOLUME_ALREADY_IN_USE;
}
if( ret==0 )
{
Expand Down

0 comments on commit 7876642

Please sign in to comment.