about summary refs log tree commit diff
path: root/src/libstore/store-api.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-09-17T10·02+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-09-17T10·02+0000
commit7ab68961e4d7c30485efde1fb9dcb6edbdea9b5c (patch)
tree2bb1faf9cb583276240ac9e9fa940205202bec39 /src/libstore/store-api.hh
parent2b2aa8a820b10aeaf8bb8f1eb70937d04869c045 (diff)
* Garbage collector: added an option `--use-atime' to delete paths in
  order of ascending last access time.  This is useful in conjunction
  with --max-freed or --max-links to prefer deleting non-recently used
  garbage, which is good (especially in the build farm) since garbage
  may become live again.

  The code could easily be modified to accept other criteria for
  ordering garbage by changing the comparison operator used by the
  priority queue in collectGarbage().

Diffstat (limited to 'src/libstore/store-api.hh')
-rw-r--r--src/libstore/store-api.hh30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 9645237e0430..3c32003cb49c 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -63,6 +63,18 @@ struct GCOptions
        has dropped below `maxLinks'. */
     unsigned int maxLinks;
 
+    /* Delete paths in order of ascending last access time.  I.e.,
+       prefer deleting unrecently used paths.  Useful in conjunction
+       with `maxFreed' and `maxLinks' (or manual interruption).  The
+       access time of a path is defined as the highest atime of any
+       non-directory, non-symlink file under that path.  Directories
+       and symlinks are ignored because their atimes are frequently
+       mass-updated, e.g. by `locate'.  Note that optimiseStore()
+       somewhat reduces the usefulness of this option: it hard-links
+       regular files and symlink together, giving them a "shared"
+       atime. */
+    bool useAtime;
+
     GCOptions();
 };
 
@@ -116,11 +128,29 @@ public:
     virtual void queryReferences(const Path & path,
         PathSet & references) = 0;
 
+    /* Like queryReferences, but with self-references filtered out. */
+    PathSet queryReferencesNoSelf(const Path & path)
+    {
+        PathSet res;
+        queryReferences(path, res);
+        res.erase(path);
+        return res;
+    }
+
     /* Queries the set of incoming FS references for a store path.
        The result is not cleared. */
     virtual void queryReferrers(const Path & path,
         PathSet & referrers) = 0;
 
+    /* Like queryReferrers, but with self-references filtered out. */
+    PathSet queryReferrersNoSelf(const Path & path)
+    {
+        PathSet res;
+        queryReferrers(path, res);
+        res.erase(path);
+        return res;
+    }
+
     /* Query the deriver of a store path.  Return the empty string if
        no deriver has been set. */
     virtual Path queryDeriver(const Path & path) = 0;