123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- #ifndef UPDATE_ENGINE_PAYLOAD_GENERATOR_INPLACE_GENERATOR_H_
- #define UPDATE_ENGINE_PAYLOAD_GENERATOR_INPLACE_GENERATOR_H_
- #include <map>
- #include <set>
- #include <string>
- #include <vector>
- #include "update_engine/payload_generator/blob_file_writer.h"
- #include "update_engine/payload_generator/delta_diff_generator.h"
- #include "update_engine/payload_generator/graph_types.h"
- #include "update_engine/payload_generator/operations_generator.h"
- namespace chromeos_update_engine {
- struct CutEdgeVertexes {
- Vertex::Index new_vertex;
- Vertex::Index old_src;
- Vertex::Index old_dst;
- std::vector<Extent> tmp_extents;
- };
- class InplaceGenerator : public OperationsGenerator {
- public:
-
- struct Block {
-
-
-
-
-
-
-
-
- Block() : reader(Vertex::kInvalidIndex), writer(Vertex::kInvalidIndex) {}
- Vertex::Index reader;
- Vertex::Index writer;
- };
- InplaceGenerator() = default;
-
- static void CheckGraph(const Graph& graph);
-
-
-
-
-
-
-
-
- static void SubstituteBlocks(Vertex* vertex,
- const std::vector<Extent>& remove_extents,
- const std::vector<Extent>& replace_extents);
-
-
-
-
-
-
-
- static bool CutEdges(Graph* graph,
- const std::set<Edge>& edges,
- std::vector<CutEdgeVertexes>* out_cuts);
-
-
-
- static void CreateEdges(Graph* graph, const std::vector<Block>& blocks);
-
-
-
- static void GenerateReverseTopoOrderMap(
- const std::vector<Vertex::Index>& op_indexes,
- std::vector<std::vector<Vertex::Index>::size_type>* reverse_op_indexes);
-
-
- static void SortCutsByTopoOrder(const std::vector<Vertex::Index>& op_indexes,
- std::vector<CutEdgeVertexes>* cuts);
-
-
-
- static void MoveAndSortFullOpsToBack(Graph* graph,
- std::vector<Vertex::Index>* op_indexes);
-
-
- static bool NoTempBlocksRemain(const Graph& graph);
-
-
-
-
-
-
-
- static bool AssignTempBlocks(
- Graph* graph,
- const std::string& new_part,
- BlobFileWriter* blob_file,
- std::vector<Vertex::Index>* op_indexes,
- std::vector<std::vector<Vertex::Index>::size_type>* reverse_op_indexes,
- const std::vector<CutEdgeVertexes>& cuts);
-
-
-
-
-
-
-
- static bool ConvertCutToFullOp(Graph* graph,
- const CutEdgeVertexes& cut,
- const std::string& new_part,
- BlobFileWriter* blob_file);
-
-
-
-
-
-
-
-
-
- static bool ConvertGraphToDag(Graph* graph,
- const std::string& new_part,
- BlobFileWriter* blob_file,
- std::vector<Vertex::Index>* final_order,
- Vertex::Index scratch_vertex);
-
-
-
-
- static void CreateScratchNode(uint64_t start_block,
- uint64_t num_blocks,
- Vertex* vertex);
-
-
-
-
-
-
-
- static bool AddInstallOpToBlocksVector(const InstallOperation& operation,
- const Graph& graph,
- Vertex::Index vertex,
- std::vector<Block>* blocks);
-
-
-
-
-
- static bool AddInstallOpToGraph(Graph* graph,
- Vertex::Index existing_vertex,
- std::vector<Block>* blocks,
- const InstallOperation& operation,
- const std::string& op_name);
-
-
-
- static void ApplyMap(std::vector<uint64_t>* collection,
- const std::map<uint64_t, uint64_t>& the_map);
-
-
-
-
-
-
-
-
-
- static bool ResolveReadAfterWriteDependencies(
- const PartitionConfig& old_part,
- const PartitionConfig& new_part,
- uint64_t partition_size,
- size_t block_size,
- BlobFileWriter* blob_file,
- std::vector<AnnotatedOperation>* aops);
-
-
-
-
-
-
-
-
- bool GenerateOperations(const PayloadGenerationConfig& config,
- const PartitionConfig& old_part,
- const PartitionConfig& new_part,
- BlobFileWriter* blob_file,
- std::vector<AnnotatedOperation>* aops) override;
- private:
- DISALLOW_COPY_AND_ASSIGN(InplaceGenerator);
- };
- };
- #endif
|