int64_t size = strtoll(value, NULL, 10);
- if (isaReconfig && *val != size)
- debugs(3, 1, "Cache dir '" << path << "' object " << option << " now " << size);
+ if (isaReconfig && *val != size) {
+ if (allowOptionReconfigure(option)) {
+ debugs(3, DBG_IMPORTANT, "cache_dir '" << path << "' object " <<
+ option << " now " << size << " Bytes");
+ } else {
+ debugs(3, DBG_IMPORTANT, "WARNING: cache_dir '" << path << "' "
+ "object " << option << " cannot be changed dynamically, " <<
+ "value left unchanged (" << *val << " Bytes)");
+ return true;
+ }
+ }
*val = size;
void parseOptions(int reconfiguring);
void dumpOptions(StoreEntry * e) const;
virtual ConfigOption *getOptionTree() const;
+ virtual bool allowOptionReconfigure(const char *const) const { return true; }
int64_t sizeInBlocks(const int64_t size) const { return (size + fs.blksize - 1) / fs.blksize; }
fname.append("/rock");
filePath = xstrdup(fname.termedBuf());
- parseSize();
+ parseSize(false);
parseOptions(0);
// Current openForWriting() code overwrites the old slot if needed
}
void
-Rock::SwapDir::reconfigure(int, char *)
+Rock::SwapDir::reconfigure(int, char *aPath)
{
- // TODO: do not update a parameter if we cannot propagate that change
- // TODO: warn if reconfigure changes any parameter that we cannot update
- parseSize();
+ parseSize(true);
parseOptions(1);
// TODO: can we reconfigure the replacement policy (repl)?
validateOptions();
/// parse maximum db disk size
void
-Rock::SwapDir::parseSize()
+Rock::SwapDir::parseSize(const bool reconfiguring)
{
const int i = GetInteger();
if (i < 0)
fatal("negative Rock cache_dir size value");
- max_size = static_cast<uint64_t>(i) << 20; // MBytes to Bytes
+ const uint64_t new_max_size =
+ static_cast<uint64_t>(i) << 20; // MBytes to Bytes
+ if (!reconfiguring)
+ max_size = new_max_size;
+ else if (new_max_size != max_size) {
+ debugs(3, DBG_IMPORTANT, "WARNING: cache_dir '" << path << "' size "
+ "cannot be changed dynamically, value left unchanged (" <<
+ (max_size >> 20) << " MB)");
+ }
}
ConfigOption *
return vector;
}
+bool
+Rock::SwapDir::allowOptionReconfigure(const char *const option) const
+{
+ return strcmp(option, "max-size") != 0 &&
+ ::SwapDir::allowOptionReconfigure(option);
+}
+
/// parses time-specific options; mimics ::SwapDir::optionObjectSizeParse()
bool
Rock::SwapDir::parseTimeOption(char const *option, const char *value, int reconfiguring)
virtual void create();
virtual void init();
virtual ConfigOption *getOptionTree() const;
+ virtual bool allowOptionReconfigure(const char *const option) const;
virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const;
virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *);
virtual void writeCompleted(int errflag, size_t len, RefCount< ::WriteRequest>);
virtual void parse(int index, char *path);
- void parseSize(); ///< parses anonymous cache_dir size option
+ void parseSize(const bool reconfiguring); ///< parses anonymous cache_dir size option
void validateOptions(); ///< warns of configuration problems; may quit
bool parseTimeOption(char const *option, const char *value, int reconfiguring);
void dumpTimeOption(StoreEntry * e) const;