if (flags.read_only)
return false; // cannot write at all
- if (cur_size > max_size)
+ if (currentSize() > max_size << 10)
return false; // already overflowing
/* Return 999 (99.9%) constant load; TODO: add a named constant for this */
virtual uint64_t minSize() const;
- virtual uint64_t currentSize() const { return cur_size << 10; }
+ virtual uint64_t currentSize() const { return cur_size; }
virtual uint64_t currentCount() const { return n_disk_objects; }
void optionObjectSizeDump(StoreEntry * e) const;
char const *theType;
+private:
+ uint64_t cur_size; ///< currently used space in the storage area
+
public:
- // TODO: store cur_size and max_size in bytes
- uint64_t cur_size; ///< currently used space in the storage area in kiloBytes
+ // TODO: store max_size in bytes
uint64_t max_size; ///< maximum allocatable size of the storage area in kiloBytes
uint64_t n_disk_objects; ///< total number of objects stored
char *path;
#include "StoreFScoss.h"
#include "Parsing.h"
#include "swap_log_op.h"
-//#include "SquidMath.h"
+#include "SquidMath.h"
#define STORE_META_BUFSZ 4096
void
CossSwapDir::statfs(StoreEntry & sentry) const
{
+ const double currentSizeInKB = currentSize() / 1024.0;
storeAppendPrintf(&sentry, "\n");
storeAppendPrintf(&sentry, "Maximum Size: %lu KB\n", max_size);
- storeAppendPrintf(&sentry, "Current Size: %lu KB\n", cur_size);
+ storeAppendPrintf(&sentry, "Current Size: %.2f KB\n", currentSizeInKB);
storeAppendPrintf(&sentry, "Percent Used: %0.2f%%\n",
- (100.0 * (double)cur_size / (double)max_size) );
+ Math::doublePercent(currentSizeInKB, max_size) );
storeAppendPrintf(&sentry, "Number of object collisions: %d\n", (int) numcollisions);
#if 0
/* is this applicable? I Hope not .. */
int totl_in = 0;
int free_in = 0;
int x;
+ const double currentSizeInKB = currentSize() / 1024.0;
storeAppendPrintf(&sentry, "First level subdirectories: %d\n", l1);
storeAppendPrintf(&sentry, "Second level subdirectories: %d\n", l2);
storeAppendPrintf(&sentry, "Maximum Size: %"PRIu64" KB\n", max_size);
- storeAppendPrintf(&sentry, "Current Size: %"PRIu64" KB\n", cur_size);
+ storeAppendPrintf(&sentry, "Current Size: %.2f KB\n", currentSizeInKB);
storeAppendPrintf(&sentry, "Percent Used: %0.2f%%\n",
- (double)(100.0 * cur_size) / (double)max_size);
+ Math::doublePercent(currentSizeInKB, max_size));
storeAppendPrintf(&sentry, "Filemap bits in use: %d of %d (%d%%)\n",
map->n_files_in_map, map->max_n_files,
Math::intPercent(map->n_files_in_map, map->max_n_files));
RemovalPurgeWalker *walker;
- double f = (double) (cur_size - minSize()) / (max_size - minSize());
+ double f = (double) (currentSize() / 1024.0 - minSize()) / (max_size - minSize());
f = f < 0.0 ? 0.0 : f > 1.0 ? 1.0 : f;
walker = repl->PurgeInit(repl, max_scan);
while (1) {
- if (cur_size < minSize())
+ if (currentSize() < minSize() << 10)
break;
if (removed >= max_remove)
static int
storeDirSelectSwapDirLeastLoad(const StoreEntry * e)
{
- ssize_t most_free = 0, cur_free;
+ uint64_t most_free = 0;
ssize_t least_objsize = -1;
int least_load = INT_MAX;
int load;
if (load > least_load)
continue;
- cur_free = SD->max_size - SD->cur_size;
+ const uint64_t cur_free = (SD->max_size << 10) - SD->currentSize();
/* If the load is equal, then look in more details */
if (load == least_load) {
void
SwapDir::updateSize(int64_t size, int sign)
{
- int64_t blks = (size + fs.blksize - 1) / fs.blksize;
- int64_t k = ((blks * fs.blksize) >> 10) * sign;
+ const int64_t blks = (size + fs.blksize - 1) / fs.blksize;
+ const int64_t k = blks * fs.blksize * sign;
cur_size += k;
if (sign > 0)
void
SwapDir::diskFull()
{
- if (cur_size >= max_size)
+ if (currentSize() >= max_size << 10)
return;
- max_size = cur_size;
+ max_size = currentSize() >> 10;
- debugs(20, 1, "WARNING: Shrinking cache_dir #" << index << " to " << cur_size << " KB");
+ debugs(20, 1, "WARNING: Shrinking cache_dir #" << index << " to " << currentSize() / 1024.0 << " KB");
}
void