]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
13 years agoFixed Ipc::Mem::Segment::reserve().
Alex Rousskov [Tue, 12 Apr 2011 18:47:31 +0000 (12:47 -0600)] 
Fixed Ipc::Mem::Segment::reserve().
It was returning the pointer to the end of the reserved area.

Added debugging.

13 years agoFixed signed-with-unsigned compiler warnings.
Alex Rousskov [Tue, 12 Apr 2011 18:26:55 +0000 (12:26 -0600)] 
Fixed signed-with-unsigned compiler warnings.

13 years agoAdded initial shared memory cache implementation (MemStore) and integrated it.
Alex Rousskov [Tue, 12 Apr 2011 00:33:41 +0000 (18:33 -0600)] 
Added initial shared memory cache implementation (MemStore) and integrated it.

Like Rock Store, shared memory cache keeps its own compact index of cached
entries using extended Ipc::StoreMap class (MemStoreMap). Like Rock Store, the
cache also struggles to keep its Root.get() results out of the store_table
except during transit.

There are several XXXs and TODOs that still need to be addressed for a more
polished implementation.

Eventually, the non-shared/local memory cache should also be implemented
using a MemStore-like class, I think. This will allow to clearly isolate
local from shared memory cache code.

13 years agoAvoid creating unlocked store_table entries when handling rebuild conflicts.
Alex Rousskov [Mon, 11 Apr 2011 23:50:50 +0000 (17:50 -0600)] 
Avoid creating unlocked store_table entries when handling rebuild conflicts.

Such StoreEntry objects persist until a hit locks and unlocks them (or the
replacement policy removes them?), creating SMP synchronization problems
because they are treated as in-transit objects even though their store slot
may be gone already.

13 years agoAdded TODOs to avoid creating unlocked store_table entries.
Alex Rousskov [Mon, 11 Apr 2011 23:49:57 +0000 (17:49 -0600)] 
Added TODOs to avoid creating unlocked store_table entries.

13 years agoSplit Rock-only Rock::DirMap into Rock::DirMap and reusable Ipc pieces
Alex Rousskov [Sat, 9 Apr 2011 04:24:06 +0000 (22:24 -0600)] 
Split Rock-only Rock::DirMap into Rock::DirMap and reusable Ipc pieces
which a shared memory cache implementation can use:

Ipc::StoreMap is responsible for maintaining a collection of lockable slots,
each with readable/writeable/free state and a "waiting to be free" flag. Kids
of this class can add more metadata (in parallel structures using the same
index as primary slots). I tried extending the slots themselves, but that
turned out to be more complex/messy.

Ipc::ReadWriteLock is a basic multiple readers, single writer lock.  Its
earlier implementation inside Rock::DirMap mixed slot locking and slot
state/flags. That simplified the caller code a little, but the current simpler
class is easier to understand and reuse.

Rock::DirMap now just adds Rock::DbCellHeader metadata to Ipc::StoreMap slots.

Simplified mapping API by reducing the number of similar-but-different
methods. For example, instead of putAt, the caller can use an
openForWriting/closeForWriting pair. This helps with moving custom metadata
manipulations outside of the reusable Ipc::StoreMap.

It would be possible to split Ipc::StoreMap further by moving Store-specific
bits outside of its slots. Currently, there is no need for that though.

13 years agoAdded reserve() method to allow nested classes or similar related users of
Alex Rousskov [Sat, 9 Apr 2011 04:20:21 +0000 (22:20 -0600)] 
Added reserve() method to allow nested classes or similar related users of
the same segment to safely bite off pieces of the same shared segment. Still
need to convert the callers.

The reserve() method is useful for single-users as well because it allows
to check that a segment has enough bytes allocated for its single user.

Changed theSize type from int to "size of any single object in RAM" size_t.

13 years agoUsed one-for-all constant page size for now; need to be made configurable.
Alex Rousskov [Fri, 8 Apr 2011 00:08:15 +0000 (18:08 -0600)] 
Used one-for-all constant page size for now; need to be made configurable.

13 years agoFixed raw page buffer type.
Alex Rousskov [Fri, 8 Apr 2011 00:07:18 +0000 (18:07 -0600)] 
Fixed raw page buffer type.

13 years agoInitial shared memory pages implementation.
Dmitry Kurochkin [Wed, 6 Apr 2011 13:23:03 +0000 (17:23 +0400)] 
Initial shared memory pages implementation.

13 years agoProvided a better description for the stack index updating step.
Alex Rousskov [Fri, 1 Apr 2011 16:33:07 +0000 (10:33 -0600)] 
Provided a better description for the stack index updating step.

13 years agoAdded initial API for managing shared memory cache and its shared memory pages.
Alex Rousskov [Thu, 31 Mar 2011 22:57:04 +0000 (16:57 -0600)] 
Added initial API for managing shared memory cache and its shared memory pages.

13 years agoMoved ipc/SharedMemory to ipc/mem/ and renamed it to Ipc::Mem::Segment.
Alex Rousskov [Thu, 31 Mar 2011 21:22:12 +0000 (15:22 -0600)] 
Moved ipc/SharedMemory to ipc/mem/ and renamed it to Ipc::Mem::Segment.

All IPC things are "shared" by default.

The new name is also more specific because there are other shared memory
structures such as queues and stacks (all using shared memory segments
internally though).

13 years agoInitial implementation of atomic container for free page numbers in a segment.
Alex Rousskov [Thu, 31 Mar 2011 20:43:33 +0000 (14:43 -0600)] 
Initial implementation of atomic container for free page numbers in a segment.

13 years agoAdded initial __sync_fetch_and_and support.
Alex Rousskov [Thu, 31 Mar 2011 20:04:20 +0000 (14:04 -0600)] 
Added initial __sync_fetch_and_and support.

13 years agoMerge IpcIoFile atomic queue v5.
Dmitry Kurochkin [Wed, 2 Mar 2011 18:05:42 +0000 (21:05 +0300)] 
Merge IpcIoFile atomic queue v5.

13 years agoIpcIoFile atomic queue v5:
Dmitry Kurochkin [Wed, 2 Mar 2011 18:04:38 +0000 (21:04 +0300)] 
IpcIoFile atomic queue v5:

* add missing src/ipc/Queue.cc

13 years agoIpcIoFile atomic queue v4.
Dmitry Kurochkin [Wed, 2 Mar 2011 01:10:28 +0000 (04:10 +0300)] 
IpcIoFile atomic queue v4.

13 years agoIpcIoFile atomic queue v4:
Dmitry Kurochkin [Wed, 2 Mar 2011 01:08:08 +0000 (04:08 +0300)] 
IpcIoFile atomic queue v4:

* change Queue push/pop interface
* fix leak in IpcIoFile::push()

13 years agoIpcIoFile atomic queue v3.
Dmitry Kurochkin [Tue, 1 Mar 2011 02:49:27 +0000 (05:49 +0300)] 
IpcIoFile atomic queue v3.

13 years agoIpcIoFile atomic queue v2:
Dmitry Kurochkin [Tue, 1 Mar 2011 02:44:52 +0000 (05:44 +0300)] 
IpcIoFile atomic queue v2:

* rework ipc/Queue, move implementation to .cc
* fix raw pointer use in IpcIoFile

13 years agoFixed blocking reads that were sometimes reading from random file offsets. take04
Alex Rousskov [Tue, 22 Feb 2011 23:13:13 +0000 (16:13 -0700)] 
Fixed blocking reads that were sometimes reading from random file offsets.

Core "disk file" reading code assumed that if the globally stored disk.offset
matches the desired offset, there is no reason to seek. This was probably done
to reduce seek overhead between consecutive reads. Unfortunately, the disk
writing code did not know about that optimization and left F->disk.offset
unchanged after writing.

This may have worked OK for UFS if it never writes to the file it reads from,
but it does not work for store modules that do both kinds of I/O at different
offsets of the same disk file.

TODO: Implement this optimization correctly or remove disk.offset.

13 years agoMerge IpcIoFile atomic queue v2.
Dmitry Kurochkin [Thu, 17 Feb 2011 15:15:32 +0000 (18:15 +0300)] 
Merge IpcIoFile atomic queue v2.

13 years agoIpcIoFile atomic queue v2.
Dmitry Kurochkin [Thu, 17 Feb 2011 11:37:59 +0000 (14:37 +0300)] 
IpcIoFile atomic queue v2.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Wed, 16 Feb 2011 16:26:46 +0000 (19:26 +0300)] 
Merge 3p2-rock.

13 years agoIpcIoFile atomic queue v1.
Dmitry Kurochkin [Wed, 16 Feb 2011 16:19:26 +0000 (19:19 +0300)] 
IpcIoFile atomic queue v1.

13 years agoUpdate fd/disk stats when doing disk I/O.
Alex Rousskov [Tue, 15 Feb 2011 23:27:58 +0000 (16:27 -0700)] 
Update fd/disk stats when doing disk I/O.

13 years ago* Removed old Rock Store hack to update swap_file_sz before it is packed into
Alex Rousskov [Tue, 15 Feb 2011 04:09:58 +0000 (21:09 -0700)] 
* Removed old Rock Store hack to update swap_file_sz before it is packed into
store entry disk "header". Prepend our own disk to each db cell. Eventually,
the same header may be used to store "next page" or other info.

Modern Squid code should not use packed swap_file_sz or object_sz because
neither can be unknown at the packing time.  The storage code should either
record its own size information (Rock Store does that now) or rely on
3rd-party metadata (UFS uses fstat(2) system call).

* Do not promise to read a being-written entry. Use peekAtReader() to check
that we can read the presumably locked (by us) entry.

It is probably possible to queue a reader somehow and wait for the entry to
become readable or even to read initial pages as we write (when we start doing
incremental writing) but it would be rather complex and expensive to
synchronize such shared read/write access across workers.

* Fixed ::StoreIOState::offset_ Rock maintenance. The old code probably
misinterpret offset_ meaning and kept the disk offset there. It should have
been just the distance from the beginning of the db cell (not db file)
instead. It probably worked because we write everything at once and the
offset_ values were usually big enough to pass "wrote everything" checks.

* Extracted storeRebuildParseEntry from storeRebuildLoadEntry.

This allows Rock Store to analyze and skip disk cell header before giving
the packed store entry info to the common core code.

* Report more disk stats. Needs more work, especially in SMP reporting case.
Map stats are only reported for tiny maps because scanning the entire map may
be too expensive for bigger maps (is it worth the overhead to maintain these
stats all the time instead of computing them from scratch on-demand?).

* Moved StoreEntryBasics into Rock namespace.

* Be more consistent in setting Rock::IoState's swap_filen, swap_dirn,
diskOffset, and payloadEnd.

* Renamed vague (and confusing after the header was added to the db cell)
entrySize to more specific payloadEnd.

* Synced with r11228 changes (making Store work with SMP-shared max-size
cache_dirs).

13 years agoChanges revolving around making Store work with SMP-shared max-size cache_dirs:
Alex Rousskov [Tue, 15 Feb 2011 04:02:28 +0000 (21:02 -0700)] 
Changes revolving around making Store work with SMP-shared max-size cache_dirs:

* Added MemObject::expectedReplySize() and used it instead of object_sz.

When deciding whether an object with a known content length can be swapped
out, do not wait until the object is completely received and its size
(mem_obj->object_sz) becomes known (while asking the store to recheck in vain
with every incoming chunk). Instead, use the known content length, if any, to
make the decision.

This optimizes the common case where the complete object is eventually
received and swapped out, preventing accumulating potentially large objects in
RAM while waiting for the end of the response. Should not affect objects with
unknown content length.

Side-effect1: probably fixes several cases of unknowingly using negative
(unknown) mem_obj->object_sz in calculations. I added a few assertions to
double check some of the remaining object_sz/objectLen() uses.

Side-effect2: When expectedReplySize() is stored on disk as StoreEntry
metadata, it may help to detect truncated entries when the writer process dies
before completing the swapout.

* Removed mem->swapout.memnode in favor of mem->swapout.queue_offset.

The code used swapout.memnode pointer to keep track of the last page that was
swapped out. The code was semi-buggy because it could reset the pointer to
NULL if no new data came in before the call to doPages(). Perhaps the code
relied on the assumption that the caller will never doPages if there is no new
data, but I am not sure that assumption was correct in all cases (it could be
that I broke the calling code, of course).

Moreover, the page pointer was kept without any protection from page
disappearing during asynchronous swapout. There were "Evil hack time" comments
discussing how the page might disappear.

Fortunately, we already have mem->swapout.queue_offset that can be fed to
getBlockContainingLocation to find the page that needs to be swapped out.
There is no need to keep the page pointer around. The queue_offset-based math
is the same so we are not adding any overheads by using that offset (in fact,
we are removing some minor computations).

* Added "close how?" parameter to storeClose() and friends.

The old code would follow the same path when closing swapout activity for an
aborted entry and when completing a perfectly healthy swapout. In non-shared
case, that could have been OK because the abort code would then release the
entry, removing any half-written entry from the index and the disk (but I am
not sure that release happened fast enough in 100% of cases).

When the index and disk storage is shared among workers, such "temporary"
inconsistencies result in truncated responses being delivered by other workers
to the user because once the swapout activity is closed, other workers can
start using the entry.

By adding the "close how?" parameter to closing methods we allow the core and
SwapDir-specific code to handle aborted swapouts appropriately.

Since swapin code is "read only", we do not currently distinguish between
aborted and fully satisfied readers: The readerGone enum value applies to both
cases. If needed, the SwapDir reading code can make that distinction by
analyzing how much was actually swapped in.

* Moved "can you store this entry?" code to virtual SwapDir::canStore().

The old code had some of the tests in SwapDir-specific canStore() methods and
some in storeDirSelect*() methods. This resulted in inconsistencies, code
duplication, and extra calculation overheads. Making this call virtual allows
individual cache_dir types to do custom access controls.

The same method is used for cache_dir load reporting (if it returns true).
Load management needs more work, but the current code is no worse than the old
one in this aspect, and further improvements are outside this change scope.

* Minimized from-disk StoreEntry loading/unpacking code duplication.

Moved common (and often rather complex!) code from store modules into
storeRebuildLoadEntry, storeRebuildParseEntry, and storeRebuildKeepEntry.

* Do not set object_sz when the entry is aborted because the true object size
(HTTP reply headers + body) is not known in this case. Setting object_sz may
fool client-side code into believing that the object is complete.

This addresses an old RBC's complaint.

* When swapout initiation fails, release StoreEntry. This prevents the caller
code from trying to swap out again and again because swap_status becomes
SWAPOUT_NONE.

TODO: Consider add SWAPOUT_ERROR, STORE_ERROR, and similar states. It may
solve several problems where the code sees _NONE or _OK and thinks everything
is peachy when in fact there was an error.

* Always call StoreEntry::abort() instead of setting ENTRY_ABORTED manually.

* Rely on entry->abort() side-effects if ENTRY_ABORTED was set.

* Added or updated comments to better document current code.

* Added operator << for dumping StoreEntry summary into the debugging log.
Needs more work to report more info (and not report yet-unknown info).

13 years agoAdded an optimization TODO comment. No runtime changes.
Alex Rousskov [Mon, 14 Feb 2011 05:00:44 +0000 (22:00 -0700)] 
Added an optimization TODO comment. No runtime changes.

13 years agoCall StoreEntry::abort() instead of setting ENTRY_ABORTED flag.
Alex Rousskov [Mon, 14 Feb 2011 04:56:59 +0000 (21:56 -0700)] 
Call StoreEntry::abort() instead of setting ENTRY_ABORTED flag.

This may be necessary because the abort() method does more than just setting
the flag and releasing the request. It guarantees, for example, that the
swapout I/O, if any, is closed.

This change is untested.

13 years agoPolished mgr query handoff from the original recepient worker to Coordinator.
Alex Rousskov [Mon, 14 Feb 2011 04:48:35 +0000 (21:48 -0700)] 
Polished mgr query handoff from the original recepient worker to Coordinator.

When the worker receives a cache manager query, gives it to Coordinator, and
receives an ACK from Coordinator, the worker should stop handling the
originating transaction without declaring the associated StoreEntry as
complete because doing so triggers store client activity on the client-side
and might cause undesirable output to the now-shared HTTP client socket.
Besides, declaring an empty entry as complete is kind of wrong.

13 years agoFixed ServerStateData::haveParsedReplyHeaders() description.
Alex Rousskov [Mon, 14 Feb 2011 04:12:50 +0000 (21:12 -0700)] 
Fixed ServerStateData::haveParsedReplyHeaders() description.
No runtime changes.

13 years agoDestroy unused entries so that they do not keep Rock::SwapDir slots locked. take02
Alex Rousskov [Tue, 8 Feb 2011 04:04:57 +0000 (21:04 -0700)] 
Destroy unused entries so that they do not keep Rock::SwapDir slots locked.

May need more work to identify all cases where [un]locked entries are [un]used.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Tue, 8 Feb 2011 03:43:45 +0000 (06:43 +0300)] 
Merge 3p2-rock.

13 years agoDo not rely on LateReleaseStack.pop() returning NULL when empty.
Alex Rousskov [Tue, 8 Feb 2011 01:58:02 +0000 (18:58 -0700)] 
Do not rely on LateReleaseStack.pop() returning NULL when empty.

Current Stack::pop() implementation returns value_type() when empty. This
is probably not guaranteed to work well when value_type is a pointer.

13 years agoDo not add in-transit store entries to the already overflowing memory cache.
Alex Rousskov [Tue, 8 Feb 2011 01:53:13 +0000 (18:53 -0700)] 
Do not add in-transit store entries to the already overflowing memory cache.

13 years agoDo not reference destroyed diskless entries when they are released
Alex Rousskov [Tue, 8 Feb 2011 01:50:19 +0000 (18:50 -0700)] 
Do not reference destroyed diskless entries when they are released
during store rebuild.

13 years agoPolished debugging. Needs more work.
Alex Rousskov [Tue, 8 Feb 2011 01:29:29 +0000 (18:29 -0700)] 
Polished debugging. Needs more work.

13 years agoFixed debugging: print the entry size, as intended, not the entry pointer.
Alex Rousskov [Tue, 8 Feb 2011 01:25:59 +0000 (18:25 -0700)] 
Fixed debugging: print the entry size, as intended, not the entry pointer.

13 years agoRemoved temporary code disabling Rock::SwapDir::maintain().
Alex Rousskov [Mon, 7 Feb 2011 18:55:41 +0000 (11:55 -0700)] 
Removed temporary code disabling Rock::SwapDir::maintain().
Standard code now works because we do not create a replacement policy.

Polished/optimized Rock::SwapDir::maintain() guards.

13 years agoDo not create an unused replacement policy and stuff it with entries
Alex Rousskov [Mon, 7 Feb 2011 18:48:40 +0000 (11:48 -0700)] 
Do not create an unused replacement policy and stuff it with entries
because those entries will leak since maintain() is disabled.

13 years agoMade Rock::Rebuild an AsyncJob because it is.
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.

13 years agoFixed "no swap_filen" test. Zero swap_filen is a valid swap_filen.
Alex Rousskov [Mon, 7 Feb 2011 01:36:27 +0000 (18:36 -0700)] 
Fixed "no swap_filen" test. Zero swap_filen is a valid swap_filen.

13 years agoFixed busy slot accounting
Alex Rousskov [Sun, 6 Feb 2011 04:44:08 +0000 (21:44 -0700)] 
Fixed busy slot accounting
The number of busy slots does not go up when a new slot overwrites an old one.

13 years agoDisabled Rock::SwapDir::maintain() because it has no positive effects
Alex Rousskov [Sun, 6 Feb 2011 01:35:23 +0000 (18:35 -0700)] 
Disabled Rock::SwapDir::maintain() because it has no positive effects
with the current hashing scheme.

13 years agoQuiet down swap out error reporting.
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.

13 years agoRevised Core/Store cooperation w.r.t. SwapDir map slot locks.
Alex Rousskov [Fri, 4 Feb 2011 22:18:41 +0000 (15:18 -0700)] 
Revised Core/Store cooperation w.r.t. SwapDir map slot locks.

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.

Polished StoreEntry initialization.

Polished and fixed Rock::SwapDir debugging.

13 years agoProvide a method to abnormally terminate slot writing.
Alex Rousskov [Fri, 4 Feb 2011 18:18:12 +0000 (11:18 -0700)] 
Provide a method to abnormally terminate slot writing.
It efficiently resets the slot while the slot is still exclusively locked.

Polished slot cleaning code to be able to reuse it more.

Added comments.

Fixed switchExclusiveToSharedLock() definition profile.

13 years agoWhen we are done writing, we still need to keep the reading lock
Alex Rousskov [Fri, 4 Feb 2011 04:26:18 +0000 (21:26 -0700)] 
When we are done writing, we still need to keep the reading lock
because the StoreEntry is not gone yet and may refer back to the Slot.

13 years agoPolished debugging.
Alex Rousskov [Fri, 4 Feb 2011 04:23:47 +0000 (21:23 -0700)] 
Polished debugging.

13 years agoRevised Slot management in Rock::DirMap.
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.

13 years agoAdded comments to explain slot read level maintenance assumptions.
Alex Rousskov [Thu, 3 Feb 2011 18:58:58 +0000 (11:58 -0700)] 
Added comments to explain slot read level maintenance assumptions.

13 years agoAvoid assertions when mgr:storedir is requested before cache_dir has a map.
Alex Rousskov [Thu, 3 Feb 2011 17:13:39 +0000 (10:13 -0700)] 
Avoid assertions when mgr:storedir is requested before cache_dir has a map.

13 years agoSupport IpcIO timeouts.
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".

13 years agoFixed Rock MapDir read and write locking:
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.

13 years agoPolished skipping of cache_dirs inactive in a given strand (e.g. Coordinator)
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().

13 years agoRemoved "multiple of page size" restriction on cache_dir rock max-size.
Alex Rousskov [Tue, 1 Feb 2011 20:43:57 +0000 (13:43 -0700)] 
Removed "multiple of page size" restriction on cache_dir rock max-size.

The restriction came from mmap writing days and was meant to prevent forcing
mmap to read and merge the unchanged tail of a page we were updating.

13 years agoCall ioCompletedNotification after we are done with the opening sequence,
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.

13 years agoDo not start rebuilding cache_dir (i.e., loading its index into RAM) until we
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.

13 years agoUse Blocking DiskIO module when runnining in a no-daemon mode.
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.

13 years agoRemoved unnecessary loud debugging.
Alex Rousskov [Tue, 1 Feb 2011 20:16:06 +0000 (13:16 -0700)] 
Removed unnecessary loud debugging.

13 years agoRaised debugging level for "got in-transit entry" messages.
Alex Rousskov [Tue, 1 Feb 2011 20:07:28 +0000 (13:07 -0700)] 
Raised debugging level for "got in-transit entry" messages.

13 years agoSkip initialization for all cache_dirs except for one managed by this disker.
Dmitry Kurochkin [Tue, 1 Feb 2011 10:48:22 +0000 (13:48 +0300)] 
Skip initialization for all cache_dirs except for one managed by this disker.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Tue, 1 Feb 2011 09:41:33 +0000 (12:41 +0300)] 
Merge 3p2-rock.

13 years agoRestrict cache_dir creation to the disk process. take01
Alex Rousskov [Tue, 1 Feb 2011 09:51:09 +0000 (02:51 -0700)] 
Restrict cache_dir creation to the disk process.

13 years agoForgot to copy the read slot into caller's buffer, causing SWAPFAIL_MISSes.
Alex Rousskov [Tue, 1 Feb 2011 09:50:11 +0000 (02:50 -0700)] 
Forgot to copy the read slot into caller's buffer, causing SWAPFAIL_MISSes.

13 years agoDebug output polishing in Rock::DirMap.
Dmitry Kurochkin [Tue, 1 Feb 2011 09:01:29 +0000 (12:01 +0300)] 
Debug output polishing in Rock::DirMap.

13 years agoShared Rock::DirMap version 12.
Dmitry Kurochkin [Tue, 1 Feb 2011 08:49:57 +0000 (11:49 +0300)] 
Shared Rock::DirMap version 12.

13 years agoShared Rock::DirMap version 11.
Dmitry Kurochkin [Tue, 1 Feb 2011 08:30:26 +0000 (11:30 +0300)] 
Shared Rock::DirMap version 11.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Tue, 1 Feb 2011 08:26:02 +0000 (11:26 +0300)] 
Merge 3p2-rock.

13 years agoShared Rock::DirMap version 10.
Dmitry Kurochkin [Tue, 1 Feb 2011 08:24:32 +0000 (11:24 +0300)] 
Shared Rock::DirMap version 10.

13 years agoPreserve old registration tag when updating registration info.
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.

13 years agoShared Rock::DirMap version 9.
Dmitry Kurochkin [Tue, 1 Feb 2011 07:14:17 +0000 (10:14 +0300)] 
Shared Rock::DirMap version 9.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Tue, 1 Feb 2011 06:41:34 +0000 (09:41 +0300)] 
Merge 3p2-rock.

13 years agoFixed Rock::DirMap::Slot::checkKey() which was ignoring its parameter.
Alex Rousskov [Tue, 1 Feb 2011 06:41:15 +0000 (23:41 -0700)] 
Fixed Rock::DirMap::Slot::checkKey() which was ignoring its parameter.

Store entry key in four 4-byte atomics instead of two 8-byte atomics because
older GCCs (e.g., v4.4.1) lack __sync_fetch_and_add_8.

13 years agoShared Rock::DirMap version 8.
Dmitry Kurochkin [Tue, 1 Feb 2011 06:38:11 +0000 (09:38 +0300)] 
Shared Rock::DirMap version 8.

13 years agoRemoved restriction on cache_dir max-size to be a multiple of pagesize.
Alex Rousskov [Tue, 1 Feb 2011 05:46:29 +0000 (22:46 -0700)] 
Removed restriction on cache_dir max-size to be a multiple of pagesize.
It was specific to Mmapped DiskIO module which we no longer use.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Tue, 1 Feb 2011 05:07:49 +0000 (08:07 +0300)] 
Merge 3p2-rock.

13 years agoAdded forgotten StrandSearch sources.
Alex Rousskov [Tue, 1 Feb 2011 05:17:51 +0000 (22:17 -0700)] 
Added forgotten StrandSearch sources.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Tue, 1 Feb 2011 05:07:38 +0000 (08:07 +0300)] 
Merge 3p2-rock.

13 years agoAdded IpcIo DiskIO module for communication with remote disk processes via UDS.
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.

13 years agoShared Rock::DirMap version 7.
Dmitry Kurochkin [Tue, 1 Feb 2011 04:59:26 +0000 (07:59 +0300)] 
Shared Rock::DirMap version 7.

13 years agoShared Rock::DirMap version 6.
Dmitry Kurochkin [Tue, 1 Feb 2011 03:57:45 +0000 (06:57 +0300)] 
Shared Rock::DirMap version 6.

13 years agoShared Rock::DirMap version 5.
Dmitry Kurochkin [Mon, 31 Jan 2011 04:08:41 +0000 (07:08 +0300)] 
Shared Rock::DirMap version 5.

13 years agoAdded "disker" processes to be responsible for individual cache_dir I/O.
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.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Sun, 30 Jan 2011 23:15:49 +0000 (02:15 +0300)] 
Merge 3p2-rock.

13 years agoShared Rock::DirMap version 4.
Dmitry Kurochkin [Sun, 30 Jan 2011 23:15:05 +0000 (02:15 +0300)] 
Shared Rock::DirMap version 4.

13 years agoRock::SwapDir::get() implementation.
Dmitry Kurochkin [Sun, 30 Jan 2011 06:06:24 +0000 (09:06 +0300)] 
Rock::SwapDir::get() implementation.

13 years agoRevert RockSwapDir changes.
Dmitry Kurochkin [Sun, 30 Jan 2011 06:04:46 +0000 (09:04 +0300)] 
Revert RockSwapDir changes.

13 years agoShared Rock::DirMap version 3.
Dmitry Kurochkin [Sun, 30 Jan 2011 06:00:04 +0000 (09:00 +0300)] 
Shared Rock::DirMap version 3.

13 years agoMerge 3p2-rock.
Dmitry Kurochkin [Sun, 30 Jan 2011 04:41:33 +0000 (07:41 +0300)] 
Merge 3p2-rock.

13 years agoShared Rock::DirMap version 2.
Dmitry Kurochkin [Sun, 30 Jan 2011 04:35:36 +0000 (07:35 +0300)] 
Shared Rock::DirMap version 2.

13 years agoWhen searching for a hit, ask each cache_dir after checking in store_table.
Alex Rousskov [Sun, 30 Jan 2011 02:21:30 +0000 (19:21 -0700)] 
When searching for a hit, ask each cache_dir after checking in store_table.

This allows SMP cache_dirs to share their contents without constantly worrying
about keeping the worker-specific store_table in sync among workers.

13 years agoAdded stream operator << for StoreEntry to ease debugging.
Alex Rousskov [Sun, 30 Jan 2011 02:19:26 +0000 (19:19 -0700)] 
Added stream operator << for StoreEntry to ease debugging.

13 years agoShared Rock::DirMap version 1.
Dmitry Kurochkin [Sun, 30 Jan 2011 01:35:32 +0000 (04:35 +0300)] 
Shared Rock::DirMap version 1.

13 years agoChange RockDirMap to use bytes instead of bits.
Dmitry Kurochkin [Sat, 29 Jan 2011 18:44:25 +0000 (21:44 +0300)] 
Change RockDirMap to use bytes instead of bits.

This is required to make it shared between multiple worker processes, because
we can not work atomically with bits.

13 years agoSupport multiple services and vectoring-point crossing in ICAP X-Next-Services.
Alex Rousskov [Sat, 29 Jan 2011 18:18:12 +0000 (11:18 -0700)] 
Support multiple services and vectoring-point crossing in ICAP X-Next-Services.

Adding source files forgotten in r11167.

Merged from the 3p1-rock branch (r9630).

13 years agoAdded a configuration check to prevent IoState::startWriting() assertions.
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.

13 years agoAdded STORE_META_OBJSIZE size to keep storeSwapMetaSize in sync with
Alex Rousskov [Fri, 28 Jan 2011 01:25:12 +0000 (18:25 -0700)] 
Added STORE_META_OBJSIZE size to keep storeSwapMetaSize in sync with
storeSwapMetaBuild.