summaryrefslogtreecommitdiff
path: root/services/incremental/ServiceWrappers.cpp
diff options
context:
space:
mode:
author Alex Buynytskyy <alexbuy@google.com> 2021-03-19 05:35:53 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-03-19 05:35:53 +0000
commit8212a70a548707e48df6f83626cbc286453a17e3 (patch)
treefc5b7ab37c39b7d2cb3ecbe273c5ed016aa0d83d /services/incremental/ServiceWrappers.cpp
parenteae3a9e4e3c93b56392edae4f3370322fb36c2c7 (diff)
parent4375a7453574a219f446222409a567acb2d60120 (diff)
Merge "[incfs] Use a more efficient getBlockCount() for incfs v2" into sc-dev
Diffstat (limited to 'services/incremental/ServiceWrappers.cpp')
-rw-r--r--services/incremental/ServiceWrappers.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/services/incremental/ServiceWrappers.cpp b/services/incremental/ServiceWrappers.cpp
index eb204c5466e0..7e85f9db70fd 100644
--- a/services/incremental/ServiceWrappers.cpp
+++ b/services/incremental/ServiceWrappers.cpp
@@ -134,6 +134,10 @@ private:
} mLooper;
};
+std::string IncFsWrapper::toString(FileId fileId) {
+ return incfs::toString(fileId);
+}
+
class RealIncFs final : public IncFsWrapper {
public:
RealIncFs() = default;
@@ -173,9 +177,16 @@ public:
FileId getFileId(const Control& control, std::string_view path) const final {
return incfs::getFileId(control, path);
}
- std::string toString(FileId fileId) const final { return incfs::toString(fileId); }
std::pair<IncFsBlockIndex, IncFsBlockIndex> countFilledBlocks(
const Control& control, std::string_view path) const final {
+ if (incfs::features() & Features::v2) {
+ const auto counts = incfs::getBlockCount(control, path);
+ if (!counts) {
+ return {-errno, -errno};
+ }
+ return {counts->filledDataBlocks + counts->filledHashBlocks,
+ counts->totalDataBlocks + counts->totalHashBlocks};
+ }
const auto fileId = incfs::getFileId(control, path);
const auto fd = incfs::openForSpecialOps(control, fileId);
int res = fd.get();