blob: 97de934fcaf572f7b76482a5b50823625a7376ac [file] [log] [blame]
Kelvin Zhang94f51cc2020-09-25 11:34:49 -04001//
2// Copyright (C) 2020 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17#include "update_engine/payload_consumer/vabc_partition_writer.h"
18
19#include <memory>
Kelvin Zhang3f60d532020-11-09 13:33:17 -050020#include <string>
Kelvin Zhange52b6cd2021-02-09 15:28:40 -050021#include <utility>
Kelvin Zhang9b10dba2020-09-25 17:09:11 -040022#include <vector>
Kelvin Zhang94f51cc2020-09-25 11:34:49 -040023
Akilesh Kailash3e6e7df2021-11-18 23:29:15 +000024#include <android-base/properties.h>
Kelvin Zhang76f10b82021-06-25 18:45:46 -040025#include <brillo/secure_blob.h>
Kelvin Zhang94f51cc2020-09-25 11:34:49 -040026#include <libsnapshot/cow_writer.h>
27
Kelvin Zhang9b10dba2020-09-25 17:09:11 -040028#include "update_engine/common/cow_operation_convert.h"
Kelvin Zhang94f51cc2020-09-25 11:34:49 -040029#include "update_engine/common/utils.h"
Kelvin Zhang76f10b82021-06-25 18:45:46 -040030#include "update_engine/payload_consumer/extent_map.h"
Kelvin Zhang7a265752020-10-29 15:51:35 -040031#include "update_engine/payload_consumer/file_descriptor.h"
Kelvin Zhang94f51cc2020-09-25 11:34:49 -040032#include "update_engine/payload_consumer/install_plan.h"
Kelvin Zhang9b10dba2020-09-25 17:09:11 -040033#include "update_engine/payload_consumer/snapshot_extent_writer.h"
Kelvin Zhang76f10b82021-06-25 18:45:46 -040034#include "update_engine/payload_consumer/xor_extent_writer.h"
Kelvin Zhanga37aafc2021-06-14 13:21:37 -040035#include "update_engine/payload_generator/extent_ranges.h"
36#include "update_engine/payload_generator/extent_utils.h"
37#include "update_engine/update_metadata.pb.h"
Kelvin Zhang94f51cc2020-09-25 11:34:49 -040038
39namespace chromeos_update_engine {
Kelvin Zhang52cb1d72020-10-27 13:44:25 -040040// Expected layout of COW file:
41// === Beginning of Cow Image ===
42// All Source Copy Operations
43// ========== Label 0 ==========
44// Operation 0 in PartitionUpdate
45// ========== Label 1 ==========
46// Operation 1 in PartitionUpdate
47// ========== label 2 ==========
48// Operation 2 in PartitionUpdate
49// ========== label 3 ==========
50// .
51// .
52// .
53
54// When resuming, pass |next_op_index_| as label to
55// |InitializeWithAppend|.
56// For example, suppose we finished writing SOURCE_COPY, and we finished writing
57// operation 2 completely. Update is suspended when we are half way through
58// operation 3.
59// |cnext_op_index_| would be 3, so we pass 3 as
60// label to |InitializeWithAppend|. The CowWriter will retain all data before
61// label 3, Which contains all operation 2's data, but none of operation 3's
62// data.
63
Kelvin Zhanga37aafc2021-06-14 13:21:37 -040064using android::snapshot::ICowWriter;
65using ::google::protobuf::RepeatedPtrField;
66
Kelvin Zhang76f10b82021-06-25 18:45:46 -040067// Compute XOR map, a map from dst extent to corresponding merge operation
68static ExtentMap<const CowMergeOperation*, ExtentLess> ComputeXorMap(
69 const RepeatedPtrField<CowMergeOperation>& merge_ops) {
70 ExtentMap<const CowMergeOperation*, ExtentLess> xor_map;
71 for (const auto& merge_op : merge_ops) {
72 if (merge_op.type() == CowMergeOperation::COW_XOR) {
73 xor_map.AddExtent(merge_op.dst_extent(), &merge_op);
74 }
75 }
76 return xor_map;
77}
78
Kelvin Zhange52b6cd2021-02-09 15:28:40 -050079VABCPartitionWriter::VABCPartitionWriter(
80 const PartitionUpdate& partition_update,
81 const InstallPlan::Partition& install_part,
82 DynamicPartitionControlInterface* dynamic_control,
Kelvin Zhanga37aafc2021-06-14 13:21:37 -040083 size_t block_size)
Kelvin Zhange52b6cd2021-02-09 15:28:40 -050084 : partition_update_(partition_update),
85 install_part_(install_part),
86 dynamic_control_(dynamic_control),
Kelvin Zhange52b6cd2021-02-09 15:28:40 -050087 block_size_(block_size),
88 executor_(block_size),
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -070089 verified_source_fd_(block_size, install_part.source_path) {
90 for (const auto& cow_op : partition_update_.merge_operations()) {
91 if (cow_op.type() != CowMergeOperation::COW_COPY) {
92 continue;
93 }
94 copy_blocks_.AddExtent(cow_op.dst_extent());
95 }
Kelvin Zhang7dd5a5e2023-05-11 15:30:38 -070096 LOG(INFO) << "Partition `" << partition_update.partition_name() << "` has "
Kelvin Zhang67144e52023-04-03 18:17:07 -070097 << copy_blocks_.blocks() << " copy blocks";
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -070098}
Kelvin Zhange52b6cd2021-02-09 15:28:40 -050099
Kelvin Zhangd7958752023-03-23 12:23:47 -0700100bool VABCPartitionWriter::DoesDeviceSupportsXor() {
101 return dynamic_control_->GetVirtualAbCompressionXorFeatureFlag().IsEnabled();
102}
103
104bool VABCPartitionWriter::WriteAllCopyOps() {
105 const bool userSnapshots = android::base::GetBoolProperty(
106 "ro.virtual_ab.userspace.snapshots.enabled", false);
107 for (const auto& cow_op : partition_update_.merge_operations()) {
108 if (cow_op.type() != CowMergeOperation::COW_COPY) {
109 continue;
110 }
111 if (cow_op.dst_extent() == cow_op.src_extent()) {
112 continue;
113 }
114 if (userSnapshots) {
115 TEST_AND_RETURN_FALSE(cow_op.src_extent().num_blocks() != 0);
116 TEST_AND_RETURN_FALSE(
117 cow_writer_->AddCopy(cow_op.dst_extent().start_block(),
118 cow_op.src_extent().start_block(),
119 cow_op.src_extent().num_blocks()));
120 } else {
121 // Add blocks in reverse order, because snapused specifically prefers
122 // this ordering. Since we already eliminated all self-overlapping
123 // SOURCE_COPY during delta generation, this should be safe to do.
124 for (size_t i = cow_op.src_extent().num_blocks(); i > 0; i--) {
125 TEST_AND_RETURN_FALSE(
126 cow_writer_->AddCopy(cow_op.dst_extent().start_block() + i - 1,
127 cow_op.src_extent().start_block() + i - 1));
128 }
129 }
130 }
131 return true;
132}
133
Kelvin Zhang94f51cc2020-09-25 11:34:49 -0400134bool VABCPartitionWriter::Init(const InstallPlan* install_plan,
Kelvin Zhang52cb1d72020-10-27 13:44:25 -0400135 bool source_may_exist,
136 size_t next_op_index) {
Kelvin Zhang1c4b9812022-04-06 17:29:00 -0700137 if (dynamic_control_->GetVirtualAbCompressionXorFeatureFlag().IsEnabled()) {
138 xor_map_ = ComputeXorMap(partition_update_.merge_operations());
139 if (xor_map_.size() > 0) {
140 LOG(INFO) << "Virtual AB Compression with XOR is enabled";
141 } else {
142 LOG(INFO) << "Device supports Virtual AB compression with XOR, but OTA "
143 "package does not.";
144 }
145 } else {
146 LOG(INFO) << "Virtual AB Compression with XOR is disabled.";
147 }
Kelvin Zhang9b10dba2020-09-25 17:09:11 -0400148 TEST_AND_RETURN_FALSE(install_plan != nullptr);
Kelvin Zhangd1f90bc2021-09-15 21:12:34 -0700149 if (source_may_exist && install_part_.source_size > 0) {
150 TEST_AND_RETURN_FALSE(!install_part_.source_path.empty());
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500151 TEST_AND_RETURN_FALSE(verified_source_fd_.Open());
152 }
Kelvin Zhang3f60d532020-11-09 13:33:17 -0500153 std::optional<std::string> source_path;
154 if (!install_part_.source_path.empty()) {
155 // TODO(zhangkelvin) Make |source_path| a std::optional<std::string>
156 source_path = install_part_.source_path;
157 }
Kelvin Zhang94f51cc2020-09-25 11:34:49 -0400158
Kelvin Zhang9b10dba2020-09-25 17:09:11 -0400159 // ===== Resume case handling code goes here ====
Kelvin Zhang52cb1d72020-10-27 13:44:25 -0400160 // It is possible that the SOURCE_COPY are already written but
161 // |next_op_index_| is still 0. In this case we discard previously written
162 // SOURCE_COPY, and start over.
David Andersona4b7ba62023-05-10 21:41:37 -0700163 std::optional<uint64_t> label;
Kelvin Zhang52cb1d72020-10-27 13:44:25 -0400164 if (install_plan->is_resume && next_op_index > 0) {
165 LOG(INFO) << "Resuming update on partition `"
166 << partition_update_.partition_name() << "` op index "
167 << next_op_index;
David Andersona4b7ba62023-05-10 21:41:37 -0700168 label = {next_op_index};
169 }
170
171 cow_writer_ =
172 dynamic_control_->OpenCowWriter(install_part_.name, source_path, label);
173 TEST_AND_RETURN_FALSE(cow_writer_ != nullptr);
174
175 if (label) {
Kelvin Zhang52cb1d72020-10-27 13:44:25 -0400176 return true;
Kelvin Zhang52cb1d72020-10-27 13:44:25 -0400177 }
Kelvin Zhang9b10dba2020-09-25 17:09:11 -0400178
179 // ==============================================
Kelvin Zhanga37aafc2021-06-14 13:21:37 -0400180 if (!partition_update_.merge_operations().empty()) {
Kelvin Zhang5d74b722021-09-29 15:24:26 -0700181 if (IsXorEnabled()) {
182 LOG(INFO) << "VABC XOR enabled for partition "
183 << partition_update_.partition_name();
Kelvin Zhangd7958752023-03-23 12:23:47 -0700184 }
185 // When merge sequence is present in COW, snapuserd will merge blocks in
186 // order specified by the merge seuqnece op. Hence we have the freedom of
187 // writing COPY operations out of order. Delay processing of copy ops so
188 // that update_engine can be more responsive in progress updates.
189 if (DoesDeviceSupportsXor()) {
190 LOG(INFO) << "Snapuserd supports XOR and merge sequence, writing merge "
191 "sequence and delay writing COPY operations";
Kelvin Zhang5d74b722021-09-29 15:24:26 -0700192 TEST_AND_RETURN_FALSE(WriteMergeSequence(
193 partition_update_.merge_operations(), cow_writer_.get()));
Kelvin Zhangd7958752023-03-23 12:23:47 -0700194 } else {
195 LOG(INFO) << "Snapuserd does not support merge sequence, writing all "
196 "COPY operations up front, this may take few "
197 "minutes.";
198 TEST_AND_RETURN_FALSE(WriteAllCopyOps());
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -0700199 }
Kelvin Zhanga37aafc2021-06-14 13:21:37 -0400200 cow_writer_->AddLabel(0);
Kelvin Zhangab3ce602021-02-24 14:46:40 -0500201 }
Kelvin Zhang7a265752020-10-29 15:51:35 -0400202 return true;
203}
204
Kelvin Zhanga37aafc2021-06-14 13:21:37 -0400205bool VABCPartitionWriter::WriteMergeSequence(
206 const RepeatedPtrField<CowMergeOperation>& merge_sequence,
207 ICowWriter* cow_writer) {
208 std::vector<uint32_t> blocks_merge_order;
209 for (const auto& merge_op : merge_sequence) {
210 const auto& dst_extent = merge_op.dst_extent();
Kelvin Zhangd1f90bc2021-09-15 21:12:34 -0700211 const auto& src_extent = merge_op.src_extent();
Kelvin Zhanga37aafc2021-06-14 13:21:37 -0400212 // In place copy are basically noops, they do not need to be "merged" at
213 // all, don't include them in merge sequence.
214 if (merge_op.type() == CowMergeOperation::COW_COPY &&
215 merge_op.src_extent() == merge_op.dst_extent()) {
216 continue;
217 }
Akilesh Kailash3e6e7df2021-11-18 23:29:15 +0000218
219 const bool extent_overlap =
220 ExtentRanges::ExtentsOverlap(src_extent, dst_extent);
221 // TODO(193863443) Remove this check once this feature
222 // lands on all pixel devices.
223 const bool is_ascending = android::base::GetBoolProperty(
224 "ro.virtual_ab.userspace.snapshots.enabled", false);
225
Kelvin Zhangd1f90bc2021-09-15 21:12:34 -0700226 // If this is a self-overlapping op and |dst_extent| comes after
227 // |src_extent|, we must write in reverse order for correctness.
Akilesh Kailash3e6e7df2021-11-18 23:29:15 +0000228 //
Kelvin Zhangd1f90bc2021-09-15 21:12:34 -0700229 // If this is self-overlapping op and |dst_extent| comes before
230 // |src_extent|, we must write in ascending order for correctness.
Akilesh Kailash3e6e7df2021-11-18 23:29:15 +0000231 //
232 // If this isn't a self overlapping op, write block in ascending order
233 // if userspace snapshots are enabled
234 if (extent_overlap) {
235 if (dst_extent.start_block() <= src_extent.start_block()) {
236 for (size_t i = 0; i < dst_extent.num_blocks(); i++) {
237 blocks_merge_order.push_back(dst_extent.start_block() + i);
238 }
239 } else {
240 for (int i = dst_extent.num_blocks() - 1; i >= 0; i--) {
241 blocks_merge_order.push_back(dst_extent.start_block() + i);
242 }
Kelvin Zhangd1f90bc2021-09-15 21:12:34 -0700243 }
244 } else {
Akilesh Kailash3e6e7df2021-11-18 23:29:15 +0000245 if (is_ascending) {
246 for (size_t i = 0; i < dst_extent.num_blocks(); i++) {
247 blocks_merge_order.push_back(dst_extent.start_block() + i);
248 }
249 } else {
250 for (int i = dst_extent.num_blocks() - 1; i >= 0; i--) {
251 blocks_merge_order.push_back(dst_extent.start_block() + i);
252 }
Kelvin Zhangd1f90bc2021-09-15 21:12:34 -0700253 }
Kelvin Zhanga37aafc2021-06-14 13:21:37 -0400254 }
255 }
256 return cow_writer->AddSequenceData(blocks_merge_order.size(),
257 blocks_merge_order.data());
258}
259
Kelvin Zhang94f51cc2020-09-25 11:34:49 -0400260std::unique_ptr<ExtentWriter> VABCPartitionWriter::CreateBaseExtentWriter() {
Kelvin Zhang9b10dba2020-09-25 17:09:11 -0400261 return std::make_unique<SnapshotExtentWriter>(cow_writer_.get());
Kelvin Zhang94f51cc2020-09-25 11:34:49 -0400262}
263
264[[nodiscard]] bool VABCPartitionWriter::PerformZeroOrDiscardOperation(
265 const InstallOperation& operation) {
Kelvin Zhang9b10dba2020-09-25 17:09:11 -0400266 for (const auto& extent : operation.dst_extents()) {
267 TEST_AND_RETURN_FALSE(
268 cow_writer_->AddZeroBlocks(extent.start_block(), extent.num_blocks()));
269 }
270 return true;
Kelvin Zhang94f51cc2020-09-25 11:34:49 -0400271}
272
273[[nodiscard]] bool VABCPartitionWriter::PerformSourceCopyOperation(
274 const InstallOperation& operation, ErrorCode* error) {
Kelvin Zhangb5bd0752022-03-10 15:45:25 -0800275 // COPY ops are already handled during Init(), no need to do actual work, but
276 // we still want to verify that all blocks contain expected data.
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -0700277 auto source_fd = verified_source_fd_.ChooseSourceFD(operation, error);
278 TEST_AND_RETURN_FALSE(source_fd != nullptr);
279 std::vector<CowOperation> converted;
280
281 const auto& src_extents = operation.src_extents();
282 const auto& dst_extents = operation.dst_extents();
283 BlockIterator it1{src_extents};
284 BlockIterator it2{dst_extents};
Kelvin Zhangd7958752023-03-23 12:23:47 -0700285 const bool userSnapshots = android::base::GetBoolProperty(
286 "ro.virtual_ab.userspace.snapshots.enabled", false);
Kelvin Zhang67144e52023-04-03 18:17:07 -0700287 // For devices not supporting XOR, sequence op is not supported, so all COPY
288 // operations are written up front in strict merge order.
289 const auto sequence_op_supported = DoesDeviceSupportsXor();
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -0700290 while (!it1.is_end() && !it2.is_end()) {
291 const auto src_block = *it1;
292 const auto dst_block = *it2;
293 ++it1;
294 ++it2;
295 if (src_block == dst_block) {
296 continue;
297 }
Kelvin Zhangd7958752023-03-23 12:23:47 -0700298 if (copy_blocks_.ContainsBlock(dst_block)) {
Kelvin Zhang67144e52023-04-03 18:17:07 -0700299 if (sequence_op_supported) {
300 push_back(&converted, {CowOperation::CowCopy, src_block, dst_block, 1});
301 }
Kelvin Zhangd7958752023-03-23 12:23:47 -0700302 } else {
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -0700303 push_back(&converted,
304 {CowOperation::CowReplace, src_block, dst_block, 1});
305 }
Kelvin Zhangdc122bc2022-03-15 14:19:04 -0700306 }
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -0700307 std::vector<uint8_t> buffer;
308 for (const auto& cow_op : converted) {
Kelvin Zhangd7958752023-03-23 12:23:47 -0700309 if (cow_op.op == CowOperation::CowCopy) {
310 if (userSnapshots) {
311 cow_writer_->AddCopy(
312 cow_op.dst_block, cow_op.src_block, cow_op.block_count);
313 } else {
314 // Add blocks in reverse order, because snapused specifically prefers
315 // this ordering. Since we already eliminated all self-overlapping
316 // SOURCE_COPY during delta generation, this should be safe to do.
317 for (size_t i = cow_op.block_count; i > 0; i--) {
318 TEST_AND_RETURN_FALSE(cow_writer_->AddCopy(cow_op.dst_block + i - 1,
319 cow_op.src_block + i - 1));
320 }
321 }
322 continue;
323 }
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -0700324 buffer.resize(block_size_ * cow_op.block_count);
325 ssize_t bytes_read = 0;
326 TEST_AND_RETURN_FALSE(utils::ReadAll(source_fd,
327 buffer.data(),
328 block_size_ * cow_op.block_count,
329 cow_op.src_block * block_size_,
330 &bytes_read));
331 if (bytes_read <= 0 || static_cast<size_t>(bytes_read) != buffer.size()) {
332 LOG(ERROR) << "source_fd->Read failed: " << bytes_read;
333 return false;
334 }
335 TEST_AND_RETURN_FALSE(cow_writer_->AddRawBlocks(
336 cow_op.dst_block, buffer.data(), buffer.size()));
337 }
338 return true;
Kelvin Zhang94f51cc2020-09-25 11:34:49 -0400339}
340
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500341bool VABCPartitionWriter::PerformReplaceOperation(const InstallOperation& op,
342 const void* data,
343 size_t count) {
344 // Setup the ExtentWriter stack based on the operation type.
345 std::unique_ptr<ExtentWriter> writer = CreateBaseExtentWriter();
346
Daniel Zheng17be0f92024-01-23 15:12:33 -0800347 return executor_.ExecuteReplaceOperation(op, std::move(writer), data);
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500348}
349
Tianjie8e0090d2021-08-30 22:35:21 -0700350bool VABCPartitionWriter::PerformDiffOperation(
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500351 const InstallOperation& operation,
352 ErrorCode* error,
353 const void* data,
354 size_t count) {
355 FileDescriptorPtr source_fd =
356 verified_source_fd_.ChooseSourceFD(operation, error);
357 TEST_AND_RETURN_FALSE(source_fd != nullptr);
Kelvin Zhang76f10b82021-06-25 18:45:46 -0400358 TEST_AND_RETURN_FALSE(source_fd->IsOpen());
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500359
Kelvin Zhang76f10b82021-06-25 18:45:46 -0400360 std::unique_ptr<ExtentWriter> writer =
361 IsXorEnabled() ? std::make_unique<XORExtentWriter>(
Kelvin Zhanga3a68a92023-04-05 13:17:18 -0700362 operation,
363 source_fd,
364 cow_writer_.get(),
365 xor_map_,
366 partition_update_.old_partition_info().size())
Kelvin Zhang76f10b82021-06-25 18:45:46 -0400367 : CreateBaseExtentWriter();
Tianjie8e0090d2021-08-30 22:35:21 -0700368 return executor_.ExecuteDiffOperation(
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500369 operation, std::move(writer), source_fd, data, count);
370}
371
Kelvin Zhang52cb1d72020-10-27 13:44:25 -0400372void VABCPartitionWriter::CheckpointUpdateProgress(size_t next_op_index) {
373 // No need to call fsync/sync, as CowWriter flushes after a label is added
374 // added.
Kelvin Zhang6a4d1ec2021-02-04 16:28:48 -0500375 // if cow_writer_ failed, that means Init() failed. This function shouldn't be
376 // called if Init() fails.
377 TEST_AND_RETURN(cow_writer_ != nullptr);
Kelvin Zhang52cb1d72020-10-27 13:44:25 -0400378 cow_writer_->AddLabel(next_op_index);
Kelvin Zhang9b10dba2020-09-25 17:09:11 -0400379}
380
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400381[[nodiscard]] bool VABCPartitionWriter::FinishedInstallOps() {
382 // Add a hardcoded magic label to indicate end of all install ops. This label
383 // is needed by filesystem verification, don't remove.
Kelvin Zhang6a4d1ec2021-02-04 16:28:48 -0500384 TEST_AND_RETURN_FALSE(cow_writer_ != nullptr);
Kelvin Zhang9e5e1ed2021-09-28 14:19:16 -0700385 TEST_AND_RETURN_FALSE(cow_writer_->AddLabel(kEndOfInstallLabel));
386 TEST_AND_RETURN_FALSE(cow_writer_->Finalize());
David Andersona4b7ba62023-05-10 21:41:37 -0700387
388 auto cow_reader = cow_writer_->OpenReader();
389 TEST_AND_RETURN_FALSE(cow_reader);
390 TEST_AND_RETURN_FALSE(cow_reader->VerifyMergeOps());
Kelvin Zhang02fe6622021-11-01 16:37:58 -0700391 return true;
Kelvin Zhangec205cf2020-09-28 13:23:40 -0400392}
393
Kelvin Zhang9b10dba2020-09-25 17:09:11 -0400394VABCPartitionWriter::~VABCPartitionWriter() {
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500395 Close();
396}
397
398int VABCPartitionWriter::Close() {
Kelvin Zhang6a4d1ec2021-02-04 16:28:48 -0500399 if (cow_writer_) {
Kelvin Zhangd11e2fc2022-10-24 15:40:30 -0700400 LOG(INFO) << "Finalizing " << partition_update_.partition_name()
401 << " COW image";
Kelvin Zhangb1c05242023-12-14 13:49:53 -0800402 if (!cow_writer_->Finalize()) {
403 return -errno;
404 }
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500405 cow_writer_ = nullptr;
Kelvin Zhang6a4d1ec2021-02-04 16:28:48 -0500406 }
Kelvin Zhange52b6cd2021-02-09 15:28:40 -0500407 return 0;
Kelvin Zhang9b10dba2020-09-25 17:09:11 -0400408}
Kelvin Zhang94f51cc2020-09-25 11:34:49 -0400409
410} // namespace chromeos_update_engine