Polish -z documentation and cache.log reporting.
When a startup script runs squid -z by mistake against a cache_dir that is
already initialized and full of cached entries, some admins prefer that
nothing happens. Rock store now skips reinitialization if both the cache_dir
directory and the db file in that directory exist. If one or both are missing,
the missing pieces are created.
UFS does something similar because it creates missing L1 and L2 directories
but does not erase any entries already present in the cache_dir path. COSS,
OTOH, re-initializes the existing db. Rock behavior will now be closer to UFS.
To clean a corrupted cache_dir, the admin must remove its top-level directory
before running squid -z.
Squid now logs "Creating missing swap directories" instead of "Creating Swap
Directories", and our documentation now reflects the "if missing" part of the
-z algorithm.
Also documented that recent Squid versions run -z in daemon mode (so that SMP
configuration macros continue to work).
debugs (47,3, HERE << "creating in " << path);
- struct stat swap_sb;
- if (::stat(path, &swap_sb) < 0) {
+ struct stat dir_sb;
+ if (::stat(path, &dir_sb) == 0) {
+ struct stat file_sb;
+ if (::stat(filePath, &file_sb) == 0) {
+ debugs (47, DBG_IMPORTANT, "Skipping existing Rock db: " << filePath);
+ return;
+ }
+ // else the db file is not there or is not accessible, and we will try
+ // to create it later below, generating a detailed error on failures.
+ } else { // path does not exist or is inaccessible
+ // If path exists but is not accessible, mkdir() below will fail, and
+ // the admin should see the error and act accordingly, so there is
+ // no need to distinguish ENOENT from other possible stat() errors.
debugs (47, DBG_IMPORTANT, "Creating Rock db directory: " << path);
const int res = mkdir(path, 0700);
if (res != 0) {
}
}
+ debugs (47, DBG_IMPORTANT, "Creating Rock db: " << filePath);
#if SLOWLY_FILL_WITH_ZEROS
char block[1024];
Must(maxSize() % sizeof(block) == 0);
" Enable logging to syslog.\n"
" -u port Specify ICP port number (default: %d), disable with 0.\n"
" -v Print version.\n"
- " -z Create swap directories\n"
+ " -z Create missing swap directories and then exit.\n"
" -C Do not catch fatal signals.\n"
" -D OBSOLETE. Scheduled for removal.\n"
" -F Don't serve any requests until store is rebuilt.\n"
}
setEffectiveUser();
- debugs(0, DBG_CRITICAL, "Creating Swap Directories");
+ debugs(0, DBG_CRITICAL, "Creating missing swap directories");
Store::Root().create();
return 0;
.
.if !'po4a'hide' .TP
.if !'po4a'hide' .B \-z
-Create swap directories
+Create missing swap directories and other missing cache_dir structures,
+then exit. All cache_dir types create the configured top-level directory if
+it is missing. Other actions are type-specific. For example, ufs-based
+storage systems create missing L1 and L2 directories while Rock creates
+the missing database file.
+.IP
+This option does not enable validation of any present swap structures. Its
+focus is on creation of missing pieces. If nothing is missing, squid -z
+just exits. If you suspect cache_dir corruption, you must delete the top-level
+cache_dir directory before running squid -z.
+.IP
+By default, squid -z runs in daemon mode (so that configuration macros and
+other SMP features work as expected). Use
+.B \-N
+option to overwrite this.
.
.SH FILES
Squid configuration files located in @SYSCONFDIR@/: