} /* namespace Rock */
/**
- Several layers of information is manipualted during the rebuild:
+ Several layers of information are manipualted during the rebuild:
Store Entry: Response message plus all the metainformation associated with
it. Identified by store key. At any given time, from Squid point
dbSize(0),
dbEntrySize(0),
dbEntryLimit(0),
- dbSlot(0),
fd(-1),
dbOffset(0),
- slotPos(0),
+ loadingPos(0),
validationPos(0)
{
assert(sd);
buf.init(SM_PAGE_SIZE, SM_PAGE_SIZE);
dbOffset = SwapDir::HeaderSize;
- slotPos = 0;
+ loadingPos = 0;
entries = new LoadingEntry[dbEntryLimit];
void
Rock::Rebuild::loadingSteps()
{
- debugs(47,5, HERE << sd->index << " slot " << slotPos << " at " <<
+ debugs(47,5, HERE << sd->index << " slot " << loadingPos << " at " <<
dbOffset << " <= " << dbSize);
// Balance our desire to maximize the number of entries processed at once
while (loaded < dbEntryLimit && dbOffset < dbSize) {
loadOneSlot();
dbOffset += dbEntrySize;
- ++slotPos;
+ ++loadingPos;
++loaded;
if (counts.scancount % 1000 == 0)
void
Rock::Rebuild::loadOneSlot()
{
- debugs(47,5, HERE << sd->index << " slot " << slotPos << " at " <<
+ debugs(47,5, HERE << sd->index << " slot " << loadingPos << " at " <<
dbOffset << " <= " << dbSize);
++counts.scancount;
if (!storeRebuildLoadEntry(fd, sd->index, buf, counts))
return;
- const SlotId slotId = slotPos;
+ const SlotId slotId = loadingPos;
// get our header
DbCellHeader header;
void
Rock::Rebuild::failure(const char *msg, int errNo)
{
- debugs(47,5, HERE << sd->index << " slot " << slotPos << " at " <<
+ debugs(47,5, HERE << sd->index << " slot " << loadingPos << " at " <<
dbOffset << " <= " << dbSize);
if (errNo)
Ipc::StoreMap::openForWriting(const cache_key *const key, sfileno &fileno)
{
debugs(54, 5, "opening entry with key " << storeKeyText(key)
- << " for writing in map [" << path << ']');
+ << " for writing " << path);
const int idx = anchorIndexByKey(key);
if (Anchor *anchor = openForWritingAt(idx)) {
// bail if we cannot empty this position
if (!s.waitingToBeFreed && s.state == Anchor::Readable && !overwriteExisting) {
lock.unlockExclusive();
- debugs(54, 5, "cannot open existing entry at " << fileno <<
- " for writing in map [" << path << ']');
+ debugs(54, 5, "cannot open existing entry " << fileno <<
+ " for writing " << path);
return NULL;
}
//s.setKey(key); // XXX: the caller should do that
debugs(54, 5, "opened entry " << fileno << " for writing " << path);
return &s; // and keep the entry locked
- }
+ }
- debugs(54, 5, "cannot open busy entry at " << fileno <<
- " for writing in map [" << path << ']');
+ debugs(54, 5, "cannot open busy entry " << fileno <<
+ " for writing " << path);
return NULL;
}
s.state = Anchor::Readable;
if (lockForReading) {
s.lock.switchExclusiveToShared();
- debugs(54, 5, "switched entry at " << fileno <<
- " from writing to reading in map [" << path << ']');
+ debugs(54, 5, "switched entry " << fileno <<
+ " from writing to reading " << path);
} else {
s.lock.unlockExclusive();
debugs(54, 5, "closed entry " << fileno << " for writing " << path);
assert(valid(anchorId));
assert(shared->slots[anchorId].anchor.state == Anchor::Writeable);
assert(valid(sliceId));
- return shared->slots[sliceId].slice;
+ return shared->slots[sliceId].slice;
}
const Ipc::StoreMap::Slice &
assert(valid(anchorId));
assert(shared->slots[anchorId].anchor.state == Anchor::Readable);
assert(valid(sliceId));
- return shared->slots[sliceId].slice;
+ return shared->slots[sliceId].slice;
}
Ipc::StoreMap::Anchor &
void
Ipc::StoreMap::abortWriting(const sfileno fileno)
{
- debugs(54, 5, "abort entry at " << fileno <<
- " for writing in map [" << path << ']');
+ debugs(54, 5, "aborting entry " << fileno << " for writing " << path);
assert(valid(fileno));
Anchor &s = shared->slots[fileno].anchor;
assert(s.state == Anchor::Writeable);
void
Ipc::StoreMap::abortIo(const sfileno fileno)
{
- debugs(54, 5, "abort entry at " << fileno <<
- " for I/O in map [" << path << ']');
+ debugs(54, 5, "aborting entry " << fileno << " for I/O in " << path);
assert(valid(fileno));
Anchor &s = shared->slots[fileno].anchor;
void
Ipc::StoreMap::freeEntry(const sfileno fileno)
{
- debugs(54, 5, HERE << " marking entry at " << fileno << " to be freed in"
- " map [" << path << ']');
+ debugs(54, 5, "marking entry " << fileno << " to be freed in " << path);
assert(valid(fileno));
Anchor &s = shared->slots[fileno].anchor;
Ipc::StoreMap::freeChain(const sfileno fileno, Anchor &inode, const bool keepLocked)
{
debugs(54, 7, "freeing " << inode.state << " entry " << fileno <<
- " in map [" << path << ']');
+ " in " << path);
if (inode.state != Anchor::Empty) {
sfileno sliceId = inode.start;
- debugs(54, 7, "first slice " << sliceId);
+ debugs(54, 8, "first slice " << sliceId);
while (sliceId >= 0) {
Slice &slice = shared->slots[sliceId].slice;
const sfileno nextId = slice.next;
if (!keepLocked)
inode.lock.unlockExclusive();
--shared->count;
- debugs(54, 5, "freed entry " << fileno <<
- " in map [" << path << ']');
+ debugs(54, 5, "freed entry " << fileno << " in " << path);
}
const Ipc::StoreMap::Anchor *
Ipc::StoreMap::openForReading(const cache_key *const key, sfileno &fileno)
{
debugs(54, 5, "opening entry with key " << storeKeyText(key)
- << " for reading in map [" << path << ']');
+ << " for reading " << path);
const int idx = anchorIndexByKey(key);
if (const Anchor *slot = openForReadingAt(idx)) {
if (slot->sameKey(key)) {
const Ipc::StoreMap::Anchor *
Ipc::StoreMap::openForReadingAt(const sfileno fileno)
{
- debugs(54, 5, "opening entry at " << fileno <<
- " for reading in map [" << path << ']');
+ debugs(54, 5, "opening entry " << fileno << " for reading " << path);
assert(valid(fileno));
Anchor &s = shared->slots[fileno].anchor;
if (!s.lock.lockShared()) {
- debugs(54, 5, "cannot open busy entry at " << fileno <<
- "for reading in map [" << path << ']');
+ debugs(54, 5, "cannot open busy entry " << fileno <<
+ " for reading " << path);
return NULL;
}
if (s.state == Anchor::Empty) {
s.lock.unlockShared();
- debugs(54, 7, "cannot open empty entry at " << fileno <<
- " for reading in map [" << path << ']');
+ debugs(54, 7, "cannot open empty entry " << fileno <<
+ " for reading " << path);
return NULL;
}
if (s.waitingToBeFreed) {
s.lock.unlockShared();
- debugs(54, 7, HERE << "cannot open marked entry at " << fileno <<
- " for reading in map [" << path << ']');
+ debugs(54, 7, HERE << "cannot open marked entry " << fileno <<
+ " for reading " << path);
return NULL;
}
const int searchLimit = min(10000, entryLimit());
int tries = 0;
for (; tries < searchLimit; ++tries) {
- const sfileno fileno = shared->victim++ % shared->limit;
+ const sfileno fileno = shared->victim++ % shared->limit;
assert(valid(fileno));
Anchor &s = shared->slots[fileno].anchor;
if (s.lock.lockExclusive()) {
if (s.state == Anchor::Readable) { // skip empties
// this entry may be marked for deletion, and that is OK
freeChain(fileno, s, false);
- debugs(54, 5, "purged entry at " << fileno);
+ debugs(54, 5, "purged entry " << fileno << " from " << path);
return true;
- }
+ }
s.lock.unlockExclusive();
}
- }
- debugs(54, 5, "found no entries to purge; tried: " << tries);
+ }
+ debugs(54, 5, "no entries to purge from " << path << "; tried: " << tries);
return false;
}