{
errcode_t retval;
struct unix_cache *cache;
- int i;
+ unsigned int i;
data->access_time = 0;
for (i=0, cache = data->cache; i < data->cache_size; i++, cache++) {
static void free_cache(struct unix_private_data *data)
{
struct unix_cache *cache;
- int i;
+ unsigned int i;
data->access_time = 0;
for (i=0, cache = data->cache; i < data->cache_size; i++, cache++) {
#define CACHE_LINE_SIZE 64
/* buffer cache hashing function, crudely stolen from xfsprogs */
-unsigned int
+static unsigned int
cache_hash(struct unix_private_data *data, blk64_t blkno)
{
uint64_t hashval = blkno;
{
struct unix_cache *cache, *unused_cache, *oldest_cache;
unsigned int hash = cache_hash(data, block);
- int i;
+ unsigned int i;
unused_cache = oldest_cache = 0;
/* walk [hash..] cache elements */
{
struct unix_cache *cache;
errcode_t retval, retval2 = 0;
- int i;
+ unsigned int i;
int errors_found = 0;
if ((flags & FLUSH_NOLOCK) == 0)
unsigned int new_size)
{
struct unix_cache *cache, *new_cache;
- int i;
+ unsigned int i;
errcode_t retval;
mutex_lock(data, CACHE_MTX);
unsigned int new_size)
{
struct unix_cache *cache, *new_cache;
- int i;
+ unsigned int i;
errcode_t retval;
mutex_lock(data, CACHE_MTX);
static unsigned long long default_cache_size(void)
{
long pages = 0, pagesize = 0;
+ unsigned long long max_cache;
+ unsigned long long ret = 32ULL << 20; /* 32 MB */
#ifdef _SC_PHYS_PAGES
pages = sysconf(_SC_PHYS_PAGES);
#ifdef _SC_PAGESIZE
pagesize = sysconf(_SC_PAGESIZE);
#endif
- long long max_cache = (long long)pagesize * pages / 20;
- unsigned long long ret = 32ULL << 20; /* 32 MB */
+ if (pages > 0 && pagesize > 0) {
+ max_cache = (unsigned long long)pagesize * pages / 20;
- if (max_cache > 0 && ret > max_cache)
- return max_cache;
+ if (max_cache > 0 && ret > max_cache)
+ ret = max_cache;
+ }
return ret;
}