Revert "Fix hard linking issue causing overlay fs copy-ups"

This reverts commit 9ef0a9e8aa.

Master now has a better solution.
This commit is contained in:
John Ericson 2023-10-25 14:20:40 -04:00
parent 5c1cb0b696
commit 6f0a95897c
4 changed files with 3 additions and 28 deletions

View file

@ -388,9 +388,8 @@ void LocalDerivationGoal::cleanupPostOutputsRegisteredModeNonCheck()
#if __linux__
static void linkOrCopy(LocalFSStore & store, const StorePath & from_, const Path & to)
static void linkOrCopy(const Path & from, const Path & to)
{
auto from = store.toRealPathForHardLink(from_);
if (link(from.c_str(), to.c_str()) == -1) {
/* Hard-linking fails if we exceed the maximum link count on a
file (e.g. 32000 of ext3), which is quite possible after a
@ -715,7 +714,7 @@ void LocalDerivationGoal::startBuilder()
if (S_ISDIR(lstat(r).st_mode))
dirsInChroot.insert_or_assign(p, r);
else
linkOrCopy(getLocalStore(), i, chrootRootDir + p);
linkOrCopy(r, chrootRootDir + p);
}
/* If we're repairing, checking or rebuilding part of a
@ -1600,7 +1599,7 @@ void LocalDerivationGoal::addDependency(const StorePath & path)
throw Error("could not add path '%s' to sandbox", worker.store.printStorePath(path));
} else
linkOrCopy(getLocalStore(), path, target);
linkOrCopy(source, target);
#else
throw Error("don't know how to make path '%s' (produced by a recursive Nix call) appear in the sandbox",

View file

@ -73,16 +73,6 @@ public:
return getRealStoreDir() + "/" + std::string(storePath, storeDir.size() + 1);
}
/**
* If the real path is hardlinked with something else, we might
* prefer to refer to the other path instead. This is the case with
* overlayfs, for example.
*/
virtual Path toRealPathForHardLink(const StorePath & storePath)
{
return Store::toRealPath(storePath);
}
std::optional<std::string> getBuildLogExact(const StorePath & path) override;
};

View file

@ -268,14 +268,6 @@ std::pair<bool, StorePathSet> LocalOverlayStore::verifyAllValidPaths(RepairFlag
}
Path LocalOverlayStore::toRealPathForHardLink(const StorePath & path)
{
return lowerStore->isValidPath(path)
? lowerStore->Store::toRealPath(path)
: Store::toRealPath(path);
}
void LocalOverlayStore::remountIfNecessary()
{
if (!_remountRequired) return;

View file

@ -186,12 +186,6 @@ private:
*/
std::pair<bool, StorePathSet> verifyAllValidPaths(RepairFlag repair) override;
/**
* For lower-store paths, we used the lower store location. This avoids the
* wasteful "copying up" that would otherwise happen.
*/
Path toRealPathForHardLink(const StorePath & storePath) override;
/**
* Deletion only effects the upper layer, so we ignore lower-layer referrers.
*/