Revert "Rename Flush to Finalize"

This reverts commit 6177f6f6c4.

Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master&target=sdk_x86-sdk&lkgb=6919873&lkbb=6919923&fkbb=6919923, bug b/171353958

Change-Id: Iea3059b4bf64a7cac930c40b8b312b5b26b0baea
BUG: 168829493
This commit is contained in:
Jason Chiu 2020-10-21 03:16:42 +00:00
parent 6177f6f6c4
commit ebfbf7d920
8 changed files with 15 additions and 15 deletions

View File

@ -70,7 +70,7 @@ TEST_F(CowTest, ReadWrite) {
ASSERT_TRUE(writer.AddCopy(10, 20));
ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
ASSERT_TRUE(writer.AddZeroBlocks(51, 2));
ASSERT_TRUE(writer.Finalize());
ASSERT_TRUE(writer.Flush());
ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
@ -145,7 +145,7 @@ TEST_F(CowTest, CompressGz) {
data.resize(options.block_size, '\0');
ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
ASSERT_TRUE(writer.Finalize());
ASSERT_TRUE(writer.Flush());
ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
@ -182,7 +182,7 @@ TEST_F(CowTest, CompressTwoBlocks) {
data.resize(options.block_size * 2, '\0');
ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
ASSERT_TRUE(writer.Finalize());
ASSERT_TRUE(writer.Flush());
ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
@ -224,7 +224,7 @@ TEST_P(CompressionTest, HorribleSink) {
data.resize(options.block_size, '\0');
ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
ASSERT_TRUE(writer.Finalize());
ASSERT_TRUE(writer.Flush());
ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
@ -259,7 +259,7 @@ TEST_F(CowTest, GetSize) {
ASSERT_TRUE(writer.AddRawBlocks(50, data.data(), data.size()));
ASSERT_TRUE(writer.AddZeroBlocks(51, 2));
auto size_before = writer.GetCowSize();
ASSERT_TRUE(writer.Finalize());
ASSERT_TRUE(writer.Flush());
auto size_after = writer.GetCowSize();
ASSERT_EQ(size_before, size_after);
struct stat buf;
@ -279,7 +279,7 @@ TEST_F(CowTest, Append) {
std::string data = "This is some data, believe it";
data.resize(options.block_size, '\0');
ASSERT_TRUE(writer->AddRawBlocks(50, data.data(), data.size()));
ASSERT_TRUE(writer->Finalize());
ASSERT_TRUE(writer->Flush());
ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);
@ -289,7 +289,7 @@ TEST_F(CowTest, Append) {
std::string data2 = "More data!";
data2.resize(options.block_size, '\0');
ASSERT_TRUE(writer->AddRawBlocks(51, data2.data(), data2.size()));
ASSERT_TRUE(writer->Finalize());
ASSERT_TRUE(writer->Flush());
ASSERT_EQ(lseek(cow_->fd, 0, SEEK_SET), 0);

View File

@ -227,7 +227,7 @@ void SnapuserdTest::CreateCowDevice(std::unique_ptr<TemporaryFile>& cow) {
ASSERT_TRUE(writer.AddRawBlocks(blk_random2_replace_start, random_buffer_2_.get(), size_));
// Flush operations
ASSERT_TRUE(writer.Finalize());
ASSERT_TRUE(writer.Flush());
ASSERT_EQ(lseek(cow->fd, 0, SEEK_SET), 0);
}

View File

@ -293,7 +293,7 @@ static void SHA256(const void*, size_t, uint8_t[]) {
#endif
}
bool CowWriter::Finalize() {
bool CowWriter::Flush() {
header_.ops_size = ops_.size();
memset(header_.ops_checksum, 0, sizeof(uint8_t) * 32);

View File

@ -375,7 +375,7 @@ bool NonAbEstimator::AnalyzePartition(const std::string& partition_name) {
}
}
if (!writer->Finalize()) {
if (!writer->Flush()) {
return false;
}

View File

@ -53,7 +53,7 @@ class ICowWriter {
// Flush all pending writes. This must be called before closing the writer
// to ensure that the correct headers and footers are written.
virtual bool Finalize() = 0;
virtual bool Flush() = 0;
// Return number of bytes the cow image occupies on disk.
virtual uint64_t GetCowSize() = 0;
@ -84,7 +84,7 @@ class CowWriter : public ICowWriter {
bool Initialize(android::base::unique_fd&& fd, OpenMode mode = OpenMode::WRITE);
bool Initialize(android::base::borrowed_fd fd, OpenMode mode = OpenMode::WRITE);
bool Finalize() override;
bool Flush() override;
uint64_t GetCowSize() override;

View File

@ -50,7 +50,7 @@ class OnlineKernelSnapshotWriter : public ISnapshotWriter {
// Set the device used for all writes.
void SetSnapshotDevice(android::base::unique_fd&& snapshot_fd, uint64_t cow_size);
bool Finalize() override;
bool Flush() override;
uint64_t GetCowSize() override { return cow_size_; }
virtual std::unique_ptr<FileDescriptor> OpenReader() override;

View File

@ -204,7 +204,7 @@ bool PayloadConverter::ProcessPartition(const PartitionUpdate& update) {
}
}
if (!writer_->Finalize()) {
if (!writer_->Flush()) {
LOG(ERROR) << "Unable to finalize COW for " << partition_name;
return false;
}

View File

@ -40,7 +40,7 @@ void OnlineKernelSnapshotWriter::SetSnapshotDevice(android::base::unique_fd&& sn
cow_size_ = cow_size;
}
bool OnlineKernelSnapshotWriter::Finalize() {
bool OnlineKernelSnapshotWriter::Flush() {
if (fsync(snapshot_fd_.get()) < 0) {
PLOG(ERROR) << "fsync";
return false;