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 
00027         int setPeSize( long long unsigned, bool lvm1 );
00028         void unuseDev();
00029         bool equalContent( const PeContainer& rhs, bool comp_vol=true ) const;
00030         string logDifference( const PeContainer& d ) const;
00031         
00032     protected:
00033         struct Pv
00034             {
00035             string device;
00036             string uuid;
00037             string status;
00038             unsigned long num_pe;
00039             unsigned long free_pe;
00040 
00041             static bool comp_le( const Pv& a, const Pv& b )
00042                 { return( a.free_pe<b.free_pe ); }
00043             static bool no_free( const Pv& a )
00044                 { return( a.free_pe==0 ); }
00045 
00046             bool operator== ( const Pv& rhs ) const
00047                 { return( device==rhs.device ); }
00048             bool operator== ( const string& dev ) const
00049                 { return( device==dev); }
00050             bool equalContent( const Pv& rhs ) const
00051                 { return( device==rhs.device && uuid==rhs.uuid &&
00052                           status==rhs.status && num_pe==rhs.num_pe &&
00053                           free_pe==rhs.free_pe ); }
00054             Pv() { num_pe = free_pe = 0; }
00055             };
00056 
00057         friend std::ostream& operator<< (std::ostream&, const Pv& );
00058         friend void printDevList (std::ostream&, const std::list<Pv>& );
00059 
00060         void init();
00061         unsigned long long capacityInKb() const {return pe_size*num_pe;}
00062         virtual void print( std::ostream& s ) const { s << *this; }
00063         virtual Container* getCopy() const { return( new PeContainer( *this ) ); }
00064 
00065         unsigned long leByLvRemove() const;
00066         int tryUnusePe( const string& dev, std::list<Pv>& pl, std::list<Pv>& pladd,
00067                         std::list<Pv>& plrem, unsigned long& removed_pe );
00068         static int addLvPeDistribution( unsigned long le, unsigned stripe,
00069                                         std::list<Pv>& pl, std::list<Pv>& pladd, 
00070                                         std::map<string,unsigned long>& pe_map );
00071         static int remLvPeDistribution( unsigned long le, std::map<string,unsigned long>& pe_map,
00072                                         std::list<Pv>& pl, std::list<Pv>& pladd );
00073         virtual bool checkConsistency() const;
00074 
00075         void addPv( const Pv* p );
00076 
00077         unsigned long long pe_size;
00078         unsigned long num_pe;
00079         unsigned long free_pe;
00080         std::list<Pv> pv;
00081         std::list<Pv> pv_add;
00082         std::list<Pv> pv_remove;
00083     };
00084 
00085 }
00086 
00087 #endif

Generated on Thu Jul 6 00:40:24 2006 for yast2-storage by  doxygen 1.4.6