afs: Log abnormally large chunk files

Any chunk in our cache for a regular file should be smaller than or
equal to our configured chunksize. If someone sets a chunk to be
larger than that, it is very strange and may cause other confusing
issues. Specifically, afs_DoPartialWrite determines if our cache is
"too full" by counting the number of dirty chunks. If we have a dirty
chunk that is much larger than the chunksize, it can throw off the
afs_DoPartialWrite calculation.

This is only true for dcaches backing regular files, though. For
directories, we fetch the entire directory into a single chunk file,
and the size of a directory blob can easily exceed the chunksize
without issues. The aforementioned issue with afs_DoPartialWrite does
not apply, since directory chunks cannot be dirty (we only locally
modify the chunk if we modify the dir on the server, and the DVs
match).

Anyway, it should not be possible to get a chunk for a regular file
larger than the chunksize. Log a message if it does occur, to help
assist anyone in tracking down issues when this does occur.

[mmeffie@sinenomine.net remove unnecessary casts in afs_warn args.]

Reviewed-on: http://gerrit.openafs.org/11831
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 11845765c75a2f15404ac55a882358c3f88595b9)

Change-Id: I7c9f4aa147ba63e51bb805484bac5785259847cb
Reviewed-on: https://gerrit.openafs.org/12216
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Andrew Deason 2015-04-11 20:51:09 -05:00 committed by Stephan Wiesand
parent 10d148abe2
commit fbd50cb0c4

View File

@ -543,6 +543,23 @@ afs_AdjustSize(struct dcache *adc, afs_int32 newSize)
AFS_STATCNT(afs_AdjustSize);
if (newSize > afs_OtherCSize && !(adc->f.fid.Fid.Vnode & 1)) {
/* No non-dir cache files should be larger than the chunk size.
* (Directory blobs are fetched in a single chunk file, so directories
* can be larger.) If someone is requesting that a chunk is larger than
* the chunk size, something strange is happening. Log a message about
* it, to give a hint to subsequent strange behavior, if any occurs. */
static int warned;
if (!warned) {
warned = 1;
afs_warn("afs: Warning: dcache %d is very large (%d > %d). This "
"should not happen, but trying to continue regardless. If "
"AFS starts hanging or behaving strangely, this might be "
"why.\n",
adc->index, newSize, afs_OtherCSize);
}
}
adc->dflags |= DFEntryMod;
oldSize = ((adc->f.chunkBytes + afs_fsfragsize) ^ afs_fsfragsize) >> 10; /* round up */
adc->f.chunkBytes = newSize;