diff options
Diffstat (limited to 'llvm/lib/CAS/OnDiskGraphDB.cpp')
| -rw-r--r-- | llvm/lib/CAS/OnDiskGraphDB.cpp | 34 | 
1 files changed, 17 insertions, 17 deletions
diff --git a/llvm/lib/CAS/OnDiskGraphDB.cpp b/llvm/lib/CAS/OnDiskGraphDB.cpp index 64cbe9d..245b6fb 100644 --- a/llvm/lib/CAS/OnDiskGraphDB.cpp +++ b/llvm/lib/CAS/OnDiskGraphDB.cpp @@ -893,6 +893,10 @@ int64_t DataRecordHandle::getDataRelOffset() const {  }  Error OnDiskGraphDB::validate(bool Deep, HashingFuncT Hasher) const { +  if (UpstreamDB) { +    if (auto E = UpstreamDB->validate(Deep, Hasher)) +      return E; +  }    return Index.validate([&](FileOffset Offset,                              OnDiskTrieRawHashMap::ConstValueProxy Record)                              -> Error { @@ -1202,11 +1206,8 @@ OnDiskGraphDB::load(ObjectID ExternalRef) {      return I.takeError();    TrieRecord::Data Object = I->Ref.load(); -  if (Object.SK == TrieRecord::StorageKind::Unknown) { -    if (!UpstreamDB) -      return std::nullopt; +  if (Object.SK == TrieRecord::StorageKind::Unknown)      return faultInFromUpstream(ExternalRef); -  }    if (Object.SK == TrieRecord::StorageKind::DataPool)      return ObjectHandle::fromFileOffset(Object.Offset); @@ -1286,8 +1287,10 @@ OnDiskGraphDB::getObjectPresence(ObjectID ExternalRef,    TrieRecord::Data Object = I->Ref.load();    if (Object.SK != TrieRecord::StorageKind::Unknown)      return ObjectPresence::InPrimaryDB; +    if (!CheckUpstream || !UpstreamDB)      return ObjectPresence::Missing; +    std::optional<ObjectID> UpstreamID =        UpstreamDB->getExistingReference(getDigest(*I));    return UpstreamID.has_value() ? ObjectPresence::OnlyInUpstreamDB @@ -1549,9 +1552,10 @@ unsigned OnDiskGraphDB::getHardStorageLimitUtilization() const {    return std::max(IndexPercent, DataPercent);  } -Expected<std::unique_ptr<OnDiskGraphDB>> OnDiskGraphDB::open( -    StringRef AbsPath, StringRef HashName, unsigned HashByteSize, -    std::unique_ptr<OnDiskGraphDB> UpstreamDB, FaultInPolicy Policy) { +Expected<std::unique_ptr<OnDiskGraphDB>> +OnDiskGraphDB::open(StringRef AbsPath, StringRef HashName, +                    unsigned HashByteSize, OnDiskGraphDB *UpstreamDB, +                    FaultInPolicy Policy) {    if (std::error_code EC = sys::fs::create_directories(AbsPath))      return createFileError(AbsPath, EC); @@ -1604,18 +1608,15 @@ Expected<std::unique_ptr<OnDiskGraphDB>> OnDiskGraphDB::open(                               "unexpected user header in '" + DataPoolPath +                                   "'"); -  return std::unique_ptr<OnDiskGraphDB>( -      new OnDiskGraphDB(AbsPath, std::move(*Index), std::move(*DataPool), -                        std::move(UpstreamDB), Policy)); +  return std::unique_ptr<OnDiskGraphDB>(new OnDiskGraphDB( +      AbsPath, std::move(*Index), std::move(*DataPool), UpstreamDB, Policy));  }  OnDiskGraphDB::OnDiskGraphDB(StringRef RootPath, OnDiskTrieRawHashMap Index,                               OnDiskDataAllocator DataPool, -                             std::unique_ptr<OnDiskGraphDB> UpstreamDB, -                             FaultInPolicy Policy) +                             OnDiskGraphDB *UpstreamDB, FaultInPolicy Policy)      : Index(std::move(Index)), DataPool(std::move(DataPool)), -      RootPath(RootPath.str()), UpstreamDB(std::move(UpstreamDB)), -      FIPolicy(Policy) { +      RootPath(RootPath.str()), UpstreamDB(UpstreamDB), FIPolicy(Policy) {    /// Lifetime for "big" objects not in DataPool.    ///    /// NOTE: Could use ThreadSafeTrieRawHashMap here. For now, doing something @@ -1638,7 +1639,6 @@ Error OnDiskGraphDB::importFullTree(ObjectID PrimaryID,    // against the process dying during importing and leaving the database with an    // incomplete tree. Note that if the upstream has missing nodes then the tree    // will be copied with missing nodes as well, it won't be considered an error. -    struct UpstreamCursor {      ObjectHandle Node;      size_t RefsCount; @@ -1720,7 +1720,6 @@ Error OnDiskGraphDB::importSingleNode(ObjectID PrimaryID,    // Copy the node data into the primary store.    // FIXME: Use hard-link or cloning if the file-system supports it and data is    // stored into a separate file. -    auto Data = UpstreamDB->getObjectData(UpstreamNode);    auto UpstreamRefs = UpstreamDB->getObjectRefs(UpstreamNode);    SmallVector<ObjectID, 64> Refs; @@ -1737,7 +1736,8 @@ Error OnDiskGraphDB::importSingleNode(ObjectID PrimaryID,  Expected<std::optional<ObjectHandle>>  OnDiskGraphDB::faultInFromUpstream(ObjectID PrimaryID) { -  assert(UpstreamDB); +  if (!UpstreamDB) +    return std::nullopt;    auto UpstreamID = UpstreamDB->getReference(getDigest(PrimaryID));    if (LLVM_UNLIKELY(!UpstreamID))  | 
