[OpenAFS] AFS cache configuration

Mark Vitale mvitale@sinenomine.net
Mon, 16 Apr 2018 15:16:01 +0000


> On Apr 16, 2018, at 5:19 AM, Kostas Liakakis <kostas@physics.auth.gr> wro=
te:
>=20
> I am running an OpenAFS 1.6.11 client against a set of 1.6.20 servers. I =
am trying to find out if my client's cache is underutilized or thrashing be=
cause if it running out of entries. I've read the documentation here ( http=
://docs.openafs.org/Reference/5/afs_cache.html ) and the afsd page here ( h=
ttp://docs.openafs.org/Reference/8/afsd.html ) but I think I still don't ha=
ve the whole picture. So I'd like some help understanding the disk based ca=
che configuration.
>=20
> My cache is configured via /etc/openafs/cacheinfo with 1000000 blocks (1G=
B) of maximum space. afsd is started with -dynroot -fakestat -afsdb flags.
>=20
> Now, what I read from the afsdb manual my chunksize by default should be =
between, 256KB and 1MB. I can tell by looking at the Vn files in the cache =
directory that chunksize is 1M, since there is no file greater than this si=
ze while a few are more than 1023KB.
Yes, this is the correct default chunksize for a cache with 1000000 blocks =
- so far, so good.

> I also read that my Vn files number should by default be chosen as the gr=
eater of (100, 1000000/10240, or 1.5*1000000/1024). The latter being the gr=
eater I'd expect to find no more than 1464 Vn files in my cache directory. =
Contrary to this, du --inodes says there are 31270 files in my cache direct=
ory. Indeed, the highest numbered Vn file is V31249 and the rest of used in=
odes can be attributed to parent directory entries.
This documentation is unfortunately outdated.   The number of files you end=
ed up with is consistent with the number of blocks and chunksize (see sourc=
e code in src/afs/afsd.c).

> So what am I missing here? How does the cache manager calculate the limit=
 to Vn files?
The algorithm in the 1.6.11 Unix cache manager (afsd) is (from afsd_run()):
...
2033             cacheFiles =3D cacheBlocks / 32;      /* Assume 32k avg fi=
lesize */
You specified cacheBlocks 1000000, so this gives cacheFiles =3D 31250, the =
number you reported.
2034=20
2035             cacheFiles =3D max(cacheFiles, 1000);
cacheFiles remains 31250
2036=20
2037             /* Always allow more files than chunks.  Presume average V=
-file
2038              * is ~67% of a chunk...  (another guess, perhaps Honeyman=
 will
2039              * have a grad student write a paper).  i is KILOBYTES.
2040              */
2041             i =3D 1 << (chunkSize < 10 ? 0 : chunkSize - 10);
Your chunksize was 20, so i=3D1<<(20-10)=3D1024
2042             cacheFiles =3D max(cacheFiles, 1.5 * (cacheBlocks / i));
1.5*(cacheBlocks 1000000/ i 1024) =3D 1464
so cacheFiles remains 31250.


You may find the following commands useful when tuning the cache:

cmdebug <client> -cache		# gives the current cache configuration

xstat_cm_test <client> 2 -onceonly | head -n 35		# gives live cache statist=
ics

Regards,
--
Mark Vitale
mvitale@sinenomine.net