return ::SwapDir::doReportStat() && (!UsingSmp() || IamDiskProcess());
}
+int64_t
+Rock::SwapDir::entryLimitAllowed() const
+{
+ const int64_t eLimitLo = map ? map->entryLimit() : 0; // dynamic shrinking unsupported
+ const int64_t eWanted = (maximumSize() - HeaderSize)/maxObjectSize();
+ return min(max(eLimitLo, eWanted), entryLimitHigh());
+}
+
// TODO: encapsulate as a tool; identical to CossSwapDir::create()
void
Rock::SwapDir::create()
fatal("Rock store requires a positive max-size");
/* XXX: should we support resize?
- const int64_t eLimitHi = 0xFFFFFF; // Core sfileno maximum
- const int64_t eLimitLo = map->entryLimit(); // dynamic shrinking unsupported
- const int64_t eWanted = (maximumSize() - HeaderSize)/max_objsize;
- const int64_t eAllowed = min(max(eLimitLo, eWanted), eLimitHi);
-
- map->resize(eAllowed); // the map may decide to use an even lower limit
+ map->resize(entryLimitAllowed()); // the map may decide to use an even lower limit
*/
/* XXX: misplaced, map is not yet created
assert(diskOffsetLimit() <= maximumSize());
// warn if maximum db size is not reachable due to sfileno limit
- if (map->entryLimit() == eLimitHi && totalWaste > roundingWasteMx) {
+ if (map->entryLimit() == entryLimitHigh() && totalWaste > roundingWasteMx) {
debugs(47, 0, "Rock store cache_dir[" << index << "]:");
debugs(47, 0, "\tmaximum number of entries: " << map->entryLimit());
debugs(47, 0, "\tmaximum entry size: " << max_objsize << " bytes");
if (IamMasterProcess()) {
Must(owners.empty());
for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
- const Rock::SwapDir *const sd =
- dynamic_cast<Rock::SwapDir *>(INDEXSD(i));
- if (!sd)
- continue;
-
- // XXX: polish, validateOptions() has same code
- const int64_t eLimitHi = 0xFFFFFF; // Core sfileno maximum
- const int64_t eLimitLo = 0; // dynamic shrinking unsupported
- const int64_t eWanted = (sd->maximumSize() - Rock::SwapDir::HeaderSize)/sd->maxObjectSize();
- const int64_t eAllowed = min(max(eLimitLo, eWanted), eLimitHi);
- owners.push_back(Rock::SwapDir::DirMap::Init(sd->path, eAllowed));
+ if (const Rock::SwapDir *const sd = dynamic_cast<Rock::SwapDir *>(INDEXSD(i))) {
+ Rock::SwapDir::DirMap::Owner *const owner = Rock::SwapDir::DirMap::Init(sd->path, sd->entryLimitAllowed());
+ owners.push_back(owner);
+ }
}
}
}
virtual uint64_t currentCount() const;
virtual bool doReportStat() const;
+ int64_t entryLimitHigh() const { return 0xFFFFFF; } /// Core sfileno maximum
+ int64_t entryLimitAllowed() const;
+
// TODO: change cur_size and max_size type to stop this madness
int64_t maximumSize() const { return static_cast<int64_t>(max_size) << 10; }
- static const int64_t HeaderSize;
-
typedef Ipc::StoreMapWithExtras<DbCellHeader> DirMap;
protected:
DiskIOStrategy *io;
RefCount<DiskFile> theFile; ///< cache storage for this cache_dir
DirMap *map;
+
+ static const int64_t HeaderSize; ///< on-disk db header size
};
} // namespace Rock