return e;
}
+void
+UFSSwapDir::undoAddDiskRestore(StoreEntry *e)
+{
+ debugs(47, 5, HERE << *e);
+ replacementRemove(e); // checks swap_dirn so do it before we invalidate it
+ // Do not unlink the file as it might be used by a subsequent entry.
+ mapBitReset(e->swap_filen);
+ e->swap_filen = -1;
+ e->swap_dirn = -1;
+ cur_size -= fs.blksize * sizeInBlocks(e->swap_file_sz);
+ --n_disk_objects;
+}
+
void
UFSSwapDir::rebuild()
{
{
debugs(79, 3, "storeUfsUnlink: dirno " << index << ", fileno "<<
std::setfill('0') << std::hex << std::uppercase << std::setw(8) << e.swap_filen);
- if (e.swap_status == SWAPOUT_DONE && EBIT_TEST(e.flags, ENTRY_VALIDATED)) {
+ if (e.swap_status == SWAPOUT_DONE) {
cur_size -= fs.blksize * sizeInBlocks(e.swap_file_sz);
--n_disk_objects;
}
currentEntry (Store::Root().get(swapData.key));
if (currentEntry() != NULL && swapData.lastref >= e->lastref) {
- /*
- * Make sure we don't unlink the file, it might be
- * in use by a subsequent entry. Also note that
- * we don't have to subtract from cur_size because
- * adding to cur_size happens in the cleanup procedure.
- */
- currentEntry()->expireNow();
- currentEntry()->releaseRequest();
-
- if (currentEntry()->swap_filen > -1) {
- UFSSwapDir *sdForThisEntry = dynamic_cast<UFSSwapDir *>(INDEXSD(currentEntry()->swap_dirn));
- assert (sdForThisEntry);
- sdForThisEntry->replacementRemove(currentEntry());
- sdForThisEntry->mapBitReset(currentEntry()->swap_filen);
- currentEntry()->swap_filen = -1;
- currentEntry()->swap_dirn = -1;
- }
-
- currentEntry()->release();
+ undoAdd();
counts.objcount--;
counts.cancelcount++;
}
} else if (currentEntry()) {
/* key already exists, this swapfile not being used */
/* junk old, load new */
- currentEntry()->expireNow();
- currentEntry()->releaseRequest();
-
- if (currentEntry()->swap_filen > -1) {
- UFSSwapDir *sdForThisEntry = dynamic_cast<UFSSwapDir *>(INDEXSD(currentEntry()->swap_dirn));
- sdForThisEntry->replacementRemove(currentEntry());
- /* Make sure we don't actually unlink the file */
- sdForThisEntry->mapBitReset(currentEntry()->swap_filen);
- currentEntry()->swap_filen = -1;
- currentEntry()->swap_dirn = -1;
- }
-
- currentEntry()->release();
+ undoAdd();
+ counts.objcount--;
counts.dupcount++;
} else {
/* URL doesnt exist, swapfile not in use */
storeDirSwapLog(currentEntry(), SWAP_LOG_ADD);
}
+/// undo the effects of adding an entry in rebuildFromSwapLog()
+void
+RebuildState::undoAdd()
+{
+ StoreEntry *added = currentEntry();
+ assert(added);
+ currentEntry(NULL);
+
+ // TODO: Why bother with these two if we are going to release?!
+ added->expireNow();
+ added->releaseRequest();
+
+ if (added->swap_filen > -1) {
+ UFSSwapDir *sde = dynamic_cast<UFSSwapDir *>(INDEXSD(added->swap_dirn));
+ assert(sde);
+ sde->undoAddDiskRestore(added);
+ }
+
+ added->release();
+}
+
int
RebuildState::getNextFile(sfileno * filn_p, int *size)
{
uint32_t refcount,
uint16_t flags,
int clean);
+ /// Undo the effects of UFSSwapDir::addDiskRestore().
+ void undoAddDiskRestore(StoreEntry *e);
int validFileno(sfileno filn, int flag) const;
int mapBitAllocate();
virtual ConfigOption *getOptionTree() const;
void rebuildFromDirectory();
void rebuildFromSwapLog();
void rebuildStep();
+ void undoAdd();
int getNextFile(sfileno *, int *size);
StoreEntry *currentEntry() const;
void currentEntry(StoreEntry *);