[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
52/64: Shortcut already-hardlinked files
From: |
Ludovic Courtès |
Subject: |
52/64: Shortcut already-hardlinked files |
Date: |
Mon, 05 Jan 2015 16:39:09 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit a84f503d863fd77de9b6ecf149399c2ca7642b75
Author: wmertens <address@hidden>
Date: Sat May 10 15:53:01 2014 +0200
Shortcut already-hardlinked files
If an inode in the Nix store has more than 1 link, it probably means that
it was linked into .links/ by us. If so, skip.
There's a possibility that something else hardlinked the file, so it would
be nice to be able to override this.
Also, by looking at the number of hardlinks for each of the files in
.links/, you can get deduplication numbers and space savings.
---
src/libstore/optimise-store.cc | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc
index d833f3a..1b81f64 100644
--- a/src/libstore/optimise-store.cc
+++ b/src/libstore/optimise-store.cc
@@ -71,6 +71,16 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const
Path & path)
return;
}
+ stats.totalFiles++;
+
+ /* If a store inode has 2 or more links we presume that it was
+ already linked by us */
+ /* TODO: allow overriding this behavior */
+ if (st.st_nlink > 1) {
+ printMsg(lvlDebug, format("`%1%' is already linked, with %2% other
file(s).") % path % (st.st_nlink - 2));
+ return;
+ }
+
/* Hash the file. Note that hashPath() returns the hash over the
NAR serialisation, which includes the execute bit on the file.
Thus, executable and non-executable files with the same
@@ -81,7 +91,6 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const
Path & path)
contents of the symlink (i.e. the result of readlink()), not
the contents of the target (which may not even exist). */
Hash hash = hashPath(htSHA256, path).first;
- stats.totalFiles++;
printMsg(lvlDebug, format("`%1%' has hash `%2%'") % path %
printHash(hash));
/* Check if this is a known hash. */
- 28/64: Ensure that systemd units to into lib, not lib64, (continued)
- 28/64: Ensure that systemd units to into lib, not lib64, Ludovic Courtès, 2015/01/05
- 36/64: Bump version to 1.8, Ludovic Courtès, 2015/01/05
- 44/64: Install an Upstart service, Ludovic Courtès, 2015/01/05
- 45/64: Set up directories and permissions for multi-user install automatically, Ludovic Courtès, 2015/01/05
- 46/64: Simplify multi-user installation instructions, Ludovic Courtès, 2015/01/05
- 49/64: Add ubuntu 14.04, Ludovic Courtès, 2015/01/05
- 48/64: Don't install Upstart job on Fedora, Ludovic Courtès, 2015/01/05
- 51/64: Really fix the RPM builds, Ludovic Courtès, 2015/01/05
- 50/64: Fix RPM build, Ludovic Courtès, 2015/01/05
- 53/64: fix typo, Ludovic Courtès, 2015/01/05
- 52/64: Shortcut already-hardlinked files,
Ludovic Courtès <=
- 54/64: nix-instantiate --eval: Apply auto-arguments if the result is a function, Ludovic Courtès, 2015/01/05
- 47/64: Fix Debian tests, Ludovic Courtès, 2015/01/05
- 60/64: Merge branch 'master' of github.com:wmertens/nix, Ludovic Courtès, 2015/01/05
- 58/64: Use the inodes given by readdir directly, Ludovic Courtès, 2015/01/05
- 57/64: Remove redundant code, Ludovic Courtès, 2015/01/05
- 55/64: Prepare nix-mode to be uploaded to marmalade, Ludovic Courtès, 2015/01/05
- 56/64: Preload linked hashes to speed up lookups, Ludovic Courtès, 2015/01/05
- 63/64: lvlInfo -> lvlTalkative, Ludovic Courtès, 2015/01/05
- 42/64: When running as root, use build users by default, Ludovic Courtès, 2015/01/05
- 59/64: Shortcut store files before lstat, Ludovic Courtès, 2015/01/05