[Mesa-dev] [PATCH 2/2] disk_cache: use block size rather than file size

Michel Dänzer michel at daenzer.net
Thu Apr 27 06:42:57 UTC 2017


On 27/04/17 10:15 AM, Timothy Arceri wrote:
> The majority of cache files are less than 1kb this resulted in us
> greatly miscalculating the amount of disk space used by the cache.
> 
> Using the number of blocks allocated to the file is more
> conservative and less likely to cause issues.
> 
> This change will result in cache sizes being miscalculated further
> until old items added with the previous calculation have all been
> removed. However I don't see anyway around that, the previous
> patch should help limit that problem.
> 
> Cc: "17.1" <mesa-stable at lists.freedesktop.org>

[...]

> -   if (sb.st_size)
> -      p_atomic_add(cache->size, - (uint64_t)sb.st_size);
> +   if (sb.st_blocks * 512)
> +      p_atomic_add(cache->size, - (uint64_t)sb.st_blocks * 512);

No need to multiply by 512 here. With that removed,

Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer at amd.com>


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the mesa-dev mailing list