diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2019-11-26 23:35:24 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-11-27 00:03:03 +0100 |
| commit | 7738a72186583afb3bb2e0a866c8aba130372400 (patch) | |
| tree | adfc37a8db5beb8b49c5d2b4f2e9c90a7742b007 | |
| parent | 434138e2f26b28bb5cc83e62327aae8ed0902475 (diff) | |
daemon: GC remove-unused-links phase uses 'statx' when available.
* config-daemon.ac: Check for 'statx'.
* nix/libstore/gc.cc (LocalStore::removeUnusedLinks) [HAVE_STATX]: Use
'statx' instead of 'lstat'.
| -rw-r--r-- | config-daemon.ac | 3 | ||||
| -rw-r--r-- | nix/libstore/gc.cc | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/config-daemon.ac b/config-daemon.ac index 848e1e58da1..50ead355a81 100644 --- a/config-daemon.ac +++ b/config-daemon.ac | |||
| @@ -91,8 +91,9 @@ if test "x$guix_build_daemon" = "xyes"; then | |||
| 91 | dnl sched_setaffinity: to improve RPC locality. | 91 | dnl sched_setaffinity: to improve RPC locality. |
| 92 | dnl statvfs: to detect disk-full conditions. | 92 | dnl statvfs: to detect disk-full conditions. |
| 93 | dnl strsignal: for error reporting. | 93 | dnl strsignal: for error reporting. |
| 94 | dnl statx: fine-grain 'stat' call, new in glibc 2.28. | ||
| 94 | AC_CHECK_FUNCS([lutimes lchown posix_fallocate sched_setaffinity \ | 95 | AC_CHECK_FUNCS([lutimes lchown posix_fallocate sched_setaffinity \ |
| 95 | statvfs nanosleep strsignal]) | 96 | statvfs nanosleep strsignal statx]) |
| 96 | 97 | ||
| 97 | dnl Check whether the store optimiser can optimise symlinks. | 98 | dnl Check whether the store optimiser can optimise symlinks. |
| 98 | AC_MSG_CHECKING([whether it is possible to create a link to a symlink]) | 99 | AC_MSG_CHECKING([whether it is possible to create a link to a symlink]) |
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc index 7976ff7d76a..29b75aa8755 100644 --- a/nix/libstore/gc.cc +++ b/nix/libstore/gc.cc | |||
| @@ -570,8 +570,17 @@ void LocalStore::removeUnusedLinks(const GCState & state) | |||
| 570 | if (name == "." || name == "..") continue; | 570 | if (name == "." || name == "..") continue; |
| 571 | Path path = linksDir + "/" + name; | 571 | Path path = linksDir + "/" + name; |
| 572 | 572 | ||
| 573 | #ifdef HAVE_STATX | ||
| 574 | # define st_size stx_size | ||
| 575 | # define st_nlink stx_nlink | ||
| 576 | struct statx st; | ||
| 577 | if (statx(AT_FDCWD, path.c_str(), | ||
| 578 | AT_SYMLINK_NOFOLLOW | AT_STATX_DONT_SYNC, | ||
| 579 | STATX_SIZE | STATX_NLINK, &st) == -1) | ||
| 580 | #else | ||
| 573 | struct stat st; | 581 | struct stat st; |
| 574 | if (lstat(path.c_str(), &st) == -1) | 582 | if (lstat(path.c_str(), &st) == -1) |
| 583 | #endif | ||
| 575 | throw SysError(format("statting `%1%'") % path); | 584 | throw SysError(format("statting `%1%'") % path); |
| 576 | 585 | ||
| 577 | if (st.st_nlink != 1) { | 586 | if (st.st_nlink != 1) { |
| @@ -586,6 +595,8 @@ void LocalStore::removeUnusedLinks(const GCState & state) | |||
| 586 | throw SysError(format("deleting `%1%'") % path); | 595 | throw SysError(format("deleting `%1%'") % path); |
| 587 | 596 | ||
| 588 | state.results.bytesFreed += st.st_size; | 597 | state.results.bytesFreed += st.st_size; |
| 598 | #undef st_size | ||
| 599 | #undef st_nlink | ||
| 589 | } | 600 | } |
| 590 | 601 | ||
| 591 | struct stat st; | 602 | struct stat st; |
