Alex Rousskov [Mon, 7 Feb 2011 17:59:28 +0000 (10:59 -0700)]
Made Rock::Rebuild an AsyncJob because it is.
Increment StoreController::store_dirs_rebuilding early, when SwapDir is
created and before the disk db file is opened and the actual rebuild starts.
Otherwise, if one SwapDir finishes rebuild before others start,
storeRebuildComplete() will see StoreController::store_dirs_rebuilding equal
to one, and think the rebuild is over.
This was not a problem for cache_dirs using blocking I/O because they either
did not try to open some file at SwapDir::init() time or did so synchronously,
resulting in "immediate" StoreController::store_dirs_rebuilding increment from
Store init loop point of view.
Amos Jeffries [Mon, 7 Feb 2011 10:27:53 +0000 (03:27 -0700)]
Bug 2870: --disable-auth does not work
This patch attempts to make it work by removing libauth.la and all component
functionality which depends on it. So far this reduces the minimal squid
binary by a further 900 KB on disk.
It also means anything which requires an authentication process wont work.
They get wrapped in USE_AUTH or if its a specific type with the relevant
HAVE_AUTH_MODULE_* wrappers.
So far this does:
* FTP and CacheMgr dependency on --disable-auth-basic is already committed
* cache_peer login= functionality is greatly reduced under various
combinations of --disable-auth, --disable-auth-basic and
--disable-auth-negotiate
* peering userhash algorithm is removed
* delay pools class 4 is removed
* ACLs testing username are dropped.
Additionally since external ACL user= field is used interchangeably in
several places with a full login and with the right helper can be
considered a full side-band authentication I have disabled the
ExtUser/ext_user components as well.
NP: pinning is not strictly dependent on NTLM, we may use it for other
things without involving auth so left most of it in. Just the logics
which use auth to set the pinning flag are now removable.
IDENT not being an authentication mechanism is also left in.
Amos Jeffries [Mon, 7 Feb 2011 04:16:22 +0000 (21:16 -0700)]
Author: Jonathan Wolfe <jonathan.wolfe@gmail.com>
Bug 3149: not caching ecap adapted body
eCAP adapters may remove or edit the Content-Length header, and to allow
caching of the adapted body squid must reflect that new (or unspecified)
content length when deciding whether or not the adapted body can be cached.
In the case the SQUID_SNMP is disabled the MessageType enum list ends with a ","
The gcc compiler does not have any problem with this but SunStudio return a
parse error.
Amos Jeffries [Sun, 6 Feb 2011 09:20:16 +0000 (02:20 -0700)]
Enable non-caching of external ACL results
Admin configure ttl=0 and/or negative_ttl=0 to prevent Squid storing the
ACL lookup results. The problem is that results still get cached and
re-used for the grace= period or one second, whichever is larger.
Also, in the event where two or more requests with identical details
needing to be looked up at the same time there is an optimization
which will merge and share one lookup result for all these requests.
In most situations this result sharing is beneficial, however when a
unique result is wanted it can cause problems.
This patch makes ttl=0 and negative_ttl=0 prevent their respective OK and
ERR results from being stored into the helper result cache. Sharing is
still performed for overlapping duplicate requests.
When cache=0 is configured, no caching or sharing of results is performed
at all.
Alex Rousskov [Fri, 4 Feb 2011 22:25:45 +0000 (15:25 -0700)]
Quiet down swap out error reporting.
Do not report swap out errors at level 1. When things go wrong, the already
bad situation is made worse by writing lots of error messages to cache.log.
Do not report system error because the errno may be stale or irrelevant.
If error details are needed, the code should save and propagate the actual
errno in addition to the DISK_ERROR or similar status.
When StoreEntry is deleted, we need to release the SwapDir map slot locks it
holds, if any. This is difficult because SwapDir maintains the locks while
Squid Core maintains the entry swap_status. The Core gets swap_status-related
notifications using async calls so it is easy for swap_status to get out of
sync if SwapDir updates the map slot proactively.
The new code no longer releases the slot lock until the associated StoreEntry
is unlinked or gone, even if the slot is known to be unusable and waiting to
be deleted. We also do not rely on swap_status to guess which lock to release;
we use slot state to determine that instead.
Removed rock-specific code from StoreEntry destructor by introducing a general
SwapDir::disconnect(StoreEntry&) API.
Alex Rousskov [Thu, 3 Feb 2011 23:41:32 +0000 (16:41 -0700)]
Revised Slot management in Rock::DirMap.
Old code was occasionally hitting a s.state == Slot::Writing assertion when
closing the writing state. Since I could not find a specific bug that would
lead to this, I decided to simplify state management by moving Slot locking
further away from the Slot state.
Two kinds of Slot locks are now supported: exclusive and shared. These are
implemented using simple atomic counters. To obtain the shared lock, the slot
must also be in a readable, not-marked-for-freeing state (this is where the
lock and the state still overlap). The code should eventually be polished
to use explicit creation-is-acquisition lock objects.
Old code could not cope with Slot deletion event arriving when the Slot was
being written to. We now mark the slot as in need of freeing, regardless of
the slot state. This may need more work to properly cleanup marked slots.
The old code used open/closeForWriting sequences for rebuilding the map from
disk. There were possibly some race conditions in that code. It is now
replaced with an dedicated, simpler, and optimized putAt() method.
The attached patch implements aggregation of SNMP responses, similar to how
we aggregate some cache manager stats.
The code contains changes that allow us to share some of the classes between
Cache Manager and SNMP code:
* implement the following base classes under the ipc directory/module:
- Ipc::Forwarder (ipc/Forwarder{.cc,.h} files)
- Ipc::Inquirer (ipc/Inquirer{.cc,.h} files)
- Ipc::Request (ipc/Request{.cc,.h} files)
- Ipc::Response (ipc/Response{.cc,.h} files)
* fix the Mgr::Forwarder, Mgr::Inquirer, Mgr::Request and Mgr::Response
classes to be implemented as kid classes of the equivalent Icp::* classes.
Also implements for the SNMP the same mechanism used for cache manager:
The SNMP requests forwarder to coordinator which collects the statistics from
kids and aggregate them.
Alex Rousskov [Thu, 3 Feb 2011 05:33:05 +0000 (22:33 -0700)]
Support IpcIO timeouts.
Penging IpcIo requests are now stored in two alternating maps: "old" and
"new". Every T seconds, any requests remaining in the "old" map are treated
as timed out. After that check, the current "new" and (now empty) "old" map
pointers are swapped so that the previously "new" requests can now age for T
seconds. New requests are always added to the "new" map. Responses are
always checked against both maps.
This approach gives us access to pending request information and allows to
report errors to the right I/O requestors without creating additional
per-request state attached to a per-request timeout event. The price is (a)
two instead of one map lookups when the response comes and (b) timeout
precision decrease from "about T" to "anywhere from T to 2*T".
Alex Rousskov [Wed, 2 Feb 2011 19:05:25 +0000 (12:05 -0700)]
Fixed Rock MapDir read and write locking:
The IoState object created by openStoreIO() can be used for many reads. Thus,
incrementing read level at open and decrementing it at [each] readCompleted
leads to negative read levels if the stored object need more than one I/O.
Moreover, the only way core Squid can swap in an entry is if an entry has our
fileno set (by our get()). Thus, the slot is already locked for reading by
get(), with the entry responsible for decreasing the read level upon
destruction. We do not need to open/close for reading in
openStoreIO/readComleted.
When writing fails, invalidate the slot before unlocking it.
Alex Rousskov [Wed, 2 Feb 2011 01:49:34 +0000 (18:49 -0700)]
Polished skipping of cache_dirs inactive in a given strand (e.g. Coordinator)
by adding SwapDir::active() method. The directory is active if it makes sense
to call its init/create/get methods in a given strand.
Fixed counting cache_dirs that need dedicated strands. We no longer assume
that all cache_dirs do but use SwapDir::needsDiskStrand() to ask each dir.
The result is stored in Config.cacheSwap.n_strands to optimize NumberOfKids().
Alex Rousskov [Tue, 1 Feb 2011 20:35:42 +0000 (13:35 -0700)]
Call ioCompletedNotification after we are done with the opening sequence,
not in the middle of it. The effect should be the same, but the logs may be
easier to read, and there will be fewer chances of getting into a reentrant
mess of some kind.
Alex Rousskov [Tue, 1 Feb 2011 20:27:13 +0000 (13:27 -0700)]
Do not start rebuilding cache_dir (i.e., loading its index into RAM) until we
complete cache_dir initialization sequence, which ends in not in
Rock::SwapDir::init but in Rock::SwapDir::ioCompletedNotification where we
open the shared map or bail on errors.
It does not make sense to start loading index before the map is configured
because there will be no place to store loaded information.
Alex Rousskov [Tue, 1 Feb 2011 20:18:27 +0000 (13:18 -0700)]
Use Blocking DiskIO module when runnining in a no-daemon mode.
We cannot use IpcIo module in no-daemon mode because there are no diskers
to communicate with. If our implementation is correct, IpcIo module should
contain no shared map or other rock-specific manipulations and, hence,
should not be required for Rock Store to work.
This patch allow the user of the Range template class to define the type of
the returned value of Range::size() method, adding a second template argument.
The default type of the return value of Range::size() method is size_t, which
in most cases is enough (but not always, eg HttpRange).
This patch will allow Range template to be used with non numeric types.
Alex Rousskov [Tue, 1 Feb 2011 08:22:59 +0000 (01:22 -0700)]
Preserve old registration tag when updating registration info.
Sometimes, tagless strand registers self only after its module (like
IpcIoFile) supplies a tag. We need to keep the tag for future tag searches
to succeed.
Alex Rousskov [Tue, 1 Feb 2011 05:01:43 +0000 (22:01 -0700)]
Added IpcIo DiskIO module for communication with remote disk processes via UDS.
Used IpcIo for Rock Store filesystem module.
Added StrandSearch API: Workers use it to ask Coordinator for the right
address (i.e., kid identifier) of the disk process for a given cache_dir path.
If Coordinator does not know the answer, it waits for more disk processes to
register. Implemented using generic tagging of kids (StrandCoord) and
searching for the right tag.
Raised UDS message size maximum to 36K in order to accommodate non-trivial
rock store I/O while we are using UDS messages for I/O content.
Fixed shutdown handling broken by hiding cache_dirs from Coordinator while
switching IamPrimaryProcess() logic to use NumberOfKids() which needs
cache_dir count.
Alex Rousskov [Sun, 30 Jan 2011 23:16:22 +0000 (16:16 -0700)]
Added "disker" processes to be responsible for individual cache_dir I/O.
Determine kid process role based on the process name rather than kid ID.
This allows the process to perform role-specific actions before (or while)
squid.conf is parsed.
Amos Jeffries [Sat, 29 Jan 2011 02:23:48 +0000 (15:23 +1300)]
Profiler: fix report sorting algorithm
The sorting was performed in a way to exclude the UNACCOUNTED and leave it
first in the display list. However with the new auto-genenerated enum all
other entries are at indeterminate locations. Using hash_lookup resulted
in only half teh list being sorted.
Fix that by referencing from UNACCOUNTED which is guaranteed to be first.
Alex Rousskov [Sat, 29 Jan 2011 00:08:52 +0000 (17:08 -0700)]
Added a configuration check to prevent IoState::startWriting() assertions.
Rock::IoState::startWriting() asserts that [padded] write request size does
not exceed the slot size. Padded request size always exceeds the slot size for
slots smaller than the page.
This check may also help avoid using unallocated buffer for padding, but that
part may need more work.