afs: fs getcacheparms miscounts dcaches for large files

fs getcacheparms issued with the -excessive option tabulates in-memory
dcaches ("DCentries") by size.  However, any dcache with validPos > 2^31
is miscounted in the 4k-16k bucket.  This is caused by a type mismatch
between 'validPos' (afs_size_t) and 'size' (int) which leads to a
negative value for size by sign-extension.  The size comparison "sieve"
fails for negative numbers; it skips the first bucket (0-4K) and dumps
them in the second one (4k-16k).

Move the declaration of 'size' closer to its use, and declare it with
the same type as 'validPos' (afs_size_t) so the comparison sieve
correctly places these dcaches in the last (>=1M) bucket.

Reviewed-on: https://gerrit.openafs.org/12347
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit b5e4e8c14130f601bbf43dee5927222ebf7613fa)

Change-Id: I659fd86f05b29c1eac1a262d340bcc1ce2640797
Reviewed-on: https://gerrit.openafs.org/12605
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Mark Vitale 2016-01-12 18:06:51 -05:00 committed by Stephan Wiesand
parent bf222ca6ae
commit fb7eceb760

View File

@ -2879,7 +2879,7 @@ DECL_PIOCTL(PGetCacheSize)
afs_int32 results[MAXGCSTATS];
afs_int32 flags;
struct dcache * tdc;
int i, size;
int i;
AFS_STATCNT(PGetCacheSize);
@ -2911,8 +2911,9 @@ DECL_PIOCTL(PGetCacheSize)
tdc = afs_indexTable[i];
if (tdc){
afs_size_t size = tdc->validPos;
results[9]++;
size = tdc->validPos;
if ( 0 <= size && size < (1<<12) ) results[10]++;
else if (size < (1<<14) ) results[11]++;
else if (size < (1<<16) ) results[12]++;