PeContainer.h

Go to the documentation of this file.
00001 #ifndef PE_CONTAINER_H
00002 #define PE_CONTAINER_H
00003 
00004 #include "y2storage/Container.h"
00005 #include "y2storage/Dm.h"
00006 
00007 namespace storage
00008 {
00009 
00010 class PeContainer : public Container
00011     {
00012     friend class Storage;
00013 
00014     public:
00015         PeContainer( Storage * const s, storage::CType t );
00016         PeContainer( const PeContainer& c );
00017         PeContainer& operator= ( const PeContainer& rhs );
00018         virtual ~PeContainer();
00019 
00020         unsigned long long peSize() const { return pe_size; }
00021         unsigned long long sizeK() const { return pe_size*num_pe; }
00022         unsigned long peCount() const { return num_pe; }
00023         unsigned long peFree() const { return free_pe; }
00024         unsigned numPv() const { return pv.size(); }
00025         friend std::ostream& operator<< (std::ostream&, const PeContainer& );
00026         bool addedPv( const string& dev ) const;
00027         unsigned long sizeToLe( unsigned long long sizeK ) const;
00028 
00029         int setPeSize( long long unsigned, bool lvm1 );
00030         void unuseDev();
00031         bool equalContent( const PeContainer& rhs, bool comp_vol=true ) const;
00032         virtual string logDiff( const PeContainer& d ) const;
00033         
00034     protected:
00035         struct Pv
00036             {
00037             string device;
00038             string uuid;
00039             string status;
00040             unsigned long num_pe;
00041             unsigned long free_pe;
00042 
00043             static bool comp_le( const Pv& a, const Pv& b )
00044                 { return( a.free_pe<b.free_pe ); }
00045             static bool no_free( const Pv& a )
00046                 { return( a.free_pe==0 ); }
00047 
00048             bool operator== ( const Pv& rhs ) const
00049                 { return( device==rhs.device ); }
00050             bool operator== ( const string& dev ) const
00051                 { return( device==dev); }
00052             bool equalContent( const Pv& rhs ) const
00053                 { return( device==rhs.device && uuid==rhs.uuid &&
00054                           status==rhs.status && num_pe==rhs.num_pe &&
00055                           free_pe==rhs.free_pe ); }
00056             Pv() { num_pe = free_pe = 0; }
00057             };
00058 
00059         friend std::ostream& operator<< (std::ostream&, const Pv& );
00060         friend void printDevList (std::ostream&, const std::list<Pv>& );
00061 
00062         void init();
00063         string addList() const;
00064         virtual void print( std::ostream& s ) const { s << *this; }
00065         virtual Container* getCopy() const { return( new PeContainer( *this ) ); }
00066 
00067         unsigned long leByLvRemove() const;
00068         int tryUnusePe( const string& dev, std::list<Pv>& pl, std::list<Pv>& pladd,
00069                         std::list<Pv>& plrem, unsigned long& removed_pe );
00070         bool checkCreateConstraints();
00071         static int addLvPeDistribution( unsigned long le, unsigned stripe,
00072                                         std::list<Pv>& pl, std::list<Pv>& pladd, 
00073                                         std::map<string,unsigned long>& pe_map );
00074         static int remLvPeDistribution( unsigned long le, std::map<string,unsigned long>& pe_map,
00075                                         std::list<Pv>& pl, std::list<Pv>& pladd );
00076         virtual bool checkConsistency() const;
00077 
00078         void addPv( const Pv* p );
00079 
00080         unsigned long long pe_size;
00081         unsigned long num_pe;
00082         unsigned long free_pe;
00083         std::list<Pv> pv;
00084         std::list<Pv> pv_add;
00085         std::list<Pv> pv_remove;
00086     };
00087 
00088 }
00089 
00090 #endif

Generated on Tue Nov 28 17:50:00 2006 for yast2-storage by  doxygen 1.5.0