const SlotId sidNext = reserveSlotForWriting(); // throws
assert(sidNext >= 0);
writeToDisk(sidNext);
- } else if (Store::Root().transientReaders(*e)) {
+ } else if (false && Store::Root().transientReaders(*e)) {
// write partial buffer for all remote hit readers to see
writeBufToDisk(-1);
}
Rock::IoState::finishedWriting(const int errFlag)
{
// we incremented offset_ while accumulating data in write()
- writeableAnchor_ = NULL;
+ // we do not reset writeableAnchor_ here because we still keep the lock
CollapsedForwarding::Broadcast(*e);
callBack(errFlag);
}
if (!theFile) {
debugs(79, 3, "I/O already canceled");
assert(!callback);
- assert(!writeableAnchor_);
+ // We keep writeableAnchor_ after callBack() on I/O errors.
assert(!readableAnchor_);
return;
}
bool
Rock::SwapDir::anchorCollapsed(StoreEntry &collapsed, bool &inSync)
{
- if (!map || !theFile || !theFile->canRead())
+ if (true || !map || !theFile || !theFile->canRead())
return false;
sfileno filen;
// before it switches from SWAPOUT_WRITING to SWAPOUT_DONE.
// since e has swap_filen, its slot is locked for reading and/or writing
- // but it is difficult to know whether THIS worker is reading or writing e
- if (e.swap_status == SWAPOUT_WRITING ||
- (e.mem_obj && e.mem_obj->swapout.sio != NULL)) {
+ // but it is difficult to know whether THIS worker is reading or writing e,
+ // especially since we may switch from writing to reading. This code relies
+ // on Rock::IoState::writeableAnchor_ being set when we locked for writing.
+ if (e.mem_obj && e.mem_obj->swapout.sio != NULL &&
+ dynamic_cast<IoState&>(*e.mem_obj->swapout.sio).writeableAnchor_) {
map->abortWriting(e.swap_filen);
e.swap_dirn = -1;
e.swap_filen = -1;
e.swap_status = SWAPOUT_NONE;
+ dynamic_cast<IoState&>(*e.mem_obj->swapout.sio).writeableAnchor_ = NULL;
Store::Root().transientsAbandon(e); // broadcasts after the change
} else {
map->closeForReading(e.swap_filen);
assert(slot->sameKey(static_cast<const cache_key*>(e.key)));
assert(slot->basics.swap_file_sz > 0);
+ // XXX: basics.swap_file_sz may grow for collapsed disk hits
assert(slot->basics.swap_file_sz == e.swap_file_sz);
return sio;
if (request->sidNext < 0) {
// close, the entry gets the read lock
map->closeForWriting(sio.swap_filen, true);
+ sio.writeableAnchor_ = NULL;
sio.finishedWriting(errflag);
}
} else {